e320acd52fa5ec69662e4499e4d70723515b67b8
[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.Partition_Interface (s-parint.ads)::
552 * System.Pool_Global (s-pooglo.ads)::
553 * System.Pool_Local (s-pooloc.ads)::
554 * System.Restrictions (s-restri.ads)::
555 * System.Rident (s-rident.ads)::
556 * System.Strings.Stream_Ops (s-ststop.ads)::
557 * System.Task_Info (s-tasinf.ads)::
558 * System.Wch_Cnv (s-wchcnv.ads)::
559 * System.Wch_Con (s-wchcon.ads)::
560
561 Text_IO
562
563 * Text_IO Stream Pointer Positioning::
564 * Text_IO Reading and Writing Non-Regular Files::
565 * Get_Immediate::
566 * Treating Text_IO Files as Streams::
567 * Text_IO Extensions::
568 * Text_IO Facilities for Unbounded Strings::
569
570 Wide_Text_IO
571
572 * Wide_Text_IO Stream Pointer Positioning::
573 * Wide_Text_IO Reading and Writing Non-Regular Files::
574
575 Wide_Wide_Text_IO
576
577 * Wide_Wide_Text_IO Stream Pointer Positioning::
578 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
579
580 Interfacing to Other Languages
581
582 * Interfacing to C::
583 * Interfacing to C++::
584 * Interfacing to COBOL::
585 * Interfacing to Fortran::
586 * Interfacing to non-GNAT Ada code::
587
588 Specialized Needs Annexes
589
590 Implementation of Specific Ada Features
591 * Machine Code Insertions::
592 * GNAT Implementation of Tasking::
593 * GNAT Implementation of Shared Passive Packages::
594 * Code Generation for Array Aggregates::
595 * The Size of Discriminated Records with Default Discriminants::
596 * Strict Conformance to the Ada Reference Manual::
597
598 Implementation of Ada 2012 Features
599
600 Obsolescent Features
601
602 GNU Free Documentation License
603
604 Index
605 @end menu
606
607 @end ifnottex
608
609 @node About This Guide
610 @unnumbered About This Guide
611
612 @noindent
613 This manual contains useful information in writing programs using the
614 @value{EDITION} compiler. It includes information on implementation dependent
615 characteristics of @value{EDITION}, including all the information required by
616 Annex M of the Ada language standard.
617
618 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
619 Ada 83 compatibility mode.
620 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
621 but you can override with a compiler switch
622 to explicitly specify the language version.
623 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
624 @value{EDITION} User's Guide}, for details on these switches.)
625 Throughout this manual, references to ``Ada'' without a year suffix
626 apply to both the Ada 95 and Ada 2005 versions of the language.
627
628 Ada is designed to be highly portable.
629 In general, a program will have the same effect even when compiled by
630 different compilers on different platforms.
631 However, since Ada is designed to be used in a
632 wide variety of applications, it also contains a number of system
633 dependent features to be used in interfacing to the external world.
634 @cindex Implementation-dependent features
635 @cindex Portability
636
637 Note: Any program that makes use of implementation-dependent features
638 may be non-portable. You should follow good programming practice and
639 isolate and clearly document any sections of your program that make use
640 of these features in a non-portable manner.
641
642 @ifset PROEDITION
643 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
644 ``GNAT'' in the remainder of this document.
645 @end ifset
646
647 @menu
648 * What This Reference Manual Contains::
649 * Conventions::
650 * Related Information::
651 @end menu
652
653 @node What This Reference Manual Contains
654 @unnumberedsec What This Reference Manual Contains
655
656 @noindent
657 This reference manual contains the following chapters:
658
659 @itemize @bullet
660 @item
661 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
662 pragmas, which can be used to extend and enhance the functionality of the
663 compiler.
664
665 @item
666 @ref{Implementation Defined Attributes}, lists GNAT
667 implementation-dependent attributes, which can be used to extend and
668 enhance the functionality of the compiler.
669
670 @item
671 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
672 implementation-dependent restrictions, which can be used to extend and
673 enhance the functionality of the compiler.
674
675 @item
676 @ref{Implementation Advice}, provides information on generally
677 desirable behavior which are not requirements that all compilers must
678 follow since it cannot be provided on all systems, or which may be
679 undesirable on some systems.
680
681 @item
682 @ref{Implementation Defined Characteristics}, provides a guide to
683 minimizing implementation dependent features.
684
685 @item
686 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
687 implemented by GNAT, and how they can be imported into user
688 application programs.
689
690 @item
691 @ref{Representation Clauses and Pragmas}, describes in detail the
692 way that GNAT represents data, and in particular the exact set
693 of representation clauses and pragmas that is accepted.
694
695 @item
696 @ref{Standard Library Routines}, provides a listing of packages and a
697 brief description of the functionality that is provided by Ada's
698 extensive set of standard library routines as implemented by GNAT@.
699
700 @item
701 @ref{The Implementation of Standard I/O}, details how the GNAT
702 implementation of the input-output facilities.
703
704 @item
705 @ref{The GNAT Library}, is a catalog of packages that complement
706 the Ada predefined library.
707
708 @item
709 @ref{Interfacing to Other Languages}, describes how programs
710 written in Ada using GNAT can be interfaced to other programming
711 languages.
712
713 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
714 of the specialized needs annexes.
715
716 @item
717 @ref{Implementation of Specific Ada Features}, discusses issues related
718 to GNAT's implementation of machine code insertions, tasking, and several
719 other features.
720
721 @item
722 @ref{Implementation of Ada 2012 Features}, describes the status of the
723 GNAT implementation of the Ada 2012 language standard.
724
725 @item
726 @ref{Obsolescent Features} documents implementation dependent features,
727 including pragmas and attributes, which are considered obsolescent, since
728 there are other preferred ways of achieving the same results. These
729 obsolescent forms are retained for backwards compatibility.
730
731 @end itemize
732
733 @cindex Ada 95 Language Reference Manual
734 @cindex Ada 2005 Language Reference Manual
735 @noindent
736 This reference manual assumes a basic familiarity with the Ada 95 language, as
737 described in the International Standard ANSI/ISO/IEC-8652:1995,
738 January 1995.
739 It does not require knowledge of the new features introduced by Ada 2005,
740 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
741 and Amendment 1).
742 Both reference manuals are included in the GNAT documentation
743 package.
744
745 @node Conventions
746 @unnumberedsec Conventions
747 @cindex Conventions, typographical
748 @cindex Typographical conventions
749
750 @noindent
751 Following are examples of the typographical and graphic conventions used
752 in this guide:
753
754 @itemize @bullet
755 @item
756 @code{Functions}, @code{utility program names}, @code{standard names},
757 and @code{classes}.
758
759 @item
760 @code{Option flags}
761
762 @item
763 @file{File names}, @samp{button names}, and @samp{field names}.
764
765 @item
766 @code{Variables}, @env{environment variables}, and @var{metasyntactic
767 variables}.
768
769 @item
770 @emph{Emphasis}.
771
772 @item
773 [optional information or parameters]
774
775 @item
776 Examples are described by text
777 @smallexample
778 and then shown this way.
779 @end smallexample
780 @end itemize
781
782 @noindent
783 Commands that are entered by the user are preceded in this manual by the
784 characters @samp{$ } (dollar sign followed by space). If your system uses this
785 sequence as a prompt, then the commands will appear exactly as you see them
786 in the manual. If your system uses some other prompt, then the command will
787 appear with the @samp{$} replaced by whatever prompt character you are using.
788
789 @node Related Information
790 @unnumberedsec Related Information
791 @noindent
792 See the following documents for further information on GNAT:
793
794 @itemize @bullet
795 @item
796 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
797 @value{EDITION} User's Guide}, which provides information on how to use the
798 GNAT compiler system.
799
800 @item
801 @cite{Ada 95 Reference Manual}, which contains all reference
802 material for the Ada 95 programming language.
803
804 @item
805 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
806 of the Ada 95 standard. The annotations describe
807 detailed aspects of the design decision, and in particular contain useful
808 sections on Ada 83 compatibility.
809
810 @item
811 @cite{Ada 2005 Reference Manual}, which contains all reference
812 material for the Ada 2005 programming language.
813
814 @item
815 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
816 of the Ada 2005 standard. The annotations describe
817 detailed aspects of the design decision, and in particular contain useful
818 sections on Ada 83 and Ada 95 compatibility.
819
820 @item
821 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
822 which contains specific information on compatibility between GNAT and
823 DEC Ada 83 systems.
824
825 @item
826 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
827 describes in detail the pragmas and attributes provided by the DEC Ada 83
828 compiler system.
829
830 @end itemize
831
832 @node Implementation Defined Pragmas
833 @chapter Implementation Defined Pragmas
834
835 @noindent
836 Ada defines a set of pragmas that can be used to supply additional
837 information to the compiler. These language defined pragmas are
838 implemented in GNAT and work as described in the Ada Reference Manual.
839
840 In addition, Ada allows implementations to define additional pragmas
841 whose meaning is defined by the implementation. GNAT provides a number
842 of these implementation-defined pragmas, which can be used to extend
843 and enhance the functionality of the compiler. This section of the GNAT
844 Reference Manual describes these additional pragmas.
845
846 Note that any program using these pragmas might not be portable to other
847 compilers (although GNAT implements this set of pragmas on all
848 platforms). Therefore if portability to other compilers is an important
849 consideration, the use of these pragmas should be minimized.
850
851 @menu
852 * Pragma Abort_Defer::
853 * Pragma Ada_83::
854 * Pragma Ada_95::
855 * Pragma Ada_05::
856 * Pragma Ada_2005::
857 * Pragma Ada_12::
858 * Pragma Ada_2012::
859 * Pragma Annotate::
860 * Pragma Assert::
861 * Pragma Assertion_Policy::
862 * Pragma Assume_No_Invalid_Values::
863 * Pragma Attribute_Definition::
864 * Pragma Ast_Entry::
865 * Pragma C_Pass_By_Copy::
866 * Pragma Check::
867 * Pragma Check_Float_Overflow::
868 * Pragma Check_Name::
869 * Pragma Check_Policy::
870 * Pragma Comment::
871 * Pragma Common_Object::
872 * Pragma Compile_Time_Error::
873 * Pragma Compile_Time_Warning::
874 * Pragma Compiler_Unit::
875 * Pragma Complete_Representation::
876 * Pragma Complex_Representation::
877 * Pragma Component_Alignment::
878 * Pragma Contract_Case::
879 * Pragma Convention_Identifier::
880 * Pragma CPP_Class::
881 * Pragma CPP_Constructor::
882 * Pragma CPP_Virtual::
883 * Pragma CPP_Vtable::
884 * Pragma CPU::
885 * Pragma Debug::
886 * Pragma Debug_Policy::
887 * Pragma Default_Storage_Pool::
888 * Pragma Detect_Blocking::
889 * Pragma Dispatching_Domain::
890 * Pragma Elaboration_Checks::
891 * Pragma Eliminate::
892 * Pragma Export_Exception::
893 * Pragma Export_Function::
894 * Pragma Export_Object::
895 * Pragma Export_Procedure::
896 * Pragma Export_Value::
897 * Pragma Export_Valued_Procedure::
898 * Pragma Extend_System::
899 * Pragma Extensions_Allowed::
900 * Pragma External::
901 * Pragma External_Name_Casing::
902 * Pragma Fast_Math::
903 * Pragma Favor_Top_Level::
904 * Pragma Finalize_Storage_Only::
905 * Pragma Float_Representation::
906 * Pragma Ident::
907 * Pragma Implementation_Defined::
908 * Pragma Implemented::
909 * Pragma Implicit_Packing::
910 * Pragma Import_Exception::
911 * Pragma Import_Function::
912 * Pragma Import_Object::
913 * Pragma Import_Procedure::
914 * Pragma Import_Valued_Procedure::
915 * Pragma Independent::
916 * Pragma Independent_Components::
917 * Pragma Initialize_Scalars::
918 * Pragma Inline_Always::
919 * Pragma Inline_Generic::
920 * Pragma Interface::
921 * Pragma Interface_Name::
922 * Pragma Interrupt_Handler::
923 * Pragma Interrupt_State::
924 * Pragma Invariant::
925 * Pragma Keep_Names::
926 * Pragma License::
927 * Pragma Link_With::
928 * Pragma Linker_Alias::
929 * Pragma Linker_Constructor::
930 * Pragma Linker_Destructor::
931 * Pragma Linker_Section::
932 * Pragma Long_Float::
933 * Pragma Loop_Optimize::
934 * Pragma Machine_Attribute::
935 * Pragma Main::
936 * Pragma Main_Storage::
937 * Pragma No_Body::
938 * Pragma No_Inline::
939 * Pragma No_Return::
940 * Pragma No_Strict_Aliasing::
941 * Pragma Normalize_Scalars::
942 * Pragma Obsolescent::
943 * Pragma Optimize_Alignment::
944 * Pragma Ordered::
945 * Pragma Overflow_Mode::
946 * Pragma Partition_Elaboration_Policy::
947 * Pragma Passive::
948 * Pragma Persistent_BSS::
949 * Pragma Polling::
950 * Pragma Postcondition::
951 * Pragma Precondition::
952 * Pragma Preelaborable_Initialization::
953 * Pragma Priority_Specific_Dispatching::
954 * Pragma Profile (Ravenscar)::
955 * Pragma Profile (Restricted)::
956 * Pragma Profile (Rational)::
957 * Pragma Psect_Object::
958 * Pragma Pure_Function::
959 * Pragma Relative_Deadline::
960 * Pragma Remote_Access_Type::
961 * Pragma Restriction_Warnings::
962 * Pragma Shared::
963 * Pragma Short_Circuit_And_Or::
964 * Pragma Short_Descriptors::
965 * Pragma Simple_Storage_Pool_Type::
966 * Pragma Source_File_Name::
967 * Pragma Source_File_Name_Project::
968 * Pragma Source_Reference::
969 * Pragma Static_Elaboration_Desired::
970 * Pragma Stream_Convert::
971 * Pragma Style_Checks::
972 * Pragma Subtitle::
973 * Pragma Suppress::
974 * Pragma Suppress_All::
975 * Pragma Suppress_Exception_Locations::
976 * Pragma Suppress_Initialization::
977 * Pragma Task_Info::
978 * Pragma Task_Name::
979 * Pragma Task_Storage::
980 * Pragma Test_Case::
981 * Pragma Thread_Local_Storage::
982 * Pragma Time_Slice::
983 * Pragma Title::
984 * Pragma Unchecked_Union::
985 * Pragma Unimplemented_Unit::
986 * Pragma Universal_Aliasing ::
987 * Pragma Universal_Data::
988 * Pragma Unmodified::
989 * Pragma Unreferenced::
990 * Pragma Unreferenced_Objects::
991 * Pragma Unreserve_All_Interrupts::
992 * Pragma Unsuppress::
993 * Pragma Use_VADS_Size::
994 * Pragma Validity_Checks::
995 * Pragma Volatile::
996 * Pragma Warnings::
997 * Pragma Weak_External::
998 * Pragma Wide_Character_Encoding::
999 @end menu
1000
1001 @node Pragma Abort_Defer
1002 @unnumberedsec Pragma Abort_Defer
1003 @findex Abort_Defer
1004 @cindex Deferring aborts
1005 @noindent
1006 Syntax:
1007 @smallexample
1008 pragma Abort_Defer;
1009 @end smallexample
1010
1011 @noindent
1012 This pragma must appear at the start of the statement sequence of a
1013 handled sequence of statements (right after the @code{begin}). It has
1014 the effect of deferring aborts for the sequence of statements (but not
1015 for the declarations or handlers, if any, associated with this statement
1016 sequence).
1017
1018 @node Pragma Ada_83
1019 @unnumberedsec Pragma Ada_83
1020 @findex Ada_83
1021 @noindent
1022 Syntax:
1023 @smallexample @c ada
1024 pragma Ada_83;
1025 @end smallexample
1026
1027 @noindent
1028 A configuration pragma that establishes Ada 83 mode for the unit to
1029 which it applies, regardless of the mode set by the command line
1030 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1031 the syntax and semantics of Ada 83, as defined in the original Ada
1032 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1033 and Ada 2005 are not recognized, optional package bodies are allowed,
1034 and generics may name types with unknown discriminants without using
1035 the @code{(<>)} notation. In addition, some but not all of the additional
1036 restrictions of Ada 83 are enforced.
1037
1038 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1039 Ada 83 code to be compiled and adapted to GNAT with less effort.
1040 Secondly, it aids in keeping code backwards compatible with Ada 83.
1041 However, there is no guarantee that code that is processed correctly
1042 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1043 83 compiler, since GNAT does not enforce all the additional checks
1044 required by Ada 83.
1045
1046 @node Pragma Ada_95
1047 @unnumberedsec Pragma Ada_95
1048 @findex Ada_95
1049 @noindent
1050 Syntax:
1051 @smallexample @c ada
1052 pragma Ada_95;
1053 @end smallexample
1054
1055 @noindent
1056 A configuration pragma that establishes Ada 95 mode for the unit to which
1057 it applies, regardless of the mode set by the command line switches.
1058 This mode is set automatically for the @code{Ada} and @code{System}
1059 packages and their children, so you need not specify it in these
1060 contexts. This pragma is useful when writing a reusable component that
1061 itself uses Ada 95 features, but which is intended to be usable from
1062 either Ada 83 or Ada 95 programs.
1063
1064 @node Pragma Ada_05
1065 @unnumberedsec Pragma Ada_05
1066 @findex Ada_05
1067 @noindent
1068 Syntax:
1069 @smallexample @c ada
1070 pragma Ada_05;
1071 @end smallexample
1072
1073 @noindent
1074 A configuration pragma that establishes Ada 2005 mode for the unit to which
1075 it applies, regardless of the mode set by the command line switches.
1076 This pragma is useful when writing a reusable component that
1077 itself uses Ada 2005 features, but which is intended to be usable from
1078 either Ada 83 or Ada 95 programs.
1079
1080 @node Pragma Ada_2005
1081 @unnumberedsec Pragma Ada_2005
1082 @findex Ada_2005
1083 @noindent
1084 Syntax:
1085 @smallexample @c ada
1086 pragma Ada_2005;
1087 @end smallexample
1088
1089 @noindent
1090 This configuration pragma is a synonym for pragma Ada_05 and has the
1091 same syntax and effect.
1092
1093 @node Pragma Ada_12
1094 @unnumberedsec Pragma Ada_12
1095 @findex Ada_12
1096 @noindent
1097 Syntax:
1098 @smallexample @c ada
1099 pragma Ada_12;
1100 @end smallexample
1101
1102 @noindent
1103 A configuration pragma that establishes Ada 2012 mode for the unit to which
1104 it applies, regardless of the mode set by the command line switches.
1105 This mode is set automatically for the @code{Ada} and @code{System}
1106 packages and their children, so you need not specify it in these
1107 contexts. This pragma is useful when writing a reusable component that
1108 itself uses Ada 2012 features, but which is intended to be usable from
1109 Ada 83, Ada 95, or Ada 2005 programs.
1110
1111 @node Pragma Ada_2012
1112 @unnumberedsec Pragma Ada_2012
1113 @findex Ada_2005
1114 @noindent
1115 Syntax:
1116 @smallexample @c ada
1117 pragma Ada_2012;
1118 @end smallexample
1119
1120 @noindent
1121 This configuration pragma is a synonym for pragma Ada_12 and has the
1122 same syntax and effect.
1123
1124 @node Pragma Annotate
1125 @unnumberedsec Pragma Annotate
1126 @findex Annotate
1127 @noindent
1128 Syntax:
1129 @smallexample @c ada
1130 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1131
1132 ARG ::= NAME | EXPRESSION
1133 @end smallexample
1134
1135 @noindent
1136 This pragma is used to annotate programs. @var{identifier} identifies
1137 the type of annotation. GNAT verifies that it is an identifier, but does
1138 not otherwise analyze it. The second optional identifier is also left
1139 unanalyzed, and by convention is used to control the action of the tool to
1140 which the annotation is addressed. The remaining @var{arg} arguments
1141 can be either string literals or more generally expressions.
1142 String literals are assumed to be either of type
1143 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1144 depending on the character literals they contain.
1145 All other kinds of arguments are analyzed as expressions, and must be
1146 unambiguous.
1147
1148 The analyzed pragma is retained in the tree, but not otherwise processed
1149 by any part of the GNAT compiler, except to generate corresponding note
1150 lines in the generated ALI file. For the format of these note lines, see
1151 the compiler source file lib-writ.ads. This pragma is intended for use by
1152 external tools, including ASIS@. The use of pragma Annotate does not
1153 affect the compilation process in any way. This pragma may be used as
1154 a configuration pragma.
1155
1156 @node Pragma Assert
1157 @unnumberedsec Pragma Assert
1158 @findex Assert
1159 @noindent
1160 Syntax:
1161 @smallexample @c ada
1162 pragma Assert (
1163 boolean_EXPRESSION
1164 [, string_EXPRESSION]);
1165 @end smallexample
1166
1167 @noindent
1168 The effect of this pragma depends on whether the corresponding command
1169 line switch is set to activate assertions. The pragma expands into code
1170 equivalent to the following:
1171
1172 @smallexample @c ada
1173 if assertions-enabled then
1174 if not boolean_EXPRESSION then
1175 System.Assertions.Raise_Assert_Failure
1176 (string_EXPRESSION);
1177 end if;
1178 end if;
1179 @end smallexample
1180
1181 @noindent
1182 The string argument, if given, is the message that will be associated
1183 with the exception occurrence if the exception is raised. If no second
1184 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1185 where @var{file} is the name of the source file containing the assert,
1186 and @var{nnn} is the line number of the assert. A pragma is not a
1187 statement, so if a statement sequence contains nothing but a pragma
1188 assert, then a null statement is required in addition, as in:
1189
1190 @smallexample @c ada
1191 @dots{}
1192 if J > 3 then
1193 pragma Assert (K > 3, "Bad value for K");
1194 null;
1195 end if;
1196 @end smallexample
1197
1198 @noindent
1199 Note that, as with the @code{if} statement to which it is equivalent, the
1200 type of the expression is either @code{Standard.Boolean}, or any type derived
1201 from this standard type.
1202
1203 If assertions are disabled (switch @option{-gnata} not used), then there
1204 is no run-time effect (and in particular, any side effects from the
1205 expression will not occur at run time). (The expression is still
1206 analyzed at compile time, and may cause types to be frozen if they are
1207 mentioned here for the first time).
1208
1209 If assertions are enabled, then the given expression is tested, and if
1210 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1211 which results in the raising of @code{Assert_Failure} with the given message.
1212
1213 You should generally avoid side effects in the expression arguments of
1214 this pragma, because these side effects will turn on and off with the
1215 setting of the assertions mode, resulting in assertions that have an
1216 effect on the program. However, the expressions are analyzed for
1217 semantic correctness whether or not assertions are enabled, so turning
1218 assertions on and off cannot affect the legality of a program.
1219
1220 Note that the implementation defined policy @code{DISABLE}, given in a
1221 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1222
1223 Note: this is a standard language-defined pragma in versions
1224 of Ada from 2005 on. In GNAT, it is implemented in all versions
1225 of Ada, and the DISABLE policy is an implementation-defined
1226 addition.
1227
1228 @node Pragma Assertion_Policy
1229 @unnumberedsec Pragma Assertion_Policy
1230 @findex Debug_Policy
1231 @noindent
1232 Syntax:
1233
1234 @smallexample @c ada
1235 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1236 @end smallexample
1237
1238 @noindent
1239 This is a standard Ada 2005 pragma that is available as an
1240 implementation-defined pragma in earlier versions of Ada.
1241
1242 If the argument is @code{CHECK}, then assertions are enabled.
1243 If the argument is @code{IGNORE}, then assertions are ignored.
1244 This pragma overrides the effect of the @option{-gnata} switch on the
1245 command line.
1246
1247 Assertions are of three kinds:
1248
1249 @itemize @bullet
1250 @item
1251 Pragma @code{Assert}.
1252 @item
1253 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1254 postconditions, type invariants and (sub)type predicates.
1255 @item
1256 Corresponding pragmas for type invariants and (sub)type predicates.
1257 @end itemize
1258
1259 The implementation defined policy @code{DISABLE} is like
1260 @code{IGNORE} except that it completely disables semantic
1261 checking of the argument to @code{pragma Assert}. This may
1262 be useful when the pragma argument references subprograms
1263 in a with'ed package which is replaced by a dummy package
1264 for the final build.
1265
1266 Note: this is a standard language-defined pragma in versions
1267 of Ada from 2005 on. In GNAT, it is implemented in all versions
1268 of Ada, and the DISABLE policy is an implementation-defined
1269 addition.
1270
1271 @node Pragma Assume_No_Invalid_Values
1272 @unnumberedsec Pragma Assume_No_Invalid_Values
1273 @findex Assume_No_Invalid_Values
1274 @cindex Invalid representations
1275 @cindex Invalid values
1276 @noindent
1277 Syntax:
1278 @smallexample @c ada
1279 pragma Assume_No_Invalid_Values (On | Off);
1280 @end smallexample
1281
1282 @noindent
1283 This is a configuration pragma that controls the assumptions made by the
1284 compiler about the occurrence of invalid representations (invalid values)
1285 in the code.
1286
1287 The default behavior (corresponding to an Off argument for this pragma), is
1288 to assume that values may in general be invalid unless the compiler can
1289 prove they are valid. Consider the following example:
1290
1291 @smallexample @c ada
1292 V1 : Integer range 1 .. 10;
1293 V2 : Integer range 11 .. 20;
1294 ...
1295 for J in V2 .. V1 loop
1296 ...
1297 end loop;
1298 @end smallexample
1299
1300 @noindent
1301 if V1 and V2 have valid values, then the loop is known at compile
1302 time not to execute since the lower bound must be greater than the
1303 upper bound. However in default mode, no such assumption is made,
1304 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1305 is given, the compiler will assume that any occurrence of a variable
1306 other than in an explicit @code{'Valid} test always has a valid
1307 value, and the loop above will be optimized away.
1308
1309 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1310 you know your code is free of uninitialized variables and other
1311 possible sources of invalid representations, and may result in
1312 more efficient code. A program that accesses an invalid representation
1313 with this pragma in effect is erroneous, so no guarantees can be made
1314 about its behavior.
1315
1316 It is peculiar though permissible to use this pragma in conjunction
1317 with validity checking (-gnatVa). In such cases, accessing invalid
1318 values will generally give an exception, though formally the program
1319 is erroneous so there are no guarantees that this will always be the
1320 case, and it is recommended that these two options not be used together.
1321
1322 @node Pragma Ast_Entry
1323 @unnumberedsec Pragma Ast_Entry
1324 @cindex OpenVMS
1325 @findex Ast_Entry
1326 @noindent
1327 Syntax:
1328 @smallexample @c ada
1329 pragma AST_Entry (entry_IDENTIFIER);
1330 @end smallexample
1331
1332 @noindent
1333 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1334 argument is the simple name of a single entry; at most one @code{AST_Entry}
1335 pragma is allowed for any given entry. This pragma must be used in
1336 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1337 the entry declaration and in the same task type specification or single task
1338 as the entry to which it applies. This pragma specifies that the given entry
1339 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1340 resulting from an OpenVMS system service call. The pragma does not affect
1341 normal use of the entry. For further details on this pragma, see the
1342 DEC Ada Language Reference Manual, section 9.12a.
1343
1344 @node Pragma Attribute_Definition
1345 @unnumberedsec Pragma Attribute_Definition
1346 @findex Attribute_Definition
1347 @noindent
1348 Syntax:
1349 @smallexample @c ada
1350 pragma Attribute_Definition
1351 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1352 [Entity =>] LOCAL_NAME,
1353 [Expression =>] EXPRESSION | NAME);
1354 @end smallexample
1355
1356 @noindent
1357 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1358 the attribute definition clause:
1359
1360 @smallexample @c ada
1361 for Entity'Attribute use Expression;
1362 @end smallexample
1363
1364 If @code{Attribute} is not a recognized attribute name, the pragma is
1365 ignored, and a warning is emitted. This allows source
1366 code to be written that takes advantage of some new attribute, while remaining
1367 compilable with earlier compilers.
1368
1369 @node Pragma C_Pass_By_Copy
1370 @unnumberedsec Pragma C_Pass_By_Copy
1371 @cindex Passing by copy
1372 @findex C_Pass_By_Copy
1373 @noindent
1374 Syntax:
1375 @smallexample @c ada
1376 pragma C_Pass_By_Copy
1377 ([Max_Size =>] static_integer_EXPRESSION);
1378 @end smallexample
1379
1380 @noindent
1381 Normally the default mechanism for passing C convention records to C
1382 convention subprograms is to pass them by reference, as suggested by RM
1383 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1384 this default, by requiring that record formal parameters be passed by
1385 copy if all of the following conditions are met:
1386
1387 @itemize @bullet
1388 @item
1389 The size of the record type does not exceed the value specified for
1390 @code{Max_Size}.
1391 @item
1392 The record type has @code{Convention C}.
1393 @item
1394 The formal parameter has this record type, and the subprogram has a
1395 foreign (non-Ada) convention.
1396 @end itemize
1397
1398 @noindent
1399 If these conditions are met the argument is passed by copy, i.e.@: in a
1400 manner consistent with what C expects if the corresponding formal in the
1401 C prototype is a struct (rather than a pointer to a struct).
1402
1403 You can also pass records by copy by specifying the convention
1404 @code{C_Pass_By_Copy} for the record type, or by using the extended
1405 @code{Import} and @code{Export} pragmas, which allow specification of
1406 passing mechanisms on a parameter by parameter basis.
1407
1408 @node Pragma Check
1409 @unnumberedsec Pragma Check
1410 @cindex Assertions
1411 @cindex Named assertions
1412 @findex Check
1413 @noindent
1414 Syntax:
1415 @smallexample @c ada
1416 pragma Check (
1417 [Name =>] Identifier,
1418 [Check =>] Boolean_EXPRESSION
1419 [, [Message =>] string_EXPRESSION] );
1420 @end smallexample
1421
1422 @noindent
1423 This pragma is similar to the predefined pragma @code{Assert} except that an
1424 extra identifier argument is present. In conjunction with pragma
1425 @code{Check_Policy}, this can be used to define groups of assertions that can
1426 be independently controlled. The identifier @code{Assertion} is special, it
1427 refers to the normal set of pragma @code{Assert} statements. The identifiers
1428 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1429 names, so these three names would normally not be used directly in a pragma
1430 @code{Check}.
1431
1432 Checks introduced by this pragma are normally deactivated by default. They can
1433 be activated either by the command line option @option{-gnata}, which turns on
1434 all checks, or individually controlled using pragma @code{Check_Policy}.
1435
1436 @node Pragma Check_Float_Overflow
1437 @unnumberedsec Pragma Check_Float_Overflow
1438 @cindex Floating-point overflow
1439 @findex Check_Float_Overflow
1440 @noindent
1441 Syntax:
1442 @smallexample @c ada
1443 pragma Check_Float_Overflow;
1444 @end smallexample
1445
1446 @noindent
1447 In Ada, the predefined floating-point types (@code{Short_Float},
1448 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1449 defined to be @emph{unconstrained}. This means that even though each
1450 has a well-defined base range, an operation that delivers a result
1451 outside this base range is not required to raise an exception.
1452 This implementation permission accommodates the notion
1453 of infinities in IEEE floating-point, and corresponds to the
1454 efficient execution mode on most machines. GNAT will not raise
1455 overflow exceptions on these machines; instead it will generate
1456 infinities and NaN's as defined in the IEEE standard.
1457
1458 Generating infinities, although efficient, is not always desirable.
1459 Often the preferable approach is to check for overflow, even at the
1460 (perhaps considerable) expense of run-time performance.
1461 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1462 range constraints -- and indeed such a subtype
1463 can have the same base range as its base type. For example:
1464
1465 @smallexample @c ada
1466 subtype My_Float is Float range Float'Range;
1467 @end smallexample
1468
1469 @noindent
1470 Here @code{My_Float} has the same range as
1471 @code{Float} but is constrained, so operations on
1472 @code{My_Float} values will be checked for overflow
1473 against this range.
1474
1475 This style will achieve the desired goal, but
1476 it is often more convenient to be able to simply use
1477 the standard predefined floating-point types as long
1478 as overflow checking could be guaranteed.
1479 The @code{Check_Float_Overflow}
1480 configuration pragma achieves this effect. If a unit is compiled
1481 subject to this configuration pragma, then all operations
1482 on predefined floating-point types will be treated as
1483 though those types were constrained, and overflow checks
1484 will be generated. The @code{Constraint_Error}
1485 exception is raised if the result is out of range.
1486
1487 This mode can also be set by use of the compiler
1488 switch @option{-gnateF}.
1489
1490 @node Pragma Check_Name
1491 @unnumberedsec Pragma Check_Name
1492 @cindex Defining check names
1493 @cindex Check names, defining
1494 @findex Check_Name
1495 @noindent
1496 Syntax:
1497 @smallexample @c ada
1498 pragma Check_Name (check_name_IDENTIFIER);
1499 @end smallexample
1500
1501 @noindent
1502 This is a configuration pragma that defines a new implementation
1503 defined check name (unless IDENTIFIER matches one of the predefined
1504 check names, in which case the pragma has no effect). Check names
1505 are global to a partition, so if two or more configuration pragmas
1506 are present in a partition mentioning the same name, only one new
1507 check name is introduced.
1508
1509 An implementation defined check name introduced with this pragma may
1510 be used in only three contexts: @code{pragma Suppress},
1511 @code{pragma Unsuppress},
1512 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1513 any of these three cases, the check name must be visible. A check
1514 name is visible if it is in the configuration pragmas applying to
1515 the current unit, or if it appears at the start of any unit that
1516 is part of the dependency set of the current unit (e.g., units that
1517 are mentioned in @code{with} clauses).
1518
1519 Check names introduced by this pragma are subject to control by compiler
1520 switches (in particular -gnatp) in the usual manner.
1521
1522 @node Pragma Check_Policy
1523 @unnumberedsec Pragma Check_Policy
1524 @cindex Controlling assertions
1525 @cindex Assertions, control
1526 @cindex Check pragma control
1527 @cindex Named assertions
1528 @findex Check
1529 @noindent
1530 Syntax:
1531 @smallexample @c ada
1532 pragma Check_Policy
1533 ([Name =>] Identifier,
1534 [Policy =>] POLICY_IDENTIFIER);
1535
1536 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1537 @end smallexample
1538
1539 @noindent
1540 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1541 except that it controls sets of named assertions introduced using the
1542 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1543 @code{Assertion_Policy}) can be used within a declarative part, in which case
1544 it controls the status to the end of the corresponding construct (in a manner
1545 identical to pragma @code{Suppress)}.
1546
1547 The identifier given as the first argument corresponds to a name used in
1548 associated @code{Check} pragmas. For example, if the pragma:
1549
1550 @smallexample @c ada
1551 pragma Check_Policy (Critical_Error, OFF);
1552 @end smallexample
1553
1554 @noindent
1555 is given, then subsequent @code{Check} pragmas whose first argument is also
1556 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1557 controls the behavior of normal assertions (thus a pragma
1558 @code{Check_Policy} with this identifier is similar to the normal
1559 @code{Assertion_Policy} pragma except that it can appear within a
1560 declarative part).
1561
1562 The special identifiers @code{Precondition} and @code{Postcondition} control
1563 the status of preconditions and postconditions given as pragmas.
1564 If a @code{Precondition} pragma
1565 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1566 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1567 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1568 are recognized. Note that preconditions and postconditions given as aspects
1569 are controlled differently, either by the @code{Assertion_Policy} pragma or
1570 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1571
1572 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1573 to turn on corresponding checks. The default for a set of checks for which no
1574 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1575 @option{-gnata} is given, which turns on all checks by default.
1576
1577 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1578 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1579 compatibility with the standard @code{Assertion_Policy} pragma.
1580
1581 The implementation defined policy @code{DISABLE} is like
1582 @code{OFF} except that it completely disables semantic
1583 checking of the argument to the corresponding class of
1584 pragmas. This may be useful when the pragma arguments reference
1585 subprograms in a with'ed package which is replaced by a dummy package
1586 for the final build.
1587
1588 @node Pragma Comment
1589 @unnumberedsec Pragma Comment
1590 @findex Comment
1591 @noindent
1592 Syntax:
1593
1594 @smallexample @c ada
1595 pragma Comment (static_string_EXPRESSION);
1596 @end smallexample
1597
1598 @noindent
1599 This is almost identical in effect to pragma @code{Ident}. It allows the
1600 placement of a comment into the object file and hence into the
1601 executable file if the operating system permits such usage. The
1602 difference is that @code{Comment}, unlike @code{Ident}, has
1603 no limitations on placement of the pragma (it can be placed
1604 anywhere in the main source unit), and if more than one pragma
1605 is used, all comments are retained.
1606
1607 @node Pragma Common_Object
1608 @unnumberedsec Pragma Common_Object
1609 @findex Common_Object
1610 @noindent
1611 Syntax:
1612
1613 @smallexample @c ada
1614 pragma Common_Object (
1615 [Internal =>] LOCAL_NAME
1616 [, [External =>] EXTERNAL_SYMBOL]
1617 [, [Size =>] EXTERNAL_SYMBOL] );
1618
1619 EXTERNAL_SYMBOL ::=
1620 IDENTIFIER
1621 | static_string_EXPRESSION
1622 @end smallexample
1623
1624 @noindent
1625 This pragma enables the shared use of variables stored in overlaid
1626 linker areas corresponding to the use of @code{COMMON}
1627 in Fortran. The single
1628 object @var{LOCAL_NAME} is assigned to the area designated by
1629 the @var{External} argument.
1630 You may define a record to correspond to a series
1631 of fields. The @var{Size} argument
1632 is syntax checked in GNAT, but otherwise ignored.
1633
1634 @code{Common_Object} is not supported on all platforms. If no
1635 support is available, then the code generator will issue a message
1636 indicating that the necessary attribute for implementation of this
1637 pragma is not available.
1638
1639 @node Pragma Compile_Time_Error
1640 @unnumberedsec Pragma Compile_Time_Error
1641 @findex Compile_Time_Error
1642 @noindent
1643 Syntax:
1644
1645 @smallexample @c ada
1646 pragma Compile_Time_Error
1647 (boolean_EXPRESSION, static_string_EXPRESSION);
1648 @end smallexample
1649
1650 @noindent
1651 This pragma can be used to generate additional compile time
1652 error messages. It
1653 is particularly useful in generics, where errors can be issued for
1654 specific problematic instantiations. The first parameter is a boolean
1655 expression. The pragma is effective only if the value of this expression
1656 is known at compile time, and has the value True. The set of expressions
1657 whose values are known at compile time includes all static boolean
1658 expressions, and also other values which the compiler can determine
1659 at compile time (e.g., the size of a record type set by an explicit
1660 size representation clause, or the value of a variable which was
1661 initialized to a constant and is known not to have been modified).
1662 If these conditions are met, an error message is generated using
1663 the value given as the second argument. This string value may contain
1664 embedded ASCII.LF characters to break the message into multiple lines.
1665
1666 @node Pragma Compile_Time_Warning
1667 @unnumberedsec Pragma Compile_Time_Warning
1668 @findex Compile_Time_Warning
1669 @noindent
1670 Syntax:
1671
1672 @smallexample @c ada
1673 pragma Compile_Time_Warning
1674 (boolean_EXPRESSION, static_string_EXPRESSION);
1675 @end smallexample
1676
1677 @noindent
1678 Same as pragma Compile_Time_Error, except a warning is issued instead
1679 of an error message. Note that if this pragma is used in a package that
1680 is with'ed by a client, the client will get the warning even though it
1681 is issued by a with'ed package (normally warnings in with'ed units are
1682 suppressed, but this is a special exception to that rule).
1683
1684 One typical use is within a generic where compile time known characteristics
1685 of formal parameters are tested, and warnings given appropriately. Another use
1686 with a first parameter of True is to warn a client about use of a package,
1687 for example that it is not fully implemented.
1688
1689 @node Pragma Compiler_Unit
1690 @unnumberedsec Pragma Compiler_Unit
1691 @findex Compiler_Unit
1692 @noindent
1693 Syntax:
1694
1695 @smallexample @c ada
1696 pragma Compiler_Unit;
1697 @end smallexample
1698
1699 @noindent
1700 This pragma is intended only for internal use in the GNAT run-time library.
1701 It indicates that the unit is used as part of the compiler build. The effect
1702 is to disallow constructs (raise with message, conditional expressions etc)
1703 that would cause trouble when bootstrapping using an older version of GNAT.
1704 For the exact list of restrictions, see the compiler sources and references
1705 to Is_Compiler_Unit.
1706
1707 @node Pragma Complete_Representation
1708 @unnumberedsec Pragma Complete_Representation
1709 @findex Complete_Representation
1710 @noindent
1711 Syntax:
1712
1713 @smallexample @c ada
1714 pragma Complete_Representation;
1715 @end smallexample
1716
1717 @noindent
1718 This pragma must appear immediately within a record representation
1719 clause. Typical placements are before the first component clause
1720 or after the last component clause. The effect is to give an error
1721 message if any component is missing a component clause. This pragma
1722 may be used to ensure that a record representation clause is
1723 complete, and that this invariant is maintained if fields are
1724 added to the record in the future.
1725
1726 @node Pragma Complex_Representation
1727 @unnumberedsec Pragma Complex_Representation
1728 @findex Complex_Representation
1729 @noindent
1730 Syntax:
1731
1732 @smallexample @c ada
1733 pragma Complex_Representation
1734 ([Entity =>] LOCAL_NAME);
1735 @end smallexample
1736
1737 @noindent
1738 The @var{Entity} argument must be the name of a record type which has
1739 two fields of the same floating-point type. The effect of this pragma is
1740 to force gcc to use the special internal complex representation form for
1741 this record, which may be more efficient. Note that this may result in
1742 the code for this type not conforming to standard ABI (application
1743 binary interface) requirements for the handling of record types. For
1744 example, in some environments, there is a requirement for passing
1745 records by pointer, and the use of this pragma may result in passing
1746 this type in floating-point registers.
1747
1748 @node Pragma Component_Alignment
1749 @unnumberedsec Pragma Component_Alignment
1750 @cindex Alignments of components
1751 @findex Component_Alignment
1752 @noindent
1753 Syntax:
1754
1755 @smallexample @c ada
1756 pragma Component_Alignment (
1757 [Form =>] ALIGNMENT_CHOICE
1758 [, [Name =>] type_LOCAL_NAME]);
1759
1760 ALIGNMENT_CHOICE ::=
1761 Component_Size
1762 | Component_Size_4
1763 | Storage_Unit
1764 | Default
1765 @end smallexample
1766
1767 @noindent
1768 Specifies the alignment of components in array or record types.
1769 The meaning of the @var{Form} argument is as follows:
1770
1771 @table @code
1772 @findex Component_Size
1773 @item Component_Size
1774 Aligns scalar components and subcomponents of the array or record type
1775 on boundaries appropriate to their inherent size (naturally
1776 aligned). For example, 1-byte components are aligned on byte boundaries,
1777 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1778 integer components are aligned on 4-byte boundaries and so on. These
1779 alignment rules correspond to the normal rules for C compilers on all
1780 machines except the VAX@.
1781
1782 @findex Component_Size_4
1783 @item Component_Size_4
1784 Naturally aligns components with a size of four or fewer
1785 bytes. Components that are larger than 4 bytes are placed on the next
1786 4-byte boundary.
1787
1788 @findex Storage_Unit
1789 @item Storage_Unit
1790 Specifies that array or record components are byte aligned, i.e.@:
1791 aligned on boundaries determined by the value of the constant
1792 @code{System.Storage_Unit}.
1793
1794 @cindex OpenVMS
1795 @item Default
1796 Specifies that array or record components are aligned on default
1797 boundaries, appropriate to the underlying hardware or operating system or
1798 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1799 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1800 the @code{Default} choice is the same as @code{Component_Size} (natural
1801 alignment).
1802 @end table
1803
1804 @noindent
1805 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1806 refer to a local record or array type, and the specified alignment
1807 choice applies to the specified type. The use of
1808 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1809 @code{Component_Alignment} pragma to be ignored. The use of
1810 @code{Component_Alignment} together with a record representation clause
1811 is only effective for fields not specified by the representation clause.
1812
1813 If the @code{Name} parameter is absent, the pragma can be used as either
1814 a configuration pragma, in which case it applies to one or more units in
1815 accordance with the normal rules for configuration pragmas, or it can be
1816 used within a declarative part, in which case it applies to types that
1817 are declared within this declarative part, or within any nested scope
1818 within this declarative part. In either case it specifies the alignment
1819 to be applied to any record or array type which has otherwise standard
1820 representation.
1821
1822 If the alignment for a record or array type is not specified (using
1823 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1824 clause), the GNAT uses the default alignment as described previously.
1825
1826 @node Pragma Contract_Case
1827 @unnumberedsec Pragma Contract_Case
1828 @cindex Contract cases
1829 @findex Contract_Case
1830 @noindent
1831 Syntax:
1832
1833 @smallexample @c ada
1834 pragma Contract_Case (
1835 [Name =>] static_string_Expression
1836 ,[Mode =>] (Nominal | Robustness)
1837 [, Requires => Boolean_Expression]
1838 [, Ensures => Boolean_Expression]);
1839 @end smallexample
1840
1841 @noindent
1842 The @code{Contract_Case} pragma allows defining fine-grain specifications
1843 that can complement or replace the contract given by a precondition and a
1844 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1845 by testing and formal verification tools. The compiler checks its validity and,
1846 depending on the assertion policy at the point of declaration of the pragma,
1847 it may insert a check in the executable. For code generation, the contract
1848 case
1849
1850 @smallexample @c ada
1851 pragma Contract_Case (
1852 Name => ...
1853 Mode => ...
1854 Requires => R,
1855 Ensures => E);
1856 @end smallexample
1857
1858 @noindent
1859 is equivalent to
1860
1861 @smallexample @c ada
1862 pragma Postcondition (not R'Old or else E);
1863 @end smallexample
1864
1865 @noindent
1866 which is also equivalent to (in Ada 2012)
1867
1868 @smallexample @c ada
1869 pragma Postcondition (if R'Old then E);
1870 @end smallexample
1871
1872 @noindent
1873 expressing that, whenever condition @code{R} is satisfied on entry to the
1874 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1875
1876 A precondition @code{P} and postcondition @code{Q} can also be
1877 expressed as contract cases:
1878
1879 @smallexample @c ada
1880 pragma Contract_Case (
1881 Name => "Replace precondition",
1882 Mode => Nominal,
1883 Requires => not P,
1884 Ensures => False);
1885 pragma Contract_Case (
1886 Name => "Replace postcondition",
1887 Mode => Nominal,
1888 Requires => P,
1889 Ensures => Q);
1890 @end smallexample
1891
1892 @code{Contract_Case} pragmas may only appear immediately following the
1893 (separate) declaration of a subprogram in a package declaration, inside
1894 a package spec unit. Only other pragmas may intervene (that is appear
1895 between the subprogram declaration and a contract case).
1896
1897 The compiler checks that boolean expressions given in @code{Requires} and
1898 @code{Ensures} are valid, where the rules for @code{Requires} are the
1899 same as the rule for an expression in @code{Precondition} and the rules
1900 for @code{Ensures} are the same as the rule for an expression in
1901 @code{Postcondition}. In particular, attributes @code{'Old} and
1902 @code{'Result} can only be used within the @code{Ensures}
1903 expression. The following is an example of use within a package spec:
1904
1905 @smallexample @c ada
1906 package Math_Functions is
1907 ...
1908 function Sqrt (Arg : Float) return Float;
1909 pragma Contract_Case (Name => "Small argument",
1910 Mode => Nominal,
1911 Requires => Arg < 100,
1912 Ensures => Sqrt'Result < 10);
1913 ...
1914 end Math_Functions;
1915 @end smallexample
1916
1917 @noindent
1918 The meaning of a contract case is that, whenever the associated subprogram is
1919 executed in a context where @code{Requires} holds, then @code{Ensures}
1920 should hold when the subprogram returns. Mode @code{Nominal} indicates
1921 that the input context should also satisfy the precondition of the
1922 subprogram, and the output context should also satisfy its
1923 postcondition. More @code{Robustness} indicates that the precondition and
1924 postcondition of the subprogram should be ignored for this contract case,
1925 which is mostly useful when testing such a contract using a testing tool
1926 that understands contract cases.
1927
1928 @node Pragma Convention_Identifier
1929 @unnumberedsec Pragma Convention_Identifier
1930 @findex Convention_Identifier
1931 @cindex Conventions, synonyms
1932 @noindent
1933 Syntax:
1934
1935 @smallexample @c ada
1936 pragma Convention_Identifier (
1937 [Name =>] IDENTIFIER,
1938 [Convention =>] convention_IDENTIFIER);
1939 @end smallexample
1940
1941 @noindent
1942 This pragma provides a mechanism for supplying synonyms for existing
1943 convention identifiers. The @code{Name} identifier can subsequently
1944 be used as a synonym for the given convention in other pragmas (including
1945 for example pragma @code{Import} or another @code{Convention_Identifier}
1946 pragma). As an example of the use of this, suppose you had legacy code
1947 which used Fortran77 as the identifier for Fortran. Then the pragma:
1948
1949 @smallexample @c ada
1950 pragma Convention_Identifier (Fortran77, Fortran);
1951 @end smallexample
1952
1953 @noindent
1954 would allow the use of the convention identifier @code{Fortran77} in
1955 subsequent code, avoiding the need to modify the sources. As another
1956 example, you could use this to parameterize convention requirements
1957 according to systems. Suppose you needed to use @code{Stdcall} on
1958 windows systems, and @code{C} on some other system, then you could
1959 define a convention identifier @code{Library} and use a single
1960 @code{Convention_Identifier} pragma to specify which convention
1961 would be used system-wide.
1962
1963 @node Pragma CPP_Class
1964 @unnumberedsec Pragma CPP_Class
1965 @findex CPP_Class
1966 @cindex Interfacing with C++
1967 @noindent
1968 Syntax:
1969
1970 @smallexample @c ada
1971 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1972 @end smallexample
1973
1974 @noindent
1975 The argument denotes an entity in the current declarative region that is
1976 declared as a record type. It indicates that the type corresponds to an
1977 externally declared C++ class type, and is to be laid out the same way
1978 that C++ would lay out the type. If the C++ class has virtual primitives
1979 then the record must be declared as a tagged record type.
1980
1981 Types for which @code{CPP_Class} is specified do not have assignment or
1982 equality operators defined (such operations can be imported or declared
1983 as subprograms as required). Initialization is allowed only by constructor
1984 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1985 limited if not explicitly declared as limited or derived from a limited
1986 type, and an error is issued in that case.
1987
1988 See @ref{Interfacing to C++} for related information.
1989
1990 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1991 for backward compatibility but its functionality is available
1992 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1993
1994 @node Pragma CPP_Constructor
1995 @unnumberedsec Pragma CPP_Constructor
1996 @cindex Interfacing with C++
1997 @findex CPP_Constructor
1998 @noindent
1999 Syntax:
2000
2001 @smallexample @c ada
2002 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2003 [, [External_Name =>] static_string_EXPRESSION ]
2004 [, [Link_Name =>] static_string_EXPRESSION ]);
2005 @end smallexample
2006
2007 @noindent
2008 This pragma identifies an imported function (imported in the usual way
2009 with pragma @code{Import}) as corresponding to a C++ constructor. If
2010 @code{External_Name} and @code{Link_Name} are not specified then the
2011 @code{Entity} argument is a name that must have been previously mentioned
2012 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2013 must be of one of the following forms:
2014
2015 @itemize @bullet
2016 @item
2017 @code{function @var{Fname} return @var{T}}
2018
2019 @itemize @bullet
2020 @item
2021 @code{function @var{Fname} return @var{T}'Class}
2022
2023 @item
2024 @code{function @var{Fname} (@dots{}) return @var{T}}
2025 @end itemize
2026
2027 @item
2028 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2029 @end itemize
2030
2031 @noindent
2032 where @var{T} is a limited record type imported from C++ with pragma
2033 @code{Import} and @code{Convention} = @code{CPP}.
2034
2035 The first two forms import the default constructor, used when an object
2036 of type @var{T} is created on the Ada side with no explicit constructor.
2037 The latter two forms cover all the non-default constructors of the type.
2038 See the @value{EDITION} User's Guide for details.
2039
2040 If no constructors are imported, it is impossible to create any objects
2041 on the Ada side and the type is implicitly declared abstract.
2042
2043 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2044 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2045 GCC switch).
2046 See @ref{Interfacing to C++} for more related information.
2047
2048 Note: The use of functions returning class-wide types for constructors is
2049 currently obsolete. They are supported for backward compatibility. The
2050 use of functions returning the type T leave the Ada sources more clear
2051 because the imported C++ constructors always return an object of type T;
2052 that is, they never return an object whose type is a descendant of type T.
2053
2054 @node Pragma CPP_Virtual
2055 @unnumberedsec Pragma CPP_Virtual
2056 @cindex Interfacing to C++
2057 @findex CPP_Virtual
2058 @noindent
2059 This pragma is now obsolete has has no effect because GNAT generates
2060 the same object layout than the G++ compiler.
2061
2062 See @ref{Interfacing to C++} for related information.
2063
2064 @node Pragma CPP_Vtable
2065 @unnumberedsec Pragma CPP_Vtable
2066 @cindex Interfacing with C++
2067 @findex CPP_Vtable
2068 @noindent
2069 This pragma is now obsolete has has no effect because GNAT generates
2070 the same object layout than the G++ compiler.
2071
2072 See @ref{Interfacing to C++} for related information.
2073
2074 @node Pragma CPU
2075 @unnumberedsec Pragma CPU
2076 @findex CPU
2077 @noindent
2078 Syntax:
2079
2080 @smallexample @c ada
2081 pragma CPU (EXPRESSSION);
2082 @end smallexample
2083
2084 @noindent
2085 This pragma is standard in Ada 2012, but is available in all earlier
2086 versions of Ada as an implementation-defined pragma.
2087 See Ada 2012 Reference Manual for details.
2088
2089 @node Pragma Debug
2090 @unnumberedsec Pragma Debug
2091 @findex Debug
2092 @noindent
2093 Syntax:
2094
2095 @smallexample @c ada
2096 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2097
2098 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2099 PROCEDURE_NAME
2100 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2101 @end smallexample
2102
2103 @noindent
2104 The procedure call argument has the syntactic form of an expression, meeting
2105 the syntactic requirements for pragmas.
2106
2107 If debug pragmas are not enabled or if the condition is present and evaluates
2108 to False, this pragma has no effect. If debug pragmas are enabled, the
2109 semantics of the pragma is exactly equivalent to the procedure call statement
2110 corresponding to the argument with a terminating semicolon. Pragmas are
2111 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2112 intersperse calls to debug procedures in the middle of declarations. Debug
2113 pragmas can be enabled either by use of the command line switch @option{-gnata}
2114 or by use of the configuration pragma @code{Debug_Policy}.
2115
2116 @node Pragma Debug_Policy
2117 @unnumberedsec Pragma Debug_Policy
2118 @findex Debug_Policy
2119 @noindent
2120 Syntax:
2121
2122 @smallexample @c ada
2123 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
2124 @end smallexample
2125
2126 @noindent
2127 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
2128 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2129 This pragma overrides the effect of the @option{-gnata} switch on the
2130 command line.
2131
2132 The implementation defined policy @code{DISABLE} is like
2133 @code{IGNORE} except that it completely disables semantic
2134 checking of the argument to @code{pragma Debug}. This may
2135 be useful when the pragma argument references subprograms
2136 in a with'ed package which is replaced by a dummy package
2137 for the final build.
2138
2139 @node Pragma Default_Storage_Pool
2140 @unnumberedsec Pragma Default_Storage_Pool
2141 @findex Default_Storage_Pool
2142 @noindent
2143 Syntax:
2144
2145 @smallexample @c ada
2146 pragma Default_Storage_Pool (storage_pool_NAME | null);
2147 @end smallexample
2148
2149 @noindent
2150 This pragma is standard in Ada 2012, but is available in all earlier
2151 versions of Ada as an implementation-defined pragma.
2152 See Ada 2012 Reference Manual for details.
2153
2154 @node Pragma Detect_Blocking
2155 @unnumberedsec Pragma Detect_Blocking
2156 @findex Detect_Blocking
2157 @noindent
2158 Syntax:
2159
2160 @smallexample @c ada
2161 pragma Detect_Blocking;
2162 @end smallexample
2163
2164 @noindent
2165 This is a standard pragma in Ada 2005, that is available in all earlier
2166 versions of Ada as an implementation-defined pragma.
2167
2168 This is a configuration pragma that forces the detection of potentially
2169 blocking operations within a protected operation, and to raise Program_Error
2170 if that happens.
2171
2172 @node Pragma Dispatching_Domain
2173 @unnumberedsec Pragma Dispatching_Domain
2174 @findex Dispatching_Domain
2175 @noindent
2176 Syntax:
2177
2178 @smallexample @c ada
2179 pragma Dispatching_Domain (EXPRESSION);
2180 @end smallexample
2181
2182 @noindent
2183 This pragma is standard in Ada 2012, but is available in all earlier
2184 versions of Ada as an implementation-defined pragma.
2185 See Ada 2012 Reference Manual for details.
2186
2187 @node Pragma Elaboration_Checks
2188 @unnumberedsec Pragma Elaboration_Checks
2189 @cindex Elaboration control
2190 @findex Elaboration_Checks
2191 @noindent
2192 Syntax:
2193
2194 @smallexample @c ada
2195 pragma Elaboration_Checks (Dynamic | Static);
2196 @end smallexample
2197
2198 @noindent
2199 This is a configuration pragma that provides control over the
2200 elaboration model used by the compilation affected by the
2201 pragma. If the parameter is @code{Dynamic},
2202 then the dynamic elaboration
2203 model described in the Ada Reference Manual is used, as though
2204 the @option{-gnatE} switch had been specified on the command
2205 line. If the parameter is @code{Static}, then the default GNAT static
2206 model is used. This configuration pragma overrides the setting
2207 of the command line. For full details on the elaboration models
2208 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2209 gnat_ugn, @value{EDITION} User's Guide}.
2210
2211 @node Pragma Eliminate
2212 @unnumberedsec Pragma Eliminate
2213 @cindex Elimination of unused subprograms
2214 @findex Eliminate
2215 @noindent
2216 Syntax:
2217
2218 @smallexample @c ada
2219 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2220 [Source_Location =>] STRING_LITERAL);
2221 @end smallexample
2222
2223 @noindent
2224 The string literal given for the source location is a string which
2225 specifies the line number of the occurrence of the entity, using
2226 the syntax for SOURCE_TRACE given below:
2227
2228 @smallexample @c ada
2229 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2230
2231 LBRACKET ::= [
2232 RBRACKET ::= ]
2233
2234 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2235
2236 LINE_NUMBER ::= DIGIT @{DIGIT@}
2237 @end smallexample
2238
2239 @noindent
2240 Spaces around the colon in a @code{Source_Reference} are optional.
2241
2242 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2243 explicit subprogram declaration, where the @code{entity} name in this
2244 designator appears on the source line specified by the source location.
2245
2246 The source trace that is given as the @code{Source_Location} shall obey the
2247 following rules. The @code{FILE_NAME} is the short name (with no directory
2248 information) of an Ada source file, given using exactly the required syntax
2249 for the underlying file system (e.g. case is important if the underlying
2250 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2251 number of the occurrence of the @code{entity}
2252 as a decimal literal without an exponent or point. If an @code{entity} is not
2253 declared in a generic instantiation (this includes generic subprogram
2254 instances), the source trace includes only one source reference. If an entity
2255 is declared inside a generic instantiation, its source trace (when parsing
2256 from left to right) starts with the source location of the declaration of the
2257 entity in the generic unit and ends with the source location of the
2258 instantiation (it is given in square brackets). This approach is recursively
2259 used in case of nested instantiations: the rightmost (nested most deeply in
2260 square brackets) element of the source trace is the location of the outermost
2261 instantiation, the next to left element is the location of the next (first
2262 nested) instantiation in the code of the corresponding generic unit, and so
2263 on, and the leftmost element (that is out of any square brackets) is the
2264 location of the declaration of the entity to eliminate in a generic unit.
2265
2266 Note that the @code{Source_Location} argument specifies which of a set of
2267 similarly named entities is being eliminated, dealing both with overloading,
2268 and also appearence of the same entity name in different scopes.
2269
2270 This pragma indicates that the given entity is not used in the program to be
2271 compiled and built. The effect of the pragma is to allow the compiler to
2272 eliminate the code or data associated with the named entity. Any reference to
2273 an eliminated entity causes a compile-time or link-time error.
2274
2275 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2276 in a system-independent manner, with unused entities eliminated, without
2277 needing to modify the source text. Normally the required set of
2278 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2279
2280 Any source file change that removes, splits, or
2281 adds lines may make the set of Eliminate pragmas invalid because their
2282 @code{Source_Location} argument values may get out of date.
2283
2284 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2285 operation. In this case all the subprograms to which the given operation can
2286 dispatch are considered to be unused (are never called as a result of a direct
2287 or a dispatching call).
2288
2289 @node Pragma Export_Exception
2290 @unnumberedsec Pragma Export_Exception
2291 @cindex OpenVMS
2292 @findex Export_Exception
2293 @noindent
2294 Syntax:
2295
2296 @smallexample @c ada
2297 pragma Export_Exception (
2298 [Internal =>] LOCAL_NAME
2299 [, [External =>] EXTERNAL_SYMBOL]
2300 [, [Form =>] Ada | VMS]
2301 [, [Code =>] static_integer_EXPRESSION]);
2302
2303 EXTERNAL_SYMBOL ::=
2304 IDENTIFIER
2305 | static_string_EXPRESSION
2306 @end smallexample
2307
2308 @noindent
2309 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2310 causes the specified exception to be propagated outside of the Ada program,
2311 so that it can be handled by programs written in other OpenVMS languages.
2312 This pragma establishes an external name for an Ada exception and makes the
2313 name available to the OpenVMS Linker as a global symbol. For further details
2314 on this pragma, see the
2315 DEC Ada Language Reference Manual, section 13.9a3.2.
2316
2317 @node Pragma Export_Function
2318 @unnumberedsec Pragma Export_Function
2319 @cindex Argument passing mechanisms
2320 @findex Export_Function
2321
2322 @noindent
2323 Syntax:
2324
2325 @smallexample @c ada
2326 pragma Export_Function (
2327 [Internal =>] LOCAL_NAME
2328 [, [External =>] EXTERNAL_SYMBOL]
2329 [, [Parameter_Types =>] PARAMETER_TYPES]
2330 [, [Result_Type =>] result_SUBTYPE_MARK]
2331 [, [Mechanism =>] MECHANISM]
2332 [, [Result_Mechanism =>] MECHANISM_NAME]);
2333
2334 EXTERNAL_SYMBOL ::=
2335 IDENTIFIER
2336 | static_string_EXPRESSION
2337 | ""
2338
2339 PARAMETER_TYPES ::=
2340 null
2341 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2342
2343 TYPE_DESIGNATOR ::=
2344 subtype_NAME
2345 | subtype_Name ' Access
2346
2347 MECHANISM ::=
2348 MECHANISM_NAME
2349 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2350
2351 MECHANISM_ASSOCIATION ::=
2352 [formal_parameter_NAME =>] MECHANISM_NAME
2353
2354 MECHANISM_NAME ::=
2355 Value
2356 | Reference
2357 | Descriptor [([Class =>] CLASS_NAME)]
2358 | Short_Descriptor [([Class =>] CLASS_NAME)]
2359
2360 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2361 @end smallexample
2362
2363 @noindent
2364 Use this pragma to make a function externally callable and optionally
2365 provide information on mechanisms to be used for passing parameter and
2366 result values. We recommend, for the purposes of improving portability,
2367 this pragma always be used in conjunction with a separate pragma
2368 @code{Export}, which must precede the pragma @code{Export_Function}.
2369 GNAT does not require a separate pragma @code{Export}, but if none is
2370 present, @code{Convention Ada} is assumed, which is usually
2371 not what is wanted, so it is usually appropriate to use this
2372 pragma in conjunction with a @code{Export} or @code{Convention}
2373 pragma that specifies the desired foreign convention.
2374 Pragma @code{Export_Function}
2375 (and @code{Export}, if present) must appear in the same declarative
2376 region as the function to which they apply.
2377
2378 @var{internal_name} must uniquely designate the function to which the
2379 pragma applies. If more than one function name exists of this name in
2380 the declarative part you must use the @code{Parameter_Types} and
2381 @code{Result_Type} parameters is mandatory to achieve the required
2382 unique designation. @var{subtype_mark}s in these parameters must
2383 exactly match the subtypes in the corresponding function specification,
2384 using positional notation to match parameters with subtype marks.
2385 The form with an @code{'Access} attribute can be used to match an
2386 anonymous access parameter.
2387
2388 @cindex OpenVMS
2389 @cindex Passing by descriptor
2390 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2391 The default behavior for Export_Function is to accept either 64bit or
2392 32bit descriptors unless short_descriptor is specified, then only 32bit
2393 descriptors are accepted.
2394
2395 @cindex Suppressing external name
2396 Special treatment is given if the EXTERNAL is an explicit null
2397 string or a static string expressions that evaluates to the null
2398 string. In this case, no external name is generated. This form
2399 still allows the specification of parameter mechanisms.
2400
2401 @node Pragma Export_Object
2402 @unnumberedsec Pragma Export_Object
2403 @findex Export_Object
2404 @noindent
2405 Syntax:
2406
2407 @smallexample @c ada
2408 pragma Export_Object
2409 [Internal =>] LOCAL_NAME
2410 [, [External =>] EXTERNAL_SYMBOL]
2411 [, [Size =>] EXTERNAL_SYMBOL]
2412
2413 EXTERNAL_SYMBOL ::=
2414 IDENTIFIER
2415 | static_string_EXPRESSION
2416 @end smallexample
2417
2418 @noindent
2419 This pragma designates an object as exported, and apart from the
2420 extended rules for external symbols, is identical in effect to the use of
2421 the normal @code{Export} pragma applied to an object. You may use a
2422 separate Export pragma (and you probably should from the point of view
2423 of portability), but it is not required. @var{Size} is syntax checked,
2424 but otherwise ignored by GNAT@.
2425
2426 @node Pragma Export_Procedure
2427 @unnumberedsec Pragma Export_Procedure
2428 @findex Export_Procedure
2429 @noindent
2430 Syntax:
2431
2432 @smallexample @c ada
2433 pragma Export_Procedure (
2434 [Internal =>] LOCAL_NAME
2435 [, [External =>] EXTERNAL_SYMBOL]
2436 [, [Parameter_Types =>] PARAMETER_TYPES]
2437 [, [Mechanism =>] MECHANISM]);
2438
2439 EXTERNAL_SYMBOL ::=
2440 IDENTIFIER
2441 | static_string_EXPRESSION
2442 | ""
2443
2444 PARAMETER_TYPES ::=
2445 null
2446 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2447
2448 TYPE_DESIGNATOR ::=
2449 subtype_NAME
2450 | subtype_Name ' Access
2451
2452 MECHANISM ::=
2453 MECHANISM_NAME
2454 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2455
2456 MECHANISM_ASSOCIATION ::=
2457 [formal_parameter_NAME =>] MECHANISM_NAME
2458
2459 MECHANISM_NAME ::=
2460 Value
2461 | Reference
2462 | Descriptor [([Class =>] CLASS_NAME)]
2463 | Short_Descriptor [([Class =>] CLASS_NAME)]
2464
2465 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2466 @end smallexample
2467
2468 @noindent
2469 This pragma is identical to @code{Export_Function} except that it
2470 applies to a procedure rather than a function and the parameters
2471 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2472 GNAT does not require a separate pragma @code{Export}, but if none is
2473 present, @code{Convention Ada} is assumed, which is usually
2474 not what is wanted, so it is usually appropriate to use this
2475 pragma in conjunction with a @code{Export} or @code{Convention}
2476 pragma that specifies the desired foreign convention.
2477
2478 @cindex OpenVMS
2479 @cindex Passing by descriptor
2480 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2481 The default behavior for Export_Procedure is to accept either 64bit or
2482 32bit descriptors unless short_descriptor is specified, then only 32bit
2483 descriptors are accepted.
2484
2485 @cindex Suppressing external name
2486 Special treatment is given if the EXTERNAL is an explicit null
2487 string or a static string expressions that evaluates to the null
2488 string. In this case, no external name is generated. This form
2489 still allows the specification of parameter mechanisms.
2490
2491 @node Pragma Export_Value
2492 @unnumberedsec Pragma Export_Value
2493 @findex Export_Value
2494 @noindent
2495 Syntax:
2496
2497 @smallexample @c ada
2498 pragma Export_Value (
2499 [Value =>] static_integer_EXPRESSION,
2500 [Link_Name =>] static_string_EXPRESSION);
2501 @end smallexample
2502
2503 @noindent
2504 This pragma serves to export a static integer value for external use.
2505 The first argument specifies the value to be exported. The Link_Name
2506 argument specifies the symbolic name to be associated with the integer
2507 value. This pragma is useful for defining a named static value in Ada
2508 that can be referenced in assembly language units to be linked with
2509 the application. This pragma is currently supported only for the
2510 AAMP target and is ignored for other targets.
2511
2512 @node Pragma Export_Valued_Procedure
2513 @unnumberedsec Pragma Export_Valued_Procedure
2514 @findex Export_Valued_Procedure
2515 @noindent
2516 Syntax:
2517
2518 @smallexample @c ada
2519 pragma Export_Valued_Procedure (
2520 [Internal =>] LOCAL_NAME
2521 [, [External =>] EXTERNAL_SYMBOL]
2522 [, [Parameter_Types =>] PARAMETER_TYPES]
2523 [, [Mechanism =>] MECHANISM]);
2524
2525 EXTERNAL_SYMBOL ::=
2526 IDENTIFIER
2527 | static_string_EXPRESSION
2528 | ""
2529
2530 PARAMETER_TYPES ::=
2531 null
2532 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2533
2534 TYPE_DESIGNATOR ::=
2535 subtype_NAME
2536 | subtype_Name ' Access
2537
2538 MECHANISM ::=
2539 MECHANISM_NAME
2540 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2541
2542 MECHANISM_ASSOCIATION ::=
2543 [formal_parameter_NAME =>] MECHANISM_NAME
2544
2545 MECHANISM_NAME ::=
2546 Value
2547 | Reference
2548 | Descriptor [([Class =>] CLASS_NAME)]
2549 | Short_Descriptor [([Class =>] CLASS_NAME)]
2550
2551 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2552 @end smallexample
2553
2554 @noindent
2555 This pragma is identical to @code{Export_Procedure} except that the
2556 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2557 mode @code{OUT}, and externally the subprogram is treated as a function
2558 with this parameter as the result of the function. GNAT provides for
2559 this capability to allow the use of @code{OUT} and @code{IN OUT}
2560 parameters in interfacing to external functions (which are not permitted
2561 in Ada functions).
2562 GNAT does not require a separate pragma @code{Export}, but if none is
2563 present, @code{Convention Ada} is assumed, which is almost certainly
2564 not what is wanted since the whole point of this pragma is to interface
2565 with foreign language functions, so it is usually appropriate to use this
2566 pragma in conjunction with a @code{Export} or @code{Convention}
2567 pragma that specifies the desired foreign convention.
2568
2569 @cindex OpenVMS
2570 @cindex Passing by descriptor
2571 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2572 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2573 32bit descriptors unless short_descriptor is specified, then only 32bit
2574 descriptors are accepted.
2575
2576 @cindex Suppressing external name
2577 Special treatment is given if the EXTERNAL is an explicit null
2578 string or a static string expressions that evaluates to the null
2579 string. In this case, no external name is generated. This form
2580 still allows the specification of parameter mechanisms.
2581
2582 @node Pragma Extend_System
2583 @unnumberedsec Pragma Extend_System
2584 @cindex @code{system}, extending
2585 @cindex Dec Ada 83
2586 @findex Extend_System
2587 @noindent
2588 Syntax:
2589
2590 @smallexample @c ada
2591 pragma Extend_System ([Name =>] IDENTIFIER);
2592 @end smallexample
2593
2594 @noindent
2595 This pragma is used to provide backwards compatibility with other
2596 implementations that extend the facilities of package @code{System}. In
2597 GNAT, @code{System} contains only the definitions that are present in
2598 the Ada RM@. However, other implementations, notably the DEC Ada 83
2599 implementation, provide many extensions to package @code{System}.
2600
2601 For each such implementation accommodated by this pragma, GNAT provides a
2602 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2603 implementation, which provides the required additional definitions. You
2604 can use this package in two ways. You can @code{with} it in the normal
2605 way and access entities either by selection or using a @code{use}
2606 clause. In this case no special processing is required.
2607
2608 However, if existing code contains references such as
2609 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2610 definitions provided in package @code{System}, you may use this pragma
2611 to extend visibility in @code{System} in a non-standard way that
2612 provides greater compatibility with the existing code. Pragma
2613 @code{Extend_System} is a configuration pragma whose single argument is
2614 the name of the package containing the extended definition
2615 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2616 control of this pragma will be processed using special visibility
2617 processing that looks in package @code{System.Aux_@var{xxx}} where
2618 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2619 package @code{System}, but not found in package @code{System}.
2620
2621 You can use this pragma either to access a predefined @code{System}
2622 extension supplied with the compiler, for example @code{Aux_DEC} or
2623 you can construct your own extension unit following the above
2624 definition. Note that such a package is a child of @code{System}
2625 and thus is considered part of the implementation. To compile
2626 it you will have to use the appropriate switch for compiling
2627 system units.
2628 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2629 for details.
2630
2631 @node Pragma Extensions_Allowed
2632 @unnumberedsec Pragma Extensions_Allowed
2633 @cindex Ada Extensions
2634 @cindex GNAT Extensions
2635 @findex Extensions_Allowed
2636 @noindent
2637 Syntax:
2638
2639 @smallexample @c ada
2640 pragma Extensions_Allowed (On | Off);
2641 @end smallexample
2642
2643 @noindent
2644 This configuration pragma enables or disables the implementation
2645 extension mode (the use of Off as a parameter cancels the effect
2646 of the @option{-gnatX} command switch).
2647
2648 In extension mode, the latest version of the Ada language is
2649 implemented (currently Ada 2012), and in addition a small number
2650 of GNAT specific extensions are recognized as follows:
2651
2652 @table @asis
2653 @item Constrained attribute for generic objects
2654 The @code{Constrained} attribute is permitted for objects of
2655 generic types. The result indicates if the corresponding actual
2656 is constrained.
2657
2658 @end table
2659
2660 @node Pragma External
2661 @unnumberedsec Pragma External
2662 @findex External
2663 @noindent
2664 Syntax:
2665
2666 @smallexample @c ada
2667 pragma External (
2668 [ Convention =>] convention_IDENTIFIER,
2669 [ Entity =>] LOCAL_NAME
2670 [, [External_Name =>] static_string_EXPRESSION ]
2671 [, [Link_Name =>] static_string_EXPRESSION ]);
2672 @end smallexample
2673
2674 @noindent
2675 This pragma is identical in syntax and semantics to pragma
2676 @code{Export} as defined in the Ada Reference Manual. It is
2677 provided for compatibility with some Ada 83 compilers that
2678 used this pragma for exactly the same purposes as pragma
2679 @code{Export} before the latter was standardized.
2680
2681 @node Pragma External_Name_Casing
2682 @unnumberedsec Pragma External_Name_Casing
2683 @cindex Dec Ada 83 casing compatibility
2684 @cindex External Names, casing
2685 @cindex Casing of External names
2686 @findex External_Name_Casing
2687 @noindent
2688 Syntax:
2689
2690 @smallexample @c ada
2691 pragma External_Name_Casing (
2692 Uppercase | Lowercase
2693 [, Uppercase | Lowercase | As_Is]);
2694 @end smallexample
2695
2696 @noindent
2697 This pragma provides control over the casing of external names associated
2698 with Import and Export pragmas. There are two cases to consider:
2699
2700 @table @asis
2701 @item Implicit external names
2702 Implicit external names are derived from identifiers. The most common case
2703 arises when a standard Ada Import or Export pragma is used with only two
2704 arguments, as in:
2705
2706 @smallexample @c ada
2707 pragma Import (C, C_Routine);
2708 @end smallexample
2709
2710 @noindent
2711 Since Ada is a case-insensitive language, the spelling of the identifier in
2712 the Ada source program does not provide any information on the desired
2713 casing of the external name, and so a convention is needed. In GNAT the
2714 default treatment is that such names are converted to all lower case
2715 letters. This corresponds to the normal C style in many environments.
2716 The first argument of pragma @code{External_Name_Casing} can be used to
2717 control this treatment. If @code{Uppercase} is specified, then the name
2718 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2719 then the normal default of all lower case letters will be used.
2720
2721 This same implicit treatment is also used in the case of extended DEC Ada 83
2722 compatible Import and Export pragmas where an external name is explicitly
2723 specified using an identifier rather than a string.
2724
2725 @item Explicit external names
2726 Explicit external names are given as string literals. The most common case
2727 arises when a standard Ada Import or Export pragma is used with three
2728 arguments, as in:
2729
2730 @smallexample @c ada
2731 pragma Import (C, C_Routine, "C_routine");
2732 @end smallexample
2733
2734 @noindent
2735 In this case, the string literal normally provides the exact casing required
2736 for the external name. The second argument of pragma
2737 @code{External_Name_Casing} may be used to modify this behavior.
2738 If @code{Uppercase} is specified, then the name
2739 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2740 then the name will be forced to all lowercase letters. A specification of
2741 @code{As_Is} provides the normal default behavior in which the casing is
2742 taken from the string provided.
2743 @end table
2744
2745 @noindent
2746 This pragma may appear anywhere that a pragma is valid. In particular, it
2747 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2748 case it applies to all subsequent compilations, or it can be used as a program
2749 unit pragma, in which case it only applies to the current unit, or it can
2750 be used more locally to control individual Import/Export pragmas.
2751
2752 It is primarily intended for use with OpenVMS systems, where many
2753 compilers convert all symbols to upper case by default. For interfacing to
2754 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2755 the pragma:
2756
2757 @smallexample @c ada
2758 pragma External_Name_Casing (Uppercase, Uppercase);
2759 @end smallexample
2760
2761 @noindent
2762 to enforce the upper casing of all external symbols.
2763
2764 @node Pragma Fast_Math
2765 @unnumberedsec Pragma Fast_Math
2766 @findex Fast_Math
2767 @noindent
2768 Syntax:
2769
2770 @smallexample @c ada
2771 pragma Fast_Math;
2772 @end smallexample
2773
2774 @noindent
2775 This is a configuration pragma which activates a mode in which speed is
2776 considered more important for floating-point operations than absolutely
2777 accurate adherence to the requirements of the standard. Currently the
2778 following operations are affected:
2779
2780 @table @asis
2781 @item Complex Multiplication
2782 The normal simple formula for complex multiplication can result in intermediate
2783 overflows for numbers near the end of the range. The Ada standard requires that
2784 this situation be detected and corrected by scaling, but in Fast_Math mode such
2785 cases will simply result in overflow. Note that to take advantage of this you
2786 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2787 under control of the pragma, rather than use the preinstantiated versions.
2788 @end table
2789
2790 @node Pragma Favor_Top_Level
2791 @unnumberedsec Pragma Favor_Top_Level
2792 @findex Favor_Top_Level
2793 @noindent
2794 Syntax:
2795
2796 @smallexample @c ada
2797 pragma Favor_Top_Level (type_NAME);
2798 @end smallexample
2799
2800 @noindent
2801 The named type must be an access-to-subprogram type. This pragma is an
2802 efficiency hint to the compiler, regarding the use of 'Access or
2803 'Unrestricted_Access on nested (non-library-level) subprograms. The
2804 pragma means that nested subprograms are not used with this type, or
2805 are rare, so that the generated code should be efficient in the
2806 top-level case. When this pragma is used, dynamically generated
2807 trampolines may be used on some targets for nested subprograms.
2808 See also the No_Implicit_Dynamic_Code restriction.
2809
2810 @node Pragma Finalize_Storage_Only
2811 @unnumberedsec Pragma Finalize_Storage_Only
2812 @findex Finalize_Storage_Only
2813 @noindent
2814 Syntax:
2815
2816 @smallexample @c ada
2817 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2818 @end smallexample
2819
2820 @noindent
2821 This pragma allows the compiler not to emit a Finalize call for objects
2822 defined at the library level. This is mostly useful for types where
2823 finalization is only used to deal with storage reclamation since in most
2824 environments it is not necessary to reclaim memory just before terminating
2825 execution, hence the name.
2826
2827 @node Pragma Float_Representation
2828 @unnumberedsec Pragma Float_Representation
2829 @cindex OpenVMS
2830 @findex Float_Representation
2831 @noindent
2832 Syntax:
2833
2834 @smallexample @c ada
2835 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2836
2837 FLOAT_REP ::= VAX_Float | IEEE_Float
2838 @end smallexample
2839
2840 @noindent
2841 In the one argument form, this pragma is a configuration pragma which
2842 allows control over the internal representation chosen for the predefined
2843 floating point types declared in the packages @code{Standard} and
2844 @code{System}. On all systems other than OpenVMS, the argument must
2845 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2846 argument may be @code{VAX_Float} to specify the use of the VAX float
2847 format for the floating-point types in Standard. This requires that
2848 the standard runtime libraries be recompiled.
2849
2850 The two argument form specifies the representation to be used for
2851 the specified floating-point type. On all systems other than OpenVMS,
2852 the argument must
2853 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2854 argument may be @code{VAX_Float} to specify the use of the VAX float
2855 format, as follows:
2856
2857 @itemize @bullet
2858 @item
2859 For digits values up to 6, F float format will be used.
2860 @item
2861 For digits values from 7 to 9, D float format will be used.
2862 @item
2863 For digits values from 10 to 15, G float format will be used.
2864 @item
2865 Digits values above 15 are not allowed.
2866 @end itemize
2867
2868 @node Pragma Ident
2869 @unnumberedsec Pragma Ident
2870 @findex Ident
2871 @noindent
2872 Syntax:
2873
2874 @smallexample @c ada
2875 pragma Ident (static_string_EXPRESSION);
2876 @end smallexample
2877
2878 @noindent
2879 This pragma provides a string identification in the generated object file,
2880 if the system supports the concept of this kind of identification string.
2881 This pragma is allowed only in the outermost declarative part or
2882 declarative items of a compilation unit. If more than one @code{Ident}
2883 pragma is given, only the last one processed is effective.
2884 @cindex OpenVMS
2885 On OpenVMS systems, the effect of the pragma is identical to the effect of
2886 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2887 maximum allowed length is 31 characters, so if it is important to
2888 maintain compatibility with this compiler, you should obey this length
2889 limit.
2890
2891 @node Pragma Implementation_Defined
2892 @unnumberedsec Pragma Implementation_Defined
2893 @findex Implementation_Defined
2894 @noindent
2895 Syntax:
2896
2897 @smallexample @c ada
2898 pragma Implementation_Defined (local_NAME);
2899 @end smallexample
2900
2901 @noindent
2902 This pragma marks a previously declared entioty as implementation-defined.
2903 For an overloaded entity, applies to the most recent homonym.
2904
2905 @smallexample @c ada
2906 pragma Implementation_Defined;
2907 @end smallexample
2908
2909 @noindent
2910 The form with no arguments appears anywhere within a scope, most
2911 typically a package spec, and indicates that all entities that are
2912 defined within the package spec are Implementation_Defined.
2913
2914 This pragma is used within the GNAT runtime library to identify
2915 implementation-defined entities introduced in language-defined units,
2916 for the purpose of implementing the No_Implementation_Identifiers
2917 restriction.
2918
2919 @node Pragma Implemented
2920 @unnumberedsec Pragma Implemented
2921 @findex Implemented
2922 @noindent
2923 Syntax:
2924
2925 @smallexample @c ada
2926 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2927
2928 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2929 @end smallexample
2930
2931 @noindent
2932 This is an Ada 2012 representation pragma which applies to protected, task
2933 and synchronized interface primitives. The use of pragma Implemented provides
2934 a way to impose a static requirement on the overriding operation by adhering
2935 to one of the three implementation kinds: entry, protected procedure or any of
2936 the above. This pragma is available in all earlier versions of Ada as an
2937 implementation-defined pragma.
2938
2939 @smallexample @c ada
2940 type Synch_Iface is synchronized interface;
2941 procedure Prim_Op (Obj : in out Iface) is abstract;
2942 pragma Implemented (Prim_Op, By_Protected_Procedure);
2943
2944 protected type Prot_1 is new Synch_Iface with
2945 procedure Prim_Op; -- Legal
2946 end Prot_1;
2947
2948 protected type Prot_2 is new Synch_Iface with
2949 entry Prim_Op; -- Illegal
2950 end Prot_2;
2951
2952 task type Task_Typ is new Synch_Iface with
2953 entry Prim_Op; -- Illegal
2954 end Task_Typ;
2955 @end smallexample
2956
2957 @noindent
2958 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2959 Implemented determines the runtime behavior of the requeue. Implementation kind
2960 By_Entry guarantees that the action of requeueing will proceed from an entry to
2961 another entry. Implementation kind By_Protected_Procedure transforms the
2962 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2963 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2964 the target's overriding subprogram kind.
2965
2966 @node Pragma Implicit_Packing
2967 @unnumberedsec Pragma Implicit_Packing
2968 @findex Implicit_Packing
2969 @cindex Rational Profile
2970 @noindent
2971 Syntax:
2972
2973 @smallexample @c ada
2974 pragma Implicit_Packing;
2975 @end smallexample
2976
2977 @noindent
2978 This is a configuration pragma that requests implicit packing for packed
2979 arrays for which a size clause is given but no explicit pragma Pack or
2980 specification of Component_Size is present. It also applies to records
2981 where no record representation clause is present. Consider this example:
2982
2983 @smallexample @c ada
2984 type R is array (0 .. 7) of Boolean;
2985 for R'Size use 8;
2986 @end smallexample
2987
2988 @noindent
2989 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2990 does not change the layout of a composite object. So the Size clause in the
2991 above example is normally rejected, since the default layout of the array uses
2992 8-bit components, and thus the array requires a minimum of 64 bits.
2993
2994 If this declaration is compiled in a region of code covered by an occurrence
2995 of the configuration pragma Implicit_Packing, then the Size clause in this
2996 and similar examples will cause implicit packing and thus be accepted. For
2997 this implicit packing to occur, the type in question must be an array of small
2998 components whose size is known at compile time, and the Size clause must
2999 specify the exact size that corresponds to the length of the array multiplied
3000 by the size in bits of the component type.
3001 @cindex Array packing
3002
3003 Similarly, the following example shows the use in the record case
3004
3005 @smallexample @c ada
3006 type r is record
3007 a, b, c, d, e, f, g, h : boolean;
3008 chr : character;
3009 end record;
3010 for r'size use 16;
3011 @end smallexample
3012
3013 @noindent
3014 Without a pragma Pack, each Boolean field requires 8 bits, so the
3015 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3016 sufficient. The use of pragma Implicit_Packing allows this record
3017 declaration to compile without an explicit pragma Pack.
3018 @node Pragma Import_Exception
3019 @unnumberedsec Pragma Import_Exception
3020 @cindex OpenVMS
3021 @findex Import_Exception
3022 @noindent
3023 Syntax:
3024
3025 @smallexample @c ada
3026 pragma Import_Exception (
3027 [Internal =>] LOCAL_NAME
3028 [, [External =>] EXTERNAL_SYMBOL]
3029 [, [Form =>] Ada | VMS]
3030 [, [Code =>] static_integer_EXPRESSION]);
3031
3032 EXTERNAL_SYMBOL ::=
3033 IDENTIFIER
3034 | static_string_EXPRESSION
3035 @end smallexample
3036
3037 @noindent
3038 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3039 It allows OpenVMS conditions (for example, from OpenVMS system services or
3040 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3041 The pragma specifies that the exception associated with an exception
3042 declaration in an Ada program be defined externally (in non-Ada code).
3043 For further details on this pragma, see the
3044 DEC Ada Language Reference Manual, section 13.9a.3.1.
3045
3046 @node Pragma Import_Function
3047 @unnumberedsec Pragma Import_Function
3048 @findex Import_Function
3049 @noindent
3050 Syntax:
3051
3052 @smallexample @c ada
3053 pragma Import_Function (
3054 [Internal =>] LOCAL_NAME,
3055 [, [External =>] EXTERNAL_SYMBOL]
3056 [, [Parameter_Types =>] PARAMETER_TYPES]
3057 [, [Result_Type =>] SUBTYPE_MARK]
3058 [, [Mechanism =>] MECHANISM]
3059 [, [Result_Mechanism =>] MECHANISM_NAME]
3060 [, [First_Optional_Parameter =>] IDENTIFIER]);
3061
3062 EXTERNAL_SYMBOL ::=
3063 IDENTIFIER
3064 | static_string_EXPRESSION
3065
3066 PARAMETER_TYPES ::=
3067 null
3068 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3069
3070 TYPE_DESIGNATOR ::=
3071 subtype_NAME
3072 | subtype_Name ' Access
3073
3074 MECHANISM ::=
3075 MECHANISM_NAME
3076 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3077
3078 MECHANISM_ASSOCIATION ::=
3079 [formal_parameter_NAME =>] MECHANISM_NAME
3080
3081 MECHANISM_NAME ::=
3082 Value
3083 | Reference
3084 | Descriptor [([Class =>] CLASS_NAME)]
3085 | Short_Descriptor [([Class =>] CLASS_NAME)]
3086
3087 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3088 @end smallexample
3089
3090 @noindent
3091 This pragma is used in conjunction with a pragma @code{Import} to
3092 specify additional information for an imported function. The pragma
3093 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3094 @code{Import_Function} pragma and both must appear in the same
3095 declarative part as the function specification.
3096
3097 The @var{Internal} argument must uniquely designate
3098 the function to which the
3099 pragma applies. If more than one function name exists of this name in
3100 the declarative part you must use the @code{Parameter_Types} and
3101 @var{Result_Type} parameters to achieve the required unique
3102 designation. Subtype marks in these parameters must exactly match the
3103 subtypes in the corresponding function specification, using positional
3104 notation to match parameters with subtype marks.
3105 The form with an @code{'Access} attribute can be used to match an
3106 anonymous access parameter.
3107
3108 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3109 parameters to specify passing mechanisms for the
3110 parameters and result. If you specify a single mechanism name, it
3111 applies to all parameters. Otherwise you may specify a mechanism on a
3112 parameter by parameter basis using either positional or named
3113 notation. If the mechanism is not specified, the default mechanism
3114 is used.
3115
3116 @cindex OpenVMS
3117 @cindex Passing by descriptor
3118 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3119 The default behavior for Import_Function is to pass a 64bit descriptor
3120 unless short_descriptor is specified, then a 32bit descriptor is passed.
3121
3122 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3123 It specifies that the designated parameter and all following parameters
3124 are optional, meaning that they are not passed at the generated code
3125 level (this is distinct from the notion of optional parameters in Ada
3126 where the parameters are passed anyway with the designated optional
3127 parameters). All optional parameters must be of mode @code{IN} and have
3128 default parameter values that are either known at compile time
3129 expressions, or uses of the @code{'Null_Parameter} attribute.
3130
3131 @node Pragma Import_Object
3132 @unnumberedsec Pragma Import_Object
3133 @findex Import_Object
3134 @noindent
3135 Syntax:
3136
3137 @smallexample @c ada
3138 pragma Import_Object
3139 [Internal =>] LOCAL_NAME
3140 [, [External =>] EXTERNAL_SYMBOL]
3141 [, [Size =>] EXTERNAL_SYMBOL]);
3142
3143 EXTERNAL_SYMBOL ::=
3144 IDENTIFIER
3145 | static_string_EXPRESSION
3146 @end smallexample
3147
3148 @noindent
3149 This pragma designates an object as imported, and apart from the
3150 extended rules for external symbols, is identical in effect to the use of
3151 the normal @code{Import} pragma applied to an object. Unlike the
3152 subprogram case, you need not use a separate @code{Import} pragma,
3153 although you may do so (and probably should do so from a portability
3154 point of view). @var{size} is syntax checked, but otherwise ignored by
3155 GNAT@.
3156
3157 @node Pragma Import_Procedure
3158 @unnumberedsec Pragma Import_Procedure
3159 @findex Import_Procedure
3160 @noindent
3161 Syntax:
3162
3163 @smallexample @c ada
3164 pragma Import_Procedure (
3165 [Internal =>] LOCAL_NAME
3166 [, [External =>] EXTERNAL_SYMBOL]
3167 [, [Parameter_Types =>] PARAMETER_TYPES]
3168 [, [Mechanism =>] MECHANISM]
3169 [, [First_Optional_Parameter =>] IDENTIFIER]);
3170
3171 EXTERNAL_SYMBOL ::=
3172 IDENTIFIER
3173 | static_string_EXPRESSION
3174
3175 PARAMETER_TYPES ::=
3176 null
3177 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3178
3179 TYPE_DESIGNATOR ::=
3180 subtype_NAME
3181 | subtype_Name ' Access
3182
3183 MECHANISM ::=
3184 MECHANISM_NAME
3185 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3186
3187 MECHANISM_ASSOCIATION ::=
3188 [formal_parameter_NAME =>] MECHANISM_NAME
3189
3190 MECHANISM_NAME ::=
3191 Value
3192 | Reference
3193 | Descriptor [([Class =>] CLASS_NAME)]
3194 | Short_Descriptor [([Class =>] CLASS_NAME)]
3195
3196 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3197 @end smallexample
3198
3199 @noindent
3200 This pragma is identical to @code{Import_Function} except that it
3201 applies to a procedure rather than a function and the parameters
3202 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3203
3204 @node Pragma Import_Valued_Procedure
3205 @unnumberedsec Pragma Import_Valued_Procedure
3206 @findex Import_Valued_Procedure
3207 @noindent
3208 Syntax:
3209
3210 @smallexample @c ada
3211 pragma Import_Valued_Procedure (
3212 [Internal =>] LOCAL_NAME
3213 [, [External =>] EXTERNAL_SYMBOL]
3214 [, [Parameter_Types =>] PARAMETER_TYPES]
3215 [, [Mechanism =>] MECHANISM]
3216 [, [First_Optional_Parameter =>] IDENTIFIER]);
3217
3218 EXTERNAL_SYMBOL ::=
3219 IDENTIFIER
3220 | static_string_EXPRESSION
3221
3222 PARAMETER_TYPES ::=
3223 null
3224 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3225
3226 TYPE_DESIGNATOR ::=
3227 subtype_NAME
3228 | subtype_Name ' Access
3229
3230 MECHANISM ::=
3231 MECHANISM_NAME
3232 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3233
3234 MECHANISM_ASSOCIATION ::=
3235 [formal_parameter_NAME =>] MECHANISM_NAME
3236
3237 MECHANISM_NAME ::=
3238 Value
3239 | Reference
3240 | Descriptor [([Class =>] CLASS_NAME)]
3241 | Short_Descriptor [([Class =>] CLASS_NAME)]
3242
3243 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3244 @end smallexample
3245
3246 @noindent
3247 This pragma is identical to @code{Import_Procedure} except that the
3248 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3249 mode @code{OUT}, and externally the subprogram is treated as a function
3250 with this parameter as the result of the function. The purpose of this
3251 capability is to allow the use of @code{OUT} and @code{IN OUT}
3252 parameters in interfacing to external functions (which are not permitted
3253 in Ada functions). You may optionally use the @code{Mechanism}
3254 parameters to specify passing mechanisms for the parameters.
3255 If you specify a single mechanism name, it applies to all parameters.
3256 Otherwise you may specify a mechanism on a parameter by parameter
3257 basis using either positional or named notation. If the mechanism is not
3258 specified, the default mechanism is used.
3259
3260 Note that it is important to use this pragma in conjunction with a separate
3261 pragma Import that specifies the desired convention, since otherwise the
3262 default convention is Ada, which is almost certainly not what is required.
3263
3264 @node Pragma Independent
3265 @unnumberedsec Pragma Independent
3266 @findex Independent
3267 @noindent
3268 Syntax:
3269
3270 @smallexample @c ada
3271 pragma Independent (Local_NAME);
3272 @end smallexample
3273
3274 @noindent
3275 This pragma is standard in Ada 2012 mode (which also provides an aspect
3276 of the same name). It is also available as an implementation-defined
3277 pragma in all earlier versions. It specifies that the
3278 designated object or all objects of the designated type must be
3279 independently addressable. This means that separate tasks can safely
3280 manipulate such objects. For example, if two components of a record are
3281 independent, then two separate tasks may access these two components.
3282 This may place
3283 constraints on the representation of the object (for instance prohibiting
3284 tight packing).
3285
3286 @node Pragma Independent_Components
3287 @unnumberedsec Pragma Independent_Components
3288 @findex Independent_Components
3289 @noindent
3290 Syntax:
3291
3292 @smallexample @c ada
3293 pragma Independent_Components (Local_NAME);
3294 @end smallexample
3295
3296 @noindent
3297 This pragma is standard in Ada 2012 mode (which also provides an aspect
3298 of the same name). It is also available as an implementation-defined
3299 pragma in all earlier versions. It specifies that the components of the
3300 designated object, or the components of each object of the designated
3301 type, must be
3302 independently addressable. This means that separate tasks can safely
3303 manipulate separate components in the composite object. This may place
3304 constraints on the representation of the object (for instance prohibiting
3305 tight packing).
3306
3307 @node Pragma Initialize_Scalars
3308 @unnumberedsec Pragma Initialize_Scalars
3309 @findex Initialize_Scalars
3310 @cindex debugging with Initialize_Scalars
3311 @noindent
3312 Syntax:
3313
3314 @smallexample @c ada
3315 pragma Initialize_Scalars;
3316 @end smallexample
3317
3318 @noindent
3319 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3320 two important differences. First, there is no requirement for the pragma
3321 to be used uniformly in all units of a partition, in particular, it is fine
3322 to use this just for some or all of the application units of a partition,
3323 without needing to recompile the run-time library.
3324
3325 In the case where some units are compiled with the pragma, and some without,
3326 then a declaration of a variable where the type is defined in package
3327 Standard or is locally declared will always be subject to initialization,
3328 as will any declaration of a scalar variable. For composite variables,
3329 whether the variable is initialized may also depend on whether the package
3330 in which the type of the variable is declared is compiled with the pragma.
3331
3332 The other important difference is that you can control the value used
3333 for initializing scalar objects. At bind time, you can select several
3334 options for initialization. You can
3335 initialize with invalid values (similar to Normalize_Scalars, though for
3336 Initialize_Scalars it is not always possible to determine the invalid
3337 values in complex cases like signed component fields with non-standard
3338 sizes). You can also initialize with high or
3339 low values, or with a specified bit pattern. See the @value{EDITION}
3340 User's Guide for binder options for specifying these cases.
3341
3342 This means that you can compile a program, and then without having to
3343 recompile the program, you can run it with different values being used
3344 for initializing otherwise uninitialized values, to test if your program
3345 behavior depends on the choice. Of course the behavior should not change,
3346 and if it does, then most likely you have an erroneous reference to an
3347 uninitialized value.
3348
3349 It is even possible to change the value at execution time eliminating even
3350 the need to rebind with a different switch using an environment variable.
3351 See the @value{EDITION} User's Guide for details.
3352
3353 Note that pragma @code{Initialize_Scalars} is particularly useful in
3354 conjunction with the enhanced validity checking that is now provided
3355 in GNAT, which checks for invalid values under more conditions.
3356 Using this feature (see description of the @option{-gnatV} flag in the
3357 @value{EDITION} User's Guide) in conjunction with
3358 pragma @code{Initialize_Scalars}
3359 provides a powerful new tool to assist in the detection of problems
3360 caused by uninitialized variables.
3361
3362 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3363 effect on the generated code. This may cause your code to be
3364 substantially larger. It may also cause an increase in the amount
3365 of stack required, so it is probably a good idea to turn on stack
3366 checking (see description of stack checking in the @value{EDITION}
3367 User's Guide) when using this pragma.
3368
3369 @node Pragma Inline_Always
3370 @unnumberedsec Pragma Inline_Always
3371 @findex Inline_Always
3372 @noindent
3373 Syntax:
3374
3375 @smallexample @c ada
3376 pragma Inline_Always (NAME [, NAME]);
3377 @end smallexample
3378
3379 @noindent
3380 Similar to pragma @code{Inline} except that inlining is not subject to
3381 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3382 happens regardless of whether these options are used.
3383
3384 @node Pragma Inline_Generic
3385 @unnumberedsec Pragma Inline_Generic
3386 @findex Inline_Generic
3387 @noindent
3388 Syntax:
3389
3390 @smallexample @c ada
3391 pragma Inline_Generic (generic_package_NAME);
3392 @end smallexample
3393
3394 @noindent
3395 This is implemented for compatibility with DEC Ada 83 and is recognized,
3396 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3397 by default when using GNAT@.
3398
3399 @node Pragma Interface
3400 @unnumberedsec Pragma Interface
3401 @findex Interface
3402 @noindent
3403 Syntax:
3404
3405 @smallexample @c ada
3406 pragma Interface (
3407 [Convention =>] convention_identifier,
3408 [Entity =>] local_NAME
3409 [, [External_Name =>] static_string_expression]
3410 [, [Link_Name =>] static_string_expression]);
3411 @end smallexample
3412
3413 @noindent
3414 This pragma is identical in syntax and semantics to
3415 the standard Ada pragma @code{Import}. It is provided for compatibility
3416 with Ada 83. The definition is upwards compatible both with pragma
3417 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3418 with some extended implementations of this pragma in certain Ada 83
3419 implementations. The only difference between pragma @code{Interface}
3420 and pragma @code{Import} is that there is special circuitry to allow
3421 both pragmas to appear for the same subprogram entity (normally it
3422 is illegal to have multiple @code{Import} pragmas. This is useful in
3423 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3424 Ada 83 compilers.
3425
3426 @node Pragma Interface_Name
3427 @unnumberedsec Pragma Interface_Name
3428 @findex Interface_Name
3429 @noindent
3430 Syntax:
3431
3432 @smallexample @c ada
3433 pragma Interface_Name (
3434 [Entity =>] LOCAL_NAME
3435 [, [External_Name =>] static_string_EXPRESSION]
3436 [, [Link_Name =>] static_string_EXPRESSION]);
3437 @end smallexample
3438
3439 @noindent
3440 This pragma provides an alternative way of specifying the interface name
3441 for an interfaced subprogram, and is provided for compatibility with Ada
3442 83 compilers that use the pragma for this purpose. You must provide at
3443 least one of @var{External_Name} or @var{Link_Name}.
3444
3445 @node Pragma Interrupt_Handler
3446 @unnumberedsec Pragma Interrupt_Handler
3447 @findex Interrupt_Handler
3448 @noindent
3449 Syntax:
3450
3451 @smallexample @c ada
3452 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3453 @end smallexample
3454
3455 @noindent
3456 This program unit pragma is supported for parameterless protected procedures
3457 as described in Annex C of the Ada Reference Manual. On the AAMP target
3458 the pragma can also be specified for nonprotected parameterless procedures
3459 that are declared at the library level (which includes procedures
3460 declared at the top level of a library package). In the case of AAMP,
3461 when this pragma is applied to a nonprotected procedure, the instruction
3462 @code{IERET} is generated for returns from the procedure, enabling
3463 maskable interrupts, in place of the normal return instruction.
3464
3465 @node Pragma Interrupt_State
3466 @unnumberedsec Pragma Interrupt_State
3467 @findex Interrupt_State
3468 @noindent
3469 Syntax:
3470
3471 @smallexample @c ada
3472 pragma Interrupt_State
3473 ([Name =>] value,
3474 [State =>] SYSTEM | RUNTIME | USER);
3475 @end smallexample
3476
3477 @noindent
3478 Normally certain interrupts are reserved to the implementation. Any attempt
3479 to attach an interrupt causes Program_Error to be raised, as described in
3480 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3481 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3482 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3483 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3484 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3485 Ada exceptions, or used to implement run-time functions such as the
3486 @code{abort} statement and stack overflow checking.
3487
3488 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3489 such uses of interrupts. It subsumes the functionality of pragma
3490 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3491 available on Windows or VMS. On all other platforms than VxWorks,
3492 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3493 and may be used to mark interrupts required by the board support package
3494 as reserved.
3495
3496 Interrupts can be in one of three states:
3497 @itemize @bullet
3498 @item System
3499
3500 The interrupt is reserved (no Ada handler can be installed), and the
3501 Ada run-time may not install a handler. As a result you are guaranteed
3502 standard system default action if this interrupt is raised.
3503
3504 @item Runtime
3505
3506 The interrupt is reserved (no Ada handler can be installed). The run time
3507 is allowed to install a handler for internal control purposes, but is
3508 not required to do so.
3509
3510 @item User
3511
3512 The interrupt is unreserved. The user may install a handler to provide
3513 some other action.
3514 @end itemize
3515
3516 @noindent
3517 These states are the allowed values of the @code{State} parameter of the
3518 pragma. The @code{Name} parameter is a value of the type
3519 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3520 @code{Ada.Interrupts.Names}.
3521
3522 This is a configuration pragma, and the binder will check that there
3523 are no inconsistencies between different units in a partition in how a
3524 given interrupt is specified. It may appear anywhere a pragma is legal.
3525
3526 The effect is to move the interrupt to the specified state.
3527
3528 By declaring interrupts to be SYSTEM, you guarantee the standard system
3529 action, such as a core dump.
3530
3531 By declaring interrupts to be USER, you guarantee that you can install
3532 a handler.
3533
3534 Note that certain signals on many operating systems cannot be caught and
3535 handled by applications. In such cases, the pragma is ignored. See the
3536 operating system documentation, or the value of the array @code{Reserved}
3537 declared in the spec of package @code{System.OS_Interface}.
3538
3539 Overriding the default state of signals used by the Ada runtime may interfere
3540 with an application's runtime behavior in the cases of the synchronous signals,
3541 and in the case of the signal used to implement the @code{abort} statement.
3542
3543 @node Pragma Invariant
3544 @unnumberedsec Pragma Invariant
3545 @findex Invariant
3546 @noindent
3547 Syntax:
3548
3549 @smallexample @c ada
3550 pragma Invariant
3551 ([Entity =>] private_type_LOCAL_NAME,
3552 [Check =>] EXPRESSION
3553 [,[Message =>] String_Expression]);
3554 @end smallexample
3555
3556 @noindent
3557 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3558 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3559 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3560 requires the use of the aspect syntax, which is not available except in 2012
3561 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3562 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3563 note that the aspect Invariant is a synonym in GNAT for the aspect
3564 Type_Invariant, but there is no pragma Type_Invariant.
3565
3566 The pragma must appear within the visible part of the package specification,
3567 after the type to which its Entity argument appears. As with the Invariant
3568 aspect, the Check expression is not analyzed until the end of the visible
3569 part of the package, so it may contain forward references. The Message
3570 argument, if present, provides the exception message used if the invariant
3571 is violated. If no Message parameter is provided, a default message that
3572 identifies the line on which the pragma appears is used.
3573
3574 It is permissible to have multiple Invariants for the same type entity, in
3575 which case they are and'ed together. It is permissible to use this pragma
3576 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3577 invariant pragma for the same entity.
3578
3579 For further details on the use of this pragma, see the Ada 2012 documentation
3580 of the Type_Invariant aspect.
3581
3582 @node Pragma Keep_Names
3583 @unnumberedsec Pragma Keep_Names
3584 @findex Keep_Names
3585 @noindent
3586 Syntax:
3587
3588 @smallexample @c ada
3589 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3590 @end smallexample
3591
3592 @noindent
3593 The @var{LOCAL_NAME} argument
3594 must refer to an enumeration first subtype
3595 in the current declarative part. The effect is to retain the enumeration
3596 literal names for use by @code{Image} and @code{Value} even if a global
3597 @code{Discard_Names} pragma applies. This is useful when you want to
3598 generally suppress enumeration literal names and for example you therefore
3599 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3600 want to retain the names for specific enumeration types.
3601
3602 @node Pragma License
3603 @unnumberedsec Pragma License
3604 @findex License
3605 @cindex License checking
3606 @noindent
3607 Syntax:
3608
3609 @smallexample @c ada
3610 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3611 @end smallexample
3612
3613 @noindent
3614 This pragma is provided to allow automated checking for appropriate license
3615 conditions with respect to the standard and modified GPL@. A pragma
3616 @code{License}, which is a configuration pragma that typically appears at
3617 the start of a source file or in a separate @file{gnat.adc} file, specifies
3618 the licensing conditions of a unit as follows:
3619
3620 @itemize @bullet
3621 @item Unrestricted
3622 This is used for a unit that can be freely used with no license restrictions.
3623 Examples of such units are public domain units, and units from the Ada
3624 Reference Manual.
3625
3626 @item GPL
3627 This is used for a unit that is licensed under the unmodified GPL, and which
3628 therefore cannot be @code{with}'ed by a restricted unit.
3629
3630 @item Modified_GPL
3631 This is used for a unit licensed under the GNAT modified GPL that includes
3632 a special exception paragraph that specifically permits the inclusion of
3633 the unit in programs without requiring the entire program to be released
3634 under the GPL@.
3635
3636 @item Restricted
3637 This is used for a unit that is restricted in that it is not permitted to
3638 depend on units that are licensed under the GPL@. Typical examples are
3639 proprietary code that is to be released under more restrictive license
3640 conditions. Note that restricted units are permitted to @code{with} units
3641 which are licensed under the modified GPL (this is the whole point of the
3642 modified GPL).
3643
3644 @end itemize
3645
3646 @noindent
3647 Normally a unit with no @code{License} pragma is considered to have an
3648 unknown license, and no checking is done. However, standard GNAT headers
3649 are recognized, and license information is derived from them as follows.
3650
3651 @itemize @bullet
3652
3653 A GNAT license header starts with a line containing 78 hyphens. The following
3654 comment text is searched for the appearance of any of the following strings.
3655
3656 If the string ``GNU General Public License'' is found, then the unit is assumed
3657 to have GPL license, unless the string ``As a special exception'' follows, in
3658 which case the license is assumed to be modified GPL@.
3659
3660 If one of the strings
3661 ``This specification is adapted from the Ada Semantic Interface'' or
3662 ``This specification is derived from the Ada Reference Manual'' is found
3663 then the unit is assumed to be unrestricted.
3664 @end itemize
3665
3666 @noindent
3667 These default actions means that a program with a restricted license pragma
3668 will automatically get warnings if a GPL unit is inappropriately
3669 @code{with}'ed. For example, the program:
3670
3671 @smallexample @c ada
3672 with Sem_Ch3;
3673 with GNAT.Sockets;
3674 procedure Secret_Stuff is
3675 @dots{}
3676 end Secret_Stuff
3677 @end smallexample
3678
3679 @noindent
3680 if compiled with pragma @code{License} (@code{Restricted}) in a
3681 @file{gnat.adc} file will generate the warning:
3682
3683 @smallexample
3684 1. with Sem_Ch3;
3685 |
3686 >>> license of withed unit "Sem_Ch3" is incompatible
3687
3688 2. with GNAT.Sockets;
3689 3. procedure Secret_Stuff is
3690 @end smallexample
3691
3692 @noindent
3693 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3694 compiler and is licensed under the
3695 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3696 run time, and is therefore licensed under the modified GPL@.
3697
3698 @node Pragma Link_With
3699 @unnumberedsec Pragma Link_With
3700 @findex Link_With
3701 @noindent
3702 Syntax:
3703
3704 @smallexample @c ada
3705 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3706 @end smallexample
3707
3708 @noindent
3709 This pragma is provided for compatibility with certain Ada 83 compilers.
3710 It has exactly the same effect as pragma @code{Linker_Options} except
3711 that spaces occurring within one of the string expressions are treated
3712 as separators. For example, in the following case:
3713
3714 @smallexample @c ada
3715 pragma Link_With ("-labc -ldef");
3716 @end smallexample
3717
3718 @noindent
3719 results in passing the strings @code{-labc} and @code{-ldef} as two
3720 separate arguments to the linker. In addition pragma Link_With allows
3721 multiple arguments, with the same effect as successive pragmas.
3722
3723 @node Pragma Linker_Alias
3724 @unnumberedsec Pragma Linker_Alias
3725 @findex Linker_Alias
3726 @noindent
3727 Syntax:
3728
3729 @smallexample @c ada
3730 pragma Linker_Alias (
3731 [Entity =>] LOCAL_NAME,
3732 [Target =>] static_string_EXPRESSION);
3733 @end smallexample
3734
3735 @noindent
3736 @var{LOCAL_NAME} must refer to an object that is declared at the library
3737 level. This pragma establishes the given entity as a linker alias for the
3738 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3739 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3740 @var{static_string_EXPRESSION} in the object file, that is to say no space
3741 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3742 to the same address as @var{static_string_EXPRESSION} by the linker.
3743
3744 The actual linker name for the target must be used (e.g.@: the fully
3745 encoded name with qualification in Ada, or the mangled name in C++),
3746 or it must be declared using the C convention with @code{pragma Import}
3747 or @code{pragma Export}.
3748
3749 Not all target machines support this pragma. On some of them it is accepted
3750 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3751
3752 @smallexample @c ada
3753 -- Example of the use of pragma Linker_Alias
3754
3755 package p is
3756 i : Integer := 1;
3757 pragma Export (C, i);
3758
3759 new_name_for_i : Integer;
3760 pragma Linker_Alias (new_name_for_i, "i");
3761 end p;
3762 @end smallexample
3763
3764 @node Pragma Linker_Constructor
3765 @unnumberedsec Pragma Linker_Constructor
3766 @findex Linker_Constructor
3767 @noindent
3768 Syntax:
3769
3770 @smallexample @c ada
3771 pragma Linker_Constructor (procedure_LOCAL_NAME);
3772 @end smallexample
3773
3774 @noindent
3775 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3776 is declared at the library level. A procedure to which this pragma is
3777 applied will be treated as an initialization routine by the linker.
3778 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3779 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3780 of the executable is called (or immediately after the shared library is
3781 loaded if the procedure is linked in a shared library), in particular
3782 before the Ada run-time environment is set up.
3783
3784 Because of these specific contexts, the set of operations such a procedure
3785 can perform is very limited and the type of objects it can manipulate is
3786 essentially restricted to the elementary types. In particular, it must only
3787 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3788
3789 This pragma is used by GNAT to implement auto-initialization of shared Stand
3790 Alone Libraries, which provides a related capability without the restrictions
3791 listed above. Where possible, the use of Stand Alone Libraries is preferable
3792 to the use of this pragma.
3793
3794 @node Pragma Linker_Destructor
3795 @unnumberedsec Pragma Linker_Destructor
3796 @findex Linker_Destructor
3797 @noindent
3798 Syntax:
3799
3800 @smallexample @c ada
3801 pragma Linker_Destructor (procedure_LOCAL_NAME);
3802 @end smallexample
3803
3804 @noindent
3805 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3806 is declared at the library level. A procedure to which this pragma is
3807 applied will be treated as a finalization routine by the linker.
3808 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3809 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3810 of the executable has exited (or immediately before the shared library
3811 is unloaded if the procedure is linked in a shared library), in particular
3812 after the Ada run-time environment is shut down.
3813
3814 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3815 because of these specific contexts.
3816
3817 @node Pragma Linker_Section
3818 @unnumberedsec Pragma Linker_Section
3819 @findex Linker_Section
3820 @noindent
3821 Syntax:
3822
3823 @smallexample @c ada
3824 pragma Linker_Section (
3825 [Entity =>] LOCAL_NAME,
3826 [Section =>] static_string_EXPRESSION);
3827 @end smallexample
3828
3829 @noindent
3830 @var{LOCAL_NAME} must refer to an object that is declared at the library
3831 level. This pragma specifies the name of the linker section for the given
3832 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3833 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3834 section of the executable (assuming the linker doesn't rename the section).
3835
3836 The compiler normally places library-level objects in standard sections
3837 depending on their type: procedures and functions generally go in the
3838 @code{.text} section, initialized variables in the @code{.data} section
3839 and uninitialized variables in the @code{.bss} section.
3840
3841 Other, special sections may exist on given target machines to map special
3842 hardware, for example I/O ports or flash memory. This pragma is a means to
3843 defer the final layout of the executable to the linker, thus fully working
3844 at the symbolic level with the compiler.
3845
3846 Some file formats do not support arbitrary sections so not all target
3847 machines support this pragma. The use of this pragma may cause a program
3848 execution to be erroneous if it is used to place an entity into an
3849 inappropriate section (e.g.@: a modified variable into the @code{.text}
3850 section). See also @code{pragma Persistent_BSS}.
3851
3852 @smallexample @c ada
3853 -- Example of the use of pragma Linker_Section
3854
3855 package IO_Card is
3856 Port_A : Integer;
3857 pragma Volatile (Port_A);
3858 pragma Linker_Section (Port_A, ".bss.port_a");
3859
3860 Port_B : Integer;
3861 pragma Volatile (Port_B);
3862 pragma Linker_Section (Port_B, ".bss.port_b");
3863 end IO_Card;
3864 @end smallexample
3865
3866 @node Pragma Long_Float
3867 @unnumberedsec Pragma Long_Float
3868 @cindex OpenVMS
3869 @findex Long_Float
3870 @noindent
3871 Syntax:
3872
3873 @smallexample @c ada
3874 pragma Long_Float (FLOAT_FORMAT);
3875
3876 FLOAT_FORMAT ::= D_Float | G_Float
3877 @end smallexample
3878
3879 @noindent
3880 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3881 It allows control over the internal representation chosen for the predefined
3882 type @code{Long_Float} and for floating point type representations with
3883 @code{digits} specified in the range 7 through 15.
3884 For further details on this pragma, see the
3885 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3886 this pragma, the standard runtime libraries must be recompiled.
3887
3888 @node Pragma Loop_Optimize
3889 @unnumberedsec Pragma Loop_Optimize
3890 @findex Loop_Optimize
3891 @noindent
3892 Syntax:
3893
3894 @smallexample @c ada
3895 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
3896
3897 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
3898 @end smallexample
3899
3900 @noindent
3901 This pragma must appear immediately within a loop statement. It allows the
3902 programmer to specify optimization hints for the enclosing loop. The hints
3903 are not mutually exclusive and can be freely mixed, but not all combinations
3904 will yield a sensible outcome.
3905
3906 There are four supported optimization hints for a loop:
3907 @itemize @bullet
3908 @item No_Unroll
3909
3910 The loop must not be unrolled. This is a strong hint: the compiler will not
3911 unroll a loop marked with this hint.
3912
3913 @item Unroll
3914
3915 The loop should be unrolled. This is a weak hint: the compiler will try to
3916 apply unrolling to this loop preferably to other optimizations, notably
3917 vectorization, but there is no guarantee that the loop will be unrolled.
3918
3919 @item No_Vector
3920
3921 The loop must not be vectorized. This is a strong hint: the compiler will not
3922 vectorize a loop marked with this hint.
3923
3924 @item Vector
3925
3926 The loop should be vectorized. This is a weak hint: the compiler will try to
3927 apply vectorization to this loop preferably to other optimizations, notably
3928 unrolling, but there is no guarantee that the loop will be vectorized.
3929
3930 @end itemize
3931
3932 These hints do not void the need to pass the appropriate switches to the
3933 compiler in order to enable the relevant optimizations, that is to say
3934 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
3935 vectorization.
3936
3937 @node Pragma Machine_Attribute
3938 @unnumberedsec Pragma Machine_Attribute
3939 @findex Machine_Attribute
3940 @noindent
3941 Syntax:
3942
3943 @smallexample @c ada
3944 pragma Machine_Attribute (
3945 [Entity =>] LOCAL_NAME,
3946 [Attribute_Name =>] static_string_EXPRESSION
3947 [, [Info =>] static_EXPRESSION] );
3948 @end smallexample
3949
3950 @noindent
3951 Machine-dependent attributes can be specified for types and/or
3952 declarations. This pragma is semantically equivalent to
3953 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3954 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3955 in GNU C, where @code{@var{attribute_name}} is recognized by the
3956 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3957 specific macro. A string literal for the optional parameter @var{info}
3958 is transformed into an identifier, which may make this pragma unusable
3959 for some attributes. @xref{Target Attributes,, Defining target-specific
3960 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3961 Internals}, further information.
3962
3963 @node Pragma Main
3964 @unnumberedsec Pragma Main
3965 @cindex OpenVMS
3966 @findex Main
3967 @noindent
3968 Syntax:
3969
3970 @smallexample @c ada
3971 pragma Main
3972 (MAIN_OPTION [, MAIN_OPTION]);
3973
3974 MAIN_OPTION ::=
3975 [Stack_Size =>] static_integer_EXPRESSION
3976 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3977 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3978 @end smallexample
3979
3980 @noindent
3981 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3982 no effect in GNAT, other than being syntax checked.
3983
3984 @node Pragma Main_Storage
3985 @unnumberedsec Pragma Main_Storage
3986 @cindex OpenVMS
3987 @findex Main_Storage
3988 @noindent
3989 Syntax:
3990
3991 @smallexample @c ada
3992 pragma Main_Storage
3993 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3994
3995 MAIN_STORAGE_OPTION ::=
3996 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3997 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3998 @end smallexample
3999
4000 @noindent
4001 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4002 no effect in GNAT, other than being syntax checked. Note that the pragma
4003 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4004
4005 @node Pragma No_Body
4006 @unnumberedsec Pragma No_Body
4007 @findex No_Body
4008 @noindent
4009 Syntax:
4010
4011 @smallexample @c ada
4012 pragma No_Body;
4013 @end smallexample
4014
4015 @noindent
4016 There are a number of cases in which a package spec does not require a body,
4017 and in fact a body is not permitted. GNAT will not permit the spec to be
4018 compiled if there is a body around. The pragma No_Body allows you to provide
4019 a body file, even in a case where no body is allowed. The body file must
4020 contain only comments and a single No_Body pragma. This is recognized by
4021 the compiler as indicating that no body is logically present.
4022
4023 This is particularly useful during maintenance when a package is modified in
4024 such a way that a body needed before is no longer needed. The provision of a
4025 dummy body with a No_Body pragma ensures that there is no interference from
4026 earlier versions of the package body.
4027
4028 @node Pragma No_Inline
4029 @unnumberedsec Pragma No_Inline
4030 @findex No_Inline
4031 @noindent
4032 Syntax:
4033
4034 @smallexample @c ada
4035 pragma No_Inline (NAME @{, NAME@});
4036 @end smallexample
4037
4038 @noindent
4039 This pragma suppresses inlining for the callable entity or the instances of
4040 the generic subprogram designated by @var{NAME}, including inlining that
4041 results from the use of pragma @code{Inline}. This pragma is always active,
4042 in particular it is not subject to the use of option @option{-gnatn} or
4043 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4044 pragma @code{Inline_Always} for the same @var{NAME}.
4045
4046 @node Pragma No_Return
4047 @unnumberedsec Pragma No_Return
4048 @findex No_Return
4049 @noindent
4050 Syntax:
4051
4052 @smallexample @c ada
4053 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4054 @end smallexample
4055
4056 @noindent
4057 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4058 declarations in the current declarative part. A procedure to which this
4059 pragma is applied may not contain any explicit @code{return} statements.
4060 In addition, if the procedure contains any implicit returns from falling
4061 off the end of a statement sequence, then execution of that implicit
4062 return will cause Program_Error to be raised.
4063
4064 One use of this pragma is to identify procedures whose only purpose is to raise
4065 an exception. Another use of this pragma is to suppress incorrect warnings
4066 about missing returns in functions, where the last statement of a function
4067 statement sequence is a call to such a procedure.
4068
4069 Note that in Ada 2005 mode, this pragma is part of the language. It is
4070 available in all earlier versions of Ada as an implementation-defined
4071 pragma.
4072
4073 @node Pragma No_Strict_Aliasing
4074 @unnumberedsec Pragma No_Strict_Aliasing
4075 @findex No_Strict_Aliasing
4076 @noindent
4077 Syntax:
4078
4079 @smallexample @c ada
4080 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4081 @end smallexample
4082
4083 @noindent
4084 @var{type_LOCAL_NAME} must refer to an access type
4085 declaration in the current declarative part. The effect is to inhibit
4086 strict aliasing optimization for the given type. The form with no
4087 arguments is a configuration pragma which applies to all access types
4088 declared in units to which the pragma applies. For a detailed
4089 description of the strict aliasing optimization, and the situations
4090 in which it must be suppressed, see @ref{Optimization and Strict
4091 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4092
4093 This pragma currently has no effects on access to unconstrained array types.
4094
4095 @node Pragma Normalize_Scalars
4096 @unnumberedsec Pragma Normalize_Scalars
4097 @findex Normalize_Scalars
4098 @noindent
4099 Syntax:
4100
4101 @smallexample @c ada
4102 pragma Normalize_Scalars;
4103 @end smallexample
4104
4105 @noindent
4106 This is a language defined pragma which is fully implemented in GNAT@. The
4107 effect is to cause all scalar objects that are not otherwise initialized
4108 to be initialized. The initial values are implementation dependent and
4109 are as follows:
4110
4111 @table @code
4112 @item Standard.Character
4113 @noindent
4114 Objects whose root type is Standard.Character are initialized to
4115 Character'Last unless the subtype range excludes NUL (in which case
4116 NUL is used). This choice will always generate an invalid value if
4117 one exists.
4118
4119 @item Standard.Wide_Character
4120 @noindent
4121 Objects whose root type is Standard.Wide_Character are initialized to
4122 Wide_Character'Last unless the subtype range excludes NUL (in which case
4123 NUL is used). This choice will always generate an invalid value if
4124 one exists.
4125
4126 @item Standard.Wide_Wide_Character
4127 @noindent
4128 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4129 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4130 which case NUL is used). This choice will always generate an invalid value if
4131 one exists.
4132
4133 @item Integer types
4134 @noindent
4135 Objects of an integer type are treated differently depending on whether
4136 negative values are present in the subtype. If no negative values are
4137 present, then all one bits is used as the initial value except in the
4138 special case where zero is excluded from the subtype, in which case
4139 all zero bits are used. This choice will always generate an invalid
4140 value if one exists.
4141
4142 For subtypes with negative values present, the largest negative number
4143 is used, except in the unusual case where this largest negative number
4144 is in the subtype, and the largest positive number is not, in which case
4145 the largest positive value is used. This choice will always generate
4146 an invalid value if one exists.
4147
4148 @item Floating-Point Types
4149 Objects of all floating-point types are initialized to all 1-bits. For
4150 standard IEEE format, this corresponds to a NaN (not a number) which is
4151 indeed an invalid value.
4152
4153 @item Fixed-Point Types
4154 Objects of all fixed-point types are treated as described above for integers,
4155 with the rules applying to the underlying integer value used to represent
4156 the fixed-point value.
4157
4158 @item Modular types
4159 Objects of a modular type are initialized to all one bits, except in
4160 the special case where zero is excluded from the subtype, in which
4161 case all zero bits are used. This choice will always generate an
4162 invalid value if one exists.
4163
4164 @item Enumeration types
4165 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4166 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4167 whose Pos value is zero, in which case a code of zero is used. This choice
4168 will always generate an invalid value if one exists.
4169
4170 @end table
4171
4172 @node Pragma Obsolescent
4173 @unnumberedsec Pragma Obsolescent
4174 @findex Obsolescent
4175 @noindent
4176 Syntax:
4177
4178 @smallexample @c ada
4179 pragma Obsolescent;
4180
4181 pragma Obsolescent (
4182 [Message =>] static_string_EXPRESSION
4183 [,[Version =>] Ada_05]]);
4184
4185 pragma Obsolescent (
4186 [Entity =>] NAME
4187 [,[Message =>] static_string_EXPRESSION
4188 [,[Version =>] Ada_05]] );
4189 @end smallexample
4190
4191 @noindent
4192 This pragma can occur immediately following a declaration of an entity,
4193 including the case of a record component. If no Entity argument is present,
4194 then this declaration is the one to which the pragma applies. If an Entity
4195 parameter is present, it must either match the name of the entity in this
4196 declaration, or alternatively, the pragma can immediately follow an enumeration
4197 type declaration, where the Entity argument names one of the enumeration
4198 literals.
4199
4200 This pragma is used to indicate that the named entity
4201 is considered obsolescent and should not be used. Typically this is
4202 used when an API must be modified by eventually removing or modifying
4203 existing subprograms or other entities. The pragma can be used at an
4204 intermediate stage when the entity is still present, but will be
4205 removed later.
4206
4207 The effect of this pragma is to output a warning message on a reference to
4208 an entity thus marked that the subprogram is obsolescent if the appropriate
4209 warning option in the compiler is activated. If the Message parameter is
4210 present, then a second warning message is given containing this text. In
4211 addition, a reference to the entity is considered to be a violation of pragma
4212 Restrictions (No_Obsolescent_Features).
4213
4214 This pragma can also be used as a program unit pragma for a package,
4215 in which case the entity name is the name of the package, and the
4216 pragma indicates that the entire package is considered
4217 obsolescent. In this case a client @code{with}'ing such a package
4218 violates the restriction, and the @code{with} statement is
4219 flagged with warnings if the warning option is set.
4220
4221 If the Version parameter is present (which must be exactly
4222 the identifier Ada_05, no other argument is allowed), then the
4223 indication of obsolescence applies only when compiling in Ada 2005
4224 mode. This is primarily intended for dealing with the situations
4225 in the predefined library where subprograms or packages
4226 have become defined as obsolescent in Ada 2005
4227 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4228
4229 The following examples show typical uses of this pragma:
4230
4231 @smallexample @c ada
4232 package p is
4233 pragma Obsolescent (p, Message => "use pp instead of p");
4234 end p;
4235
4236 package q is
4237 procedure q2;
4238 pragma Obsolescent ("use q2new instead");
4239
4240 type R is new integer;
4241 pragma Obsolescent
4242 (Entity => R,
4243 Message => "use RR in Ada 2005",
4244 Version => Ada_05);
4245
4246 type M is record
4247 F1 : Integer;
4248 F2 : Integer;
4249 pragma Obsolescent;
4250 F3 : Integer;
4251 end record;
4252
4253 type E is (a, bc, 'd', quack);
4254 pragma Obsolescent (Entity => bc)
4255 pragma Obsolescent (Entity => 'd')
4256
4257 function "+"
4258 (a, b : character) return character;
4259 pragma Obsolescent (Entity => "+");
4260 end;
4261 @end smallexample
4262
4263 @noindent
4264 Note that, as for all pragmas, if you use a pragma argument identifier,
4265 then all subsequent parameters must also use a pragma argument identifier.
4266 So if you specify "Entity =>" for the Entity argument, and a Message
4267 argument is present, it must be preceded by "Message =>".
4268
4269 @node Pragma Optimize_Alignment
4270 @unnumberedsec Pragma Optimize_Alignment
4271 @findex Optimize_Alignment
4272 @cindex Alignment, default settings
4273 @noindent
4274 Syntax:
4275
4276 @smallexample @c ada
4277 pragma Optimize_Alignment (TIME | SPACE | OFF);
4278 @end smallexample
4279
4280 @noindent
4281 This is a configuration pragma which affects the choice of default alignments
4282 for types where no alignment is explicitly specified. There is a time/space
4283 trade-off in the selection of these values. Large alignments result in more
4284 efficient code, at the expense of larger data space, since sizes have to be
4285 increased to match these alignments. Smaller alignments save space, but the
4286 access code is slower. The normal choice of default alignments (which is what
4287 you get if you do not use this pragma, or if you use an argument of OFF),
4288 tries to balance these two requirements.
4289
4290 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4291 First any packed record is given an alignment of 1. Second, if a size is given
4292 for the type, then the alignment is chosen to avoid increasing this size. For
4293 example, consider:
4294
4295 @smallexample @c ada
4296 type R is record
4297 X : Integer;
4298 Y : Character;
4299 end record;
4300
4301 for R'Size use 5*8;
4302 @end smallexample
4303
4304 @noindent
4305 In the default mode, this type gets an alignment of 4, so that access to the
4306 Integer field X are efficient. But this means that objects of the type end up
4307 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4308 allowed to be bigger than the size of the type, but it can waste space if for
4309 example fields of type R appear in an enclosing record. If the above type is
4310 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4311
4312 However, there is one case in which SPACE is ignored. If a variable length
4313 record (that is a discriminated record with a component which is an array
4314 whose length depends on a discriminant), has a pragma Pack, then it is not
4315 in general possible to set the alignment of such a record to one, so the
4316 pragma is ignored in this case (with a warning).
4317
4318 Specifying TIME causes larger default alignments to be chosen in the case of
4319 small types with sizes that are not a power of 2. For example, consider:
4320
4321 @smallexample @c ada
4322 type R is record
4323 A : Character;
4324 B : Character;
4325 C : Boolean;
4326 end record;
4327
4328 pragma Pack (R);
4329 for R'Size use 17;
4330 @end smallexample
4331
4332 @noindent
4333 The default alignment for this record is normally 1, but if this type is
4334 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4335 to 4, which wastes space for objects of the type, since they are now 4 bytes
4336 long, but results in more efficient access when the whole record is referenced.
4337
4338 As noted above, this is a configuration pragma, and there is a requirement
4339 that all units in a partition be compiled with a consistent setting of the
4340 optimization setting. This would normally be achieved by use of a configuration
4341 pragma file containing the appropriate setting. The exception to this rule is
4342 that units with an explicit configuration pragma in the same file as the source
4343 unit are excluded from the consistency check, as are all predefined units. The
4344 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4345 pragma appears at the start of the file.
4346
4347 @node Pragma Ordered
4348 @unnumberedsec Pragma Ordered
4349 @findex Ordered
4350 @findex pragma @code{Ordered}
4351 @noindent
4352 Syntax:
4353
4354 @smallexample @c ada
4355 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4356 @end smallexample
4357
4358 @noindent
4359 Most enumeration types are from a conceptual point of view unordered.
4360 For example, consider:
4361
4362 @smallexample @c ada
4363 type Color is (Red, Blue, Green, Yellow);
4364 @end smallexample
4365
4366 @noindent
4367 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4368 but really these relations make no sense; the enumeration type merely
4369 specifies a set of possible colors, and the order is unimportant.
4370
4371 For unordered enumeration types, it is generally a good idea if
4372 clients avoid comparisons (other than equality or inequality) and
4373 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4374 other than the unit where the type is declared, its body, and its subunits.)
4375 For example, if code buried in some client says:
4376
4377 @smallexample @c ada
4378 if Current_Color < Yellow then ...
4379 if Current_Color in Blue .. Green then ...
4380 @end smallexample
4381
4382 @noindent
4383 then the client code is relying on the order, which is undesirable.
4384 It makes the code hard to read and creates maintenance difficulties if
4385 entries have to be added to the enumeration type. Instead,
4386 the code in the client should list the possibilities, or an
4387 appropriate subtype should be declared in the unit that declares
4388 the original enumeration type. E.g., the following subtype could
4389 be declared along with the type @code{Color}:
4390
4391 @smallexample @c ada
4392 subtype RBG is Color range Red .. Green;
4393 @end smallexample
4394
4395 @noindent
4396 and then the client could write:
4397
4398 @smallexample @c ada
4399 if Current_Color in RBG then ...
4400 if Current_Color = Blue or Current_Color = Green then ...
4401 @end smallexample
4402
4403 @noindent
4404 However, some enumeration types are legitimately ordered from a conceptual
4405 point of view. For example, if you declare:
4406
4407 @smallexample @c ada
4408 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4409 @end smallexample
4410
4411 @noindent
4412 then the ordering imposed by the language is reasonable, and
4413 clients can depend on it, writing for example:
4414
4415 @smallexample @c ada
4416 if D in Mon .. Fri then ...
4417 if D < Wed then ...
4418 @end smallexample
4419
4420 @noindent
4421 The pragma @option{Ordered} is provided to mark enumeration types that
4422 are conceptually ordered, alerting the reader that clients may depend
4423 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4424 rather than one to mark them as unordered, since in our experience,
4425 the great majority of enumeration types are conceptually unordered.
4426
4427 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4428 and @code{Wide_Wide_Character}
4429 are considered to be ordered types, so each is declared with a
4430 pragma @code{Ordered} in package @code{Standard}.
4431
4432 Normally pragma @code{Ordered} serves only as documentation and a guide for
4433 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4434 requests warnings for inappropriate uses (comparisons and explicit
4435 subranges) for unordered types. If this switch is used, then any
4436 enumeration type not marked with pragma @code{Ordered} will be considered
4437 as unordered, and will generate warnings for inappropriate uses.
4438
4439 For additional information please refer to the description of the
4440 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4441
4442 @node Pragma Overflow_Mode
4443 @unnumberedsec Pragma Overflow_Mode
4444 @findex Overflow checks
4445 @findex Overflow mode
4446 @findex pragma @code{Overflow_Mode}
4447 @noindent
4448 Syntax:
4449
4450 @smallexample @c ada
4451 pragma Overflow_Mode
4452 ( [General =>] MODE
4453 [,[Assertions =>] MODE]);
4454
4455 MODE ::= STRICT | MINIMIZED | ELIMINATED
4456 @end smallexample
4457
4458 @noindent
4459 This pragma sets the current overflow mode to the given setting. For details
4460 of the meaning of these modes, please refer to the
4461 ``Overflow Check Handling in GNAT'' appendix in the
4462 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4463 the given mode applies to all expressions. If both parameters are present,
4464 the @code{General} mode applies to expressions outside assertions, and
4465 the @code{Eliminated} mode applies to expressions within assertions.
4466
4467 The case of the @code{MODE} parameter is ignored,
4468 so @code{MINIMIZED}, @code{Minimized} and
4469 @code{minimized} all have the same effect.
4470
4471 The @code{Overflow_Mode} pragma has the same scoping and placement
4472 rules as pragma @code{Suppress}, so it can occur either as a
4473 configuration pragma, specifying a default for the whole
4474 program, or in a declarative scope, where it applies to the
4475 remaining declarations and statements in that scope.
4476
4477 The pragma @code{Suppress (Overflow_Check)} suppresses
4478 overflow checking, but does not affect the overflow mode.
4479
4480 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4481 overflow checking, but does not affect the overflow mode.
4482
4483 @node Pragma Partition_Elaboration_Policy
4484 @unnumberedsec Pragma Partition_Elaboration_Policy
4485 @findex Partition_Elaboration_Policy
4486 @noindent
4487 Syntax:
4488
4489 @smallexample @c ada
4490 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4491
4492 POLICY_IDENTIFIER ::= Concurrent | Sequential
4493 @end smallexample
4494
4495 @noindent
4496 This pragma is standard in Ada 2005, but is available in all earlier
4497 versions of Ada as an implementation-defined pragma.
4498 See Ada 2012 Reference Manual for details.
4499
4500 @node Pragma Passive
4501 @unnumberedsec Pragma Passive
4502 @findex Passive
4503 @noindent
4504 Syntax:
4505
4506 @smallexample @c ada
4507 pragma Passive [(Semaphore | No)];
4508 @end smallexample
4509
4510 @noindent
4511 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4512 compatibility with DEC Ada 83 implementations, where it is used within a
4513 task definition to request that a task be made passive. If the argument
4514 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4515 treats the pragma as an assertion that the containing task is passive
4516 and that optimization of context switch with this task is permitted and
4517 desired. If the argument @code{No} is present, the task must not be
4518 optimized. GNAT does not attempt to optimize any tasks in this manner
4519 (since protected objects are available in place of passive tasks).
4520
4521 @node Pragma Persistent_BSS
4522 @unnumberedsec Pragma Persistent_BSS
4523 @findex Persistent_BSS
4524 @noindent
4525 Syntax:
4526
4527 @smallexample @c ada
4528 pragma Persistent_BSS [(LOCAL_NAME)]
4529 @end smallexample
4530
4531 @noindent
4532 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4533 section. On some targets the linker and loader provide for special
4534 treatment of this section, allowing a program to be reloaded without
4535 affecting the contents of this data (hence the name persistent).
4536
4537 There are two forms of usage. If an argument is given, it must be the
4538 local name of a library level object, with no explicit initialization
4539 and whose type is potentially persistent. If no argument is given, then
4540 the pragma is a configuration pragma, and applies to all library level
4541 objects with no explicit initialization of potentially persistent types.
4542
4543 A potentially persistent type is a scalar type, or a non-tagged,
4544 non-discriminated record, all of whose components have no explicit
4545 initialization and are themselves of a potentially persistent type,
4546 or an array, all of whose constraints are static, and whose component
4547 type is potentially persistent.
4548
4549 If this pragma is used on a target where this feature is not supported,
4550 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4551
4552 @node Pragma Polling
4553 @unnumberedsec Pragma Polling
4554 @findex Polling
4555 @noindent
4556 Syntax:
4557
4558 @smallexample @c ada
4559 pragma Polling (ON | OFF);
4560 @end smallexample
4561
4562 @noindent
4563 This pragma controls the generation of polling code. This is normally off.
4564 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4565 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4566 runtime library, and can be found in file @file{a-excpol.adb}.
4567
4568 Pragma @code{Polling} can appear as a configuration pragma (for example it
4569 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4570 can be used in the statement or declaration sequence to control polling
4571 more locally.
4572
4573 A call to the polling routine is generated at the start of every loop and
4574 at the start of every subprogram call. This guarantees that the @code{Poll}
4575 routine is called frequently, and places an upper bound (determined by
4576 the complexity of the code) on the period between two @code{Poll} calls.
4577
4578 The primary purpose of the polling interface is to enable asynchronous
4579 aborts on targets that cannot otherwise support it (for example Windows
4580 NT), but it may be used for any other purpose requiring periodic polling.
4581 The standard version is null, and can be replaced by a user program. This
4582 will require re-compilation of the @code{Ada.Exceptions} package that can
4583 be found in files @file{a-except.ads} and @file{a-except.adb}.
4584
4585 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4586 distribution) is used to enable the asynchronous abort capability on
4587 targets that do not normally support the capability. The version of
4588 @code{Poll} in this file makes a call to the appropriate runtime routine
4589 to test for an abort condition.
4590
4591 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4592 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4593 details.
4594
4595 @node Pragma Postcondition
4596 @unnumberedsec Pragma Postcondition
4597 @cindex Postconditions
4598 @cindex Checks, postconditions
4599 @findex Postconditions
4600 @noindent
4601 Syntax:
4602
4603 @smallexample @c ada
4604 pragma Postcondition (
4605 [Check =>] Boolean_Expression
4606 [,[Message =>] String_Expression]);
4607 @end smallexample
4608
4609 @noindent
4610 The @code{Postcondition} pragma allows specification of automatic
4611 postcondition checks for subprograms. These checks are similar to
4612 assertions, but are automatically inserted just prior to the return
4613 statements of the subprogram with which they are associated (including
4614 implicit returns at the end of procedure bodies and associated
4615 exception handlers).
4616
4617 In addition, the boolean expression which is the condition which
4618 must be true may contain references to function'Result in the case
4619 of a function to refer to the returned value.
4620
4621 @code{Postcondition} pragmas may appear either immediately following the
4622 (separate) declaration of a subprogram, or at the start of the
4623 declarations of a subprogram body. Only other pragmas may intervene
4624 (that is appear between the subprogram declaration and its
4625 postconditions, or appear before the postcondition in the
4626 declaration sequence in a subprogram body). In the case of a
4627 postcondition appearing after a subprogram declaration, the
4628 formal arguments of the subprogram are visible, and can be
4629 referenced in the postcondition expressions.
4630
4631 The postconditions are collected and automatically tested just
4632 before any return (implicit or explicit) in the subprogram body.
4633 A postcondition is only recognized if postconditions are active
4634 at the time the pragma is encountered. The compiler switch @option{gnata}
4635 turns on all postconditions by default, and pragma @code{Check_Policy}
4636 with an identifier of @code{Postcondition} can also be used to
4637 control whether postconditions are active.
4638
4639 The general approach is that postconditions are placed in the spec
4640 if they represent functional aspects which make sense to the client.
4641 For example we might have:
4642
4643 @smallexample @c ada
4644 function Direction return Integer;
4645 pragma Postcondition
4646 (Direction'Result = +1
4647 or else
4648 Direction'Result = -1);
4649 @end smallexample
4650
4651 @noindent
4652 which serves to document that the result must be +1 or -1, and
4653 will test that this is the case at run time if postcondition
4654 checking is active.
4655
4656 Postconditions within the subprogram body can be used to
4657 check that some internal aspect of the implementation,
4658 not visible to the client, is operating as expected.
4659 For instance if a square root routine keeps an internal
4660 counter of the number of times it is called, then we
4661 might have the following postcondition:
4662
4663 @smallexample @c ada
4664 Sqrt_Calls : Natural := 0;
4665
4666 function Sqrt (Arg : Float) return Float is
4667 pragma Postcondition
4668 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4669 ...
4670 end Sqrt
4671 @end smallexample
4672
4673 @noindent
4674 As this example, shows, the use of the @code{Old} attribute
4675 is often useful in postconditions to refer to the state on
4676 entry to the subprogram.
4677
4678 Note that postconditions are only checked on normal returns
4679 from the subprogram. If an abnormal return results from
4680 raising an exception, then the postconditions are not checked.
4681
4682 If a postcondition fails, then the exception
4683 @code{System.Assertions.Assert_Failure} is raised. If
4684 a message argument was supplied, then the given string
4685 will be used as the exception message. If no message
4686 argument was supplied, then the default message has
4687 the form "Postcondition failed at file:line". The
4688 exception is raised in the context of the subprogram
4689 body, so it is possible to catch postcondition failures
4690 within the subprogram body itself.
4691
4692 Within a package spec, normal visibility rules
4693 in Ada would prevent forward references within a
4694 postcondition pragma to functions defined later in
4695 the same package. This would introduce undesirable
4696 ordering constraints. To avoid this problem, all
4697 postcondition pragmas are analyzed at the end of
4698 the package spec, allowing forward references.
4699
4700 The following example shows that this even allows
4701 mutually recursive postconditions as in:
4702
4703 @smallexample @c ada
4704 package Parity_Functions is
4705 function Odd (X : Natural) return Boolean;
4706 pragma Postcondition
4707 (Odd'Result =
4708 (x = 1
4709 or else
4710 (x /= 0 and then Even (X - 1))));
4711
4712 function Even (X : Natural) return Boolean;
4713 pragma Postcondition
4714 (Even'Result =
4715 (x = 0
4716 or else
4717 (x /= 1 and then Odd (X - 1))));
4718
4719 end Parity_Functions;
4720 @end smallexample
4721
4722 @noindent
4723 There are no restrictions on the complexity or form of
4724 conditions used within @code{Postcondition} pragmas.
4725 The following example shows that it is even possible
4726 to verify performance behavior.
4727
4728 @smallexample @c ada
4729 package Sort is
4730
4731 Performance : constant Float;
4732 -- Performance constant set by implementation
4733 -- to match target architecture behavior.
4734
4735 procedure Treesort (Arg : String);
4736 -- Sorts characters of argument using N*logN sort
4737 pragma Postcondition
4738 (Float (Clock - Clock'Old) <=
4739 Float (Arg'Length) *
4740 log (Float (Arg'Length)) *
4741 Performance);
4742 end Sort;
4743 @end smallexample
4744
4745 @noindent
4746 Note: postcondition pragmas associated with subprograms that are
4747 marked as Inline_Always, or those marked as Inline with front-end
4748 inlining (-gnatN option set) are accepted and legality-checked
4749 by the compiler, but are ignored at run-time even if postcondition
4750 checking is enabled.
4751
4752 @node Pragma Preelaborable_Initialization
4753 @unnumberedsec Pragma Preelaborable_Initialization
4754 @findex Preelaborable_Initialization
4755 @noindent
4756 Syntax:
4757
4758 @smallexample @c ada
4759 pragma Preelaborable_Initialization (DIRECT_NAME);
4760 @end smallexample
4761
4762 @noindent
4763 This pragma is standard in Ada 2005, but is available in all earlier
4764 versions of Ada as an implementation-defined pragma.
4765 See Ada 2012 Reference Manual for details.
4766
4767 @node Pragma Priority_Specific_Dispatching
4768 @unnumberedsec Pragma Priority_Specific_Dispatching
4769 @findex Priority_Specific_Dispatching
4770 @noindent
4771 Syntax:
4772
4773 @smallexample @c ada
4774 pragma Priority_Specific_Dispatching (
4775 POLICY_IDENTIFIER,
4776 first_priority_EXPRESSION,
4777 last_priority_EXPRESSION)
4778
4779 POLICY_IDENTIFIER ::=
4780 EDF_Across_Priorities |
4781 FIFO_Within_Priorities |
4782 Non_Preemptive_Within_Priorities |
4783 Round_Robin_Within_Priorities
4784 @end smallexample
4785
4786 @noindent
4787 This pragma is standard in Ada 2005, but is available in all earlier
4788 versions of Ada as an implementation-defined pragma.
4789 See Ada 2012 Reference Manual for details.
4790
4791 @node Pragma Precondition
4792 @unnumberedsec Pragma Precondition
4793 @cindex Preconditions
4794 @cindex Checks, preconditions
4795 @findex Preconditions
4796 @noindent
4797 Syntax:
4798
4799 @smallexample @c ada
4800 pragma Precondition (
4801 [Check =>] Boolean_Expression
4802 [,[Message =>] String_Expression]);
4803 @end smallexample
4804
4805 @noindent
4806 The @code{Precondition} pragma is similar to @code{Postcondition}
4807 except that the corresponding checks take place immediately upon
4808 entry to the subprogram, and if a precondition fails, the exception
4809 is raised in the context of the caller, and the attribute 'Result
4810 cannot be used within the precondition expression.
4811
4812 Otherwise, the placement and visibility rules are identical to those
4813 described for postconditions. The following is an example of use
4814 within a package spec:
4815
4816 @smallexample @c ada
4817 package Math_Functions is
4818 ...
4819 function Sqrt (Arg : Float) return Float;
4820 pragma Precondition (Arg >= 0.0)
4821 ...
4822 end Math_Functions;
4823 @end smallexample
4824
4825 @noindent
4826 @code{Precondition} pragmas may appear either immediately following the
4827 (separate) declaration of a subprogram, or at the start of the
4828 declarations of a subprogram body. Only other pragmas may intervene
4829 (that is appear between the subprogram declaration and its
4830 postconditions, or appear before the postcondition in the
4831 declaration sequence in a subprogram body).
4832
4833 Note: postcondition pragmas associated with subprograms that are
4834 marked as Inline_Always, or those marked as Inline with front-end
4835 inlining (-gnatN option set) are accepted and legality-checked
4836 by the compiler, but are ignored at run-time even if postcondition
4837 checking is enabled.
4838
4839 @node Pragma Profile (Ravenscar)
4840 @unnumberedsec Pragma Profile (Ravenscar)
4841 @findex Ravenscar
4842 @noindent
4843 Syntax:
4844
4845 @smallexample @c ada
4846 pragma Profile (Ravenscar | Restricted);
4847 @end smallexample
4848
4849 @noindent
4850 This pragma is standard in Ada 2005, but is available in all earlier
4851 versions of Ada as an implementation-defined pragma. This is a
4852 configuration pragma that establishes the following set of configuration
4853 pragmas:
4854
4855 @table @code
4856 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4857 [RM D.2.2] Tasks are dispatched following a preemptive
4858 priority-ordered scheduling policy.
4859
4860 @item Locking_Policy (Ceiling_Locking)
4861 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4862 the ceiling priority of the corresponding protected object.
4863
4864 @item Detect_Blocking
4865 This pragma forces the detection of potentially blocking operations within a
4866 protected operation, and to raise Program_Error if that happens.
4867 @end table
4868 @noindent
4869
4870 plus the following set of restrictions:
4871
4872 @table @code
4873 @item Max_Entry_Queue_Length => 1
4874 No task can be queued on a protected entry.
4875 @item Max_Protected_Entries => 1
4876 @item Max_Task_Entries => 0
4877 No rendezvous statements are allowed.
4878 @item No_Abort_Statements
4879 @item No_Dynamic_Attachment
4880 @item No_Dynamic_Priorities
4881 @item No_Implicit_Heap_Allocations
4882 @item No_Local_Protected_Objects
4883 @item No_Local_Timing_Events
4884 @item No_Protected_Type_Allocators
4885 @item No_Relative_Delay
4886 @item No_Requeue_Statements
4887 @item No_Select_Statements
4888 @item No_Specific_Termination_Handlers
4889 @item No_Task_Allocators
4890 @item No_Task_Hierarchy
4891 @item No_Task_Termination
4892 @item Simple_Barriers
4893 @end table
4894 @noindent
4895
4896 The Ravenscar profile also includes the following restrictions that specify
4897 that there are no semantic dependences on the corresponding predefined
4898 packages:
4899
4900 @table @code
4901 @item No_Dependence => Ada.Asynchronous_Task_Control
4902 @item No_Dependence => Ada.Calendar
4903 @item No_Dependence => Ada.Execution_Time.Group_Budget
4904 @item No_Dependence => Ada.Execution_Time.Timers
4905 @item No_Dependence => Ada.Task_Attributes
4906 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4907 @end table
4908
4909 @noindent
4910
4911 This set of configuration pragmas and restrictions correspond to the
4912 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4913 published by the @cite{International Real-Time Ada Workshop}, 1997,
4914 and whose most recent description is available at
4915 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4916
4917 The original definition of the profile was revised at subsequent IRTAW
4918 meetings. It has been included in the ISO
4919 @cite{Guide for the Use of the Ada Programming Language in High
4920 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4921 the next revision of the standard. The formal definition given by
4922 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4923 AI-305) available at
4924 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4925 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4926
4927 The above set is a superset of the restrictions provided by pragma
4928 @code{Profile (Restricted)}, it includes six additional restrictions
4929 (@code{Simple_Barriers}, @code{No_Select_Statements},
4930 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4931 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4932 that pragma @code{Profile (Ravenscar)}, like the pragma
4933 @code{Profile (Restricted)},
4934 automatically causes the use of a simplified,
4935 more efficient version of the tasking run-time system.
4936
4937 @node Pragma Profile (Restricted)
4938 @unnumberedsec Pragma Profile (Restricted)
4939 @findex Restricted Run Time
4940 @noindent
4941 Syntax:
4942
4943 @smallexample @c ada
4944 pragma Profile (Restricted);
4945 @end smallexample
4946
4947 @noindent
4948 This is an implementation-defined version of the standard pragma defined
4949 in Ada 2005. It is available in all versions of Ada. It is a
4950 configuration pragma that establishes the following set of restrictions:
4951
4952 @itemize @bullet
4953 @item No_Abort_Statements
4954 @item No_Entry_Queue
4955 @item No_Task_Hierarchy
4956 @item No_Task_Allocators
4957 @item No_Dynamic_Priorities
4958 @item No_Terminate_Alternatives
4959 @item No_Dynamic_Attachment
4960 @item No_Protected_Type_Allocators
4961 @item No_Local_Protected_Objects
4962 @item No_Requeue_Statements
4963 @item No_Task_Attributes_Package
4964 @item Max_Asynchronous_Select_Nesting = 0
4965 @item Max_Task_Entries = 0
4966 @item Max_Protected_Entries = 1
4967 @item Max_Select_Alternatives = 0
4968 @end itemize
4969
4970 @noindent
4971 This set of restrictions causes the automatic selection of a simplified
4972 version of the run time that provides improved performance for the
4973 limited set of tasking functionality permitted by this set of restrictions.
4974
4975 @node Pragma Profile (Rational)
4976 @unnumberedsec Pragma Profile (Rational)
4977 @findex Rational compatibility mode
4978 @noindent
4979 Syntax:
4980
4981 @smallexample @c ada
4982 pragma Profile (Rational);
4983 @end smallexample
4984
4985 @noindent
4986 The Rational profile is intended to facilitate porting legacy code that
4987 compiles with the Rational APEX compiler, even when the code includes non-
4988 conforming Ada constructs. The profile enables the following three pragmas:
4989
4990 @itemize @bullet
4991 pragma Implicit_Packing;
4992 pragma Overriding_Renamings;
4993 pragma Use_VADS_Size;
4994 @end itemize
4995
4996 @noindent
4997 @node Pragma Psect_Object
4998 @unnumberedsec Pragma Psect_Object
4999 @findex Psect_Object
5000 @noindent
5001 Syntax:
5002
5003 @smallexample @c ada
5004 pragma Psect_Object (
5005 [Internal =>] LOCAL_NAME,
5006 [, [External =>] EXTERNAL_SYMBOL]
5007 [, [Size =>] EXTERNAL_SYMBOL]);
5008
5009 EXTERNAL_SYMBOL ::=
5010 IDENTIFIER
5011 | static_string_EXPRESSION
5012 @end smallexample
5013
5014 @noindent
5015 This pragma is identical in effect to pragma @code{Common_Object}.
5016
5017 @node Pragma Pure_Function
5018 @unnumberedsec Pragma Pure_Function
5019 @findex Pure_Function
5020 @noindent
5021 Syntax:
5022
5023 @smallexample @c ada
5024 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5025 @end smallexample
5026
5027 @noindent
5028 This pragma appears in the same declarative part as a function
5029 declaration (or a set of function declarations if more than one
5030 overloaded declaration exists, in which case the pragma applies
5031 to all entities). It specifies that the function @code{Entity} is
5032 to be considered pure for the purposes of code generation. This means
5033 that the compiler can assume that there are no side effects, and
5034 in particular that two calls with identical arguments produce the
5035 same result. It also means that the function can be used in an
5036 address clause.
5037
5038 Note that, quite deliberately, there are no static checks to try
5039 to ensure that this promise is met, so @code{Pure_Function} can be used
5040 with functions that are conceptually pure, even if they do modify
5041 global variables. For example, a square root function that is
5042 instrumented to count the number of times it is called is still
5043 conceptually pure, and can still be optimized, even though it
5044 modifies a global variable (the count). Memo functions are another
5045 example (where a table of previous calls is kept and consulted to
5046 avoid re-computation).
5047
5048 Note also that the normal rules excluding optimization of subprograms
5049 in pure units (when parameter types are descended from System.Address,
5050 or when the full view of a parameter type is limited), do not apply
5051 for the Pure_Function case. If you explicitly specify Pure_Function,
5052 the compiler may optimize away calls with identical arguments, and
5053 if that results in unexpected behavior, the proper action is not to
5054 use the pragma for subprograms that are not (conceptually) pure.
5055
5056 @findex Pure
5057 Note: Most functions in a @code{Pure} package are automatically pure, and
5058 there is no need to use pragma @code{Pure_Function} for such functions. One
5059 exception is any function that has at least one formal of type
5060 @code{System.Address} or a type derived from it. Such functions are not
5061 considered pure by default, since the compiler assumes that the
5062 @code{Address} parameter may be functioning as a pointer and that the
5063 referenced data may change even if the address value does not.
5064 Similarly, imported functions are not considered to be pure by default,
5065 since there is no way of checking that they are in fact pure. The use
5066 of pragma @code{Pure_Function} for such a function will override these default
5067 assumption, and cause the compiler to treat a designated subprogram as pure
5068 in these cases.
5069
5070 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5071 applies to the underlying renamed function. This can be used to
5072 disambiguate cases of overloading where some but not all functions
5073 in a set of overloaded functions are to be designated as pure.
5074
5075 If pragma @code{Pure_Function} is applied to a library level function, the
5076 function is also considered pure from an optimization point of view, but the
5077 unit is not a Pure unit in the categorization sense. So for example, a function
5078 thus marked is free to @code{with} non-pure units.
5079
5080 @node Pragma Relative_Deadline
5081 @unnumberedsec Pragma Relative_Deadline
5082 @findex Relative_Deadline
5083 @noindent
5084 Syntax:
5085
5086 @smallexample @c ada
5087 pragma Relative_Deadline (time_span_EXPRESSSION);
5088 @end smallexample
5089
5090 @noindent
5091 This pragma is standard in Ada 2005, but is available in all earlier
5092 versions of Ada as an implementation-defined pragma.
5093 See Ada 2012 Reference Manual for details.
5094
5095 @node Pragma Remote_Access_Type
5096 @unnumberedsec Pragma Remote_Access_Type
5097 @findex Remote_Access_Type
5098 @noindent
5099 Syntax:
5100
5101 @smallexample @c ada
5102 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5103 @end smallexample
5104
5105 @noindent
5106 This pragma appears in the formal part of a generic declaration.
5107 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5108 the use of a remote access to class-wide type as actual for a formal
5109 access type.
5110
5111 When this pragma applies to a formal access type @code{Entity}, that
5112 type is treated as a remote access to class-wide type in the generic.
5113 It must be a formal general access type, and its designated type must
5114 be the class-wide type of a formal tagged limited private type from the
5115 same generic declaration.
5116
5117 In the generic unit, the formal type is subject to all restrictions
5118 pertaining to remote access to class-wide types. At instantiation, the
5119 actual type must be a remote access to class-wide type.
5120
5121 @node Pragma Restriction_Warnings
5122 @unnumberedsec Pragma Restriction_Warnings
5123 @findex Restriction_Warnings
5124 @noindent
5125 Syntax:
5126
5127 @smallexample @c ada
5128 pragma Restriction_Warnings
5129 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5130 @end smallexample
5131
5132 @noindent
5133 This pragma allows a series of restriction identifiers to be
5134 specified (the list of allowed identifiers is the same as for
5135 pragma @code{Restrictions}). For each of these identifiers
5136 the compiler checks for violations of the restriction, but
5137 generates a warning message rather than an error message
5138 if the restriction is violated.
5139
5140 @node Pragma Shared
5141 @unnumberedsec Pragma Shared
5142 @findex Shared
5143
5144 @noindent
5145 This pragma is provided for compatibility with Ada 83. The syntax and
5146 semantics are identical to pragma Atomic.
5147
5148 @node Pragma Short_Circuit_And_Or
5149 @unnumberedsec Pragma Short_Circuit_And_Or
5150 @findex Short_Circuit_And_Or
5151
5152 @noindent
5153 This configuration pragma causes any occurrence of the AND operator applied to
5154 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5155 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5156 may be useful in the context of certification protocols requiring the use of
5157 short-circuited logical operators. If this configuration pragma occurs locally
5158 within the file being compiled, it applies only to the file being compiled.
5159 There is no requirement that all units in a partition use this option.
5160
5161 @node Pragma Short_Descriptors
5162 @unnumberedsec Pragma Short_Descriptors
5163 @findex Short_Descriptors
5164 @noindent
5165 Syntax:
5166
5167 @smallexample @c ada
5168 pragma Short_Descriptors
5169 @end smallexample
5170
5171 @noindent
5172 In VMS versions of the compiler, this configuration pragma causes all
5173 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5174 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5175 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5176 versions.
5177
5178 @node Pragma Simple_Storage_Pool_Type
5179 @unnumberedsec Pragma Simple_Storage_Pool_Type
5180 @findex Simple_Storage_Pool_Type
5181 @cindex Storage pool, simple
5182 @cindex Simple storage pool
5183 @noindent
5184 Syntax:
5185
5186 @smallexample @c ada
5187 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5188 @end smallexample
5189
5190 @noindent
5191 A type can be established as a ``simple storage pool type'' by applying
5192 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5193 A type named in the pragma must be a library-level immutably limited record
5194 type or limited tagged type declared immediately within a package declaration.
5195 The type can also be a limited private type whose full type is allowed as
5196 a simple storage pool type.
5197
5198 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5199 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5200 are subtype conformant with the following subprogram declarations:
5201
5202 @smallexample @c ada
5203 procedure Allocate
5204 (Pool : in out SSP;
5205 Storage_Address : out System.Address;
5206 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5207 Alignment : System.Storage_Elements.Storage_Count);
5208
5209 procedure Deallocate
5210 (Pool : in out SSP;
5211 Storage_Address : System.Address;
5212 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5213 Alignment : System.Storage_Elements.Storage_Count);
5214
5215 function Storage_Size (Pool : SSP)
5216 return System.Storage_Elements.Storage_Count;
5217 @end smallexample
5218
5219 @noindent
5220 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5221 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5222 applying an unchecked deallocation has no effect other than to set its actual
5223 parameter to null. If @code{Storage_Size} is not declared, then the
5224 @code{Storage_Size} attribute applied to an access type associated with
5225 a pool object of type SSP returns zero. Additional operations can be declared
5226 for a simple storage pool type (such as for supporting a mark/release
5227 storage-management discipline).
5228
5229 An object of a simple storage pool type can be associated with an access
5230 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5231
5232 @smallexample @c ada
5233
5234 My_Pool : My_Simple_Storage_Pool_Type;
5235
5236 type Acc is access My_Data_Type;
5237
5238 for Acc'Simple_Storage_Pool use My_Pool;
5239
5240 @end smallexample
5241
5242 @noindent
5243 See attribute @code{Simple_Storage_Pool} for further details.
5244
5245 @node Pragma Source_File_Name
5246 @unnumberedsec Pragma Source_File_Name
5247 @findex Source_File_Name
5248 @noindent
5249 Syntax:
5250
5251 @smallexample @c ada
5252 pragma Source_File_Name (
5253 [Unit_Name =>] unit_NAME,
5254 Spec_File_Name => STRING_LITERAL,
5255 [Index => INTEGER_LITERAL]);
5256
5257 pragma Source_File_Name (
5258 [Unit_Name =>] unit_NAME,
5259 Body_File_Name => STRING_LITERAL,
5260 [Index => INTEGER_LITERAL]);
5261 @end smallexample
5262
5263 @noindent
5264 Use this to override the normal naming convention. It is a configuration
5265 pragma, and so has the usual applicability of configuration pragmas
5266 (i.e.@: it applies to either an entire partition, or to all units in a
5267 compilation, or to a single unit, depending on how it is used.
5268 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5269 the second argument is required, and indicates whether this is the file
5270 name for the spec or for the body.
5271
5272 The optional Index argument should be used when a file contains multiple
5273 units, and when you do not want to use @code{gnatchop} to separate then
5274 into multiple files (which is the recommended procedure to limit the
5275 number of recompilations that are needed when some sources change).
5276 For instance, if the source file @file{source.ada} contains
5277
5278 @smallexample @c ada
5279 package B is
5280 ...
5281 end B;
5282
5283 with B;
5284 procedure A is
5285 begin
5286 ..
5287 end A;
5288 @end smallexample
5289
5290 you could use the following configuration pragmas:
5291
5292 @smallexample @c ada
5293 pragma Source_File_Name
5294 (B, Spec_File_Name => "source.ada", Index => 1);
5295 pragma Source_File_Name
5296 (A, Body_File_Name => "source.ada", Index => 2);
5297 @end smallexample
5298
5299 Note that the @code{gnatname} utility can also be used to generate those
5300 configuration pragmas.
5301
5302 Another form of the @code{Source_File_Name} pragma allows
5303 the specification of patterns defining alternative file naming schemes
5304 to apply to all files.
5305
5306 @smallexample @c ada
5307 pragma Source_File_Name
5308 ( [Spec_File_Name =>] STRING_LITERAL
5309 [,[Casing =>] CASING_SPEC]
5310 [,[Dot_Replacement =>] STRING_LITERAL]);
5311
5312 pragma Source_File_Name
5313 ( [Body_File_Name =>] STRING_LITERAL
5314 [,[Casing =>] CASING_SPEC]
5315 [,[Dot_Replacement =>] STRING_LITERAL]);
5316
5317 pragma Source_File_Name
5318 ( [Subunit_File_Name =>] STRING_LITERAL
5319 [,[Casing =>] CASING_SPEC]
5320 [,[Dot_Replacement =>] STRING_LITERAL]);
5321
5322 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5323 @end smallexample
5324
5325 @noindent
5326 The first argument is a pattern that contains a single asterisk indicating
5327 the point at which the unit name is to be inserted in the pattern string
5328 to form the file name. The second argument is optional. If present it
5329 specifies the casing of the unit name in the resulting file name string.
5330 The default is lower case. Finally the third argument allows for systematic
5331 replacement of any dots in the unit name by the specified string literal.
5332
5333 Note that Source_File_Name pragmas should not be used if you are using
5334 project files. The reason for this rule is that the project manager is not
5335 aware of these pragmas, and so other tools that use the projet file would not
5336 be aware of the intended naming conventions. If you are using project files,
5337 file naming is controlled by Source_File_Name_Project pragmas, which are
5338 usually supplied automatically by the project manager. A pragma
5339 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5340
5341 For more details on the use of the @code{Source_File_Name} pragma,
5342 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5343 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5344 User's Guide}.
5345
5346 @node Pragma Source_File_Name_Project
5347 @unnumberedsec Pragma Source_File_Name_Project
5348 @findex Source_File_Name_Project
5349 @noindent
5350
5351 This pragma has the same syntax and semantics as pragma Source_File_Name.
5352 It is only allowed as a stand alone configuration pragma.
5353 It cannot appear after a @ref{Pragma Source_File_Name}, and
5354 most importantly, once pragma Source_File_Name_Project appears,
5355 no further Source_File_Name pragmas are allowed.
5356
5357 The intention is that Source_File_Name_Project pragmas are always
5358 generated by the Project Manager in a manner consistent with the naming
5359 specified in a project file, and when naming is controlled in this manner,
5360 it is not permissible to attempt to modify this naming scheme using
5361 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5362 known to the project manager).
5363
5364 @node Pragma Source_Reference
5365 @unnumberedsec Pragma Source_Reference
5366 @findex Source_Reference
5367 @noindent
5368 Syntax:
5369
5370 @smallexample @c ada
5371 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5372 @end smallexample
5373
5374 @noindent
5375 This pragma must appear as the first line of a source file.
5376 @var{integer_literal} is the logical line number of the line following
5377 the pragma line (for use in error messages and debugging
5378 information). @var{string_literal} is a static string constant that
5379 specifies the file name to be used in error messages and debugging
5380 information. This is most notably used for the output of @code{gnatchop}
5381 with the @option{-r} switch, to make sure that the original unchopped
5382 source file is the one referred to.
5383
5384 The second argument must be a string literal, it cannot be a static
5385 string expression other than a string literal. This is because its value
5386 is needed for error messages issued by all phases of the compiler.
5387
5388 @node Pragma Static_Elaboration_Desired
5389 @unnumberedsec Pragma Static_Elaboration_Desired
5390 @findex Static_Elaboration_Desired
5391 @noindent
5392 Syntax:
5393
5394 @smallexample @c ada
5395 pragma Static_Elaboration_Desired;
5396 @end smallexample
5397
5398 @noindent
5399 This pragma is used to indicate that the compiler should attempt to initialize
5400 statically the objects declared in the library unit to which the pragma applies,
5401 when these objects are initialized (explicitly or implicitly) by an aggregate.
5402 In the absence of this pragma, aggregates in object declarations are expanded
5403 into assignments and loops, even when the aggregate components are static
5404 constants. When the aggregate is present the compiler builds a static expression
5405 that requires no run-time code, so that the initialized object can be placed in
5406 read-only data space. If the components are not static, or the aggregate has
5407 more that 100 components, the compiler emits a warning that the pragma cannot
5408 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5409 construction of larger aggregates with static components that include an others
5410 choice.)
5411
5412 @node Pragma Stream_Convert
5413 @unnumberedsec Pragma Stream_Convert
5414 @findex Stream_Convert
5415 @noindent
5416 Syntax:
5417
5418 @smallexample @c ada
5419 pragma Stream_Convert (
5420 [Entity =>] type_LOCAL_NAME,
5421 [Read =>] function_NAME,
5422 [Write =>] function_NAME);
5423 @end smallexample
5424
5425 @noindent
5426 This pragma provides an efficient way of providing stream functions for
5427 types defined in packages. Not only is it simpler to use than declaring
5428 the necessary functions with attribute representation clauses, but more
5429 significantly, it allows the declaration to made in such a way that the
5430 stream packages are not loaded unless they are needed. The use of
5431 the Stream_Convert pragma adds no overhead at all, unless the stream
5432 attributes are actually used on the designated type.
5433
5434 The first argument specifies the type for which stream functions are
5435 provided. The second parameter provides a function used to read values
5436 of this type. It must name a function whose argument type may be any
5437 subtype, and whose returned type must be the type given as the first
5438 argument to the pragma.
5439
5440 The meaning of the @var{Read}
5441 parameter is that if a stream attribute directly
5442 or indirectly specifies reading of the type given as the first parameter,
5443 then a value of the type given as the argument to the Read function is
5444 read from the stream, and then the Read function is used to convert this
5445 to the required target type.
5446
5447 Similarly the @var{Write} parameter specifies how to treat write attributes
5448 that directly or indirectly apply to the type given as the first parameter.
5449 It must have an input parameter of the type specified by the first parameter,
5450 and the return type must be the same as the input type of the Read function.
5451 The effect is to first call the Write function to convert to the given stream
5452 type, and then write the result type to the stream.
5453
5454 The Read and Write functions must not be overloaded subprograms. If necessary
5455 renamings can be supplied to meet this requirement.
5456 The usage of this attribute is best illustrated by a simple example, taken
5457 from the GNAT implementation of package Ada.Strings.Unbounded:
5458
5459 @smallexample @c ada
5460 function To_Unbounded (S : String)
5461 return Unbounded_String
5462 renames To_Unbounded_String;
5463
5464 pragma Stream_Convert
5465 (Unbounded_String, To_Unbounded, To_String);
5466 @end smallexample
5467
5468 @noindent
5469 The specifications of the referenced functions, as given in the Ada
5470 Reference Manual are:
5471
5472 @smallexample @c ada
5473 function To_Unbounded_String (Source : String)
5474 return Unbounded_String;
5475
5476 function To_String (Source : Unbounded_String)
5477 return String;
5478 @end smallexample
5479
5480 @noindent
5481 The effect is that if the value of an unbounded string is written to a stream,
5482 then the representation of the item in the stream is in the same format that
5483 would be used for @code{Standard.String'Output}, and this same representation
5484 is expected when a value of this type is read from the stream. Note that the
5485 value written always includes the bounds, even for Unbounded_String'Write,
5486 since Unbounded_String is not an array type.
5487
5488 @node Pragma Style_Checks
5489 @unnumberedsec Pragma Style_Checks
5490 @findex Style_Checks
5491 @noindent
5492 Syntax:
5493
5494 @smallexample @c ada
5495 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5496 On | Off [, LOCAL_NAME]);
5497 @end smallexample
5498
5499 @noindent
5500 This pragma is used in conjunction with compiler switches to control the
5501 built in style checking provided by GNAT@. The compiler switches, if set,
5502 provide an initial setting for the switches, and this pragma may be used
5503 to modify these settings, or the settings may be provided entirely by
5504 the use of the pragma. This pragma can be used anywhere that a pragma
5505 is legal, including use as a configuration pragma (including use in
5506 the @file{gnat.adc} file).
5507
5508 The form with a string literal specifies which style options are to be
5509 activated. These are additive, so they apply in addition to any previously
5510 set style check options. The codes for the options are the same as those
5511 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5512 For example the following two methods can be used to enable
5513 layout checking:
5514
5515 @itemize @bullet
5516 @item
5517 @smallexample @c ada
5518 pragma Style_Checks ("l");
5519 @end smallexample
5520
5521 @item
5522 @smallexample
5523 gcc -c -gnatyl @dots{}
5524 @end smallexample
5525 @end itemize
5526
5527 @noindent
5528 The form ALL_CHECKS activates all standard checks (its use is equivalent
5529 to the use of the @code{gnaty} switch with no options. @xref{Top,
5530 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5531 @value{EDITION} User's Guide}, for details.)
5532
5533 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5534 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5535 options (i.e. equivalent to -gnatyg).
5536
5537 The forms with @code{Off} and @code{On}
5538 can be used to temporarily disable style checks
5539 as shown in the following example:
5540
5541 @smallexample @c ada
5542 @iftex
5543 @leftskip=0cm
5544 @end iftex
5545 pragma Style_Checks ("k"); -- requires keywords in lower case
5546 pragma Style_Checks (Off); -- turn off style checks
5547 NULL; -- this will not generate an error message
5548 pragma Style_Checks (On); -- turn style checks back on
5549 NULL; -- this will generate an error message
5550 @end smallexample
5551
5552 @noindent
5553 Finally the two argument form is allowed only if the first argument is
5554 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5555 for the specified entity, as shown in the following example:
5556
5557 @smallexample @c ada
5558 @iftex
5559 @leftskip=0cm
5560 @end iftex
5561 pragma Style_Checks ("r"); -- require consistency of identifier casing
5562 Arg : Integer;
5563 Rf1 : Integer := ARG; -- incorrect, wrong case
5564 pragma Style_Checks (Off, Arg);
5565 Rf2 : Integer := ARG; -- OK, no error
5566 @end smallexample
5567
5568 @node Pragma Subtitle
5569 @unnumberedsec Pragma Subtitle
5570 @findex Subtitle
5571 @noindent
5572 Syntax:
5573
5574 @smallexample @c ada
5575 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5576 @end smallexample
5577
5578 @noindent
5579 This pragma is recognized for compatibility with other Ada compilers
5580 but is ignored by GNAT@.
5581
5582 @node Pragma Suppress
5583 @unnumberedsec Pragma Suppress
5584 @findex Suppress
5585 @noindent
5586 Syntax:
5587
5588 @smallexample @c ada
5589 pragma Suppress (Identifier [, [On =>] Name]);
5590 @end smallexample
5591
5592 @noindent
5593 This is a standard pragma, and supports all the check names required in
5594 the RM. It is included here because GNAT recognizes one additional check
5595 name: @code{Alignment_Check} which can be used to suppress alignment checks
5596 on addresses used in address clauses. Such checks can also be suppressed
5597 by suppressing range checks, but the specific use of @code{Alignment_Check}
5598 allows suppression of alignment checks without suppressing other range checks.
5599
5600 Note that pragma Suppress gives the compiler permission to omit
5601 checks, but does not require the compiler to omit checks. The compiler
5602 will generate checks if they are essentially free, even when they are
5603 suppressed. In particular, if the compiler can prove that a certain
5604 check will necessarily fail, it will generate code to do an
5605 unconditional ``raise'', even if checks are suppressed. The compiler
5606 warns in this case.
5607
5608 Of course, run-time checks are omitted whenever the compiler can prove
5609 that they will not fail, whether or not checks are suppressed.
5610
5611 @node Pragma Suppress_All
5612 @unnumberedsec Pragma Suppress_All
5613 @findex Suppress_All
5614 @noindent
5615 Syntax:
5616
5617 @smallexample @c ada
5618 pragma Suppress_All;
5619 @end smallexample
5620
5621 @noindent
5622 This pragma can appear anywhere within a unit.
5623 The effect is to apply @code{Suppress (All_Checks)} to the unit
5624 in which it appears. This pragma is implemented for compatibility with DEC
5625 Ada 83 usage where it appears at the end of a unit, and for compatibility
5626 with Rational Ada, where it appears as a program unit pragma.
5627 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5628 as a normal configuration pragma is the preferred usage in GNAT@.
5629
5630 @node Pragma Suppress_Exception_Locations
5631 @unnumberedsec Pragma Suppress_Exception_Locations
5632 @findex Suppress_Exception_Locations
5633 @noindent
5634 Syntax:
5635
5636 @smallexample @c ada
5637 pragma Suppress_Exception_Locations;
5638 @end smallexample
5639
5640 @noindent
5641 In normal mode, a raise statement for an exception by default generates
5642 an exception message giving the file name and line number for the location
5643 of the raise. This is useful for debugging and logging purposes, but this
5644 entails extra space for the strings for the messages. The configuration
5645 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5646 generation of these strings, with the result that space is saved, but the
5647 exception message for such raises is null. This configuration pragma may
5648 appear in a global configuration pragma file, or in a specific unit as
5649 usual. It is not required that this pragma be used consistently within
5650 a partition, so it is fine to have some units within a partition compiled
5651 with this pragma and others compiled in normal mode without it.
5652
5653 @node Pragma Suppress_Initialization
5654 @unnumberedsec Pragma Suppress_Initialization
5655 @findex Suppress_Initialization
5656 @cindex Suppressing initialization
5657 @cindex Initialization, suppression of
5658 @noindent
5659 Syntax:
5660
5661 @smallexample @c ada
5662 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5663 @end smallexample
5664
5665 @noindent
5666 Here subtype_Name is the name introduced by a type declaration
5667 or subtype declaration.
5668 This pragma suppresses any implicit or explicit initialization
5669 for all variables of the given type or subtype,
5670 including initialization resulting from the use of pragmas
5671 Normalize_Scalars or Initialize_Scalars.
5672
5673 This is considered a representation item, so it cannot be given after
5674 the type is frozen. It applies to all subsequent object declarations,
5675 and also any allocator that creates objects of the type.
5676
5677 If the pragma is given for the first subtype, then it is considered
5678 to apply to the base type and all its subtypes. If the pragma is given
5679 for other than a first subtype, then it applies only to the given subtype.
5680 The pragma may not be given after the type is frozen.
5681
5682 @node Pragma Task_Info
5683 @unnumberedsec Pragma Task_Info
5684 @findex Task_Info
5685 @noindent
5686 Syntax
5687
5688 @smallexample @c ada
5689 pragma Task_Info (EXPRESSION);
5690 @end smallexample
5691
5692 @noindent
5693 This pragma appears within a task definition (like pragma
5694 @code{Priority}) and applies to the task in which it appears. The
5695 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5696 The @code{Task_Info} pragma provides system dependent control over
5697 aspects of tasking implementation, for example, the ability to map
5698 tasks to specific processors. For details on the facilities available
5699 for the version of GNAT that you are using, see the documentation
5700 in the spec of package System.Task_Info in the runtime
5701 library.
5702
5703 @node Pragma Task_Name
5704 @unnumberedsec Pragma Task_Name
5705 @findex Task_Name
5706 @noindent
5707 Syntax
5708
5709 @smallexample @c ada
5710 pragma Task_Name (string_EXPRESSION);
5711 @end smallexample
5712
5713 @noindent
5714 This pragma appears within a task definition (like pragma
5715 @code{Priority}) and applies to the task in which it appears. The
5716 argument must be of type String, and provides a name to be used for
5717 the task instance when the task is created. Note that this expression
5718 is not required to be static, and in particular, it can contain
5719 references to task discriminants. This facility can be used to
5720 provide different names for different tasks as they are created,
5721 as illustrated in the example below.
5722
5723 The task name is recorded internally in the run-time structures
5724 and is accessible to tools like the debugger. In addition the
5725 routine @code{Ada.Task_Identification.Image} will return this
5726 string, with a unique task address appended.
5727
5728 @smallexample @c ada
5729 -- Example of the use of pragma Task_Name
5730
5731 with Ada.Task_Identification;
5732 use Ada.Task_Identification;
5733 with Text_IO; use Text_IO;
5734 procedure t3 is
5735
5736 type Astring is access String;
5737
5738 task type Task_Typ (Name : access String) is
5739 pragma Task_Name (Name.all);
5740 end Task_Typ;
5741
5742 task body Task_Typ is
5743 Nam : constant String := Image (Current_Task);
5744 begin
5745 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5746 end Task_Typ;
5747
5748 type Ptr_Task is access Task_Typ;
5749 Task_Var : Ptr_Task;
5750
5751 begin
5752 Task_Var :=
5753 new Task_Typ (new String'("This is task 1"));
5754 Task_Var :=
5755 new Task_Typ (new String'("This is task 2"));
5756 end;
5757 @end smallexample
5758
5759 @node Pragma Task_Storage
5760 @unnumberedsec Pragma Task_Storage
5761 @findex Task_Storage
5762 Syntax:
5763
5764 @smallexample @c ada
5765 pragma Task_Storage (
5766 [Task_Type =>] LOCAL_NAME,
5767 [Top_Guard =>] static_integer_EXPRESSION);
5768 @end smallexample
5769
5770 @noindent
5771 This pragma specifies the length of the guard area for tasks. The guard
5772 area is an additional storage area allocated to a task. A value of zero
5773 means that either no guard area is created or a minimal guard area is
5774 created, depending on the target. This pragma can appear anywhere a
5775 @code{Storage_Size} attribute definition clause is allowed for a task
5776 type.
5777
5778 @node Pragma Test_Case
5779 @unnumberedsec Pragma Test_Case
5780 @cindex Test cases
5781 @findex Test_Case
5782 @noindent
5783 Syntax:
5784
5785 @smallexample @c ada
5786 pragma Test_Case (
5787 [Name =>] static_string_Expression
5788 ,[Mode =>] (Nominal | Robustness)
5789 [, Requires => Boolean_Expression]
5790 [, Ensures => Boolean_Expression]);
5791 @end smallexample
5792
5793 @noindent
5794 The @code{Test_Case} pragma allows defining fine-grain specifications
5795 for use by testing tools. Its syntax is similar to the syntax of the
5796 @code{Contract_Case} pragma, which is used for both testing and
5797 formal verification.
5798 The compiler checks the validity of the @code{Test_Case} pragma, but its
5799 presence does not lead to any modification of the code generated by the
5800 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5801
5802 @code{Test_Case} pragmas may only appear immediately following the
5803 (separate) declaration of a subprogram in a package declaration, inside
5804 a package spec unit. Only other pragmas may intervene (that is appear
5805 between the subprogram declaration and a test case).
5806
5807 The compiler checks that boolean expressions given in @code{Requires} and
5808 @code{Ensures} are valid, where the rules for @code{Requires} are the
5809 same as the rule for an expression in @code{Precondition} and the rules
5810 for @code{Ensures} are the same as the rule for an expression in
5811 @code{Postcondition}. In particular, attributes @code{'Old} and
5812 @code{'Result} can only be used within the @code{Ensures}
5813 expression. The following is an example of use within a package spec:
5814
5815 @smallexample @c ada
5816 package Math_Functions is
5817 ...
5818 function Sqrt (Arg : Float) return Float;
5819 pragma Test_Case (Name => "Test 1",
5820 Mode => Nominal,
5821 Requires => Arg < 10000,
5822 Ensures => Sqrt'Result < 10);
5823 ...
5824 end Math_Functions;
5825 @end smallexample
5826
5827 @noindent
5828 The meaning of a test case is that there is at least one context where
5829 @code{Requires} holds such that, if the associated subprogram is executed in
5830 that context, then @code{Ensures} holds when the subprogram returns.
5831 Mode @code{Nominal} indicates that the input context should also satisfy the
5832 precondition of the subprogram, and the output context should also satisfy its
5833 postcondition. More @code{Robustness} indicates that the precondition and
5834 postcondition of the subprogram should be ignored for this test case.
5835
5836 @node Pragma Thread_Local_Storage
5837 @unnumberedsec Pragma Thread_Local_Storage
5838 @findex Thread_Local_Storage
5839 @cindex Task specific storage
5840 @cindex TLS (Thread Local Storage)
5841 Syntax:
5842
5843 @smallexample @c ada
5844 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5845 @end smallexample
5846
5847 @noindent
5848 This pragma specifies that the specified entity, which must be
5849 a variable declared in a library level package, is to be marked as
5850 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5851 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5852 (and hence each Ada task) to see a distinct copy of the variable.
5853
5854 The variable may not have default initialization, and if there is
5855 an explicit initialization, it must be either @code{null} for an
5856 access variable, or a static expression for a scalar variable.
5857 This provides a low level mechanism similar to that provided by
5858 the @code{Ada.Task_Attributes} package, but much more efficient
5859 and is also useful in writing interface code that will interact
5860 with foreign threads.
5861
5862 If this pragma is used on a system where @code{TLS} is not supported,
5863 then an error message will be generated and the program will be rejected.
5864
5865 @node Pragma Time_Slice
5866 @unnumberedsec Pragma Time_Slice
5867 @findex Time_Slice
5868 @noindent
5869 Syntax:
5870
5871 @smallexample @c ada
5872 pragma Time_Slice (static_duration_EXPRESSION);
5873 @end smallexample
5874
5875 @noindent
5876 For implementations of GNAT on operating systems where it is possible
5877 to supply a time slice value, this pragma may be used for this purpose.
5878 It is ignored if it is used in a system that does not allow this control,
5879 or if it appears in other than the main program unit.
5880 @cindex OpenVMS
5881 Note that the effect of this pragma is identical to the effect of the
5882 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5883
5884 @node Pragma Title
5885 @unnumberedsec Pragma Title
5886 @findex Title
5887 @noindent
5888 Syntax:
5889
5890 @smallexample @c ada
5891 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5892
5893 TITLING_OPTION ::=
5894 [Title =>] STRING_LITERAL,
5895 | [Subtitle =>] STRING_LITERAL
5896 @end smallexample
5897
5898 @noindent
5899 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5900 pragma used in DEC Ada 83 implementations to provide a title and/or
5901 subtitle for the program listing. The program listing generated by GNAT
5902 does not have titles or subtitles.
5903
5904 Unlike other pragmas, the full flexibility of named notation is allowed
5905 for this pragma, i.e.@: the parameters may be given in any order if named
5906 notation is used, and named and positional notation can be mixed
5907 following the normal rules for procedure calls in Ada.
5908
5909 @node Pragma Unchecked_Union
5910 @unnumberedsec Pragma Unchecked_Union
5911 @cindex Unions in C
5912 @findex Unchecked_Union
5913 @noindent
5914 Syntax:
5915
5916 @smallexample @c ada
5917 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5918 @end smallexample
5919
5920 @noindent
5921 This pragma is used to specify a representation of a record type that is
5922 equivalent to a C union. It was introduced as a GNAT implementation defined
5923 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5924 pragma, making it language defined, and GNAT fully implements this extended
5925 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5926 details, consult the Ada 2012 Reference Manual, section B.3.3.
5927
5928 @node Pragma Unimplemented_Unit
5929 @unnumberedsec Pragma Unimplemented_Unit
5930 @findex Unimplemented_Unit
5931 @noindent
5932 Syntax:
5933
5934 @smallexample @c ada
5935 pragma Unimplemented_Unit;
5936 @end smallexample
5937
5938 @noindent
5939 If this pragma occurs in a unit that is processed by the compiler, GNAT
5940 aborts with the message @samp{@var{xxx} not implemented}, where
5941 @var{xxx} is the name of the current compilation unit. This pragma is
5942 intended to allow the compiler to handle unimplemented library units in
5943 a clean manner.
5944
5945 The abort only happens if code is being generated. Thus you can use
5946 specs of unimplemented packages in syntax or semantic checking mode.
5947
5948 @node Pragma Universal_Aliasing
5949 @unnumberedsec Pragma Universal_Aliasing
5950 @findex Universal_Aliasing
5951 @noindent
5952 Syntax:
5953
5954 @smallexample @c ada
5955 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5956 @end smallexample
5957
5958 @noindent
5959 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5960 declarative part. The effect is to inhibit strict type-based aliasing
5961 optimization for the given type. In other words, the effect is as though
5962 access types designating this type were subject to pragma No_Strict_Aliasing.
5963 For a detailed description of the strict aliasing optimization, and the
5964 situations in which it must be suppressed, @xref{Optimization and Strict
5965 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5966
5967 @node Pragma Universal_Data
5968 @unnumberedsec Pragma Universal_Data
5969 @findex Universal_Data
5970 @noindent
5971 Syntax:
5972
5973 @smallexample @c ada
5974 pragma Universal_Data [(library_unit_Name)];
5975 @end smallexample
5976
5977 @noindent
5978 This pragma is supported only for the AAMP target and is ignored for
5979 other targets. The pragma specifies that all library-level objects
5980 (Counter 0 data) associated with the library unit are to be accessed
5981 and updated using universal addressing (24-bit addresses for AAMP5)
5982 rather than the default of 16-bit Data Environment (DENV) addressing.
5983 Use of this pragma will generally result in less efficient code for
5984 references to global data associated with the library unit, but
5985 allows such data to be located anywhere in memory. This pragma is
5986 a library unit pragma, but can also be used as a configuration pragma
5987 (including use in the @file{gnat.adc} file). The functionality
5988 of this pragma is also available by applying the -univ switch on the
5989 compilations of units where universal addressing of the data is desired.
5990
5991 @node Pragma Unmodified
5992 @unnumberedsec Pragma Unmodified
5993 @findex Unmodified
5994 @cindex Warnings, unmodified
5995 @noindent
5996 Syntax:
5997
5998 @smallexample @c ada
5999 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6000 @end smallexample
6001
6002 @noindent
6003 This pragma signals that the assignable entities (variables,
6004 @code{out} parameters, @code{in out} parameters) whose names are listed are
6005 deliberately not assigned in the current source unit. This
6006 suppresses warnings about the
6007 entities being referenced but not assigned, and in addition a warning will be
6008 generated if one of these entities is in fact assigned in the
6009 same unit as the pragma (or in the corresponding body, or one
6010 of its subunits).
6011
6012 This is particularly useful for clearly signaling that a particular
6013 parameter is not modified, even though the spec suggests that it might
6014 be.
6015
6016 @node Pragma Unreferenced
6017 @unnumberedsec Pragma Unreferenced
6018 @findex Unreferenced
6019 @cindex Warnings, unreferenced
6020 @noindent
6021 Syntax:
6022
6023 @smallexample @c ada
6024 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6025 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6026 @end smallexample
6027
6028 @noindent
6029 This pragma signals that the entities whose names are listed are
6030 deliberately not referenced in the current source unit. This
6031 suppresses warnings about the
6032 entities being unreferenced, and in addition a warning will be
6033 generated if one of these entities is in fact subsequently referenced in the
6034 same unit as the pragma (or in the corresponding body, or one
6035 of its subunits).
6036
6037 This is particularly useful for clearly signaling that a particular
6038 parameter is not referenced in some particular subprogram implementation
6039 and that this is deliberate. It can also be useful in the case of
6040 objects declared only for their initialization or finalization side
6041 effects.
6042
6043 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6044 current scope, then the entity most recently declared is the one to which
6045 the pragma applies. Note that in the case of accept formals, the pragma
6046 Unreferenced may appear immediately after the keyword @code{do} which
6047 allows the indication of whether or not accept formals are referenced
6048 or not to be given individually for each accept statement.
6049
6050 The left hand side of an assignment does not count as a reference for the
6051 purpose of this pragma. Thus it is fine to assign to an entity for which
6052 pragma Unreferenced is given.
6053
6054 Note that if a warning is desired for all calls to a given subprogram,
6055 regardless of whether they occur in the same unit as the subprogram
6056 declaration, then this pragma should not be used (calls from another
6057 unit would not be flagged); pragma Obsolescent can be used instead
6058 for this purpose, see @xref{Pragma Obsolescent}.
6059
6060 The second form of pragma @code{Unreferenced} is used within a context
6061 clause. In this case the arguments must be unit names of units previously
6062 mentioned in @code{with} clauses (similar to the usage of pragma
6063 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6064 units and unreferenced entities within these units.
6065
6066 @node Pragma Unreferenced_Objects
6067 @unnumberedsec Pragma Unreferenced_Objects
6068 @findex Unreferenced_Objects
6069 @cindex Warnings, unreferenced
6070 @noindent
6071 Syntax:
6072
6073 @smallexample @c ada
6074 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6075 @end smallexample
6076
6077 @noindent
6078 This pragma signals that for the types or subtypes whose names are
6079 listed, objects which are declared with one of these types or subtypes may
6080 not be referenced, and if no references appear, no warnings are given.
6081
6082 This is particularly useful for objects which are declared solely for their
6083 initialization and finalization effect. Such variables are sometimes referred
6084 to as RAII variables (Resource Acquisition Is Initialization). Using this
6085 pragma on the relevant type (most typically a limited controlled type), the
6086 compiler will automatically suppress unwanted warnings about these variables
6087 not being referenced.
6088
6089 @node Pragma Unreserve_All_Interrupts
6090 @unnumberedsec Pragma Unreserve_All_Interrupts
6091 @findex Unreserve_All_Interrupts
6092 @noindent
6093 Syntax:
6094
6095 @smallexample @c ada
6096 pragma Unreserve_All_Interrupts;
6097 @end smallexample
6098
6099 @noindent
6100 Normally certain interrupts are reserved to the implementation. Any attempt
6101 to attach an interrupt causes Program_Error to be raised, as described in
6102 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6103 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6104 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6105 interrupt execution.
6106
6107 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6108 a program, then all such interrupts are unreserved. This allows the
6109 program to handle these interrupts, but disables their standard
6110 functions. For example, if this pragma is used, then pressing
6111 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6112 a program can then handle the @code{SIGINT} interrupt as it chooses.
6113
6114 For a full list of the interrupts handled in a specific implementation,
6115 see the source code for the spec of @code{Ada.Interrupts.Names} in
6116 file @file{a-intnam.ads}. This is a target dependent file that contains the
6117 list of interrupts recognized for a given target. The documentation in
6118 this file also specifies what interrupts are affected by the use of
6119 the @code{Unreserve_All_Interrupts} pragma.
6120
6121 For a more general facility for controlling what interrupts can be
6122 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6123 of the @code{Unreserve_All_Interrupts} pragma.
6124
6125 @node Pragma Unsuppress
6126 @unnumberedsec Pragma Unsuppress
6127 @findex Unsuppress
6128 @noindent
6129 Syntax:
6130
6131 @smallexample @c ada
6132 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6133 @end smallexample
6134
6135 @noindent
6136 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6137 there is no corresponding pragma @code{Suppress} in effect, it has no
6138 effect. The range of the effect is the same as for pragma
6139 @code{Suppress}. The meaning of the arguments is identical to that used
6140 in pragma @code{Suppress}.
6141
6142 One important application is to ensure that checks are on in cases where
6143 code depends on the checks for its correct functioning, so that the code
6144 will compile correctly even if the compiler switches are set to suppress
6145 checks.
6146
6147 This pragma is standard in Ada 2005. It is available in all earlier versions
6148 of Ada as an implementation-defined pragma.
6149
6150 @node Pragma Use_VADS_Size
6151 @unnumberedsec Pragma Use_VADS_Size
6152 @cindex @code{Size}, VADS compatibility
6153 @cindex Rational profile
6154 @findex Use_VADS_Size
6155 @noindent
6156 Syntax:
6157
6158 @smallexample @c ada
6159 pragma Use_VADS_Size;
6160 @end smallexample
6161
6162 @noindent
6163 This is a configuration pragma. In a unit to which it applies, any use
6164 of the 'Size attribute is automatically interpreted as a use of the
6165 'VADS_Size attribute. Note that this may result in incorrect semantic
6166 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6167 the handling of existing code which depends on the interpretation of Size
6168 as implemented in the VADS compiler. See description of the VADS_Size
6169 attribute for further details.
6170
6171 @node Pragma Validity_Checks
6172 @unnumberedsec Pragma Validity_Checks
6173 @findex Validity_Checks
6174 @noindent
6175 Syntax:
6176
6177 @smallexample @c ada
6178 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6179 @end smallexample
6180
6181 @noindent
6182 This pragma is used in conjunction with compiler switches to control the
6183 built-in validity checking provided by GNAT@. The compiler switches, if set
6184 provide an initial setting for the switches, and this pragma may be used
6185 to modify these settings, or the settings may be provided entirely by
6186 the use of the pragma. This pragma can be used anywhere that a pragma
6187 is legal, including use as a configuration pragma (including use in
6188 the @file{gnat.adc} file).
6189
6190 The form with a string literal specifies which validity options are to be
6191 activated. The validity checks are first set to include only the default
6192 reference manual settings, and then a string of letters in the string
6193 specifies the exact set of options required. The form of this string
6194 is exactly as described for the @option{-gnatVx} compiler switch (see the
6195 @value{EDITION} User's Guide for details). For example the following two
6196 methods can be used to enable validity checking for mode @code{in} and
6197 @code{in out} subprogram parameters:
6198
6199 @itemize @bullet
6200 @item
6201 @smallexample @c ada
6202 pragma Validity_Checks ("im");
6203 @end smallexample
6204
6205 @item
6206 @smallexample
6207 gcc -c -gnatVim @dots{}
6208 @end smallexample
6209 @end itemize
6210
6211 @noindent
6212 The form ALL_CHECKS activates all standard checks (its use is equivalent
6213 to the use of the @code{gnatva} switch.
6214
6215 The forms with @code{Off} and @code{On}
6216 can be used to temporarily disable validity checks
6217 as shown in the following example:
6218
6219 @smallexample @c ada
6220 @iftex
6221 @leftskip=0cm
6222 @end iftex
6223 pragma Validity_Checks ("c"); -- validity checks for copies
6224 pragma Validity_Checks (Off); -- turn off validity checks
6225 A := B; -- B will not be validity checked
6226 pragma Validity_Checks (On); -- turn validity checks back on
6227 A := C; -- C will be validity checked
6228 @end smallexample
6229
6230 @node Pragma Volatile
6231 @unnumberedsec Pragma Volatile
6232 @findex Volatile
6233 @noindent
6234 Syntax:
6235
6236 @smallexample @c ada
6237 pragma Volatile (LOCAL_NAME);
6238 @end smallexample
6239
6240 @noindent
6241 This pragma is defined by the Ada Reference Manual, and the GNAT
6242 implementation is fully conformant with this definition. The reason it
6243 is mentioned in this section is that a pragma of the same name was supplied
6244 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6245 implementation of pragma Volatile is upwards compatible with the
6246 implementation in DEC Ada 83.
6247
6248 @node Pragma Warnings
6249 @unnumberedsec Pragma Warnings
6250 @findex Warnings
6251 @noindent
6252 Syntax:
6253
6254 @smallexample @c ada
6255 pragma Warnings (On | Off);
6256 pragma Warnings (On | Off, LOCAL_NAME);
6257 pragma Warnings (static_string_EXPRESSION);
6258 pragma Warnings (On | Off, static_string_EXPRESSION);
6259 @end smallexample
6260
6261 @noindent
6262 Normally warnings are enabled, with the output being controlled by
6263 the command line switch. Warnings (@code{Off}) turns off generation of
6264 warnings until a Warnings (@code{On}) is encountered or the end of the
6265 current unit. If generation of warnings is turned off using this
6266 pragma, then no warning messages are output, regardless of the
6267 setting of the command line switches.
6268
6269 The form with a single argument may be used as a configuration pragma.
6270
6271 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6272 the specified entity. This suppression is effective from the point where
6273 it occurs till the end of the extended scope of the variable (similar to
6274 the scope of @code{Suppress}).
6275
6276 The form with a single static_string_EXPRESSION argument provides more precise
6277 control over which warnings are active. The string is a list of letters
6278 specifying which warnings are to be activated and which deactivated. The
6279 code for these letters is the same as the string used in the command
6280 line switch controlling warnings. For a brief summary, use the gnatmake
6281 command with no arguments, which will generate usage information containing
6282 the list of warnings switches supported. For
6283 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6284 User's Guide}.
6285
6286 @noindent
6287 The warnings controlled by the `-gnatw' switch are generated by the front end
6288 of the compiler. The `GCC' back end can provide additional warnings and they
6289 are controlled by the `-W' switch.
6290 The form with a single static_string_EXPRESSION argument also works for the
6291 latters, but the string must be a single full `-W' switch in this case.
6292 The above reference lists a few examples of these additional warnings.
6293
6294 @noindent
6295 The specified warnings will be in effect until the end of the program
6296 or another pragma Warnings is encountered. The effect of the pragma is
6297 cumulative. Initially the set of warnings is the standard default set
6298 as possibly modified by compiler switches. Then each pragma Warning
6299 modifies this set of warnings as specified. This form of the pragma may
6300 also be used as a configuration pragma.
6301
6302 The fourth form, with an @code{On|Off} parameter and a string, is used to
6303 control individual messages, based on their text. The string argument
6304 is a pattern that is used to match against the text of individual
6305 warning messages (not including the initial "warning: " tag).
6306
6307 The pattern may contain asterisks, which match zero or more characters in
6308 the message. For example, you can use
6309 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6310 message @code{warning: 960 bits of "a" unused}. No other regular
6311 expression notations are permitted. All characters other than asterisk in
6312 these three specific cases are treated as literal characters in the match.
6313
6314 The above use of patterns to match the message applies only to warning
6315 messages generated by the front end. This form of the pragma with a
6316 string argument can also be used to control back end warnings controlled
6317 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6318 of a string of the form "[-Wxxx]" in the message which identifies the
6319 "-W" switch that controls the message. By using the text of the
6320 "-W" switch in the pragma, such back end warnings can be turned on and off.
6321
6322 There are two ways to use the pragma in this form. The OFF form can be used as a
6323 configuration pragma. The effect is to suppress all warnings (if any)
6324 that match the pattern string throughout the compilation (or match the
6325 -W switch in the back end case).
6326
6327 The second usage is to suppress a warning locally, and in this case, two
6328 pragmas must appear in sequence:
6329
6330 @smallexample @c ada
6331 pragma Warnings (Off, Pattern);
6332 @dots{} code where given warning is to be suppressed
6333 pragma Warnings (On, Pattern);
6334 @end smallexample
6335
6336 @noindent
6337 In this usage, the pattern string must match in the Off and On pragmas,
6338 and at least one matching warning must be suppressed.
6339
6340 Note: to write a string that will match any warning, use the string
6341 @code{"***"}. It will not work to use a single asterisk or two asterisks
6342 since this looks like an operator name. This form with three asterisks
6343 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
6344 matching @code{pragma Warnings (On, "***")} will be required. This can be
6345 helpful in avoiding forgetting to turn warnings back on.
6346
6347 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
6348 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6349 be useful in checking whether obsolete pragmas in existing programs are hiding
6350 real problems.
6351
6352 Note: pragma Warnings does not affect the processing of style messages. See
6353 separate entry for pragma Style_Checks for control of style messages.
6354
6355 @node Pragma Weak_External
6356 @unnumberedsec Pragma Weak_External
6357 @findex Weak_External
6358 @noindent
6359 Syntax:
6360
6361 @smallexample @c ada
6362 pragma Weak_External ([Entity =>] LOCAL_NAME);
6363 @end smallexample
6364
6365 @noindent
6366 @var{LOCAL_NAME} must refer to an object that is declared at the library
6367 level. This pragma specifies that the given entity should be marked as a
6368 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
6369 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
6370 of a regular symbol, that is to say a symbol that does not have to be
6371 resolved by the linker if used in conjunction with a pragma Import.
6372
6373 When a weak symbol is not resolved by the linker, its address is set to
6374 zero. This is useful in writing interfaces to external modules that may
6375 or may not be linked in the final executable, for example depending on
6376 configuration settings.
6377
6378 If a program references at run time an entity to which this pragma has been
6379 applied, and the corresponding symbol was not resolved at link time, then
6380 the execution of the program is erroneous. It is not erroneous to take the
6381 Address of such an entity, for example to guard potential references,
6382 as shown in the example below.
6383
6384 Some file formats do not support weak symbols so not all target machines
6385 support this pragma.
6386
6387 @smallexample @c ada
6388 -- Example of the use of pragma Weak_External
6389
6390 package External_Module is
6391 key : Integer;
6392 pragma Import (C, key);
6393 pragma Weak_External (key);
6394 function Present return boolean;
6395 end External_Module;
6396
6397 with System; use System;
6398 package body External_Module is
6399 function Present return boolean is
6400 begin
6401 return key'Address /= System.Null_Address;
6402 end Present;
6403 end External_Module;
6404 @end smallexample
6405
6406 @node Pragma Wide_Character_Encoding
6407 @unnumberedsec Pragma Wide_Character_Encoding
6408 @findex Wide_Character_Encoding
6409 @noindent
6410 Syntax:
6411
6412 @smallexample @c ada
6413 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6414 @end smallexample
6415
6416 @noindent
6417 This pragma specifies the wide character encoding to be used in program
6418 source text appearing subsequently. It is a configuration pragma, but may
6419 also be used at any point that a pragma is allowed, and it is permissible
6420 to have more than one such pragma in a file, allowing multiple encodings
6421 to appear within the same file.
6422
6423 The argument can be an identifier or a character literal. In the identifier
6424 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6425 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6426 case it is correspondingly one of the characters @samp{h}, @samp{u},
6427 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6428
6429 Note that when the pragma is used within a file, it affects only the
6430 encoding within that file, and does not affect withed units, specs,
6431 or subunits.
6432
6433 @node Implementation Defined Attributes
6434 @chapter Implementation Defined Attributes
6435 Ada defines (throughout the Ada reference manual,
6436 summarized in Annex K),
6437 a set of attributes that provide useful additional functionality in all
6438 areas of the language. These language defined attributes are implemented
6439 in GNAT and work as described in the Ada Reference Manual.
6440
6441 In addition, Ada allows implementations to define additional
6442 attributes whose meaning is defined by the implementation. GNAT provides
6443 a number of these implementation-dependent attributes which can be used
6444 to extend and enhance the functionality of the compiler. This section of
6445 the GNAT reference manual describes these additional attributes.
6446
6447 Note that any program using these attributes may not be portable to
6448 other compilers (although GNAT implements this set of attributes on all
6449 platforms). Therefore if portability to other compilers is an important
6450 consideration, you should minimize the use of these attributes.
6451
6452 @menu
6453 * Abort_Signal::
6454 * Address_Size::
6455 * Asm_Input::
6456 * Asm_Output::
6457 * AST_Entry::
6458 * Bit::
6459 * Bit_Position::
6460 * Compiler_Version::
6461 * Code_Address::
6462 * Default_Bit_Order::
6463 * Descriptor_Size::
6464 * Elaborated::
6465 * Elab_Body::
6466 * Elab_Spec::
6467 * Elab_Subp_Body::
6468 * Emax::
6469 * Enabled::
6470 * Enum_Rep::
6471 * Enum_Val::
6472 * Epsilon::
6473 * Fixed_Value::
6474 * Has_Access_Values::
6475 * Has_Discriminants::
6476 * Img::
6477 * Integer_Value::
6478 * Invalid_Value::
6479 * Large::
6480 * Machine_Size::
6481 * Mantissa::
6482 * Max_Interrupt_Priority::
6483 * Max_Priority::
6484 * Maximum_Alignment::
6485 * Mechanism_Code::
6486 * Null_Parameter::
6487 * Object_Size::
6488 * Passed_By_Reference::
6489 * Pool_Address::
6490 * Range_Length::
6491 * Ref::
6492 * Result::
6493 * Safe_Emax::
6494 * Safe_Large::
6495 * Scalar_Storage_Order::
6496 * Simple_Storage_Pool::
6497 * Small::
6498 * Storage_Unit::
6499 * Stub_Type::
6500 * System_Allocator_Alignment::
6501 * Target_Name::
6502 * Tick::
6503 * To_Address::
6504 * Type_Class::
6505 * UET_Address::
6506 * Unconstrained_Array::
6507 * Universal_Literal_String::
6508 * Unrestricted_Access::
6509 * Valid_Scalars::
6510 * VADS_Size::
6511 * Value_Size::
6512 * Wchar_T_Size::
6513 * Word_Size::
6514 @end menu
6515
6516 @node Abort_Signal
6517 @unnumberedsec Abort_Signal
6518 @findex Abort_Signal
6519 @noindent
6520 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6521 prefix) provides the entity for the special exception used to signal
6522 task abort or asynchronous transfer of control. Normally this attribute
6523 should only be used in the tasking runtime (it is highly peculiar, and
6524 completely outside the normal semantics of Ada, for a user program to
6525 intercept the abort exception).
6526
6527 @node Address_Size
6528 @unnumberedsec Address_Size
6529 @cindex Size of @code{Address}
6530 @findex Address_Size
6531 @noindent
6532 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6533 prefix) is a static constant giving the number of bits in an
6534 @code{Address}. It is the same value as System.Address'Size,
6535 but has the advantage of being static, while a direct
6536 reference to System.Address'Size is non-static because Address
6537 is a private type.
6538
6539 @node Asm_Input
6540 @unnumberedsec Asm_Input
6541 @findex Asm_Input
6542 @noindent
6543 The @code{Asm_Input} attribute denotes a function that takes two
6544 parameters. The first is a string, the second is an expression of the
6545 type designated by the prefix. The first (string) argument is required
6546 to be a static expression, and is the constraint for the parameter,
6547 (e.g.@: what kind of register is required). The second argument is the
6548 value to be used as the input argument. The possible values for the
6549 constant are the same as those used in the RTL, and are dependent on
6550 the configuration file used to built the GCC back end.
6551 @ref{Machine Code Insertions}
6552
6553 @node Asm_Output
6554 @unnumberedsec Asm_Output
6555 @findex Asm_Output
6556 @noindent
6557 The @code{Asm_Output} attribute denotes a function that takes two
6558 parameters. The first is a string, the second is the name of a variable
6559 of the type designated by the attribute prefix. The first (string)
6560 argument is required to be a static expression and designates the
6561 constraint for the parameter (e.g.@: what kind of register is
6562 required). The second argument is the variable to be updated with the
6563 result. The possible values for constraint are the same as those used in
6564 the RTL, and are dependent on the configuration file used to build the
6565 GCC back end. If there are no output operands, then this argument may
6566 either be omitted, or explicitly given as @code{No_Output_Operands}.
6567 @ref{Machine Code Insertions}
6568
6569 @node AST_Entry
6570 @unnumberedsec AST_Entry
6571 @cindex OpenVMS
6572 @findex AST_Entry
6573 @noindent
6574 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6575 the name of an entry, it yields a value of the predefined type AST_Handler
6576 (declared in the predefined package System, as extended by the use of
6577 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6578 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6579 Language Reference Manual}, section 9.12a.
6580
6581 @node Bit
6582 @unnumberedsec Bit
6583 @findex Bit
6584 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6585 offset within the storage unit (byte) that contains the first bit of
6586 storage allocated for the object. The value of this attribute is of the
6587 type @code{Universal_Integer}, and is always a non-negative number not
6588 exceeding the value of @code{System.Storage_Unit}.
6589
6590 For an object that is a variable or a constant allocated in a register,
6591 the value is zero. (The use of this attribute does not force the
6592 allocation of a variable to memory).
6593
6594 For an object that is a formal parameter, this attribute applies
6595 to either the matching actual parameter or to a copy of the
6596 matching actual parameter.
6597
6598 For an access object the value is zero. Note that
6599 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6600 designated object. Similarly for a record component
6601 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6602 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6603 are subject to index checks.
6604
6605 This attribute is designed to be compatible with the DEC Ada 83 definition
6606 and implementation of the @code{Bit} attribute.
6607
6608 @node Bit_Position
6609 @unnumberedsec Bit_Position
6610 @findex Bit_Position
6611 @noindent
6612 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6613 of the fields of the record type, yields the bit
6614 offset within the record contains the first bit of
6615 storage allocated for the object. The value of this attribute is of the
6616 type @code{Universal_Integer}. The value depends only on the field
6617 @var{C} and is independent of the alignment of
6618 the containing record @var{R}.
6619
6620 @node Compiler_Version
6621 @unnumberedsec Compiler_Version
6622 @findex Compiler_Version
6623 @noindent
6624 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6625 prefix) yields a static string identifying the version of the compiler
6626 being used to compile the unit containing the attribute reference. A
6627 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6628
6629 @node Code_Address
6630 @unnumberedsec Code_Address
6631 @findex Code_Address
6632 @cindex Subprogram address
6633 @cindex Address of subprogram code
6634 @noindent
6635 The @code{'Address}
6636 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6637 intended effect seems to be to provide
6638 an address value which can be used to call the subprogram by means of
6639 an address clause as in the following example:
6640
6641 @smallexample @c ada
6642 procedure K is @dots{}
6643
6644 procedure L;
6645 for L'Address use K'Address;
6646 pragma Import (Ada, L);
6647 @end smallexample
6648
6649 @noindent
6650 A call to @code{L} is then expected to result in a call to @code{K}@.
6651 In Ada 83, where there were no access-to-subprogram values, this was
6652 a common work-around for getting the effect of an indirect call.
6653 GNAT implements the above use of @code{Address} and the technique
6654 illustrated by the example code works correctly.
6655
6656 However, for some purposes, it is useful to have the address of the start
6657 of the generated code for the subprogram. On some architectures, this is
6658 not necessarily the same as the @code{Address} value described above.
6659 For example, the @code{Address} value may reference a subprogram
6660 descriptor rather than the subprogram itself.
6661
6662 The @code{'Code_Address} attribute, which can only be applied to
6663 subprogram entities, always returns the address of the start of the
6664 generated code of the specified subprogram, which may or may not be
6665 the same value as is returned by the corresponding @code{'Address}
6666 attribute.
6667
6668 @node Default_Bit_Order
6669 @unnumberedsec Default_Bit_Order
6670 @cindex Big endian
6671 @cindex Little endian
6672 @findex Default_Bit_Order
6673 @noindent
6674 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6675 permissible prefix), provides the value @code{System.Default_Bit_Order}
6676 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6677 @code{Low_Order_First}). This is used to construct the definition of
6678 @code{Default_Bit_Order} in package @code{System}.
6679
6680 @node Descriptor_Size
6681 @unnumberedsec Descriptor_Size
6682 @cindex Descriptor
6683 @cindex Dope vector
6684 @findex Descriptor_Size
6685 @noindent
6686 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6687 descriptor allocated for a type. The result is non-zero only for unconstrained
6688 array types and the returned value is of type universal integer. In GNAT, an
6689 array descriptor contains bounds information and is located immediately before
6690 the first element of the array.
6691
6692 @smallexample @c ada
6693 type Unconstr_Array is array (Positive range <>) of Boolean;
6694 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6695 @end smallexample
6696
6697 @noindent
6698 The attribute takes into account any additional padding due to type alignment.
6699 In the example above, the descriptor contains two values of type
6700 @code{Positive} representing the low and high bound. Since @code{Positive} has
6701 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6702 Positive'Size + 2} or 64 bits.
6703
6704 @node Elaborated
6705 @unnumberedsec Elaborated
6706 @findex Elaborated
6707 @noindent
6708 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6709 value is a Boolean which indicates whether or not the given unit has been
6710 elaborated. This attribute is primarily intended for internal use by the
6711 generated code for dynamic elaboration checking, but it can also be used
6712 in user programs. The value will always be True once elaboration of all
6713 units has been completed. An exception is for units which need no
6714 elaboration, the value is always False for such units.
6715
6716 @node Elab_Body
6717 @unnumberedsec Elab_Body
6718 @findex Elab_Body
6719 @noindent
6720 This attribute can only be applied to a program unit name. It returns
6721 the entity for the corresponding elaboration procedure for elaborating
6722 the body of the referenced unit. This is used in the main generated
6723 elaboration procedure by the binder and is not normally used in any
6724 other context. However, there may be specialized situations in which it
6725 is useful to be able to call this elaboration procedure from Ada code,
6726 e.g.@: if it is necessary to do selective re-elaboration to fix some
6727 error.
6728
6729 @node Elab_Spec
6730 @unnumberedsec Elab_Spec
6731 @findex Elab_Spec
6732 @noindent
6733 This attribute can only be applied to a program unit name. It returns
6734 the entity for the corresponding elaboration procedure for elaborating
6735 the spec of the referenced unit. This is used in the main
6736 generated elaboration procedure by the binder and is not normally used
6737 in any other context. However, there may be specialized situations in
6738 which it is useful to be able to call this elaboration procedure from
6739 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6740 some error.
6741
6742 @node Elab_Subp_Body
6743 @unnumberedsec Elab_Subp_Body
6744 @findex Elab_Subp_Body
6745 @noindent
6746 This attribute can only be applied to a library level subprogram
6747 name and is only allowed in CodePeer mode. It returns the entity
6748 for the corresponding elaboration procedure for elaborating the body
6749 of the referenced subprogram unit. This is used in the main generated
6750 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6751 otherwise.
6752
6753 @node Emax
6754 @unnumberedsec Emax
6755 @cindex Ada 83 attributes
6756 @findex Emax
6757 @noindent
6758 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6759 the Ada 83 reference manual for an exact description of the semantics of
6760 this attribute.
6761
6762 @node Enabled
6763 @unnumberedsec Enabled
6764 @findex Enabled
6765 @noindent
6766 The @code{Enabled} attribute allows an application program to check at compile
6767 time to see if the designated check is currently enabled. The prefix is a
6768 simple identifier, referencing any predefined check name (other than
6769 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6770 no argument is given for the attribute, the check is for the general state
6771 of the check, if an argument is given, then it is an entity name, and the
6772 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6773 given naming the entity (if not, then the argument is ignored).
6774
6775 Note that instantiations inherit the check status at the point of the
6776 instantiation, so a useful idiom is to have a library package that
6777 introduces a check name with @code{pragma Check_Name}, and then contains
6778 generic packages or subprograms which use the @code{Enabled} attribute
6779 to see if the check is enabled. A user of this package can then issue
6780 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6781 the package or subprogram, controlling whether the check will be present.
6782
6783 @node Enum_Rep
6784 @unnumberedsec Enum_Rep
6785 @cindex Representation of enums
6786 @findex Enum_Rep
6787 @noindent
6788 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6789 function with the following spec:
6790
6791 @smallexample @c ada
6792 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6793 return @i{Universal_Integer};
6794 @end smallexample
6795
6796 @noindent
6797 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6798 enumeration type or to a non-overloaded enumeration
6799 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6800 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6801 enumeration literal or object.
6802
6803 The function returns the representation value for the given enumeration
6804 value. This will be equal to value of the @code{Pos} attribute in the
6805 absence of an enumeration representation clause. This is a static
6806 attribute (i.e.@: the result is static if the argument is static).
6807
6808 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6809 in which case it simply returns the integer value. The reason for this
6810 is to allow it to be used for @code{(<>)} discrete formal arguments in
6811 a generic unit that can be instantiated with either enumeration types
6812 or integer types. Note that if @code{Enum_Rep} is used on a modular
6813 type whose upper bound exceeds the upper bound of the largest signed
6814 integer type, and the argument is a variable, so that the universal
6815 integer calculation is done at run time, then the call to @code{Enum_Rep}
6816 may raise @code{Constraint_Error}.
6817
6818 @node Enum_Val
6819 @unnumberedsec Enum_Val
6820 @cindex Representation of enums
6821 @findex Enum_Val
6822 @noindent
6823 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6824 function with the following spec:
6825
6826 @smallexample @c ada
6827 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6828 return @var{S}'Base};
6829 @end smallexample
6830
6831 @noindent
6832 The function returns the enumeration value whose representation matches the
6833 argument, or raises Constraint_Error if no enumeration literal of the type
6834 has the matching value.
6835 This will be equal to value of the @code{Val} attribute in the
6836 absence of an enumeration representation clause. This is a static
6837 attribute (i.e.@: the result is static if the argument is static).
6838
6839 @node Epsilon
6840 @unnumberedsec Epsilon
6841 @cindex Ada 83 attributes
6842 @findex Epsilon
6843 @noindent
6844 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6845 the Ada 83 reference manual for an exact description of the semantics of
6846 this attribute.
6847
6848 @node Fixed_Value
6849 @unnumberedsec Fixed_Value
6850 @findex Fixed_Value
6851 @noindent
6852 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6853 function with the following specification:
6854
6855 @smallexample @c ada
6856 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6857 return @var{S};
6858 @end smallexample
6859
6860 @noindent
6861 The value returned is the fixed-point value @var{V} such that
6862
6863 @smallexample @c ada
6864 @var{V} = Arg * @var{S}'Small
6865 @end smallexample
6866
6867 @noindent
6868 The effect is thus similar to first converting the argument to the
6869 integer type used to represent @var{S}, and then doing an unchecked
6870 conversion to the fixed-point type. The difference is
6871 that there are full range checks, to ensure that the result is in range.
6872 This attribute is primarily intended for use in implementation of the
6873 input-output functions for fixed-point values.
6874
6875 @node Has_Access_Values
6876 @unnumberedsec Has_Access_Values
6877 @cindex Access values, testing for
6878 @findex Has_Access_Values
6879 @noindent
6880 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6881 is a Boolean value which is True if the is an access type, or is a composite
6882 type with a component (at any nesting depth) that is an access type, and is
6883 False otherwise.
6884 The intended use of this attribute is in conjunction with generic
6885 definitions. If the attribute is applied to a generic private type, it
6886 indicates whether or not the corresponding actual type has access values.
6887
6888 @node Has_Discriminants
6889 @unnumberedsec Has_Discriminants
6890 @cindex Discriminants, testing for
6891 @findex Has_Discriminants
6892 @noindent
6893 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6894 is a Boolean value which is True if the type has discriminants, and False
6895 otherwise. The intended use of this attribute is in conjunction with generic
6896 definitions. If the attribute is applied to a generic private type, it
6897 indicates whether or not the corresponding actual type has discriminants.
6898
6899 @node Img
6900 @unnumberedsec Img
6901 @findex Img
6902 @noindent
6903 The @code{Img} attribute differs from @code{Image} in that it may be
6904 applied to objects as well as types, in which case it gives the
6905 @code{Image} for the subtype of the object. This is convenient for
6906 debugging:
6907
6908 @smallexample @c ada
6909 Put_Line ("X = " & X'Img);
6910 @end smallexample
6911
6912 @noindent
6913 has the same meaning as the more verbose:
6914
6915 @smallexample @c ada
6916 Put_Line ("X = " & @var{T}'Image (X));
6917 @end smallexample
6918
6919 @noindent
6920 where @var{T} is the (sub)type of the object @code{X}.
6921
6922 @node Integer_Value
6923 @unnumberedsec Integer_Value
6924 @findex Integer_Value
6925 @noindent
6926 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6927 function with the following spec:
6928
6929 @smallexample @c ada
6930 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6931 return @var{S};
6932 @end smallexample
6933
6934 @noindent
6935 The value returned is the integer value @var{V}, such that
6936
6937 @smallexample @c ada
6938 Arg = @var{V} * @var{T}'Small
6939 @end smallexample
6940
6941 @noindent
6942 where @var{T} is the type of @code{Arg}.
6943 The effect is thus similar to first doing an unchecked conversion from
6944 the fixed-point type to its corresponding implementation type, and then
6945 converting the result to the target integer type. The difference is
6946 that there are full range checks, to ensure that the result is in range.
6947 This attribute is primarily intended for use in implementation of the
6948 standard input-output functions for fixed-point values.
6949
6950 @node Invalid_Value
6951 @unnumberedsec Invalid_Value
6952 @findex Invalid_Value
6953 @noindent
6954 For every scalar type S, S'Invalid_Value returns an undefined value of the
6955 type. If possible this value is an invalid representation for the type. The
6956 value returned is identical to the value used to initialize an otherwise
6957 uninitialized value of the type if pragma Initialize_Scalars is used,
6958 including the ability to modify the value with the binder -Sxx flag and
6959 relevant environment variables at run time.
6960
6961 @node Large
6962 @unnumberedsec Large
6963 @cindex Ada 83 attributes
6964 @findex Large
6965 @noindent
6966 The @code{Large} attribute is provided for compatibility with Ada 83. See
6967 the Ada 83 reference manual for an exact description of the semantics of
6968 this attribute.
6969
6970 @node Machine_Size
6971 @unnumberedsec Machine_Size
6972 @findex Machine_Size
6973 @noindent
6974 This attribute is identical to the @code{Object_Size} attribute. It is
6975 provided for compatibility with the DEC Ada 83 attribute of this name.
6976
6977 @node Mantissa
6978 @unnumberedsec Mantissa
6979 @cindex Ada 83 attributes
6980 @findex Mantissa
6981 @noindent
6982 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6983 the Ada 83 reference manual for an exact description of the semantics of
6984 this attribute.
6985
6986 @node Max_Interrupt_Priority
6987 @unnumberedsec Max_Interrupt_Priority
6988 @cindex Interrupt priority, maximum
6989 @findex Max_Interrupt_Priority
6990 @noindent
6991 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6992 permissible prefix), provides the same value as
6993 @code{System.Max_Interrupt_Priority}.
6994
6995 @node Max_Priority
6996 @unnumberedsec Max_Priority
6997 @cindex Priority, maximum
6998 @findex Max_Priority
6999 @noindent
7000 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
7001 prefix) provides the same value as @code{System.Max_Priority}.
7002
7003 @node Maximum_Alignment
7004 @unnumberedsec Maximum_Alignment
7005 @cindex Alignment, maximum
7006 @findex Maximum_Alignment
7007 @noindent
7008 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
7009 permissible prefix) provides the maximum useful alignment value for the
7010 target. This is a static value that can be used to specify the alignment
7011 for an object, guaranteeing that it is properly aligned in all
7012 cases.
7013
7014 @node Mechanism_Code
7015 @unnumberedsec Mechanism_Code
7016 @cindex Return values, passing mechanism
7017 @cindex Parameters, passing mechanism
7018 @findex Mechanism_Code
7019 @noindent
7020 @code{@var{function}'Mechanism_Code} yields an integer code for the
7021 mechanism used for the result of function, and
7022 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
7023 used for formal parameter number @var{n} (a static integer value with 1
7024 meaning the first parameter) of @var{subprogram}. The code returned is:
7025
7026 @table @asis
7027 @item 1
7028 by copy (value)
7029 @item 2
7030 by reference
7031 @item 3
7032 by descriptor (default descriptor class)
7033 @item 4
7034 by descriptor (UBS: unaligned bit string)
7035 @item 5
7036 by descriptor (UBSB: aligned bit string with arbitrary bounds)
7037 @item 6
7038 by descriptor (UBA: unaligned bit array)
7039 @item 7
7040 by descriptor (S: string, also scalar access type parameter)
7041 @item 8
7042 by descriptor (SB: string with arbitrary bounds)
7043 @item 9
7044 by descriptor (A: contiguous array)
7045 @item 10
7046 by descriptor (NCA: non-contiguous array)
7047 @end table
7048
7049 @noindent
7050 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
7051 @cindex OpenVMS
7052
7053 @node Null_Parameter
7054 @unnumberedsec Null_Parameter
7055 @cindex Zero address, passing
7056 @findex Null_Parameter
7057 @noindent
7058 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
7059 type or subtype @var{T} allocated at machine address zero. The attribute
7060 is allowed only as the default expression of a formal parameter, or as
7061 an actual expression of a subprogram call. In either case, the
7062 subprogram must be imported.
7063
7064 The identity of the object is represented by the address zero in the
7065 argument list, independent of the passing mechanism (explicit or
7066 default).
7067
7068 This capability is needed to specify that a zero address should be
7069 passed for a record or other composite object passed by reference.
7070 There is no way of indicating this without the @code{Null_Parameter}
7071 attribute.
7072
7073 @node Object_Size
7074 @unnumberedsec Object_Size
7075 @cindex Size, used for objects
7076 @findex Object_Size
7077 @noindent
7078 The size of an object is not necessarily the same as the size of the type
7079 of an object. This is because by default object sizes are increased to be
7080 a multiple of the alignment of the object. For example,
7081 @code{Natural'Size} is
7082 31, but by default objects of type @code{Natural} will have a size of 32 bits.
7083 Similarly, a record containing an integer and a character:
7084
7085 @smallexample @c ada
7086 type Rec is record
7087 I : Integer;
7088 C : Character;
7089 end record;
7090 @end smallexample
7091
7092 @noindent
7093 will have a size of 40 (that is @code{Rec'Size} will be 40). The
7094 alignment will be 4, because of the
7095 integer field, and so the default size of record objects for this type
7096 will be 64 (8 bytes).
7097
7098 @node Passed_By_Reference
7099 @unnumberedsec Passed_By_Reference
7100 @cindex Parameters, when passed by reference
7101 @findex Passed_By_Reference
7102 @noindent
7103 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
7104 a value of type @code{Boolean} value that is @code{True} if the type is
7105 normally passed by reference and @code{False} if the type is normally
7106 passed by copy in calls. For scalar types, the result is always @code{False}
7107 and is static. For non-scalar types, the result is non-static.
7108
7109 @node Pool_Address
7110 @unnumberedsec Pool_Address
7111 @cindex Parameters, when passed by reference
7112 @findex Pool_Address
7113 @noindent
7114 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
7115 of X within its storage pool. This is the same as
7116 @code{@var{X}'Address}, except that for an unconstrained array whose
7117 bounds are allocated just before the first component,
7118 @code{@var{X}'Pool_Address} returns the address of those bounds,
7119 whereas @code{@var{X}'Address} returns the address of the first
7120 component.
7121
7122 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
7123 the object is allocated'', which could be a user-defined storage pool,
7124 the global heap, on the stack, or in a static memory area. For an
7125 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
7126 what is passed to @code{Allocate} and returned from @code{Deallocate}.
7127
7128 @node Range_Length
7129 @unnumberedsec Range_Length
7130 @findex Range_Length
7131 @noindent
7132 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
7133 the number of values represented by the subtype (zero for a null
7134 range). The result is static for static subtypes. @code{Range_Length}
7135 applied to the index subtype of a one dimensional array always gives the
7136 same result as @code{Range} applied to the array itself.
7137
7138 @node Ref
7139 @unnumberedsec Ref
7140 @findex Ref
7141 @noindent
7142 The @code{System.Address'Ref}
7143 (@code{System.Address} is the only permissible prefix)
7144 denotes a function identical to
7145 @code{System.Storage_Elements.To_Address} except that
7146 it is a static attribute. See @ref{To_Address} for more details.
7147
7148 @node Result
7149 @unnumberedsec Result
7150 @findex Result
7151 @noindent
7152 @code{@var{function}'Result} can only be used with in a Postcondition pragma
7153 for a function. The prefix must be the name of the corresponding function. This
7154 is used to refer to the result of the function in the postcondition expression.
7155 For a further discussion of the use of this attribute and examples of its use,
7156 see the description of pragma Postcondition.
7157
7158 @node Safe_Emax
7159 @unnumberedsec Safe_Emax
7160 @cindex Ada 83 attributes
7161 @findex Safe_Emax
7162 @noindent
7163 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
7164 the Ada 83 reference manual for an exact description of the semantics of
7165 this attribute.
7166
7167 @node Safe_Large
7168 @unnumberedsec Safe_Large
7169 @cindex Ada 83 attributes
7170 @findex Safe_Large
7171 @noindent
7172 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
7173 the Ada 83 reference manual for an exact description of the semantics of
7174 this attribute.
7175
7176 @node Scalar_Storage_Order
7177 @unnumberedsec Scalar_Storage_Order
7178 @cindex Endianness
7179 @cindex Scalar storage order
7180 @findex Scalar_Storage_Order
7181 @noindent
7182 For every array or record type @var{S}, the representation attribute
7183 @code{Scalar_Storage_Order} denotes the order in which storage elements
7184 that make up scalar components are ordered within S:
7185
7186 @smallexample @c ada
7187 -- Component type definitions
7188
7189 subtype Yr_Type is Natural range 0 .. 127;
7190 subtype Mo_Type is Natural range 1 .. 12;
7191 subtype Da_Type is Natural range 1 .. 31;
7192
7193 -- Record declaration
7194
7195 type Date is record
7196 Years_Since_1980 : Yr_Type;
7197 Month : Mo_Type;
7198 Day_Of_Month : Da_Type;
7199 end record;
7200
7201 -- Record representation clause
7202
7203 for Date use record
7204 Years_Since_1980 at 0 range 0 .. 6;
7205 Month at 0 range 7 .. 10;
7206 Day_Of_Month at 0 range 11 .. 15;
7207 end record;
7208
7209 -- Attribute definition clauses
7210
7211 for Date'Bit_Order use System.High_Order_First;
7212 for Date'Scalar_Storage_Order use System.High_Order_First;
7213 -- If Scalar_Storage_Order is specified, it must be consistent with
7214 -- Bit_Order, so it's best to always define the latter explicitly if
7215 -- the former is used.
7216 @end smallexample
7217
7218 Other properties are
7219 as for standard representation attribute @code{Bit_Order}, as defined by
7220 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
7221
7222 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
7223 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
7224 this means that if a @code{Scalar_Storage_Order} attribute definition
7225 clause is not confirming, then the type's @code{Bit_Order} shall be
7226 specified explicitly and set to the same value.
7227
7228 For a record extension, the derived type shall have the same scalar storage
7229 order as the parent type.
7230
7231 If a component of @var{S} has itself a record or array type, then it shall also
7232 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
7233 if the component does not start on a byte boundary, then the scalar storage
7234 order specified for S and for the nested component type shall be identical.
7235
7236 No component of a type that has a @code{Scalar_Storage_Order} attribute
7237 definition may be aliased.
7238
7239 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
7240 with a value equal to @code{System.Default_Bit_Order}) has no effect.
7241
7242 If the opposite storage order is specified, then whenever the value of
7243 a scalar component of an object of type @var{S} is read, the storage
7244 elements of the enclosing machine scalar are first reversed (before
7245 retrieving the component value, possibly applying some shift and mask
7246 operatings on the enclosing machine scalar), and the opposite operation
7247 is done for writes.
7248
7249 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
7250 are relaxed. Instead, the following rules apply:
7251
7252 @itemize @bullet
7253 @item the underlying storage elements are those at positions
7254 @code{(position + first_bit / storage_element_size) ..
7255 (position + (last_bit + storage_element_size - 1) /
7256 storage_element_size)}
7257 @item the sequence of underlying storage elements shall have
7258 a size no greater than the largest machine scalar
7259 @item the enclosing machine scalar is defined as the smallest machine
7260 scalar starting at a position no greater than
7261 @code{position + first_bit / storage_element_size} and covering
7262 storage elements at least up to @code{position + (last_bit +
7263 storage_element_size - 1) / storage_element_size}
7264 @item the position of the component is interpreted relative to that machine
7265 scalar.
7266
7267 @end itemize
7268
7269 @node Simple_Storage_Pool
7270 @unnumberedsec Simple_Storage_Pool
7271 @cindex Storage pool, simple
7272 @cindex Simple storage pool
7273 @findex Simple_Storage_Pool
7274 @noindent
7275 For every nonformal, nonderived access-to-object type @var{Acc}, the
7276 representation attribute @code{Simple_Storage_Pool} may be specified
7277 via an attribute_definition_clause (or by specifying the equivalent aspect):
7278
7279 @smallexample @c ada
7280
7281 My_Pool : My_Simple_Storage_Pool_Type;
7282
7283 type Acc is access My_Data_Type;
7284
7285 for Acc'Simple_Storage_Pool use My_Pool;
7286
7287 @end smallexample
7288
7289 @noindent
7290 The name given in an attribute_definition_clause for the
7291 @code{Simple_Storage_Pool} attribute shall denote a variable of
7292 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
7293
7294 The use of this attribute is only allowed for a prefix denoting a type
7295 for which it has been specified. The type of the attribute is the type
7296 of the variable specified as the simple storage pool of the access type,
7297 and the attribute denotes that variable.
7298
7299 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
7300 for the same access type.
7301
7302 If the @code{Simple_Storage_Pool} attribute has been specified for an access
7303 type, then applying the @code{Storage_Pool} attribute to the type is flagged
7304 with a warning and its evaluation raises the exception @code{Program_Error}.
7305
7306 If the Simple_Storage_Pool attribute has been specified for an access
7307 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
7308 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
7309 which is intended to indicate the number of storage elements reserved for
7310 the simple storage pool. If the Storage_Size function has not been defined
7311 for the simple storage pool type, then this attribute returns zero.
7312
7313 If an access type @var{S} has a specified simple storage pool of type
7314 @var{SSP}, then the evaluation of an allocator for that access type calls
7315 the primitive @code{Allocate} procedure for type @var{SSP}, passing
7316 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
7317 semantics of such allocators is the same as those defined for allocators
7318 in section 13.11 of the Ada Reference Manual, with the term
7319 ``simple storage pool'' substituted for ``storage pool''.
7320
7321 If an access type @var{S} has a specified simple storage pool of type
7322 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
7323 for that access type invokes the primitive @code{Deallocate} procedure
7324 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
7325 parameter. The detailed semantics of such unchecked deallocations is the same
7326 as defined in section 13.11.2 of the Ada Reference Manual, except that the
7327 term ``simple storage pool'' is substituted for ``storage pool''.
7328
7329 @node Small
7330 @unnumberedsec Small
7331 @cindex Ada 83 attributes
7332 @findex Small
7333 @noindent
7334 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
7335 fixed-point types.
7336 GNAT also allows this attribute to be applied to floating-point types
7337 for compatibility with Ada 83. See
7338 the Ada 83 reference manual for an exact description of the semantics of
7339 this attribute when applied to floating-point types.
7340
7341 @node Storage_Unit
7342 @unnumberedsec Storage_Unit
7343 @findex Storage_Unit
7344 @noindent
7345 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
7346 prefix) provides the same value as @code{System.Storage_Unit}.
7347
7348 @node Stub_Type
7349 @unnumberedsec Stub_Type
7350 @findex Stub_Type
7351 @noindent
7352 The GNAT implementation of remote access-to-classwide types is
7353 organized as described in AARM section E.4 (20.t): a value of an RACW type
7354 (designating a remote object) is represented as a normal access
7355 value, pointing to a "stub" object which in turn contains the
7356 necessary information to contact the designated remote object. A
7357 call on any dispatching operation of such a stub object does the
7358 remote call, if necessary, using the information in the stub object
7359 to locate the target partition, etc.
7360
7361 For a prefix @code{T} that denotes a remote access-to-classwide type,
7362 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
7363
7364 By construction, the layout of @code{T'Stub_Type} is identical to that of
7365 type @code{RACW_Stub_Type} declared in the internal implementation-defined
7366 unit @code{System.Partition_Interface}. Use of this attribute will create
7367 an implicit dependency on this unit.
7368
7369 @node System_Allocator_Alignment
7370 @unnumberedsec System_Allocator_Alignment
7371 @cindex Alignment, allocator
7372 @findex System_Allocator_Alignment
7373 @noindent
7374 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
7375 permissible prefix) provides the observable guaranted to be honored by
7376 the system allocator (malloc). This is a static value that can be used
7377 in user storage pools based on malloc either to reject allocation
7378 with alignment too large or to enable a realignment circuitry if the
7379 alignment request is larger than this value.
7380
7381 @node Target_Name
7382 @unnumberedsec Target_Name
7383 @findex Target_Name
7384 @noindent
7385 @code{Standard'Target_Name} (@code{Standard} is the only permissible
7386 prefix) provides a static string value that identifies the target
7387 for the current compilation. For GCC implementations, this is the
7388 standard gcc target name without the terminating slash (for
7389 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
7390
7391 @node Tick
7392 @unnumberedsec Tick
7393 @findex Tick
7394 @noindent
7395 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
7396 provides the same value as @code{System.Tick},
7397
7398 @node To_Address
7399 @unnumberedsec To_Address
7400 @findex To_Address
7401 @noindent
7402 The @code{System'To_Address}
7403 (@code{System} is the only permissible prefix)
7404 denotes a function identical to
7405 @code{System.Storage_Elements.To_Address} except that
7406 it is a static attribute. This means that if its argument is
7407 a static expression, then the result of the attribute is a
7408 static expression. The result is that such an expression can be
7409 used in contexts (e.g.@: preelaborable packages) which require a
7410 static expression and where the function call could not be used
7411 (since the function call is always non-static, even if its
7412 argument is static).
7413
7414 @node Type_Class
7415 @unnumberedsec Type_Class
7416 @findex Type_Class
7417 @noindent
7418 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
7419 the value of the type class for the full type of @var{type}. If
7420 @var{type} is a generic formal type, the value is the value for the
7421 corresponding actual subtype. The value of this attribute is of type
7422 @code{System.Aux_DEC.Type_Class}, which has the following definition:
7423
7424 @smallexample @c ada
7425 type Type_Class is
7426 (Type_Class_Enumeration,
7427 Type_Class_Integer,
7428 Type_Class_Fixed_Point,
7429 Type_Class_Floating_Point,
7430 Type_Class_Array,
7431 Type_Class_Record,
7432 Type_Class_Access,
7433 Type_Class_Task,
7434 Type_Class_Address);
7435 @end smallexample
7436
7437 @noindent
7438 Protected types yield the value @code{Type_Class_Task}, which thus
7439 applies to all concurrent types. This attribute is designed to
7440 be compatible with the DEC Ada 83 attribute of the same name.
7441
7442 @node UET_Address
7443 @unnumberedsec UET_Address
7444 @findex UET_Address
7445 @noindent
7446 The @code{UET_Address} attribute can only be used for a prefix which
7447 denotes a library package. It yields the address of the unit exception
7448 table when zero cost exception handling is used. This attribute is
7449 intended only for use within the GNAT implementation. See the unit
7450 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7451 for details on how this attribute is used in the implementation.
7452
7453 @node Unconstrained_Array
7454 @unnumberedsec Unconstrained_Array
7455 @findex Unconstrained_Array
7456 @noindent
7457 The @code{Unconstrained_Array} attribute can be used with a prefix that
7458 denotes any type or subtype. It is a static attribute that yields
7459 @code{True} if the prefix designates an unconstrained array,
7460 and @code{False} otherwise. In a generic instance, the result is
7461 still static, and yields the result of applying this test to the
7462 generic actual.
7463
7464 @node Universal_Literal_String
7465 @unnumberedsec Universal_Literal_String
7466 @cindex Named numbers, representation of
7467 @findex Universal_Literal_String
7468 @noindent
7469 The prefix of @code{Universal_Literal_String} must be a named
7470 number. The static result is the string consisting of the characters of
7471 the number as defined in the original source. This allows the user
7472 program to access the actual text of named numbers without intermediate
7473 conversions and without the need to enclose the strings in quotes (which
7474 would preclude their use as numbers).
7475
7476 For example, the following program prints the first 50 digits of pi:
7477
7478 @smallexample @c ada
7479 with Text_IO; use Text_IO;
7480 with Ada.Numerics;
7481 procedure Pi is
7482 begin
7483 Put (Ada.Numerics.Pi'Universal_Literal_String);
7484 end;
7485 @end smallexample
7486
7487 @node Unrestricted_Access
7488 @unnumberedsec Unrestricted_Access
7489 @cindex @code{Access}, unrestricted
7490 @findex Unrestricted_Access
7491 @noindent
7492 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7493 except that all accessibility and aliased view checks are omitted. This
7494 is a user-beware attribute. It is similar to
7495 @code{Address}, for which it is a desirable replacement where the value
7496 desired is an access type. In other words, its effect is identical to
7497 first applying the @code{Address} attribute and then doing an unchecked
7498 conversion to a desired access type. In GNAT, but not necessarily in
7499 other implementations, the use of static chains for inner level
7500 subprograms means that @code{Unrestricted_Access} applied to a
7501 subprogram yields a value that can be called as long as the subprogram
7502 is in scope (normal Ada accessibility rules restrict this usage).
7503
7504 It is possible to use @code{Unrestricted_Access} for any type, but care
7505 must be exercised if it is used to create pointers to unconstrained
7506 objects. In this case, the resulting pointer has the same scope as the
7507 context of the attribute, and may not be returned to some enclosing
7508 scope. For instance, a function cannot use @code{Unrestricted_Access}
7509 to create a unconstrained pointer and then return that value to the
7510 caller.
7511
7512 @node Valid_Scalars
7513 @unnumberedsec Valid_Scalars
7514 @findex Valid_Scalars
7515 @noindent
7516 The @code{'Valid_Scalars} attribute is intended to make it easier to
7517 check the validity of scalar subcomponents of composite objects. It
7518 is defined for any prefix @code{X} that denotes an object.
7519 The value of this attribute is of the predefined type Boolean.
7520 @code{X'Valid_Scalars} yields True if and only if evaluation of
7521 @code{P'Valid} yields True for every scalar part P of X or if X has
7522 no scalar parts. It is not specified in what order the scalar parts
7523 are checked, nor whether any more are checked after any one of them
7524 is determined to be invalid. If the prefix @code{X} is of a class-wide
7525 type @code{T'Class} (where @code{T} is the associated specific type),
7526 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7527 only the scalar parts of components of @code{T} are traversed; in other
7528 words, components of extensions of @code{T} are not traversed even if
7529 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7530 be determined at compile time that the prefix of the attribute has no
7531 scalar parts (e.g., if the prefix is of an access type, an interface type,
7532 an undiscriminated task type, or an undiscriminated protected type).
7533
7534 @node VADS_Size
7535 @unnumberedsec VADS_Size
7536 @cindex @code{Size}, VADS compatibility
7537 @findex VADS_Size
7538 @noindent
7539 The @code{'VADS_Size} attribute is intended to make it easier to port
7540 legacy code which relies on the semantics of @code{'Size} as implemented
7541 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7542 same semantic interpretation. In particular, @code{'VADS_Size} applied
7543 to a predefined or other primitive type with no Size clause yields the
7544 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7545 typical machines). In addition @code{'VADS_Size} applied to an object
7546 gives the result that would be obtained by applying the attribute to
7547 the corresponding type.
7548
7549 @node Value_Size
7550 @unnumberedsec Value_Size
7551 @cindex @code{Size}, setting for not-first subtype
7552 @findex Value_Size
7553 @code{@var{type}'Value_Size} is the number of bits required to represent
7554 a value of the given subtype. It is the same as @code{@var{type}'Size},
7555 but, unlike @code{Size}, may be set for non-first subtypes.
7556
7557 @node Wchar_T_Size
7558 @unnumberedsec Wchar_T_Size
7559 @findex Wchar_T_Size
7560 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7561 prefix) provides the size in bits of the C @code{wchar_t} type
7562 primarily for constructing the definition of this type in
7563 package @code{Interfaces.C}.
7564
7565 @node Word_Size
7566 @unnumberedsec Word_Size
7567 @findex Word_Size
7568 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7569 prefix) provides the value @code{System.Word_Size}.
7570
7571 @node Standard and Implementation Defined Restrictions
7572 @chapter Standard and Implementation Defined Restrictions
7573
7574 @noindent
7575 All RM defined Restriction identifiers are implemented:
7576
7577 @itemize @bullet
7578 @item language-defined restrictions (see 13.12.1)
7579 @item tasking restrictions (see D.7)
7580 @item high integrity restrictions (see H.4)
7581 @end itemize
7582
7583 @noindent
7584 GNAT implements additional restriction identifiers. All restrictions, whether
7585 language defined or GNAT-specific, are listed in the following.
7586
7587 @menu
7588 * Partition-Wide Restrictions::
7589 * Program Unit Level Restrictions::
7590 @end menu
7591
7592 @node Partition-Wide Restrictions
7593 @section Partition-Wide Restrictions
7594
7595 There are two separate lists of restriction identifiers. The first
7596 set requires consistency throughout a partition (in other words, if the
7597 restriction identifier is used for any compilation unit in the partition,
7598 then all compilation units in the partition must obey the restriction).
7599
7600 @menu
7601 * Immediate_Reclamation::
7602 * Max_Asynchronous_Select_Nesting::
7603 * Max_Entry_Queue_Length::
7604 * Max_Protected_Entries::
7605 * Max_Select_Alternatives::
7606 * Max_Storage_At_Blocking::
7607 * Max_Task_Entries::
7608 * Max_Tasks::
7609 * No_Abort_Statements::
7610 * No_Access_Parameter_Allocators::
7611 * No_Access_Subprograms::
7612 * No_Allocators::
7613 * No_Anonymous_Allocators::
7614 * No_Calendar::
7615 * No_Coextensions::
7616 * No_Default_Initialization::
7617 * No_Delay::
7618 * No_Dependence::
7619 * No_Direct_Boolean_Operators::
7620 * No_Dispatch::
7621 * No_Dispatching_Calls::
7622 * No_Dynamic_Attachment::
7623 * No_Dynamic_Priorities::
7624 * No_Entry_Calls_In_Elaboration_Code::
7625 * No_Enumeration_Maps::
7626 * No_Exception_Handlers::
7627 * No_Exception_Propagation::
7628 * No_Exception_Registration::
7629 * No_Exceptions::
7630 * No_Finalization::
7631 * No_Fixed_Point::
7632 * No_Floating_Point::
7633 * No_Implicit_Conditionals::
7634 * No_Implicit_Dynamic_Code::
7635 * No_Implicit_Heap_Allocations::
7636 * No_Implicit_Loops::
7637 * No_Initialize_Scalars::
7638 * No_IO::
7639 * No_Local_Allocators::
7640 * No_Local_Protected_Objects::
7641 * No_Local_Timing_Events::
7642 * No_Nested_Finalization::
7643 * No_Protected_Type_Allocators::
7644 * No_Protected_Types::
7645 * No_Recursion::
7646 * No_Reentrancy::
7647 * No_Relative_Delay::
7648 * No_Requeue_Statements::
7649 * No_Secondary_Stack::
7650 * No_Select_Statements::
7651 * No_Specific_Termination_Handlers::
7652 * No_Specification_of_Aspect::
7653 * No_Standard_Allocators_After_Elaboration::
7654 * No_Standard_Storage_Pools::
7655 * No_Stream_Optimizations::
7656 * No_Streams::
7657 * No_Task_Allocators::
7658 * No_Task_Attributes_Package::
7659 * No_Task_Hierarchy::
7660 * No_Task_Termination::
7661 * No_Tasking::
7662 * No_Terminate_Alternatives::
7663 * No_Unchecked_Access::
7664 * Simple_Barriers::
7665 * Static_Priorities::
7666 * Static_Storage_Size::
7667 @end menu
7668
7669 @node Immediate_Reclamation
7670 @unnumberedsubsec Immediate_Reclamation
7671 @findex Immediate_Reclamation
7672 [RM H.4] This restriction ensures that, except for storage occupied by
7673 objects created by allocators and not deallocated via unchecked
7674 deallocation, any storage reserved at run time for an object is
7675 immediately reclaimed when the object no longer exists.
7676
7677 @node Max_Asynchronous_Select_Nesting
7678 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7679 @findex Max_Asynchronous_Select_Nesting
7680 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7681 selects. Violations of this restriction with a value of zero are
7682 detected at compile time. Violations of this restriction with values
7683 other than zero cause Storage_Error to be raised.
7684
7685 @node Max_Entry_Queue_Length
7686 @unnumberedsubsec Max_Entry_Queue_Length
7687 @findex Max_Entry_Queue_Length
7688 [RM D.7] This restriction is a declaration that any protected entry compiled in
7689 the scope of the restriction has at most the specified number of
7690 tasks waiting on the entry at any one time, and so no queue is required.
7691 Note that this restriction is checked at run time. Violation of this
7692 restriction results in the raising of Program_Error exception at the point of
7693 the call.
7694
7695 @node Max_Protected_Entries
7696 @unnumberedsubsec Max_Protected_Entries
7697 @findex Max_Protected_Entries
7698 [RM D.7] Specifies the maximum number of entries per protected type. The
7699 bounds of every entry family of a protected unit shall be static, or shall be
7700 defined by a discriminant of a subtype whose corresponding bound is static.
7701
7702 @node Max_Select_Alternatives
7703 @unnumberedsubsec Max_Select_Alternatives
7704 @findex Max_Select_Alternatives
7705 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7706
7707 @node Max_Storage_At_Blocking
7708 @unnumberedsubsec Max_Storage_At_Blocking
7709 @findex Max_Storage_At_Blocking
7710 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7711 Storage_Size that can be retained by a blocked task. A violation of this
7712 restriction causes Storage_Error to be raised.
7713
7714 @node Max_Task_Entries
7715 @unnumberedsubsec Max_Task_Entries
7716 @findex Max_Task_Entries
7717 [RM D.7] Specifies the maximum number of entries
7718 per task. The bounds of every entry family
7719 of a task unit shall be static, or shall be
7720 defined by a discriminant of a subtype whose
7721 corresponding bound is static.
7722
7723 @node Max_Tasks
7724 @unnumberedsubsec Max_Tasks
7725 @findex Max_Tasks
7726 [RM D.7] Specifies the maximum number of task that may be created, not
7727 counting the creation of the environment task. Violations of this
7728 restriction with a value of zero are detected at compile
7729 time. Violations of this restriction with values other than zero cause
7730 Storage_Error to be raised.
7731
7732 @node No_Abort_Statements
7733 @unnumberedsubsec No_Abort_Statements
7734 @findex No_Abort_Statements
7735 [RM D.7] There are no abort_statements, and there are
7736 no calls to Task_Identification.Abort_Task.
7737
7738 @node No_Access_Parameter_Allocators
7739 @unnumberedsubsec No_Access_Parameter_Allocators
7740 @findex No_Access_Parameter_Allocators
7741 [RM H.4] This restriction ensures at compile time that there are no
7742 occurrences of an allocator as the actual parameter to an access
7743 parameter.
7744
7745 @node No_Access_Subprograms
7746 @unnumberedsubsec No_Access_Subprograms
7747 @findex No_Access_Subprograms
7748 [RM H.4] This restriction ensures at compile time that there are no
7749 declarations of access-to-subprogram types.
7750
7751 @node No_Allocators
7752 @unnumberedsubsec No_Allocators
7753 @findex No_Allocators
7754 [RM H.4] This restriction ensures at compile time that there are no
7755 occurrences of an allocator.
7756
7757 @node No_Anonymous_Allocators
7758 @unnumberedsubsec No_Anonymous_Allocators
7759 @findex No_Anonymous_Allocators
7760 [RM H.4] This restriction ensures at compile time that there are no
7761 occurrences of an allocator of anonymous access type.
7762
7763 @node No_Calendar
7764 @unnumberedsubsec No_Calendar
7765 @findex No_Calendar
7766 [GNAT] This restriction ensures at compile time that there is no implicit or
7767 explicit dependence on the package @code{Ada.Calendar}.
7768
7769 @node No_Coextensions
7770 @unnumberedsubsec No_Coextensions
7771 @findex No_Coextensions
7772 [RM H.4] This restriction ensures at compile time that there are no
7773 coextensions. See 3.10.2.
7774
7775 @node No_Default_Initialization
7776 @unnumberedsubsec No_Default_Initialization
7777 @findex No_Default_Initialization
7778
7779 [GNAT] This restriction prohibits any instance of default initialization
7780 of variables. The binder implements a consistency rule which prevents
7781 any unit compiled without the restriction from with'ing a unit with the
7782 restriction (this allows the generation of initialization procedures to
7783 be skipped, since you can be sure that no call is ever generated to an
7784 initialization procedure in a unit with the restriction active). If used
7785 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7786 is to prohibit all cases of variables declared without a specific
7787 initializer (including the case of OUT scalar parameters).
7788
7789 @node No_Delay
7790 @unnumberedsubsec No_Delay
7791 @findex No_Delay
7792 [RM H.4] This restriction ensures at compile time that there are no
7793 delay statements and no dependences on package Calendar.
7794
7795 @node No_Dependence
7796 @unnumberedsubsec No_Dependence
7797 @findex No_Dependence
7798 [RM 13.12.1] This restriction checks at compile time that there are no
7799 dependence on a library unit.
7800
7801 @node No_Direct_Boolean_Operators
7802 @unnumberedsubsec No_Direct_Boolean_Operators
7803 @findex No_Direct_Boolean_Operators
7804 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7805 operands of type Boolean (or any type derived
7806 from Boolean). This is intended for use in safety critical programs
7807 where the certification protocol requires the use of short-circuit
7808 (and then, or else) forms for all composite boolean operations.
7809
7810 @node No_Dispatch
7811 @unnumberedsubsec No_Dispatch
7812 @findex No_Dispatch
7813 [RM H.4] This restriction ensures at compile time that there are no
7814 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7815
7816 @node No_Dispatching_Calls
7817 @unnumberedsubsec No_Dispatching_Calls
7818 @findex No_Dispatching_Calls
7819 [GNAT] This restriction ensures at compile time that the code generated by the
7820 compiler involves no dispatching calls. The use of this restriction allows the
7821 safe use of record extensions, classwide membership tests and other classwide
7822 features not involving implicit dispatching. This restriction ensures that
7823 the code contains no indirect calls through a dispatching mechanism. Note that
7824 this includes internally-generated calls created by the compiler, for example
7825 in the implementation of class-wide objects assignments. The
7826 membership test is allowed in the presence of this restriction, because its
7827 implementation requires no dispatching.
7828 This restriction is comparable to the official Ada restriction
7829 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7830 all classwide constructs that do not imply dispatching.
7831 The following example indicates constructs that violate this restriction.
7832
7833 @smallexample
7834 package Pkg is
7835 type T is tagged record
7836 Data : Natural;
7837 end record;
7838 procedure P (X : T);
7839
7840 type DT is new T with record
7841 More_Data : Natural;
7842 end record;
7843 procedure Q (X : DT);
7844 end Pkg;
7845
7846 with Pkg; use Pkg;
7847 procedure Example is
7848 procedure Test (O : T'Class) is
7849 N : Natural := O'Size;-- Error: Dispatching call
7850 C : T'Class := O; -- Error: implicit Dispatching Call
7851 begin
7852 if O in DT'Class then -- OK : Membership test
7853 Q (DT (O)); -- OK : Type conversion plus direct call
7854 else
7855 P (O); -- Error: Dispatching call
7856 end if;
7857 end Test;
7858
7859 Obj : DT;
7860 begin
7861 P (Obj); -- OK : Direct call
7862 P (T (Obj)); -- OK : Type conversion plus direct call
7863 P (T'Class (Obj)); -- Error: Dispatching call
7864
7865 Test (Obj); -- OK : Type conversion
7866
7867 if Obj in T'Class then -- OK : Membership test
7868 null;
7869 end if;
7870 end Example;
7871 @end smallexample
7872
7873 @node No_Dynamic_Attachment
7874 @unnumberedsubsec No_Dynamic_Attachment
7875 @findex No_Dynamic_Attachment
7876 [RM D.7] This restriction ensures that there is no call to any of the
7877 operations defined in package Ada.Interrupts
7878 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7879 Detach_Handler, and Reference).
7880
7881 @node No_Dynamic_Priorities
7882 @unnumberedsubsec No_Dynamic_Priorities
7883 @findex No_Dynamic_Priorities
7884 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7885
7886 @node No_Entry_Calls_In_Elaboration_Code
7887 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7888 @findex No_Entry_Calls_In_Elaboration_Code
7889 [GNAT] This restriction ensures at compile time that no task or protected entry
7890 calls are made during elaboration code. As a result of the use of this
7891 restriction, the compiler can assume that no code past an accept statement
7892 in a task can be executed at elaboration time.
7893
7894 @node No_Enumeration_Maps
7895 @unnumberedsubsec No_Enumeration_Maps
7896 @findex No_Enumeration_Maps
7897 [GNAT] This restriction ensures at compile time that no operations requiring
7898 enumeration maps are used (that is Image and Value attributes applied
7899 to enumeration types).
7900
7901 @node No_Exception_Handlers
7902 @unnumberedsubsec No_Exception_Handlers
7903 @findex No_Exception_Handlers
7904 [GNAT] This restriction ensures at compile time that there are no explicit
7905 exception handlers. It also indicates that no exception propagation will
7906 be provided. In this mode, exceptions may be raised but will result in
7907 an immediate call to the last chance handler, a routine that the user
7908 must define with the following profile:
7909
7910 @smallexample @c ada
7911 procedure Last_Chance_Handler
7912 (Source_Location : System.Address; Line : Integer);
7913 pragma Export (C, Last_Chance_Handler,
7914 "__gnat_last_chance_handler");
7915 @end smallexample
7916
7917 The parameter is a C null-terminated string representing a message to be
7918 associated with the exception (typically the source location of the raise
7919 statement generated by the compiler). The Line parameter when nonzero
7920 represents the line number in the source program where the raise occurs.
7921
7922 @node No_Exception_Propagation
7923 @unnumberedsubsec No_Exception_Propagation
7924 @findex No_Exception_Propagation
7925 [GNAT] This restriction guarantees that exceptions are never propagated
7926 to an outer subprogram scope. The only case in which an exception may
7927 be raised is when the handler is statically in the same subprogram, so
7928 that the effect of a raise is essentially like a goto statement. Any
7929 other raise statement (implicit or explicit) will be considered
7930 unhandled. Exception handlers are allowed, but may not contain an
7931 exception occurrence identifier (exception choice). In addition, use of
7932 the package GNAT.Current_Exception is not permitted, and reraise
7933 statements (raise with no operand) are not permitted.
7934
7935 @node No_Exception_Registration
7936 @unnumberedsubsec No_Exception_Registration
7937 @findex No_Exception_Registration
7938 [GNAT] This restriction ensures at compile time that no stream operations for
7939 types Exception_Id or Exception_Occurrence are used. This also makes it
7940 impossible to pass exceptions to or from a partition with this restriction
7941 in a distributed environment. If this exception is active, then the generated
7942 code is simplified by omitting the otherwise-required global registration
7943 of exceptions when they are declared.
7944
7945 @node No_Exceptions
7946 @unnumberedsubsec No_Exceptions
7947 @findex No_Exceptions
7948 [RM H.4] This restriction ensures at compile time that there are no
7949 raise statements and no exception handlers.
7950
7951 @node No_Finalization
7952 @unnumberedsubsec No_Finalization
7953 @findex No_Finalization
7954 [GNAT] This restriction disables the language features described in
7955 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7956 performed by the compiler to support these features. The following types
7957 are no longer considered controlled when this restriction is in effect:
7958 @itemize @bullet
7959 @item
7960 @code{Ada.Finalization.Controlled}
7961 @item
7962 @code{Ada.Finalization.Limited_Controlled}
7963 @item
7964 Derivations from @code{Controlled} or @code{Limited_Controlled}
7965 @item
7966 Class-wide types
7967 @item
7968 Protected types
7969 @item
7970 Task types
7971 @item
7972 Array and record types with controlled components
7973 @end itemize
7974 The compiler no longer generates code to initialize, finalize or adjust an
7975 object or a nested component, either declared on the stack or on the heap. The
7976 deallocation of a controlled object no longer finalizes its contents.
7977
7978 @node No_Fixed_Point
7979 @unnumberedsubsec No_Fixed_Point
7980 @findex No_Fixed_Point
7981 [RM H.4] This restriction ensures at compile time that there are no
7982 occurrences of fixed point types and operations.
7983
7984 @node No_Floating_Point
7985 @unnumberedsubsec No_Floating_Point
7986 @findex No_Floating_Point
7987 [RM H.4] This restriction ensures at compile time that there are no
7988 occurrences of floating point types and operations.
7989
7990 @node No_Implicit_Conditionals
7991 @unnumberedsubsec No_Implicit_Conditionals
7992 @findex No_Implicit_Conditionals
7993 [GNAT] This restriction ensures that the generated code does not contain any
7994 implicit conditionals, either by modifying the generated code where possible,
7995 or by rejecting any construct that would otherwise generate an implicit
7996 conditional. Note that this check does not include run time constraint
7997 checks, which on some targets may generate implicit conditionals as
7998 well. To control the latter, constraint checks can be suppressed in the
7999 normal manner. Constructs generating implicit conditionals include comparisons
8000 of composite objects and the Max/Min attributes.
8001
8002 @node No_Implicit_Dynamic_Code
8003 @unnumberedsubsec No_Implicit_Dynamic_Code
8004 @findex No_Implicit_Dynamic_Code
8005 @cindex trampoline
8006 [GNAT] This restriction prevents the compiler from building ``trampolines''.
8007 This is a structure that is built on the stack and contains dynamic
8008 code to be executed at run time. On some targets, a trampoline is
8009 built for the following features: @code{Access},
8010 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8011 nested task bodies; primitive operations of nested tagged types.
8012 Trampolines do not work on machines that prevent execution of stack
8013 data. For example, on windows systems, enabling DEP (data execution
8014 protection) will cause trampolines to raise an exception.
8015 Trampolines are also quite slow at run time.
8016
8017 On many targets, trampolines have been largely eliminated. Look at the
8018 version of system.ads for your target --- if it has
8019 Always_Compatible_Rep equal to False, then trampolines are largely
8020 eliminated. In particular, a trampoline is built for the following
8021 features: @code{Address} of a nested subprogram;
8022 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8023 but only if pragma Favor_Top_Level applies, or the access type has a
8024 foreign-language convention; primitive operations of nested tagged
8025 types.
8026
8027 @node No_Implicit_Heap_Allocations
8028 @unnumberedsubsec No_Implicit_Heap_Allocations
8029 @findex No_Implicit_Heap_Allocations
8030 [RM D.7] No constructs are allowed to cause implicit heap allocation.
8031
8032 @node No_Implicit_Loops
8033 @unnumberedsubsec No_Implicit_Loops
8034 @findex No_Implicit_Loops
8035 [GNAT] This restriction ensures that the generated code does not contain any
8036 implicit @code{for} loops, either by modifying
8037 the generated code where possible,
8038 or by rejecting any construct that would otherwise generate an implicit
8039 @code{for} loop. If this restriction is active, it is possible to build
8040 large array aggregates with all static components without generating an
8041 intermediate temporary, and without generating a loop to initialize individual
8042 components. Otherwise, a loop is created for arrays larger than about 5000
8043 scalar components.
8044
8045 @node No_Initialize_Scalars
8046 @unnumberedsubsec No_Initialize_Scalars
8047 @findex No_Initialize_Scalars
8048 [GNAT] This restriction ensures that no unit in the partition is compiled with
8049 pragma Initialize_Scalars. This allows the generation of more efficient
8050 code, and in particular eliminates dummy null initialization routines that
8051 are otherwise generated for some record and array types.
8052
8053 @node No_IO
8054 @unnumberedsubsec No_IO
8055 @findex No_IO
8056 [RM H.4] This restriction ensures at compile time that there are no
8057 dependences on any of the library units Sequential_IO, Direct_IO,
8058 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
8059
8060 @node No_Local_Allocators
8061 @unnumberedsubsec No_Local_Allocators
8062 @findex No_Local_Allocators
8063 [RM H.4] This restriction ensures at compile time that there are no
8064 occurrences of an allocator in subprograms, generic subprograms, tasks,
8065 and entry bodies.
8066
8067 @node No_Local_Protected_Objects
8068 @unnumberedsubsec No_Local_Protected_Objects
8069 @findex No_Local_Protected_Objects
8070 [RM D.7] This restriction ensures at compile time that protected objects are
8071 only declared at the library level.
8072
8073 @node No_Local_Timing_Events
8074 @unnumberedsubsec No_Local_Timing_Events
8075 @findex No_Local_Timing_Events
8076 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
8077 declared at the library level.
8078
8079 @node No_Nested_Finalization
8080 @unnumberedsubsec No_Nested_Finalization
8081 @findex No_Nested_Finalization
8082 [RM D.7] All objects requiring finalization are declared at the library level.
8083
8084 @node No_Protected_Type_Allocators
8085 @unnumberedsubsec No_Protected_Type_Allocators
8086 @findex No_Protected_Type_Allocators
8087 [RM D.7] This restriction ensures at compile time that there are no allocator
8088 expressions that attempt to allocate protected objects.
8089
8090 @node No_Protected_Types
8091 @unnumberedsubsec No_Protected_Types
8092 @findex No_Protected_Types
8093 [RM H.4] This restriction ensures at compile time that there are no
8094 declarations of protected types or protected objects.
8095
8096 @node No_Recursion
8097 @unnumberedsubsec No_Recursion
8098 @findex No_Recursion
8099 [RM H.4] A program execution is erroneous if a subprogram is invoked as
8100 part of its execution.
8101
8102 @node No_Reentrancy
8103 @unnumberedsubsec No_Reentrancy
8104 @findex No_Reentrancy
8105 [RM H.4] A program execution is erroneous if a subprogram is executed by
8106 two tasks at the same time.
8107
8108 @node No_Relative_Delay
8109 @unnumberedsubsec No_Relative_Delay
8110 @findex No_Relative_Delay
8111 [RM D.7] This restriction ensures at compile time that there are no delay
8112 relative statements and prevents expressions such as @code{delay 1.23;} from
8113 appearing in source code.
8114
8115 @node No_Requeue_Statements
8116 @unnumberedsubsec No_Requeue_Statements
8117 @findex No_Requeue_Statements
8118 [RM D.7] This restriction ensures at compile time that no requeue statements
8119 are permitted and prevents keyword @code{requeue} from being used in source
8120 code.
8121
8122 @node No_Secondary_Stack
8123 @unnumberedsubsec No_Secondary_Stack
8124 @findex No_Secondary_Stack
8125 [GNAT] This restriction ensures at compile time that the generated code
8126 does not contain any reference to the secondary stack. The secondary
8127 stack is used to implement functions returning unconstrained objects
8128 (arrays or records) on some targets.
8129
8130 @node No_Select_Statements
8131 @unnumberedsubsec No_Select_Statements
8132 @findex No_Select_Statements
8133 [RM D.7] This restriction ensures at compile time no select statements of any
8134 kind are permitted, that is the keyword @code{select} may not appear.
8135
8136 @node No_Specific_Termination_Handlers
8137 @unnumberedsubsec No_Specific_Termination_Handlers
8138 @findex No_Specific_Termination_Handlers
8139 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
8140 or to Ada.Task_Termination.Specific_Handler.
8141
8142 @node No_Specification_of_Aspect
8143 @unnumberedsubsec No_Specification_of_Aspect
8144 @findex No_Specification_of_Aspect
8145 [RM 13.12.1] This restriction checks at compile time that no aspect
8146 specification, attribute definition clause, or pragma is given for a
8147 given aspect.
8148
8149 @node No_Standard_Allocators_After_Elaboration
8150 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
8151 @findex No_Standard_Allocators_After_Elaboration
8152 [RM D.7] Specifies that an allocator using a standard storage pool
8153 should never be evaluated at run time after the elaboration of the
8154 library items of the partition has completed. Otherwise, Storage_Error
8155 is raised.
8156
8157 @node No_Standard_Storage_Pools
8158 @unnumberedsubsec No_Standard_Storage_Pools
8159 @findex No_Standard_Storage_Pools
8160 [GNAT] This restriction ensures at compile time that no access types
8161 use the standard default storage pool. Any access type declared must
8162 have an explicit Storage_Pool attribute defined specifying a
8163 user-defined storage pool.
8164
8165 @node No_Stream_Optimizations
8166 @unnumberedsubsec No_Stream_Optimizations
8167 @findex No_Stream_Optimizations
8168 [GNAT] This restriction affects the performance of stream operations on types
8169 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
8170 compiler uses block reads and writes when manipulating @code{String} objects
8171 due to their supperior performance. When this restriction is in effect, the
8172 compiler performs all IO operations on a per-character basis.
8173
8174 @node No_Streams
8175 @unnumberedsubsec No_Streams
8176 @findex No_Streams
8177 [GNAT] This restriction ensures at compile/bind time that there are no
8178 stream objects created and no use of stream attributes.
8179 This restriction does not forbid dependences on the package
8180 @code{Ada.Streams}. So it is permissible to with
8181 @code{Ada.Streams} (or another package that does so itself)
8182 as long as no actual stream objects are created and no
8183 stream attributes are used.
8184
8185 Note that the use of restriction allows optimization of tagged types,
8186 since they do not need to worry about dispatching stream operations.
8187 To take maximum advantage of this space-saving optimization, any
8188 unit declaring a tagged type should be compiled with the restriction,
8189 though this is not required.
8190
8191 @node No_Task_Allocators
8192 @unnumberedsubsec No_Task_Allocators
8193 @findex No_Task_Allocators
8194 [RM D.7] There are no allocators for task types
8195 or types containing task subcomponents.
8196
8197 @node No_Task_Attributes_Package
8198 @unnumberedsubsec No_Task_Attributes_Package
8199 @findex No_Task_Attributes_Package
8200 [GNAT] This restriction ensures at compile time that there are no implicit or
8201 explicit dependencies on the package @code{Ada.Task_Attributes}.
8202
8203 @node No_Task_Hierarchy
8204 @unnumberedsubsec No_Task_Hierarchy
8205 @findex No_Task_Hierarchy
8206 [RM D.7] All (non-environment) tasks depend
8207 directly on the environment task of the partition.
8208
8209 @node No_Task_Termination
8210 @unnumberedsubsec No_Task_Termination
8211 @findex No_Task_Termination
8212 [RM D.7] Tasks which terminate are erroneous.
8213
8214 @node No_Tasking
8215 @unnumberedsubsec No_Tasking
8216 @findex No_Tasking
8217 [GNAT] This restriction prevents the declaration of tasks or task types
8218 throughout the partition. It is similar in effect to the use of
8219 @code{Max_Tasks => 0} except that violations are caught at compile time
8220 and cause an error message to be output either by the compiler or
8221 binder.
8222
8223 @node No_Terminate_Alternatives
8224 @unnumberedsubsec No_Terminate_Alternatives
8225 @findex No_Terminate_Alternatives
8226 [RM D.7] There are no selective accepts with terminate alternatives.
8227
8228 @node No_Unchecked_Access
8229 @unnumberedsubsec No_Unchecked_Access
8230 @findex No_Unchecked_Access
8231 [RM H.4] This restriction ensures at compile time that there are no
8232 occurrences of the Unchecked_Access attribute.
8233
8234 @node Simple_Barriers
8235 @unnumberedsubsec Simple_Barriers
8236 @findex Simple_Barriers
8237 [RM D.7] This restriction ensures at compile time that barriers in entry
8238 declarations for protected types are restricted to either static boolean
8239 expressions or references to simple boolean variables defined in the private
8240 part of the protected type. No other form of entry barriers is permitted.
8241
8242 @node Static_Priorities
8243 @unnumberedsubsec Static_Priorities
8244 @findex Static_Priorities
8245 [GNAT] This restriction ensures at compile time that all priority expressions
8246 are static, and that there are no dependences on the package
8247 @code{Ada.Dynamic_Priorities}.
8248
8249 @node Static_Storage_Size
8250 @unnumberedsubsec Static_Storage_Size
8251 @findex Static_Storage_Size
8252 [GNAT] This restriction ensures at compile time that any expression appearing
8253 in a Storage_Size pragma or attribute definition clause is static.
8254
8255 @node Program Unit Level Restrictions
8256 @section Program Unit Level Restrictions
8257
8258 @noindent
8259 The second set of restriction identifiers
8260 does not require partition-wide consistency.
8261 The restriction may be enforced for a single
8262 compilation unit without any effect on any of the
8263 other compilation units in the partition.
8264
8265 @menu
8266 * No_Elaboration_Code::
8267 * No_Entry_Queue::
8268 * No_Implementation_Aspect_Specifications::
8269 * No_Implementation_Attributes::
8270 * No_Implementation_Identifiers::
8271 * No_Implementation_Pragmas::
8272 * No_Implementation_Restrictions::
8273 * No_Implementation_Units::
8274 * No_Implicit_Aliasing::
8275 * No_Obsolescent_Features::
8276 * No_Wide_Characters::
8277 * SPARK::
8278 @end menu
8279
8280 @node No_Elaboration_Code
8281 @unnumberedsubsec No_Elaboration_Code
8282 @findex No_Elaboration_Code
8283 [GNAT] This restriction ensures at compile time that no elaboration code is
8284 generated. Note that this is not the same condition as is enforced
8285 by pragma @code{Preelaborate}. There are cases in which pragma
8286 @code{Preelaborate} still permits code to be generated (e.g.@: code
8287 to initialize a large array to all zeroes), and there are cases of units
8288 which do not meet the requirements for pragma @code{Preelaborate},
8289 but for which no elaboration code is generated. Generally, it is
8290 the case that preelaborable units will meet the restrictions, with
8291 the exception of large aggregates initialized with an others_clause,
8292 and exception declarations (which generate calls to a run-time
8293 registry procedure). This restriction is enforced on
8294 a unit by unit basis, it need not be obeyed consistently
8295 throughout a partition.
8296
8297 In the case of aggregates with others, if the aggregate has a dynamic
8298 size, there is no way to eliminate the elaboration code (such dynamic
8299 bounds would be incompatible with @code{Preelaborate} in any case). If
8300 the bounds are static, then use of this restriction actually modifies
8301 the code choice of the compiler to avoid generating a loop, and instead
8302 generate the aggregate statically if possible, no matter how many times
8303 the data for the others clause must be repeatedly generated.
8304
8305 It is not possible to precisely document
8306 the constructs which are compatible with this restriction, since,
8307 unlike most other restrictions, this is not a restriction on the
8308 source code, but a restriction on the generated object code. For
8309 example, if the source contains a declaration:
8310
8311 @smallexample
8312 Val : constant Integer := X;
8313 @end smallexample
8314
8315 @noindent
8316 where X is not a static constant, it may be possible, depending
8317 on complex optimization circuitry, for the compiler to figure
8318 out the value of X at compile time, in which case this initialization
8319 can be done by the loader, and requires no initialization code. It
8320 is not possible to document the precise conditions under which the
8321 optimizer can figure this out.
8322
8323 Note that this the implementation of this restriction requires full
8324 code generation. If it is used in conjunction with "semantics only"
8325 checking, then some cases of violations may be missed.
8326
8327 @node No_Entry_Queue
8328 @unnumberedsubsec No_Entry_Queue
8329 @findex No_Entry_Queue
8330 [GNAT] This restriction is a declaration that any protected entry compiled in
8331 the scope of the restriction has at most one task waiting on the entry
8332 at any one time, and so no queue is required. This restriction is not
8333 checked at compile time. A program execution is erroneous if an attempt
8334 is made to queue a second task on such an entry.
8335
8336 @node No_Implementation_Aspect_Specifications
8337 @unnumberedsubsec No_Implementation_Aspect_Specifications
8338 @findex No_Implementation_Aspect_Specifications
8339 [RM 13.12.1] This restriction checks at compile time that no
8340 GNAT-defined aspects are present. With this restriction, the only
8341 aspects that can be used are those defined in the Ada Reference Manual.
8342
8343 @node No_Implementation_Attributes
8344 @unnumberedsubsec No_Implementation_Attributes
8345 @findex No_Implementation_Attributes
8346 [RM 13.12.1] This restriction checks at compile time that no
8347 GNAT-defined attributes are present. With this restriction, the only
8348 attributes that can be used are those defined in the Ada Reference
8349 Manual.
8350
8351 @node No_Implementation_Identifiers
8352 @unnumberedsubsec No_Implementation_Identifiers
8353 @findex No_Implementation_Identifiers
8354 [RM 13.12.1] This restriction checks at compile time that no
8355 implementation-defined identifiers (marked with pragma Implementation_Defined)
8356 occur within language-defined packages.
8357
8358 @node No_Implementation_Pragmas
8359 @unnumberedsubsec No_Implementation_Pragmas
8360 @findex No_Implementation_Pragmas
8361 [RM 13.12.1] This restriction checks at compile time that no
8362 GNAT-defined pragmas are present. With this restriction, the only
8363 pragmas that can be used are those defined in the Ada Reference Manual.
8364
8365 @node No_Implementation_Restrictions
8366 @unnumberedsubsec No_Implementation_Restrictions
8367 @findex No_Implementation_Restrictions
8368 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
8369 identifiers (other than @code{No_Implementation_Restrictions} itself)
8370 are present. With this restriction, the only other restriction identifiers
8371 that can be used are those defined in the Ada Reference Manual.
8372
8373 @node No_Implementation_Units
8374 @unnumberedsubsec No_Implementation_Units
8375 @findex No_Implementation_Units
8376 [RM 13.12.1] This restriction checks at compile time that there is no
8377 mention in the context clause of any implementation-defined descendants
8378 of packages Ada, Interfaces, or System.
8379
8380 @node No_Implicit_Aliasing
8381 @unnumberedsubsec No_Implicit_Aliasing
8382 @findex No_Implicit_Aliasing
8383 [GNAT] This restriction, which is not required to be partition-wide consistent,
8384 requires an explicit aliased keyword for an object to which 'Access,
8385 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
8386 the 'Unrestricted_Access attribute for objects. Note: the reason that
8387 Unrestricted_Access is forbidden is that it would require the prefix
8388 to be aliased, and in such cases, it can always be replaced by
8389 the standard attribute Unchecked_Access which is preferable.
8390
8391 @node No_Obsolescent_Features
8392 @unnumberedsubsec No_Obsolescent_Features
8393 @findex No_Obsolescent_Features
8394 [RM 13.12.1] This restriction checks at compile time that no obsolescent
8395 features are used, as defined in Annex J of the Ada Reference Manual.
8396
8397 @node No_Wide_Characters
8398 @unnumberedsubsec No_Wide_Characters
8399 @findex No_Wide_Characters
8400 [GNAT] This restriction ensures at compile time that no uses of the types
8401 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8402 wide types
8403 appear, and that no wide or wide wide string or character literals
8404 appear in the program (that is literals representing characters not in
8405 type @code{Character}).
8406
8407 @node SPARK
8408 @unnumberedsubsec SPARK
8409 @findex SPARK
8410 [GNAT] This restriction checks at compile time that some constructs
8411 forbidden in SPARK are not present. The SPARK version used as a
8412 reference is the same as the Ada mode for the unit, so a unit compiled
8413 in Ada 95 mode with SPARK restrictions will be checked for constructs
8414 forbidden in SPARK 95. Error messages related to SPARK restriction have
8415 the form:
8416
8417 @smallexample
8418 violation of restriction "SPARK" at <file>
8419 <error message>
8420 @end smallexample
8421
8422 This is not a replacement for the semantic checks performed by the
8423 SPARK Examiner tool, as the compiler only deals currently with code,
8424 not at all with SPARK annotations and does not guarantee catching all
8425 cases of constructs forbidden by SPARK.
8426
8427 Thus it may well be the case that code which
8428 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
8429 e.g. due to the different visibility rules of the Examiner based on
8430 SPARK @code{inherit} annotations.
8431
8432 This restriction can be useful in providing an initial filter for
8433 code developed using SPARK, or in examining legacy code to see how far
8434 it is from meeting SPARK restrictions.
8435
8436 @c ------------------------
8437 @node Implementation Advice
8438 @chapter Implementation Advice
8439 @noindent
8440 The main text of the Ada Reference Manual describes the required
8441 behavior of all Ada compilers, and the GNAT compiler conforms to
8442 these requirements.
8443
8444 In addition, there are sections throughout the Ada Reference Manual headed
8445 by the phrase ``Implementation advice''. These sections are not normative,
8446 i.e., they do not specify requirements that all compilers must
8447 follow. Rather they provide advice on generally desirable behavior. You
8448 may wonder why they are not requirements. The most typical answer is
8449 that they describe behavior that seems generally desirable, but cannot
8450 be provided on all systems, or which may be undesirable on some systems.
8451
8452 As far as practical, GNAT follows the implementation advice sections in
8453 the Ada Reference Manual. This chapter contains a table giving the
8454 reference manual section number, paragraph number and several keywords
8455 for each advice. Each entry consists of the text of the advice followed
8456 by the GNAT interpretation of this advice. Most often, this simply says
8457 ``followed'', which means that GNAT follows the advice. However, in a
8458 number of cases, GNAT deliberately deviates from this advice, in which
8459 case the text describes what GNAT does and why.
8460
8461 @cindex Error detection
8462 @unnumberedsec 1.1.3(20): Error Detection
8463 @sp 1
8464 @cartouche
8465 If an implementation detects the use of an unsupported Specialized Needs
8466 Annex feature at run time, it should raise @code{Program_Error} if
8467 feasible.
8468 @end cartouche
8469 Not relevant. All specialized needs annex features are either supported,
8470 or diagnosed at compile time.
8471
8472 @cindex Child Units
8473 @unnumberedsec 1.1.3(31): Child Units
8474 @sp 1
8475 @cartouche
8476 If an implementation wishes to provide implementation-defined
8477 extensions to the functionality of a language-defined library unit, it
8478 should normally do so by adding children to the library unit.
8479 @end cartouche
8480 Followed.
8481
8482 @cindex Bounded errors
8483 @unnumberedsec 1.1.5(12): Bounded Errors
8484 @sp 1
8485 @cartouche
8486 If an implementation detects a bounded error or erroneous
8487 execution, it should raise @code{Program_Error}.
8488 @end cartouche
8489 Followed in all cases in which the implementation detects a bounded
8490 error or erroneous execution. Not all such situations are detected at
8491 runtime.
8492
8493 @cindex Pragmas
8494 @unnumberedsec 2.8(16): Pragmas
8495 @sp 1
8496 @cartouche
8497 Normally, implementation-defined pragmas should have no semantic effect
8498 for error-free programs; that is, if the implementation-defined pragmas
8499 are removed from a working program, the program should still be legal,
8500 and should still have the same semantics.
8501 @end cartouche
8502 The following implementation defined pragmas are exceptions to this
8503 rule:
8504
8505 @table @code
8506 @item Abort_Defer
8507 Affects semantics
8508 @item Ada_83
8509 Affects legality
8510 @item Assert
8511 Affects semantics
8512 @item CPP_Class
8513 Affects semantics
8514 @item CPP_Constructor
8515 Affects semantics
8516 @item Debug
8517 Affects semantics
8518 @item Interface_Name
8519 Affects semantics
8520 @item Machine_Attribute
8521 Affects semantics
8522 @item Unimplemented_Unit
8523 Affects legality
8524 @item Unchecked_Union
8525 Affects semantics
8526 @end table
8527
8528 @noindent
8529 In each of the above cases, it is essential to the purpose of the pragma
8530 that this advice not be followed. For details see the separate section
8531 on implementation defined pragmas.
8532
8533 @unnumberedsec 2.8(17-19): Pragmas
8534 @sp 1
8535 @cartouche
8536 Normally, an implementation should not define pragmas that can
8537 make an illegal program legal, except as follows:
8538 @end cartouche
8539 @sp 1
8540 @cartouche
8541 A pragma used to complete a declaration, such as a pragma @code{Import};
8542 @end cartouche
8543 @sp 1
8544 @cartouche
8545 A pragma used to configure the environment by adding, removing, or
8546 replacing @code{library_items}.
8547 @end cartouche
8548 See response to paragraph 16 of this same section.
8549
8550 @cindex Character Sets
8551 @cindex Alternative Character Sets
8552 @unnumberedsec 3.5.2(5): Alternative Character Sets
8553 @sp 1
8554 @cartouche
8555 If an implementation supports a mode with alternative interpretations
8556 for @code{Character} and @code{Wide_Character}, the set of graphic
8557 characters of @code{Character} should nevertheless remain a proper
8558 subset of the set of graphic characters of @code{Wide_Character}. Any
8559 character set ``localizations'' should be reflected in the results of
8560 the subprograms defined in the language-defined package
8561 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8562 an alternative interpretation of @code{Character}, the implementation should
8563 also support a corresponding change in what is a legal
8564 @code{identifier_letter}.
8565 @end cartouche
8566 Not all wide character modes follow this advice, in particular the JIS
8567 and IEC modes reflect standard usage in Japan, and in these encoding,
8568 the upper half of the Latin-1 set is not part of the wide-character
8569 subset, since the most significant bit is used for wide character
8570 encoding. However, this only applies to the external forms. Internally
8571 there is no such restriction.
8572
8573 @cindex Integer types
8574 @unnumberedsec 3.5.4(28): Integer Types
8575
8576 @sp 1
8577 @cartouche
8578 An implementation should support @code{Long_Integer} in addition to
8579 @code{Integer} if the target machine supports 32-bit (or longer)
8580 arithmetic. No other named integer subtypes are recommended for package
8581 @code{Standard}. Instead, appropriate named integer subtypes should be
8582 provided in the library package @code{Interfaces} (see B.2).
8583 @end cartouche
8584 @code{Long_Integer} is supported. Other standard integer types are supported
8585 so this advice is not fully followed. These types
8586 are supported for convenient interface to C, and so that all hardware
8587 types of the machine are easily available.
8588 @unnumberedsec 3.5.4(29): Integer Types
8589
8590 @sp 1
8591 @cartouche
8592 An implementation for a two's complement machine should support
8593 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8594 implementation should support a non-binary modules up to @code{Integer'Last}.
8595 @end cartouche
8596 Followed.
8597
8598 @cindex Enumeration values
8599 @unnumberedsec 3.5.5(8): Enumeration Values
8600 @sp 1
8601 @cartouche
8602 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8603 subtype, if the value of the operand does not correspond to the internal
8604 code for any enumeration literal of its type (perhaps due to an
8605 un-initialized variable), then the implementation should raise
8606 @code{Program_Error}. This is particularly important for enumeration
8607 types with noncontiguous internal codes specified by an
8608 enumeration_representation_clause.
8609 @end cartouche
8610 Followed.
8611
8612 @cindex Float types
8613 @unnumberedsec 3.5.7(17): Float Types
8614 @sp 1
8615 @cartouche
8616 An implementation should support @code{Long_Float} in addition to
8617 @code{Float} if the target machine supports 11 or more digits of
8618 precision. No other named floating point subtypes are recommended for
8619 package @code{Standard}. Instead, appropriate named floating point subtypes
8620 should be provided in the library package @code{Interfaces} (see B.2).
8621 @end cartouche
8622 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8623 former provides improved compatibility with other implementations
8624 supporting this type. The latter corresponds to the highest precision
8625 floating-point type supported by the hardware. On most machines, this
8626 will be the same as @code{Long_Float}, but on some machines, it will
8627 correspond to the IEEE extended form. The notable case is all ia32
8628 (x86) implementations, where @code{Long_Long_Float} corresponds to
8629 the 80-bit extended precision format supported in hardware on this
8630 processor. Note that the 128-bit format on SPARC is not supported,
8631 since this is a software rather than a hardware format.
8632
8633 @cindex Multidimensional arrays
8634 @cindex Arrays, multidimensional
8635 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8636 @sp 1
8637 @cartouche
8638 An implementation should normally represent multidimensional arrays in
8639 row-major order, consistent with the notation used for multidimensional
8640 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8641 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8642 column-major order should be used instead (see B.5, ``Interfacing with
8643 Fortran'').
8644 @end cartouche
8645 Followed.
8646
8647 @findex Duration'Small
8648 @unnumberedsec 9.6(30-31): Duration'Small
8649 @sp 1
8650 @cartouche
8651 Whenever possible in an implementation, the value of @code{Duration'Small}
8652 should be no greater than 100 microseconds.
8653 @end cartouche
8654 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8655
8656 @sp 1
8657 @cartouche
8658 The time base for @code{delay_relative_statements} should be monotonic;
8659 it need not be the same time base as used for @code{Calendar.Clock}.
8660 @end cartouche
8661 Followed.
8662
8663 @unnumberedsec 10.2.1(12): Consistent Representation
8664 @sp 1
8665 @cartouche
8666 In an implementation, a type declared in a pre-elaborated package should
8667 have the same representation in every elaboration of a given version of
8668 the package, whether the elaborations occur in distinct executions of
8669 the same program, or in executions of distinct programs or partitions
8670 that include the given version.
8671 @end cartouche
8672 Followed, except in the case of tagged types. Tagged types involve
8673 implicit pointers to a local copy of a dispatch table, and these pointers
8674 have representations which thus depend on a particular elaboration of the
8675 package. It is not easy to see how it would be possible to follow this
8676 advice without severely impacting efficiency of execution.
8677
8678 @cindex Exception information
8679 @unnumberedsec 11.4.1(19): Exception Information
8680 @sp 1
8681 @cartouche
8682 @code{Exception_Message} by default and @code{Exception_Information}
8683 should produce information useful for
8684 debugging. @code{Exception_Message} should be short, about one
8685 line. @code{Exception_Information} can be long. @code{Exception_Message}
8686 should not include the
8687 @code{Exception_Name}. @code{Exception_Information} should include both
8688 the @code{Exception_Name} and the @code{Exception_Message}.
8689 @end cartouche
8690 Followed. For each exception that doesn't have a specified
8691 @code{Exception_Message}, the compiler generates one containing the location
8692 of the raise statement. This location has the form ``file:line'', where
8693 file is the short file name (without path information) and line is the line
8694 number in the file. Note that in the case of the Zero Cost Exception
8695 mechanism, these messages become redundant with the Exception_Information that
8696 contains a full backtrace of the calling sequence, so they are disabled.
8697 To disable explicitly the generation of the source location message, use the
8698 Pragma @code{Discard_Names}.
8699
8700 @cindex Suppression of checks
8701 @cindex Checks, suppression of
8702 @unnumberedsec 11.5(28): Suppression of Checks
8703 @sp 1
8704 @cartouche
8705 The implementation should minimize the code executed for checks that
8706 have been suppressed.
8707 @end cartouche
8708 Followed.
8709
8710 @cindex Representation clauses
8711 @unnumberedsec 13.1 (21-24): Representation Clauses
8712 @sp 1
8713 @cartouche
8714 The recommended level of support for all representation items is
8715 qualified as follows:
8716 @end cartouche
8717 @sp 1
8718 @cartouche
8719 An implementation need not support representation items containing
8720 non-static expressions, except that an implementation should support a
8721 representation item for a given entity if each non-static expression in
8722 the representation item is a name that statically denotes a constant
8723 declared before the entity.
8724 @end cartouche
8725 Followed. In fact, GNAT goes beyond the recommended level of support
8726 by allowing nonstatic expressions in some representation clauses even
8727 without the need to declare constants initialized with the values of
8728 such expressions.
8729 For example:
8730
8731 @smallexample @c ada
8732 X : Integer;
8733 Y : Float;
8734 for Y'Address use X'Address;>>
8735 @end smallexample
8736
8737 @sp 1
8738 @cartouche
8739 An implementation need not support a specification for the @code{Size}
8740 for a given composite subtype, nor the size or storage place for an
8741 object (including a component) of a given composite subtype, unless the
8742 constraints on the subtype and its composite subcomponents (if any) are
8743 all static constraints.
8744 @end cartouche
8745 Followed. Size Clauses are not permitted on non-static components, as
8746 described above.
8747
8748 @sp 1
8749 @cartouche
8750 An aliased component, or a component whose type is by-reference, should
8751 always be allocated at an addressable location.
8752 @end cartouche
8753 Followed.
8754
8755 @cindex Packed types
8756 @unnumberedsec 13.2(6-8): Packed Types
8757 @sp 1
8758 @cartouche
8759 If a type is packed, then the implementation should try to minimize
8760 storage allocated to objects of the type, possibly at the expense of
8761 speed of accessing components, subject to reasonable complexity in
8762 addressing calculations.
8763 @end cartouche
8764 @sp 1
8765 @cartouche
8766 The recommended level of support pragma @code{Pack} is:
8767
8768 For a packed record type, the components should be packed as tightly as
8769 possible subject to the Sizes of the component subtypes, and subject to
8770 any @code{record_representation_clause} that applies to the type; the
8771 implementation may, but need not, reorder components or cross aligned
8772 word boundaries to improve the packing. A component whose @code{Size} is
8773 greater than the word size may be allocated an integral number of words.
8774 @end cartouche
8775 Followed. Tight packing of arrays is supported for all component sizes
8776 up to 64-bits. If the array component size is 1 (that is to say, if
8777 the component is a boolean type or an enumeration type with two values)
8778 then values of the type are implicitly initialized to zero. This
8779 happens both for objects of the packed type, and for objects that have a
8780 subcomponent of the packed type.
8781
8782 @sp 1
8783 @cartouche
8784 An implementation should support Address clauses for imported
8785 subprograms.
8786 @end cartouche
8787 Followed.
8788 @cindex @code{Address} clauses
8789 @unnumberedsec 13.3(14-19): Address Clauses
8790
8791 @sp 1
8792 @cartouche
8793 For an array @var{X}, @code{@var{X}'Address} should point at the first
8794 component of the array, and not at the array bounds.
8795 @end cartouche
8796 Followed.
8797
8798 @sp 1
8799 @cartouche
8800 The recommended level of support for the @code{Address} attribute is:
8801
8802 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8803 object that is aliased or of a by-reference type, or is an entity whose
8804 @code{Address} has been specified.
8805 @end cartouche
8806 Followed. A valid address will be produced even if none of those
8807 conditions have been met. If necessary, the object is forced into
8808 memory to ensure the address is valid.
8809
8810 @sp 1
8811 @cartouche
8812 An implementation should support @code{Address} clauses for imported
8813 subprograms.
8814 @end cartouche
8815 Followed.
8816
8817 @sp 1
8818 @cartouche
8819 Objects (including subcomponents) that are aliased or of a by-reference
8820 type should be allocated on storage element boundaries.
8821 @end cartouche
8822 Followed.
8823
8824 @sp 1
8825 @cartouche
8826 If the @code{Address} of an object is specified, or it is imported or exported,
8827 then the implementation should not perform optimizations based on
8828 assumptions of no aliases.
8829 @end cartouche
8830 Followed.
8831
8832 @cindex @code{Alignment} clauses
8833 @unnumberedsec 13.3(29-35): Alignment Clauses
8834 @sp 1
8835 @cartouche
8836 The recommended level of support for the @code{Alignment} attribute for
8837 subtypes is:
8838
8839 An implementation should support specified Alignments that are factors
8840 and multiples of the number of storage elements per word, subject to the
8841 following:
8842 @end cartouche
8843 Followed.
8844
8845 @sp 1
8846 @cartouche
8847 An implementation need not support specified @code{Alignment}s for
8848 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8849 loaded and stored by available machine instructions.
8850 @end cartouche
8851 Followed.
8852
8853 @sp 1
8854 @cartouche
8855 An implementation need not support specified @code{Alignment}s that are
8856 greater than the maximum @code{Alignment} the implementation ever returns by
8857 default.
8858 @end cartouche
8859 Followed.
8860
8861 @sp 1
8862 @cartouche
8863 The recommended level of support for the @code{Alignment} attribute for
8864 objects is:
8865
8866 Same as above, for subtypes, but in addition:
8867 @end cartouche
8868 Followed.
8869
8870 @sp 1
8871 @cartouche
8872 For stand-alone library-level objects of statically constrained
8873 subtypes, the implementation should support all @code{Alignment}s
8874 supported by the target linker. For example, page alignment is likely to
8875 be supported for such objects, but not for subtypes.
8876 @end cartouche
8877 Followed.
8878
8879 @cindex @code{Size} clauses
8880 @unnumberedsec 13.3(42-43): Size Clauses
8881 @sp 1
8882 @cartouche
8883 The recommended level of support for the @code{Size} attribute of
8884 objects is:
8885
8886 A @code{Size} clause should be supported for an object if the specified
8887 @code{Size} is at least as large as its subtype's @code{Size}, and
8888 corresponds to a size in storage elements that is a multiple of the
8889 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8890 @end cartouche
8891 Followed.
8892
8893 @unnumberedsec 13.3(50-56): Size Clauses
8894 @sp 1
8895 @cartouche
8896 If the @code{Size} of a subtype is specified, and allows for efficient
8897 independent addressability (see 9.10) on the target architecture, then
8898 the @code{Size} of the following objects of the subtype should equal the
8899 @code{Size} of the subtype:
8900
8901 Aliased objects (including components).
8902 @end cartouche
8903 Followed.
8904
8905 @sp 1
8906 @cartouche
8907 @code{Size} clause on a composite subtype should not affect the
8908 internal layout of components.
8909 @end cartouche
8910 Followed. But note that this can be overridden by use of the implementation
8911 pragma Implicit_Packing in the case of packed arrays.
8912
8913 @sp 1
8914 @cartouche
8915 The recommended level of support for the @code{Size} attribute of subtypes is:
8916 @end cartouche
8917 @sp 1
8918 @cartouche
8919 The @code{Size} (if not specified) of a static discrete or fixed point
8920 subtype should be the number of bits needed to represent each value
8921 belonging to the subtype using an unbiased representation, leaving space
8922 for a sign bit only if the subtype contains negative values. If such a
8923 subtype is a first subtype, then an implementation should support a
8924 specified @code{Size} for it that reflects this representation.
8925 @end cartouche
8926 Followed.
8927
8928 @sp 1
8929 @cartouche
8930 For a subtype implemented with levels of indirection, the @code{Size}
8931 should include the size of the pointers, but not the size of what they
8932 point at.
8933 @end cartouche
8934 Followed.
8935
8936 @cindex @code{Component_Size} clauses
8937 @unnumberedsec 13.3(71-73): Component Size Clauses
8938 @sp 1
8939 @cartouche
8940 The recommended level of support for the @code{Component_Size}
8941 attribute is:
8942 @end cartouche
8943 @sp 1
8944 @cartouche
8945 An implementation need not support specified @code{Component_Sizes} that are
8946 less than the @code{Size} of the component subtype.
8947 @end cartouche
8948 Followed.
8949
8950 @sp 1
8951 @cartouche
8952 An implementation should support specified @code{Component_Size}s that
8953 are factors and multiples of the word size. For such
8954 @code{Component_Size}s, the array should contain no gaps between
8955 components. For other @code{Component_Size}s (if supported), the array
8956 should contain no gaps between components when packing is also
8957 specified; the implementation should forbid this combination in cases
8958 where it cannot support a no-gaps representation.
8959 @end cartouche
8960 Followed.
8961
8962 @cindex Enumeration representation clauses
8963 @cindex Representation clauses, enumeration
8964 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8965 @sp 1
8966 @cartouche
8967 The recommended level of support for enumeration representation clauses
8968 is:
8969
8970 An implementation need not support enumeration representation clauses
8971 for boolean types, but should at minimum support the internal codes in
8972 the range @code{System.Min_Int.System.Max_Int}.
8973 @end cartouche
8974 Followed.
8975
8976 @cindex Record representation clauses
8977 @cindex Representation clauses, records
8978 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8979 @sp 1
8980 @cartouche
8981 The recommended level of support for
8982 @*@code{record_representation_clauses} is:
8983
8984 An implementation should support storage places that can be extracted
8985 with a load, mask, shift sequence of machine code, and set with a load,
8986 shift, mask, store sequence, given the available machine instructions
8987 and run-time model.
8988 @end cartouche
8989 Followed.
8990
8991 @sp 1
8992 @cartouche
8993 A storage place should be supported if its size is equal to the
8994 @code{Size} of the component subtype, and it starts and ends on a
8995 boundary that obeys the @code{Alignment} of the component subtype.
8996 @end cartouche
8997 Followed.
8998
8999 @sp 1
9000 @cartouche
9001 If the default bit ordering applies to the declaration of a given type,
9002 then for a component whose subtype's @code{Size} is less than the word
9003 size, any storage place that does not cross an aligned word boundary
9004 should be supported.
9005 @end cartouche
9006 Followed.
9007
9008 @sp 1
9009 @cartouche
9010 An implementation may reserve a storage place for the tag field of a
9011 tagged type, and disallow other components from overlapping that place.
9012 @end cartouche
9013 Followed. The storage place for the tag field is the beginning of the tagged
9014 record, and its size is Address'Size. GNAT will reject an explicit component
9015 clause for the tag field.
9016
9017 @sp 1
9018 @cartouche
9019 An implementation need not support a @code{component_clause} for a
9020 component of an extension part if the storage place is not after the
9021 storage places of all components of the parent type, whether or not
9022 those storage places had been specified.
9023 @end cartouche
9024 Followed. The above advice on record representation clauses is followed,
9025 and all mentioned features are implemented.
9026
9027 @cindex Storage place attributes
9028 @unnumberedsec 13.5.2(5): Storage Place Attributes
9029 @sp 1
9030 @cartouche
9031 If a component is represented using some form of pointer (such as an
9032 offset) to the actual data of the component, and this data is contiguous
9033 with the rest of the object, then the storage place attributes should
9034 reflect the place of the actual data, not the pointer. If a component is
9035 allocated discontinuously from the rest of the object, then a warning
9036 should be generated upon reference to one of its storage place
9037 attributes.
9038 @end cartouche
9039 Followed. There are no such components in GNAT@.
9040
9041 @cindex Bit ordering
9042 @unnumberedsec 13.5.3(7-8): Bit Ordering
9043 @sp 1
9044 @cartouche
9045 The recommended level of support for the non-default bit ordering is:
9046 @end cartouche
9047 @sp 1
9048 @cartouche
9049 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
9050 should support the non-default bit ordering in addition to the default
9051 bit ordering.
9052 @end cartouche
9053 Followed. Word size does not equal storage size in this implementation.
9054 Thus non-default bit ordering is not supported.
9055
9056 @cindex @code{Address}, as private type
9057 @unnumberedsec 13.7(37): Address as Private
9058 @sp 1
9059 @cartouche
9060 @code{Address} should be of a private type.
9061 @end cartouche
9062 Followed.
9063
9064 @cindex Operations, on @code{Address}
9065 @cindex @code{Address}, operations of
9066 @unnumberedsec 13.7.1(16): Address Operations
9067 @sp 1
9068 @cartouche
9069 Operations in @code{System} and its children should reflect the target
9070 environment semantics as closely as is reasonable. For example, on most
9071 machines, it makes sense for address arithmetic to ``wrap around''.
9072 Operations that do not make sense should raise @code{Program_Error}.
9073 @end cartouche
9074 Followed. Address arithmetic is modular arithmetic that wraps around. No
9075 operation raises @code{Program_Error}, since all operations make sense.
9076
9077 @cindex Unchecked conversion
9078 @unnumberedsec 13.9(14-17): Unchecked Conversion
9079 @sp 1
9080 @cartouche
9081 The @code{Size} of an array object should not include its bounds; hence,
9082 the bounds should not be part of the converted data.
9083 @end cartouche
9084 Followed.
9085
9086 @sp 1
9087 @cartouche
9088 The implementation should not generate unnecessary run-time checks to
9089 ensure that the representation of @var{S} is a representation of the
9090 target type. It should take advantage of the permission to return by
9091 reference when possible. Restrictions on unchecked conversions should be
9092 avoided unless required by the target environment.
9093 @end cartouche
9094 Followed. There are no restrictions on unchecked conversion. A warning is
9095 generated if the source and target types do not have the same size since
9096 the semantics in this case may be target dependent.
9097
9098 @sp 1
9099 @cartouche
9100 The recommended level of support for unchecked conversions is:
9101 @end cartouche
9102 @sp 1
9103 @cartouche
9104 Unchecked conversions should be supported and should be reversible in
9105 the cases where this clause defines the result. To enable meaningful use
9106 of unchecked conversion, a contiguous representation should be used for
9107 elementary subtypes, for statically constrained array subtypes whose
9108 component subtype is one of the subtypes described in this paragraph,
9109 and for record subtypes without discriminants whose component subtypes
9110 are described in this paragraph.
9111 @end cartouche
9112 Followed.
9113
9114 @cindex Heap usage, implicit
9115 @unnumberedsec 13.11(23-25): Implicit Heap Usage
9116 @sp 1
9117 @cartouche
9118 An implementation should document any cases in which it dynamically
9119 allocates heap storage for a purpose other than the evaluation of an
9120 allocator.
9121 @end cartouche
9122 Followed, the only other points at which heap storage is dynamically
9123 allocated are as follows:
9124
9125 @itemize @bullet
9126 @item
9127 At initial elaboration time, to allocate dynamically sized global
9128 objects.
9129
9130 @item
9131 To allocate space for a task when a task is created.
9132
9133 @item
9134 To extend the secondary stack dynamically when needed. The secondary
9135 stack is used for returning variable length results.
9136 @end itemize
9137
9138 @sp 1
9139 @cartouche
9140 A default (implementation-provided) storage pool for an
9141 access-to-constant type should not have overhead to support deallocation of
9142 individual objects.
9143 @end cartouche
9144 Followed.
9145
9146 @sp 1
9147 @cartouche
9148 A storage pool for an anonymous access type should be created at the
9149 point of an allocator for the type, and be reclaimed when the designated
9150 object becomes inaccessible.
9151 @end cartouche
9152 Followed.
9153
9154 @cindex Unchecked deallocation
9155 @unnumberedsec 13.11.2(17): Unchecked De-allocation
9156 @sp 1
9157 @cartouche
9158 For a standard storage pool, @code{Free} should actually reclaim the
9159 storage.
9160 @end cartouche
9161 Followed.
9162
9163 @cindex Stream oriented attributes
9164 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
9165 @sp 1
9166 @cartouche
9167 If a stream element is the same size as a storage element, then the
9168 normal in-memory representation should be used by @code{Read} and
9169 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
9170 should use the smallest number of stream elements needed to represent
9171 all values in the base range of the scalar type.
9172 @end cartouche
9173
9174 Followed. By default, GNAT uses the interpretation suggested by AI-195,
9175 which specifies using the size of the first subtype.
9176 However, such an implementation is based on direct binary
9177 representations and is therefore target- and endianness-dependent.
9178 To address this issue, GNAT also supplies an alternate implementation
9179 of the stream attributes @code{Read} and @code{Write},
9180 which uses the target-independent XDR standard representation
9181 for scalar types.
9182 @cindex XDR representation
9183 @cindex @code{Read} attribute
9184 @cindex @code{Write} attribute
9185 @cindex Stream oriented attributes
9186 The XDR implementation is provided as an alternative body of the
9187 @code{System.Stream_Attributes} package, in the file
9188 @file{s-stratt-xdr.adb} in the GNAT library.
9189 There is no @file{s-stratt-xdr.ads} file.
9190 In order to install the XDR implementation, do the following:
9191 @enumerate
9192 @item Replace the default implementation of the
9193 @code{System.Stream_Attributes} package with the XDR implementation.
9194 For example on a Unix platform issue the commands:
9195 @smallexample
9196 $ mv s-stratt.adb s-stratt-default.adb
9197 $ mv s-stratt-xdr.adb s-stratt.adb
9198 @end smallexample
9199
9200 @item
9201 Rebuild the GNAT run-time library as documented in
9202 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
9203 @end enumerate
9204
9205 @unnumberedsec A.1(52): Names of Predefined Numeric Types
9206 @sp 1
9207 @cartouche
9208 If an implementation provides additional named predefined integer types,
9209 then the names should end with @samp{Integer} as in
9210 @samp{Long_Integer}. If an implementation provides additional named
9211 predefined floating point types, then the names should end with
9212 @samp{Float} as in @samp{Long_Float}.
9213 @end cartouche
9214 Followed.
9215
9216 @findex Ada.Characters.Handling
9217 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
9218 @sp 1
9219 @cartouche
9220 If an implementation provides a localized definition of @code{Character}
9221 or @code{Wide_Character}, then the effects of the subprograms in
9222 @code{Characters.Handling} should reflect the localizations. See also
9223 3.5.2.
9224 @end cartouche
9225 Followed. GNAT provides no such localized definitions.
9226
9227 @cindex Bounded-length strings
9228 @unnumberedsec A.4.4(106): Bounded-Length String Handling
9229 @sp 1
9230 @cartouche
9231 Bounded string objects should not be implemented by implicit pointers
9232 and dynamic allocation.
9233 @end cartouche
9234 Followed. No implicit pointers or dynamic allocation are used.
9235
9236 @cindex Random number generation
9237 @unnumberedsec A.5.2(46-47): Random Number Generation
9238 @sp 1
9239 @cartouche
9240 Any storage associated with an object of type @code{Generator} should be
9241 reclaimed on exit from the scope of the object.
9242 @end cartouche
9243 Followed.
9244
9245 @sp 1
9246 @cartouche
9247 If the generator period is sufficiently long in relation to the number
9248 of distinct initiator values, then each possible value of
9249 @code{Initiator} passed to @code{Reset} should initiate a sequence of
9250 random numbers that does not, in a practical sense, overlap the sequence
9251 initiated by any other value. If this is not possible, then the mapping
9252 between initiator values and generator states should be a rapidly
9253 varying function of the initiator value.
9254 @end cartouche
9255 Followed. The generator period is sufficiently long for the first
9256 condition here to hold true.
9257
9258 @findex Get_Immediate
9259 @unnumberedsec A.10.7(23): @code{Get_Immediate}
9260 @sp 1
9261 @cartouche
9262 The @code{Get_Immediate} procedures should be implemented with
9263 unbuffered input. For a device such as a keyboard, input should be
9264 @dfn{available} if a key has already been typed, whereas for a disk
9265 file, input should always be available except at end of file. For a file
9266 associated with a keyboard-like device, any line-editing features of the
9267 underlying operating system should be disabled during the execution of
9268 @code{Get_Immediate}.
9269 @end cartouche
9270 Followed on all targets except VxWorks. For VxWorks, there is no way to
9271 provide this functionality that does not result in the input buffer being
9272 flushed before the @code{Get_Immediate} call. A special unit
9273 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
9274 this functionality.
9275
9276 @findex Export
9277 @unnumberedsec B.1(39-41): Pragma @code{Export}
9278 @sp 1
9279 @cartouche
9280 If an implementation supports pragma @code{Export} to a given language,
9281 then it should also allow the main subprogram to be written in that
9282 language. It should support some mechanism for invoking the elaboration
9283 of the Ada library units included in the system, and for invoking the
9284 finalization of the environment task. On typical systems, the
9285 recommended mechanism is to provide two subprograms whose link names are
9286 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
9287 elaboration code for library units. @code{adafinal} should contain the
9288 finalization code. These subprograms should have no effect the second
9289 and subsequent time they are called.
9290 @end cartouche
9291 Followed.
9292
9293 @sp 1
9294 @cartouche
9295 Automatic elaboration of pre-elaborated packages should be
9296 provided when pragma @code{Export} is supported.
9297 @end cartouche
9298 Followed when the main program is in Ada. If the main program is in a
9299 foreign language, then
9300 @code{adainit} must be called to elaborate pre-elaborated
9301 packages.
9302
9303 @sp 1
9304 @cartouche
9305 For each supported convention @var{L} other than @code{Intrinsic}, an
9306 implementation should support @code{Import} and @code{Export} pragmas
9307 for objects of @var{L}-compatible types and for subprograms, and pragma
9308 @code{Convention} for @var{L}-eligible types and for subprograms,
9309 presuming the other language has corresponding features. Pragma
9310 @code{Convention} need not be supported for scalar types.
9311 @end cartouche
9312 Followed.
9313
9314 @cindex Package @code{Interfaces}
9315 @findex Interfaces
9316 @unnumberedsec B.2(12-13): Package @code{Interfaces}
9317 @sp 1
9318 @cartouche
9319 For each implementation-defined convention identifier, there should be a
9320 child package of package Interfaces with the corresponding name. This
9321 package should contain any declarations that would be useful for
9322 interfacing to the language (implementation) represented by the
9323 convention. Any declarations useful for interfacing to any language on
9324 the given hardware architecture should be provided directly in
9325 @code{Interfaces}.
9326 @end cartouche
9327 Followed. An additional package not defined
9328 in the Ada Reference Manual is @code{Interfaces.CPP}, used
9329 for interfacing to C++.
9330
9331 @sp 1
9332 @cartouche
9333 An implementation supporting an interface to C, COBOL, or Fortran should
9334 provide the corresponding package or packages described in the following
9335 clauses.
9336 @end cartouche
9337 Followed. GNAT provides all the packages described in this section.
9338
9339 @cindex C, interfacing with
9340 @unnumberedsec B.3(63-71): Interfacing with C
9341 @sp 1
9342 @cartouche
9343 An implementation should support the following interface correspondences
9344 between Ada and C@.
9345 @end cartouche
9346 Followed.
9347
9348 @sp 1
9349 @cartouche
9350 An Ada procedure corresponds to a void-returning C function.
9351 @end cartouche
9352 Followed.
9353
9354 @sp 1
9355 @cartouche
9356 An Ada function corresponds to a non-void C function.
9357 @end cartouche
9358 Followed.
9359
9360 @sp 1
9361 @cartouche
9362 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
9363 function.
9364 @end cartouche
9365 Followed.
9366
9367 @sp 1
9368 @cartouche
9369 An Ada @code{in} parameter of an access-to-object type with designated
9370 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
9371 where @var{t} is the C type corresponding to the Ada type @var{T}.
9372 @end cartouche
9373 Followed.
9374
9375 @sp 1
9376 @cartouche
9377 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
9378 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
9379 argument to a C function, where @var{t} is the C type corresponding to
9380 the Ada type @var{T}. In the case of an elementary @code{out} or
9381 @code{in out} parameter, a pointer to a temporary copy is used to
9382 preserve by-copy semantics.
9383 @end cartouche
9384 Followed.
9385
9386 @sp 1
9387 @cartouche
9388 An Ada parameter of a record type @var{T}, of any mode, is passed as a
9389 @code{@var{t}*} argument to a C function, where @var{t} is the C
9390 structure corresponding to the Ada type @var{T}.
9391 @end cartouche
9392 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
9393 pragma, or Convention, or by explicitly specifying the mechanism for a given
9394 call using an extended import or export pragma.
9395
9396 @sp 1
9397 @cartouche
9398 An Ada parameter of an array type with component type @var{T}, of any
9399 mode, is passed as a @code{@var{t}*} argument to a C function, where
9400 @var{t} is the C type corresponding to the Ada type @var{T}.
9401 @end cartouche
9402 Followed.
9403
9404 @sp 1
9405 @cartouche
9406 An Ada parameter of an access-to-subprogram type is passed as a pointer
9407 to a C function whose prototype corresponds to the designated
9408 subprogram's specification.
9409 @end cartouche
9410 Followed.
9411
9412 @cindex COBOL, interfacing with
9413 @unnumberedsec B.4(95-98): Interfacing with COBOL
9414 @sp 1
9415 @cartouche
9416 An Ada implementation should support the following interface
9417 correspondences between Ada and COBOL@.
9418 @end cartouche
9419 Followed.
9420
9421 @sp 1
9422 @cartouche
9423 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
9424 the COBOL type corresponding to @var{T}.
9425 @end cartouche
9426 Followed.
9427
9428 @sp 1
9429 @cartouche
9430 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
9431 the corresponding COBOL type.
9432 @end cartouche
9433 Followed.
9434
9435 @sp 1
9436 @cartouche
9437 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
9438 COBOL type corresponding to the Ada parameter type; for scalars, a local
9439 copy is used if necessary to ensure by-copy semantics.
9440 @end cartouche
9441 Followed.
9442
9443 @cindex Fortran, interfacing with
9444 @unnumberedsec B.5(22-26): Interfacing with Fortran
9445 @sp 1
9446 @cartouche
9447 An Ada implementation should support the following interface
9448 correspondences between Ada and Fortran:
9449 @end cartouche
9450 Followed.
9451
9452 @sp 1
9453 @cartouche
9454 An Ada procedure corresponds to a Fortran subroutine.
9455 @end cartouche
9456 Followed.
9457
9458 @sp 1
9459 @cartouche
9460 An Ada function corresponds to a Fortran function.
9461 @end cartouche
9462 Followed.
9463
9464 @sp 1
9465 @cartouche
9466 An Ada parameter of an elementary, array, or record type @var{T} is
9467 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9468 the Fortran type corresponding to the Ada type @var{T}, and where the
9469 INTENT attribute of the corresponding dummy argument matches the Ada
9470 formal parameter mode; the Fortran implementation's parameter passing
9471 conventions are used. For elementary types, a local copy is used if
9472 necessary to ensure by-copy semantics.
9473 @end cartouche
9474 Followed.
9475
9476 @sp 1
9477 @cartouche
9478 An Ada parameter of an access-to-subprogram type is passed as a
9479 reference to a Fortran procedure whose interface corresponds to the
9480 designated subprogram's specification.
9481 @end cartouche
9482 Followed.
9483
9484 @cindex Machine operations
9485 @unnumberedsec C.1(3-5): Access to Machine Operations
9486 @sp 1
9487 @cartouche
9488 The machine code or intrinsic support should allow access to all
9489 operations normally available to assembly language programmers for the
9490 target environment, including privileged instructions, if any.
9491 @end cartouche
9492 Followed.
9493
9494 @sp 1
9495 @cartouche
9496 The interfacing pragmas (see Annex B) should support interface to
9497 assembler; the default assembler should be associated with the
9498 convention identifier @code{Assembler}.
9499 @end cartouche
9500 Followed.
9501
9502 @sp 1
9503 @cartouche
9504 If an entity is exported to assembly language, then the implementation
9505 should allocate it at an addressable location, and should ensure that it
9506 is retained by the linking process, even if not otherwise referenced
9507 from the Ada code. The implementation should assume that any call to a
9508 machine code or assembler subprogram is allowed to read or update every
9509 object that is specified as exported.
9510 @end cartouche
9511 Followed.
9512
9513 @unnumberedsec C.1(10-16): Access to Machine Operations
9514 @sp 1
9515 @cartouche
9516 The implementation should ensure that little or no overhead is
9517 associated with calling intrinsic and machine-code subprograms.
9518 @end cartouche
9519 Followed for both intrinsics and machine-code subprograms.
9520
9521 @sp 1
9522 @cartouche
9523 It is recommended that intrinsic subprograms be provided for convenient
9524 access to any machine operations that provide special capabilities or
9525 efficiency and that are not otherwise available through the language
9526 constructs.
9527 @end cartouche
9528 Followed. A full set of machine operation intrinsic subprograms is provided.
9529
9530 @sp 1
9531 @cartouche
9532 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9533 swap, decrement and test, enqueue/dequeue.
9534 @end cartouche
9535 Followed on any target supporting such operations.
9536
9537 @sp 1
9538 @cartouche
9539 Standard numeric functions---e.g.@:, sin, log.
9540 @end cartouche
9541 Followed on any target supporting such operations.
9542
9543 @sp 1
9544 @cartouche
9545 String manipulation operations---e.g.@:, translate and test.
9546 @end cartouche
9547 Followed on any target supporting such operations.
9548
9549 @sp 1
9550 @cartouche
9551 Vector operations---e.g.@:, compare vector against thresholds.
9552 @end cartouche
9553 Followed on any target supporting such operations.
9554
9555 @sp 1
9556 @cartouche
9557 Direct operations on I/O ports.
9558 @end cartouche
9559 Followed on any target supporting such operations.
9560
9561 @cindex Interrupt support
9562 @unnumberedsec C.3(28): Interrupt Support
9563 @sp 1
9564 @cartouche
9565 If the @code{Ceiling_Locking} policy is not in effect, the
9566 implementation should provide means for the application to specify which
9567 interrupts are to be blocked during protected actions, if the underlying
9568 system allows for a finer-grain control of interrupt blocking.
9569 @end cartouche
9570 Followed. The underlying system does not allow for finer-grain control
9571 of interrupt blocking.
9572
9573 @cindex Protected procedure handlers
9574 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9575 @sp 1
9576 @cartouche
9577 Whenever possible, the implementation should allow interrupt handlers to
9578 be called directly by the hardware.
9579 @end cartouche
9580 Followed on any target where the underlying operating system permits
9581 such direct calls.
9582
9583 @sp 1
9584 @cartouche
9585 Whenever practical, violations of any
9586 implementation-defined restrictions should be detected before run time.
9587 @end cartouche
9588 Followed. Compile time warnings are given when possible.
9589
9590 @cindex Package @code{Interrupts}
9591 @findex Interrupts
9592 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9593
9594 @sp 1
9595 @cartouche
9596 If implementation-defined forms of interrupt handler procedures are
9597 supported, such as protected procedures with parameters, then for each
9598 such form of a handler, a type analogous to @code{Parameterless_Handler}
9599 should be specified in a child package of @code{Interrupts}, with the
9600 same operations as in the predefined package Interrupts.
9601 @end cartouche
9602 Followed.
9603
9604 @cindex Pre-elaboration requirements
9605 @unnumberedsec C.4(14): Pre-elaboration Requirements
9606 @sp 1
9607 @cartouche
9608 It is recommended that pre-elaborated packages be implemented in such a
9609 way that there should be little or no code executed at run time for the
9610 elaboration of entities not already covered by the Implementation
9611 Requirements.
9612 @end cartouche
9613 Followed. Executable code is generated in some cases, e.g.@: loops
9614 to initialize large arrays.
9615
9616 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9617 @sp 1
9618 @cartouche
9619 If the pragma applies to an entity, then the implementation should
9620 reduce the amount of storage used for storing names associated with that
9621 entity.
9622 @end cartouche
9623 Followed.
9624
9625 @cindex Package @code{Task_Attributes}
9626 @findex Task_Attributes
9627 @unnumberedsec C.7.2(30): The Package Task_Attributes
9628 @sp 1
9629 @cartouche
9630 Some implementations are targeted to domains in which memory use at run
9631 time must be completely deterministic. For such implementations, it is
9632 recommended that the storage for task attributes will be pre-allocated
9633 statically and not from the heap. This can be accomplished by either
9634 placing restrictions on the number and the size of the task's
9635 attributes, or by using the pre-allocated storage for the first @var{N}
9636 attribute objects, and the heap for the others. In the latter case,
9637 @var{N} should be documented.
9638 @end cartouche
9639 Not followed. This implementation is not targeted to such a domain.
9640
9641 @cindex Locking Policies
9642 @unnumberedsec D.3(17): Locking Policies
9643
9644 @sp 1
9645 @cartouche
9646 The implementation should use names that end with @samp{_Locking} for
9647 locking policies defined by the implementation.
9648 @end cartouche
9649 Followed. Two implementation-defined locking policies are defined,
9650 whose names (@code{Inheritance_Locking} and
9651 @code{Concurrent_Readers_Locking}) follow this suggestion.
9652
9653 @cindex Entry queuing policies
9654 @unnumberedsec D.4(16): Entry Queuing Policies
9655 @sp 1
9656 @cartouche
9657 Names that end with @samp{_Queuing} should be used
9658 for all implementation-defined queuing policies.
9659 @end cartouche
9660 Followed. No such implementation-defined queuing policies exist.
9661
9662 @cindex Preemptive abort
9663 @unnumberedsec D.6(9-10): Preemptive Abort
9664 @sp 1
9665 @cartouche
9666 Even though the @code{abort_statement} is included in the list of
9667 potentially blocking operations (see 9.5.1), it is recommended that this
9668 statement be implemented in a way that never requires the task executing
9669 the @code{abort_statement} to block.
9670 @end cartouche
9671 Followed.
9672
9673 @sp 1
9674 @cartouche
9675 On a multi-processor, the delay associated with aborting a task on
9676 another processor should be bounded; the implementation should use
9677 periodic polling, if necessary, to achieve this.
9678 @end cartouche
9679 Followed.
9680
9681 @cindex Tasking restrictions
9682 @unnumberedsec D.7(21): Tasking Restrictions
9683 @sp 1
9684 @cartouche
9685 When feasible, the implementation should take advantage of the specified
9686 restrictions to produce a more efficient implementation.
9687 @end cartouche
9688 GNAT currently takes advantage of these restrictions by providing an optimized
9689 run time when the Ravenscar profile and the GNAT restricted run time set
9690 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9691 pragma @code{Profile (Restricted)} for more details.
9692
9693 @cindex Time, monotonic
9694 @unnumberedsec D.8(47-49): Monotonic Time
9695 @sp 1
9696 @cartouche
9697 When appropriate, implementations should provide configuration
9698 mechanisms to change the value of @code{Tick}.
9699 @end cartouche
9700 Such configuration mechanisms are not appropriate to this implementation
9701 and are thus not supported.
9702
9703 @sp 1
9704 @cartouche
9705 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9706 be implemented as transformations of the same time base.
9707 @end cartouche
9708 Followed.
9709
9710 @sp 1
9711 @cartouche
9712 It is recommended that the @dfn{best} time base which exists in
9713 the underlying system be available to the application through
9714 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9715 @end cartouche
9716 Followed.
9717
9718 @cindex Partition communication subsystem
9719 @cindex PCS
9720 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9721 @sp 1
9722 @cartouche
9723 Whenever possible, the PCS on the called partition should allow for
9724 multiple tasks to call the RPC-receiver with different messages and
9725 should allow them to block until the corresponding subprogram body
9726 returns.
9727 @end cartouche
9728 Followed by GLADE, a separately supplied PCS that can be used with
9729 GNAT.
9730
9731 @sp 1
9732 @cartouche
9733 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9734 should raise @code{Storage_Error} if it runs out of space trying to
9735 write the @code{Item} into the stream.
9736 @end cartouche
9737 Followed by GLADE, a separately supplied PCS that can be used with
9738 GNAT@.
9739
9740 @cindex COBOL support
9741 @unnumberedsec F(7): COBOL Support
9742 @sp 1
9743 @cartouche
9744 If COBOL (respectively, C) is widely supported in the target
9745 environment, implementations supporting the Information Systems Annex
9746 should provide the child package @code{Interfaces.COBOL} (respectively,
9747 @code{Interfaces.C}) specified in Annex B and should support a
9748 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9749 pragmas (see Annex B), thus allowing Ada programs to interface with
9750 programs written in that language.
9751 @end cartouche
9752 Followed.
9753
9754 @cindex Decimal radix support
9755 @unnumberedsec F.1(2): Decimal Radix Support
9756 @sp 1
9757 @cartouche
9758 Packed decimal should be used as the internal representation for objects
9759 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9760 @end cartouche
9761 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9762 representations.
9763
9764 @cindex Numerics
9765 @unnumberedsec G: Numerics
9766 @sp 2
9767 @cartouche
9768 If Fortran (respectively, C) is widely supported in the target
9769 environment, implementations supporting the Numerics Annex
9770 should provide the child package @code{Interfaces.Fortran} (respectively,
9771 @code{Interfaces.C}) specified in Annex B and should support a
9772 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9773 pragmas (see Annex B), thus allowing Ada programs to interface with
9774 programs written in that language.
9775 @end cartouche
9776 Followed.
9777
9778 @cindex Complex types
9779 @unnumberedsec G.1.1(56-58): Complex Types
9780 @sp 2
9781 @cartouche
9782 Because the usual mathematical meaning of multiplication of a complex
9783 operand and a real operand is that of the scaling of both components of
9784 the former by the latter, an implementation should not perform this
9785 operation by first promoting the real operand to complex type and then
9786 performing a full complex multiplication. In systems that, in the
9787 future, support an Ada binding to IEC 559:1989, the latter technique
9788 will not generate the required result when one of the components of the
9789 complex operand is infinite. (Explicit multiplication of the infinite
9790 component by the zero component obtained during promotion yields a NaN
9791 that propagates into the final result.) Analogous advice applies in the
9792 case of multiplication of a complex operand and a pure-imaginary
9793 operand, and in the case of division of a complex operand by a real or
9794 pure-imaginary operand.
9795 @end cartouche
9796 Not followed.
9797
9798 @sp 1
9799 @cartouche
9800 Similarly, because the usual mathematical meaning of addition of a
9801 complex operand and a real operand is that the imaginary operand remains
9802 unchanged, an implementation should not perform this operation by first
9803 promoting the real operand to complex type and then performing a full
9804 complex addition. In implementations in which the @code{Signed_Zeros}
9805 attribute of the component type is @code{True} (and which therefore
9806 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9807 predefined arithmetic operations), the latter technique will not
9808 generate the required result when the imaginary component of the complex
9809 operand is a negatively signed zero. (Explicit addition of the negative
9810 zero to the zero obtained during promotion yields a positive zero.)
9811 Analogous advice applies in the case of addition of a complex operand
9812 and a pure-imaginary operand, and in the case of subtraction of a
9813 complex operand and a real or pure-imaginary operand.
9814 @end cartouche
9815 Not followed.
9816
9817 @sp 1
9818 @cartouche
9819 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9820 attempt to provide a rational treatment of the signs of zero results and
9821 result components. As one example, the result of the @code{Argument}
9822 function should have the sign of the imaginary component of the
9823 parameter @code{X} when the point represented by that parameter lies on
9824 the positive real axis; as another, the sign of the imaginary component
9825 of the @code{Compose_From_Polar} function should be the same as
9826 (respectively, the opposite of) that of the @code{Argument} parameter when that
9827 parameter has a value of zero and the @code{Modulus} parameter has a
9828 nonnegative (respectively, negative) value.
9829 @end cartouche
9830 Followed.
9831
9832 @cindex Complex elementary functions
9833 @unnumberedsec G.1.2(49): Complex Elementary Functions
9834 @sp 1
9835 @cartouche
9836 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9837 @code{True} should attempt to provide a rational treatment of the signs
9838 of zero results and result components. For example, many of the complex
9839 elementary functions have components that are odd functions of one of
9840 the parameter components; in these cases, the result component should
9841 have the sign of the parameter component at the origin. Other complex
9842 elementary functions have zero components whose sign is opposite that of
9843 a parameter component at the origin, or is always positive or always
9844 negative.
9845 @end cartouche
9846 Followed.
9847
9848 @cindex Accuracy requirements
9849 @unnumberedsec G.2.4(19): Accuracy Requirements
9850 @sp 1
9851 @cartouche
9852 The versions of the forward trigonometric functions without a
9853 @code{Cycle} parameter should not be implemented by calling the
9854 corresponding version with a @code{Cycle} parameter of
9855 @code{2.0*Numerics.Pi}, since this will not provide the required
9856 accuracy in some portions of the domain. For the same reason, the
9857 version of @code{Log} without a @code{Base} parameter should not be
9858 implemented by calling the corresponding version with a @code{Base}
9859 parameter of @code{Numerics.e}.
9860 @end cartouche
9861 Followed.
9862
9863 @cindex Complex arithmetic accuracy
9864 @cindex Accuracy, complex arithmetic
9865 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9866
9867 @sp 1
9868 @cartouche
9869 The version of the @code{Compose_From_Polar} function 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.
9874 @end cartouche
9875 Followed.
9876
9877 @cindex Sequential elaboration policy
9878 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
9879
9880 @sp 1
9881 @cartouche
9882 If the partition elaboration policy is @code{Sequential} and the
9883 Environment task becomes permanently blocked during elaboration then the
9884 partition is deadlocked and it is recommended that the partition be
9885 immediately terminated.
9886 @end cartouche
9887 Not followed.
9888
9889 @c -----------------------------------------
9890 @node Implementation Defined Characteristics
9891 @chapter Implementation Defined Characteristics
9892
9893 @noindent
9894 In addition to the implementation dependent pragmas and attributes, and the
9895 implementation advice, there are a number of other Ada features that are
9896 potentially implementation dependent and are designated as
9897 implementation-defined. These are mentioned throughout the Ada Reference
9898 Manual, and are summarized in Annex M@.
9899
9900 A requirement for conforming Ada compilers is that they provide
9901 documentation describing how the implementation deals with each of these
9902 issues. In this chapter, you will find each point in Annex M listed
9903 followed by a description in italic font of how GNAT
9904 handles the implementation dependence.
9905
9906 You can use this chapter as a guide to minimizing implementation
9907 dependent features in your programs if portability to other compilers
9908 and other operating systems is an important consideration. The numbers
9909 in each section below correspond to the paragraph number in the Ada
9910 Reference Manual.
9911
9912 @sp 1
9913 @cartouche
9914 @noindent
9915 @strong{2}. Whether or not each recommendation given in Implementation
9916 Advice is followed. See 1.1.2(37).
9917 @end cartouche
9918 @noindent
9919 @xref{Implementation Advice}.
9920
9921 @sp 1
9922 @cartouche
9923 @noindent
9924 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9925 @end cartouche
9926 @noindent
9927 The complexity of programs that can be processed is limited only by the
9928 total amount of available virtual memory, and disk space for the
9929 generated object files.
9930
9931 @sp 1
9932 @cartouche
9933 @noindent
9934 @strong{4}. Variations from the standard that are impractical to avoid
9935 given the implementation's execution environment. See 1.1.3(6).
9936 @end cartouche
9937 @noindent
9938 There are no variations from the standard.
9939
9940 @sp 1
9941 @cartouche
9942 @noindent
9943 @strong{5}. Which @code{code_statement}s cause external
9944 interactions. See 1.1.3(10).
9945 @end cartouche
9946 @noindent
9947 Any @code{code_statement} can potentially cause external interactions.
9948
9949 @sp 1
9950 @cartouche
9951 @noindent
9952 @strong{6}. The coded representation for the text of an Ada
9953 program. See 2.1(4).
9954 @end cartouche
9955 @noindent
9956 See separate section on source representation.
9957
9958 @sp 1
9959 @cartouche
9960 @noindent
9961 @strong{7}. The control functions allowed in comments. See 2.1(14).
9962 @end cartouche
9963 @noindent
9964 See separate section on source representation.
9965
9966 @sp 1
9967 @cartouche
9968 @noindent
9969 @strong{8}. The representation for an end of line. See 2.2(2).
9970 @end cartouche
9971 @noindent
9972 See separate section on source representation.
9973
9974 @sp 1
9975 @cartouche
9976 @noindent
9977 @strong{9}. Maximum supported line length and lexical element
9978 length. See 2.2(15).
9979 @end cartouche
9980 @noindent
9981 The maximum line length is 255 characters and the maximum length of
9982 a lexical element is also 255 characters. This is the default setting
9983 if not overridden by the use of compiler switch @option{-gnaty} (which
9984 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
9985 line length to be specified to be any value up to 32767. The maximum
9986 length of a lexical element is the same as the maximum line length.
9987
9988 @sp 1
9989 @cartouche
9990 @noindent
9991 @strong{10}. Implementation defined pragmas. See 2.8(14).
9992 @end cartouche
9993 @noindent
9994
9995 @xref{Implementation Defined Pragmas}.
9996
9997 @sp 1
9998 @cartouche
9999 @noindent
10000 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
10001 @end cartouche
10002 @noindent
10003 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
10004 parameter, checks that the optimization flag is set, and aborts if it is
10005 not.
10006
10007 @sp 1
10008 @cartouche
10009 @noindent
10010 @strong{12}. The sequence of characters of the value returned by
10011 @code{@var{S}'Image} when some of the graphic characters of
10012 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
10013 3.5(37).
10014 @end cartouche
10015 @noindent
10016 The sequence of characters is as defined by the wide character encoding
10017 method used for the source. See section on source representation for
10018 further details.
10019
10020 @sp 1
10021 @cartouche
10022 @noindent
10023 @strong{13}. The predefined integer types declared in
10024 @code{Standard}. See 3.5.4(25).
10025 @end cartouche
10026 @noindent
10027 @table @code
10028 @item Short_Short_Integer
10029 8 bit signed
10030 @item Short_Integer
10031 (Short) 16 bit signed
10032 @item Integer
10033 32 bit signed
10034 @item Long_Integer
10035 64 bit signed (on most 64 bit targets, depending on the C definition of long).
10036 32 bit signed (all other targets)
10037 @item Long_Long_Integer
10038 64 bit signed
10039 @end table
10040
10041 @sp 1
10042 @cartouche
10043 @noindent
10044 @strong{14}. Any nonstandard integer types and the operators defined
10045 for them. See 3.5.4(26).
10046 @end cartouche
10047 @noindent
10048 There are no nonstandard integer types.
10049
10050 @sp 1
10051 @cartouche
10052 @noindent
10053 @strong{15}. Any nonstandard real types and the operators defined for
10054 them. See 3.5.6(8).
10055 @end cartouche
10056 @noindent
10057 There are no nonstandard real types.
10058
10059 @sp 1
10060 @cartouche
10061 @noindent
10062 @strong{16}. What combinations of requested decimal precision and range
10063 are supported for floating point types. See 3.5.7(7).
10064 @end cartouche
10065 @noindent
10066 The precision and range is as defined by the IEEE standard.
10067
10068 @sp 1
10069 @cartouche
10070 @noindent
10071 @strong{17}. The predefined floating point types declared in
10072 @code{Standard}. See 3.5.7(16).
10073 @end cartouche
10074 @noindent
10075 @table @code
10076 @item Short_Float
10077 32 bit IEEE short
10078 @item Float
10079 (Short) 32 bit IEEE short
10080 @item Long_Float
10081 64 bit IEEE long
10082 @item Long_Long_Float
10083 64 bit IEEE long (80 bit IEEE long on x86 processors)
10084 @end table
10085
10086 @sp 1
10087 @cartouche
10088 @noindent
10089 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
10090 @end cartouche
10091 @noindent
10092 @code{Fine_Delta} is 2**(@minus{}63)
10093
10094 @sp 1
10095 @cartouche
10096 @noindent
10097 @strong{19}. What combinations of small, range, and digits are
10098 supported for fixed point types. See 3.5.9(10).
10099 @end cartouche
10100 @noindent
10101 Any combinations are permitted that do not result in a small less than
10102 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
10103 If the mantissa is larger than 53 bits on machines where Long_Long_Float
10104 is 64 bits (true of all architectures except ia32), then the output from
10105 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
10106 is because floating-point conversions are used to convert fixed point.
10107
10108 @sp 1
10109 @cartouche
10110 @noindent
10111 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
10112 within an unnamed @code{block_statement}. See 3.9(10).
10113 @end cartouche
10114 @noindent
10115 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
10116 decimal integer are allocated.
10117
10118 @sp 1
10119 @cartouche
10120 @noindent
10121 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
10122 @end cartouche
10123 @noindent
10124 @xref{Implementation Defined Attributes}.
10125
10126 @sp 1
10127 @cartouche
10128 @noindent
10129 @strong{22}. Any implementation-defined time types. See 9.6(6).
10130 @end cartouche
10131 @noindent
10132 There are no implementation-defined time types.
10133
10134 @sp 1
10135 @cartouche
10136 @noindent
10137 @strong{23}. The time base associated with relative delays.
10138 @end cartouche
10139 @noindent
10140 See 9.6(20). The time base used is that provided by the C library
10141 function @code{gettimeofday}.
10142
10143 @sp 1
10144 @cartouche
10145 @noindent
10146 @strong{24}. The time base of the type @code{Calendar.Time}. See
10147 9.6(23).
10148 @end cartouche
10149 @noindent
10150 The time base used is that provided by the C library function
10151 @code{gettimeofday}.
10152
10153 @sp 1
10154 @cartouche
10155 @noindent
10156 @strong{25}. The time zone used for package @code{Calendar}
10157 operations. See 9.6(24).
10158 @end cartouche
10159 @noindent
10160 The time zone used by package @code{Calendar} is the current system time zone
10161 setting for local time, as accessed by the C library function
10162 @code{localtime}.
10163
10164 @sp 1
10165 @cartouche
10166 @noindent
10167 @strong{26}. Any limit on @code{delay_until_statements} of
10168 @code{select_statements}. See 9.6(29).
10169 @end cartouche
10170 @noindent
10171 There are no such limits.
10172
10173 @sp 1
10174 @cartouche
10175 @noindent
10176 @strong{27}. Whether or not two non-overlapping parts of a composite
10177 object are independently addressable, in the case where packing, record
10178 layout, or @code{Component_Size} is specified for the object. See
10179 9.10(1).
10180 @end cartouche
10181 @noindent
10182 Separate components are independently addressable if they do not share
10183 overlapping storage units.
10184
10185 @sp 1
10186 @cartouche
10187 @noindent
10188 @strong{28}. The representation for a compilation. See 10.1(2).
10189 @end cartouche
10190 @noindent
10191 A compilation is represented by a sequence of files presented to the
10192 compiler in a single invocation of the @command{gcc} command.
10193
10194 @sp 1
10195 @cartouche
10196 @noindent
10197 @strong{29}. Any restrictions on compilations that contain multiple
10198 compilation_units. See 10.1(4).
10199 @end cartouche
10200 @noindent
10201 No single file can contain more than one compilation unit, but any
10202 sequence of files can be presented to the compiler as a single
10203 compilation.
10204
10205 @sp 1
10206 @cartouche
10207 @noindent
10208 @strong{30}. The mechanisms for creating an environment and for adding
10209 and replacing compilation units. See 10.1.4(3).
10210 @end cartouche
10211 @noindent
10212 See separate section on compilation model.
10213
10214 @sp 1
10215 @cartouche
10216 @noindent
10217 @strong{31}. The manner of explicitly assigning library units to a
10218 partition. See 10.2(2).
10219 @end cartouche
10220 @noindent
10221 If a unit contains an Ada main program, then the Ada units for the partition
10222 are determined by recursive application of the rules in the Ada Reference
10223 Manual section 10.2(2-6). In other words, the Ada units will be those that
10224 are needed by the main program, and then this definition of need is applied
10225 recursively to those units, and the partition contains the transitive
10226 closure determined by this relationship. In short, all the necessary units
10227 are included, with no need to explicitly specify the list. If additional
10228 units are required, e.g.@: by foreign language units, then all units must be
10229 mentioned in the context clause of one of the needed Ada units.
10230
10231 If the partition contains no main program, or if the main program is in
10232 a language other than Ada, then GNAT
10233 provides the binder options @option{-z} and @option{-n} respectively, and in
10234 this case a list of units can be explicitly supplied to the binder for
10235 inclusion in the partition (all units needed by these units will also
10236 be included automatically). For full details on the use of these
10237 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
10238 @value{EDITION} User's Guide}.
10239
10240 @sp 1
10241 @cartouche
10242 @noindent
10243 @strong{32}. The implementation-defined means, if any, of specifying
10244 which compilation units are needed by a given compilation unit. See
10245 10.2(2).
10246 @end cartouche
10247 @noindent
10248 The units needed by a given compilation unit are as defined in
10249 the Ada Reference Manual section 10.2(2-6). There are no
10250 implementation-defined pragmas or other implementation-defined
10251 means for specifying needed units.
10252
10253 @sp 1
10254 @cartouche
10255 @noindent
10256 @strong{33}. The manner of designating the main subprogram of a
10257 partition. See 10.2(7).
10258 @end cartouche
10259 @noindent
10260 The main program is designated by providing the name of the
10261 corresponding @file{ALI} file as the input parameter to the binder.
10262
10263 @sp 1
10264 @cartouche
10265 @noindent
10266 @strong{34}. The order of elaboration of @code{library_items}. See
10267 10.2(18).
10268 @end cartouche
10269 @noindent
10270 The first constraint on ordering is that it meets the requirements of
10271 Chapter 10 of the Ada Reference Manual. This still leaves some
10272 implementation dependent choices, which are resolved by first
10273 elaborating bodies as early as possible (i.e., in preference to specs
10274 where there is a choice), and second by evaluating the immediate with
10275 clauses of a unit to determine the probably best choice, and
10276 third by elaborating in alphabetical order of unit names
10277 where a choice still remains.
10278
10279 @sp 1
10280 @cartouche
10281 @noindent
10282 @strong{35}. Parameter passing and function return for the main
10283 subprogram. See 10.2(21).
10284 @end cartouche
10285 @noindent
10286 The main program has no parameters. It may be a procedure, or a function
10287 returning an integer type. In the latter case, the returned integer
10288 value is the return code of the program (overriding any value that
10289 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
10290
10291 @sp 1
10292 @cartouche
10293 @noindent
10294 @strong{36}. The mechanisms for building and running partitions. See
10295 10.2(24).
10296 @end cartouche
10297 @noindent
10298 GNAT itself supports programs with only a single partition. The GNATDIST
10299 tool provided with the GLADE package (which also includes an implementation
10300 of the PCS) provides a completely flexible method for building and running
10301 programs consisting of multiple partitions. See the separate GLADE manual
10302 for details.
10303
10304 @sp 1
10305 @cartouche
10306 @noindent
10307 @strong{37}. The details of program execution, including program
10308 termination. See 10.2(25).
10309 @end cartouche
10310 @noindent
10311 See separate section on compilation model.
10312
10313 @sp 1
10314 @cartouche
10315 @noindent
10316 @strong{38}. The semantics of any non-active partitions supported by the
10317 implementation. See 10.2(28).
10318 @end cartouche
10319 @noindent
10320 Passive partitions are supported on targets where shared memory is
10321 provided by the operating system. See the GLADE reference manual for
10322 further details.
10323
10324 @sp 1
10325 @cartouche
10326 @noindent
10327 @strong{39}. The information returned by @code{Exception_Message}. See
10328 11.4.1(10).
10329 @end cartouche
10330 @noindent
10331 Exception message returns the null string unless a specific message has
10332 been passed by the program.
10333
10334 @sp 1
10335 @cartouche
10336 @noindent
10337 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
10338 declared within an unnamed @code{block_statement}. See 11.4.1(12).
10339 @end cartouche
10340 @noindent
10341 Blocks have implementation defined names of the form @code{B@var{nnn}}
10342 where @var{nnn} is an integer.
10343
10344 @sp 1
10345 @cartouche
10346 @noindent
10347 @strong{41}. The information returned by
10348 @code{Exception_Information}. See 11.4.1(13).
10349 @end cartouche
10350 @noindent
10351 @code{Exception_Information} returns a string in the following format:
10352
10353 @smallexample
10354 @emph{Exception_Name:} nnnnn
10355 @emph{Message:} mmmmm
10356 @emph{PID:} ppp
10357 @emph{Call stack traceback locations:}
10358 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
10359 @end smallexample
10360
10361 @noindent
10362 where
10363
10364 @itemize @bullet
10365 @item
10366 @code{nnnn} is the fully qualified name of the exception in all upper
10367 case letters. This line is always present.
10368
10369 @item
10370 @code{mmmm} is the message (this line present only if message is non-null)
10371
10372 @item
10373 @code{ppp} is the Process Id value as a decimal integer (this line is
10374 present only if the Process Id is nonzero). Currently we are
10375 not making use of this field.
10376
10377 @item
10378 The Call stack traceback locations line and the following values
10379 are present only if at least one traceback location was recorded.
10380 The values are given in C style format, with lower case letters
10381 for a-f, and only as many digits present as are necessary.
10382 @end itemize
10383
10384 @noindent
10385 The line terminator sequence at the end of each line, including
10386 the last line is a single @code{LF} character (@code{16#0A#}).
10387
10388 @sp 1
10389 @cartouche
10390 @noindent
10391 @strong{42}. Implementation-defined check names. See 11.5(27).
10392 @end cartouche
10393 @noindent
10394 The implementation defined check name Alignment_Check controls checking of
10395 address clause values for proper alignment (that is, the address supplied
10396 must be consistent with the alignment of the type).
10397
10398 In addition, a user program can add implementation-defined check names
10399 by means of the pragma Check_Name.
10400
10401 @sp 1
10402 @cartouche
10403 @noindent
10404 @strong{43}. The interpretation of each aspect of representation. See
10405 13.1(20).
10406 @end cartouche
10407 @noindent
10408 See separate section on data representations.
10409
10410 @sp 1
10411 @cartouche
10412 @noindent
10413 @strong{44}. Any restrictions placed upon representation items. See
10414 13.1(20).
10415 @end cartouche
10416 @noindent
10417 See separate section on data representations.
10418
10419 @sp 1
10420 @cartouche
10421 @noindent
10422 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
10423 13.3(48).
10424 @end cartouche
10425 @noindent
10426 Size for an indefinite subtype is the maximum possible size, except that
10427 for the case of a subprogram parameter, the size of the parameter object
10428 is the actual size.
10429
10430 @sp 1
10431 @cartouche
10432 @noindent
10433 @strong{46}. The default external representation for a type tag. See
10434 13.3(75).
10435 @end cartouche
10436 @noindent
10437 The default external representation for a type tag is the fully expanded
10438 name of the type in upper case letters.
10439
10440 @sp 1
10441 @cartouche
10442 @noindent
10443 @strong{47}. What determines whether a compilation unit is the same in
10444 two different partitions. See 13.3(76).
10445 @end cartouche
10446 @noindent
10447 A compilation unit is the same in two different partitions if and only
10448 if it derives from the same source file.
10449
10450 @sp 1
10451 @cartouche
10452 @noindent
10453 @strong{48}. Implementation-defined components. See 13.5.1(15).
10454 @end cartouche
10455 @noindent
10456 The only implementation defined component is the tag for a tagged type,
10457 which contains a pointer to the dispatching table.
10458
10459 @sp 1
10460 @cartouche
10461 @noindent
10462 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
10463 ordering. See 13.5.3(5).
10464 @end cartouche
10465 @noindent
10466 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10467 implementation, so no non-default bit ordering is supported. The default
10468 bit ordering corresponds to the natural endianness of the target architecture.
10469
10470 @sp 1
10471 @cartouche
10472 @noindent
10473 @strong{50}. The contents of the visible part of package @code{System}
10474 and its language-defined children. See 13.7(2).
10475 @end cartouche
10476 @noindent
10477 See the definition of these packages in files @file{system.ads} and
10478 @file{s-stoele.ads}.
10479
10480 @sp 1
10481 @cartouche
10482 @noindent
10483 @strong{51}. The contents of the visible part of package
10484 @code{System.Machine_Code}, and the meaning of
10485 @code{code_statements}. See 13.8(7).
10486 @end cartouche
10487 @noindent
10488 See the definition and documentation in file @file{s-maccod.ads}.
10489
10490 @sp 1
10491 @cartouche
10492 @noindent
10493 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10494 @end cartouche
10495 @noindent
10496 Unchecked conversion between types of the same size
10497 results in an uninterpreted transmission of the bits from one type
10498 to the other. If the types are of unequal sizes, then in the case of
10499 discrete types, a shorter source is first zero or sign extended as
10500 necessary, and a shorter target is simply truncated on the left.
10501 For all non-discrete types, the source is first copied if necessary
10502 to ensure that the alignment requirements of the target are met, then
10503 a pointer is constructed to the source value, and the result is obtained
10504 by dereferencing this pointer after converting it to be a pointer to the
10505 target type. Unchecked conversions where the target subtype is an
10506 unconstrained array are not permitted. If the target alignment is
10507 greater than the source alignment, then a copy of the result is
10508 made with appropriate alignment
10509
10510 @sp 1
10511 @cartouche
10512 @noindent
10513 @strong{53}. The semantics of operations on invalid representations.
10514 See 13.9.2(10-11).
10515 @end cartouche
10516 @noindent
10517 For assignments and other operations where the use of invalid values cannot
10518 result in erroneous behavior, the compiler ignores the possibility of invalid
10519 values. An exception is raised at the point where an invalid value would
10520 result in erroneous behavior. For example executing:
10521
10522 @smallexample @c ada
10523 procedure invalidvals is
10524 X : Integer := -1;
10525 Y : Natural range 1 .. 10;
10526 for Y'Address use X'Address;
10527 Z : Natural range 1 .. 10;
10528 A : array (Natural range 1 .. 10) of Integer;
10529 begin
10530 Z := Y; -- no exception
10531 A (Z) := 3; -- exception raised;
10532 end;
10533 @end smallexample
10534
10535 @noindent
10536 As indicated, an exception is raised on the array assignment, but not
10537 on the simple assignment of the invalid negative value from Y to Z.
10538
10539 @sp 1
10540 @cartouche
10541 @noindent
10542 @strong{53}. The manner of choosing a storage pool for an access type
10543 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10544 @end cartouche
10545 @noindent
10546 There are 3 different standard pools used by the compiler when
10547 @code{Storage_Pool} is not specified depending whether the type is local
10548 to a subprogram or defined at the library level and whether
10549 @code{Storage_Size}is specified or not. See documentation in the runtime
10550 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10551 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10552 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10553 default pools used.
10554
10555 @sp 1
10556 @cartouche
10557 @noindent
10558 @strong{54}. Whether or not the implementation provides user-accessible
10559 names for the standard pool type(s). See 13.11(17).
10560 @end cartouche
10561 @noindent
10562
10563 See documentation in the sources of the run time mentioned in paragraph
10564 @strong{53} . All these pools are accessible by means of @code{with}'ing
10565 these units.
10566
10567 @sp 1
10568 @cartouche
10569 @noindent
10570 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10571 @end cartouche
10572 @noindent
10573 @code{Storage_Size} is measured in storage units, and refers to the
10574 total space available for an access type collection, or to the primary
10575 stack space for a task.
10576
10577 @sp 1
10578 @cartouche
10579 @noindent
10580 @strong{56}. Implementation-defined aspects of storage pools. See
10581 13.11(22).
10582 @end cartouche
10583 @noindent
10584 See documentation in the sources of the run time mentioned in paragraph
10585 @strong{53} for details on GNAT-defined aspects of storage pools.
10586
10587 @sp 1
10588 @cartouche
10589 @noindent
10590 @strong{57}. The set of restrictions allowed in a pragma
10591 @code{Restrictions}. See 13.12(7).
10592 @end cartouche
10593 @noindent
10594 @xref{Standard and Implementation Defined Restrictions}.
10595
10596 @sp 1
10597 @cartouche
10598 @noindent
10599 @strong{58}. The consequences of violating limitations on
10600 @code{Restrictions} pragmas. See 13.12(9).
10601 @end cartouche
10602 @noindent
10603 Restrictions that can be checked at compile time result in illegalities
10604 if violated. Currently there are no other consequences of violating
10605 restrictions.
10606
10607 @sp 1
10608 @cartouche
10609 @noindent
10610 @strong{59}. The representation used by the @code{Read} and
10611 @code{Write} attributes of elementary types in terms of stream
10612 elements. See 13.13.2(9).
10613 @end cartouche
10614 @noindent
10615 The representation is the in-memory representation of the base type of
10616 the type, using the number of bits corresponding to the
10617 @code{@var{type}'Size} value, and the natural ordering of the machine.
10618
10619 @sp 1
10620 @cartouche
10621 @noindent
10622 @strong{60}. The names and characteristics of the numeric subtypes
10623 declared in the visible part of package @code{Standard}. See A.1(3).
10624 @end cartouche
10625 @noindent
10626 See items describing the integer and floating-point types supported.
10627
10628 @sp 1
10629 @cartouche
10630 @noindent
10631 @strong{61}. The accuracy actually achieved by the elementary
10632 functions. See A.5.1(1).
10633 @end cartouche
10634 @noindent
10635 The elementary functions correspond to the functions available in the C
10636 library. Only fast math mode is implemented.
10637
10638 @sp 1
10639 @cartouche
10640 @noindent
10641 @strong{62}. The sign of a zero result from some of the operators or
10642 functions in @code{Numerics.Generic_Elementary_Functions}, when
10643 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10644 @end cartouche
10645 @noindent
10646 The sign of zeroes follows the requirements of the IEEE 754 standard on
10647 floating-point.
10648
10649 @sp 1
10650 @cartouche
10651 @noindent
10652 @strong{63}. The value of
10653 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10654 @end cartouche
10655 @noindent
10656 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10657
10658 @sp 1
10659 @cartouche
10660 @noindent
10661 @strong{64}. The value of
10662 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10663 @end cartouche
10664 @noindent
10665 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10666
10667 @sp 1
10668 @cartouche
10669 @noindent
10670 @strong{65}. The algorithms for random number generation. See
10671 A.5.2(32).
10672 @end cartouche
10673 @noindent
10674 The algorithm is the Mersenne Twister, as documented in the source file
10675 @file{s-rannum.adb}. This version of the algorithm has a period of
10676 2**19937-1.
10677
10678 @sp 1
10679 @cartouche
10680 @noindent
10681 @strong{66}. The string representation of a random number generator's
10682 state. See A.5.2(38).
10683 @end cartouche
10684 @noindent
10685 The value returned by the Image function is the concatenation of
10686 the fixed-width decimal representations of the 624 32-bit integers
10687 of the state vector.
10688
10689 @sp 1
10690 @cartouche
10691 @noindent
10692 @strong{67}. The minimum time interval between calls to the
10693 time-dependent Reset procedure that are guaranteed to initiate different
10694 random number sequences. See A.5.2(45).
10695 @end cartouche
10696 @noindent
10697 The minimum period between reset calls to guarantee distinct series of
10698 random numbers is one microsecond.
10699
10700 @sp 1
10701 @cartouche
10702 @noindent
10703 @strong{68}. The values of the @code{Model_Mantissa},
10704 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10705 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10706 Annex is not supported. See A.5.3(72).
10707 @end cartouche
10708 @noindent
10709 Run the compiler with @option{-gnatS} to produce a listing of package
10710 @code{Standard}, has the values of all numeric attributes.
10711
10712 @sp 1
10713 @cartouche
10714 @noindent
10715 @strong{69}. Any implementation-defined characteristics of the
10716 input-output packages. See A.7(14).
10717 @end cartouche
10718 @noindent
10719 There are no special implementation defined characteristics for these
10720 packages.
10721
10722 @sp 1
10723 @cartouche
10724 @noindent
10725 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10726 A.9(10).
10727 @end cartouche
10728 @noindent
10729 All type representations are contiguous, and the @code{Buffer_Size} is
10730 the value of @code{@var{type}'Size} rounded up to the next storage unit
10731 boundary.
10732
10733 @sp 1
10734 @cartouche
10735 @noindent
10736 @strong{71}. External files for standard input, standard output, and
10737 standard error See A.10(5).
10738 @end cartouche
10739 @noindent
10740 These files are mapped onto the files provided by the C streams
10741 libraries. See source file @file{i-cstrea.ads} for further details.
10742
10743 @sp 1
10744 @cartouche
10745 @noindent
10746 @strong{72}. The accuracy of the value produced by @code{Put}. See
10747 A.10.9(36).
10748 @end cartouche
10749 @noindent
10750 If more digits are requested in the output than are represented by the
10751 precision of the value, zeroes are output in the corresponding least
10752 significant digit positions.
10753
10754 @sp 1
10755 @cartouche
10756 @noindent
10757 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10758 @code{Command_Name}. See A.15(1).
10759 @end cartouche
10760 @noindent
10761 These are mapped onto the @code{argv} and @code{argc} parameters of the
10762 main program in the natural manner.
10763
10764 @sp 1
10765 @cartouche
10766 @noindent
10767 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10768 @code{Create_Directory}. See A.16(56).
10769 @end cartouche
10770 @noindent
10771 The @code{Form} parameter is not used.
10772
10773 @sp 1
10774 @cartouche
10775 @noindent
10776 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10777 @code{Create_Path}. See A.16(60).
10778 @end cartouche
10779 @noindent
10780 The @code{Form} parameter is not used.
10781
10782 @sp 1
10783 @cartouche
10784 @noindent
10785 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10786 @code{Copy_File}. See A.16(68).
10787 @end cartouche
10788 @noindent
10789 The @code{Form} parameter is case-insensitive.
10790
10791 Two fields are recognized in the @code{Form} parameter:
10792
10793 @table @code
10794
10795 @item preserve=<value>
10796
10797 @item mode=<value>
10798
10799 @end table
10800
10801 @noindent
10802 <value> starts immediately after the character '=' and ends with the
10803 character immediately preceding the next comma (',') or with the last
10804 character of the parameter.
10805
10806 The only possible values for preserve= are:
10807
10808 @table @code
10809
10810 @item no_attributes
10811 Do not try to preserve any file attributes. This is the default if no
10812 preserve= is found in Form.
10813
10814 @item all_attributes
10815 Try to preserve all file attributes (timestamps, access rights).
10816
10817 @item timestamps
10818 Preserve the timestamp of the copied file, but not the other file attributes.
10819
10820 @end table
10821
10822 @noindent
10823 The only possible values for mode= are:
10824
10825 @table @code
10826
10827 @item copy
10828 Only do the copy if the destination file does not already exist. If it already
10829 exists, Copy_File fails.
10830
10831 @item overwrite
10832 Copy the file in all cases. Overwrite an already existing destination file.
10833
10834 @item append
10835 Append the original file to the destination file. If the destination file does
10836 not exist, the destination file is a copy of the source file. When mode=append,
10837 the field preserve=, if it exists, is not taken into account.
10838
10839 @end table
10840
10841 @noindent
10842 If the Form parameter includes one or both of the fields and the value or
10843 values are incorrect, Copy_file fails with Use_Error.
10844
10845 Examples of correct Forms:
10846
10847 @smallexample
10848 Form => "preserve=no_attributes,mode=overwrite" (the default)
10849 Form => "mode=append"
10850 Form => "mode=copy, preserve=all_attributes"
10851 @end smallexample
10852
10853 @noindent
10854 Examples of incorrect Forms
10855
10856 @smallexample
10857 Form => "preserve=junk"
10858 Form => "mode=internal, preserve=timestamps"
10859 @end smallexample
10860
10861 @sp 1
10862 @cartouche
10863 @noindent
10864 @strong{77}. Implementation-defined convention names. See B.1(11).
10865 @end cartouche
10866 @noindent
10867 The following convention names are supported
10868
10869 @table @code
10870 @item Ada
10871 Ada
10872 @item Ada_Pass_By_Copy
10873 Allowed for any types except by-reference types such as limited
10874 records. Compatible with convention Ada, but causes any parameters
10875 with this convention to be passed by copy.
10876 @item Ada_Pass_By_Reference
10877 Allowed for any types except by-copy types such as scalars.
10878 Compatible with convention Ada, but causes any parameters
10879 with this convention to be passed by reference.
10880 @item Assembler
10881 Assembly language
10882 @item Asm
10883 Synonym for Assembler
10884 @item Assembly
10885 Synonym for Assembler
10886 @item C
10887 C
10888 @item C_Pass_By_Copy
10889 Allowed only for record types, like C, but also notes that record
10890 is to be passed by copy rather than reference.
10891 @item COBOL
10892 COBOL
10893 @item C_Plus_Plus (or CPP)
10894 C++
10895 @item Default
10896 Treated the same as C
10897 @item External
10898 Treated the same as C
10899 @item Fortran
10900 Fortran
10901 @item Intrinsic
10902 For support of pragma @code{Import} with convention Intrinsic, see
10903 separate section on Intrinsic Subprograms.
10904 @item Stdcall
10905 Stdcall (used for Windows implementations only). This convention correspond
10906 to the WINAPI (previously called Pascal convention) C/C++ convention under
10907 Windows. A routine with this convention cleans the stack before
10908 exit. This pragma cannot be applied to a dispatching call.
10909 @item DLL
10910 Synonym for Stdcall
10911 @item Win32
10912 Synonym for Stdcall
10913 @item Stubbed
10914 Stubbed is a special convention used to indicate that the body of the
10915 subprogram will be entirely ignored. Any call to the subprogram
10916 is converted into a raise of the @code{Program_Error} exception. If a
10917 pragma @code{Import} specifies convention @code{stubbed} then no body need
10918 be present at all. This convention is useful during development for the
10919 inclusion of subprograms whose body has not yet been written.
10920
10921 @end table
10922 @noindent
10923 In addition, all otherwise unrecognized convention names are also
10924 treated as being synonymous with convention C@. In all implementations
10925 except for VMS, use of such other names results in a warning. In VMS
10926 implementations, these names are accepted silently.
10927
10928 @sp 1
10929 @cartouche
10930 @noindent
10931 @strong{78}. The meaning of link names. See B.1(36).
10932 @end cartouche
10933 @noindent
10934 Link names are the actual names used by the linker.
10935
10936 @sp 1
10937 @cartouche
10938 @noindent
10939 @strong{79}. The manner of choosing link names when neither the link
10940 name nor the address of an imported or exported entity is specified. See
10941 B.1(36).
10942 @end cartouche
10943 @noindent
10944 The default linker name is that which would be assigned by the relevant
10945 external language, interpreting the Ada name as being in all lower case
10946 letters.
10947
10948 @sp 1
10949 @cartouche
10950 @noindent
10951 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10952 @end cartouche
10953 @noindent
10954 The string passed to @code{Linker_Options} is presented uninterpreted as
10955 an argument to the link command, unless it contains ASCII.NUL characters.
10956 NUL characters if they appear act as argument separators, so for example
10957
10958 @smallexample @c ada
10959 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10960 @end smallexample
10961
10962 @noindent
10963 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10964 linker. The order of linker options is preserved for a given unit. The final
10965 list of options passed to the linker is in reverse order of the elaboration
10966 order. For example, linker options for a body always appear before the options
10967 from the corresponding package spec.
10968
10969 @sp 1
10970 @cartouche
10971 @noindent
10972 @strong{81}. The contents of the visible part of package
10973 @code{Interfaces} and its language-defined descendants. See B.2(1).
10974 @end cartouche
10975 @noindent
10976 See files with prefix @file{i-} in the distributed library.
10977
10978 @sp 1
10979 @cartouche
10980 @noindent
10981 @strong{82}. Implementation-defined children of package
10982 @code{Interfaces}. The contents of the visible part of package
10983 @code{Interfaces}. See B.2(11).
10984 @end cartouche
10985 @noindent
10986 See files with prefix @file{i-} in the distributed library.
10987
10988 @sp 1
10989 @cartouche
10990 @noindent
10991 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10992 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10993 @code{COBOL_Character}; and the initialization of the variables
10994 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10995 @code{Interfaces.COBOL}. See B.4(50).
10996 @end cartouche
10997 @noindent
10998 @table @code
10999 @item Floating
11000 Float
11001 @item Long_Floating
11002 (Floating) Long_Float
11003 @item Binary
11004 Integer
11005 @item Long_Binary
11006 Long_Long_Integer
11007 @item Decimal_Element
11008 Character
11009 @item COBOL_Character
11010 Character
11011 @end table
11012
11013 @noindent
11014 For initialization, see the file @file{i-cobol.ads} in the distributed library.
11015
11016 @sp 1
11017 @cartouche
11018 @noindent
11019 @strong{84}. Support for access to machine instructions. See C.1(1).
11020 @end cartouche
11021 @noindent
11022 See documentation in file @file{s-maccod.ads} in the distributed library.
11023
11024 @sp 1
11025 @cartouche
11026 @noindent
11027 @strong{85}. Implementation-defined aspects of access to machine
11028 operations. See C.1(9).
11029 @end cartouche
11030 @noindent
11031 See documentation in file @file{s-maccod.ads} in the distributed library.
11032
11033 @sp 1
11034 @cartouche
11035 @noindent
11036 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
11037 @end cartouche
11038 @noindent
11039 Interrupts are mapped to signals or conditions as appropriate. See
11040 definition of unit
11041 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
11042 on the interrupts supported on a particular target.
11043
11044 @sp 1
11045 @cartouche
11046 @noindent
11047 @strong{87}. Implementation-defined aspects of pre-elaboration. See
11048 C.4(13).
11049 @end cartouche
11050 @noindent
11051 GNAT does not permit a partition to be restarted without reloading,
11052 except under control of the debugger.
11053
11054 @sp 1
11055 @cartouche
11056 @noindent
11057 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
11058 @end cartouche
11059 @noindent
11060 Pragma @code{Discard_Names} causes names of enumeration literals to
11061 be suppressed. In the presence of this pragma, the Image attribute
11062 provides the image of the Pos of the literal, and Value accepts
11063 Pos values.
11064
11065 @sp 1
11066 @cartouche
11067 @noindent
11068 @strong{89}. The result of the @code{Task_Identification.Image}
11069 attribute. See C.7.1(7).
11070 @end cartouche
11071 @noindent
11072 The result of this attribute is a string that identifies
11073 the object or component that denotes a given task. If a variable @code{Var}
11074 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
11075 where the suffix
11076 is the hexadecimal representation of the virtual address of the corresponding
11077 task control block. If the variable is an array of tasks, the image of each
11078 task will have the form of an indexed component indicating the position of a
11079 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
11080 component of a record, the image of the task will have the form of a selected
11081 component. These rules are fully recursive, so that the image of a task that
11082 is a subcomponent of a composite object corresponds to the expression that
11083 designates this task.
11084 @noindent
11085 If a task is created by an allocator, its image depends on the context. If the
11086 allocator is part of an object declaration, the rules described above are used
11087 to construct its image, and this image is not affected by subsequent
11088 assignments. If the allocator appears within an expression, the image
11089 includes only the name of the task type.
11090 @noindent
11091 If the configuration pragma Discard_Names is present, or if the restriction
11092 No_Implicit_Heap_Allocation is in effect, the image reduces to
11093 the numeric suffix, that is to say the hexadecimal representation of the
11094 virtual address of the control block of the task.
11095 @sp 1
11096 @cartouche
11097 @noindent
11098 @strong{90}. The value of @code{Current_Task} when in a protected entry
11099 or interrupt handler. See C.7.1(17).
11100 @end cartouche
11101 @noindent
11102 Protected entries or interrupt handlers can be executed by any
11103 convenient thread, so the value of @code{Current_Task} is undefined.
11104
11105 @sp 1
11106 @cartouche
11107 @noindent
11108 @strong{91}. The effect of calling @code{Current_Task} from an entry
11109 body or interrupt handler. See C.7.1(19).
11110 @end cartouche
11111 @noindent
11112 The effect of calling @code{Current_Task} from an entry body or
11113 interrupt handler is to return the identification of the task currently
11114 executing the code.
11115
11116 @sp 1
11117 @cartouche
11118 @noindent
11119 @strong{92}. Implementation-defined aspects of
11120 @code{Task_Attributes}. See C.7.2(19).
11121 @end cartouche
11122 @noindent
11123 There are no implementation-defined aspects of @code{Task_Attributes}.
11124
11125 @sp 1
11126 @cartouche
11127 @noindent
11128 @strong{93}. Values of all @code{Metrics}. See D(2).
11129 @end cartouche
11130 @noindent
11131 The metrics information for GNAT depends on the performance of the
11132 underlying operating system. The sources of the run-time for tasking
11133 implementation, together with the output from @option{-gnatG} can be
11134 used to determine the exact sequence of operating systems calls made
11135 to implement various tasking constructs. Together with appropriate
11136 information on the performance of the underlying operating system,
11137 on the exact target in use, this information can be used to determine
11138 the required metrics.
11139
11140 @sp 1
11141 @cartouche
11142 @noindent
11143 @strong{94}. The declarations of @code{Any_Priority} and
11144 @code{Priority}. See D.1(11).
11145 @end cartouche
11146 @noindent
11147 See declarations in file @file{system.ads}.
11148
11149 @sp 1
11150 @cartouche
11151 @noindent
11152 @strong{95}. Implementation-defined execution resources. See D.1(15).
11153 @end cartouche
11154 @noindent
11155 There are no implementation-defined execution resources.
11156
11157 @sp 1
11158 @cartouche
11159 @noindent
11160 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
11161 access to a protected object keeps its processor busy. See D.2.1(3).
11162 @end cartouche
11163 @noindent
11164 On a multi-processor, a task that is waiting for access to a protected
11165 object does not keep its processor busy.
11166
11167 @sp 1
11168 @cartouche
11169 @noindent
11170 @strong{97}. The affect of implementation defined execution resources
11171 on task dispatching. See D.2.1(9).
11172 @end cartouche
11173 @noindent
11174 Tasks map to threads in the threads package used by GNAT@. Where possible
11175 and appropriate, these threads correspond to native threads of the
11176 underlying operating system.
11177
11178 @sp 1
11179 @cartouche
11180 @noindent
11181 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
11182 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
11183 @end cartouche
11184 @noindent
11185 There are no implementation-defined policy-identifiers allowed in this
11186 pragma.
11187
11188 @sp 1
11189 @cartouche
11190 @noindent
11191 @strong{99}. Implementation-defined aspects of priority inversion. See
11192 D.2.2(16).
11193 @end cartouche
11194 @noindent
11195 Execution of a task cannot be preempted by the implementation processing
11196 of delay expirations for lower priority tasks.
11197
11198 @sp 1
11199 @cartouche
11200 @noindent
11201 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
11202 @end cartouche
11203 @noindent
11204 The policy is the same as that of the underlying threads implementation.
11205
11206 @sp 1
11207 @cartouche
11208 @noindent
11209 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
11210 in a pragma @code{Locking_Policy}. See D.3(4).
11211 @end cartouche
11212 @noindent
11213 The two implementation defined policies permitted in GNAT are
11214 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
11215 targets that support the @code{Inheritance_Locking} policy, locking is
11216 implemented by inheritance, i.e.@: the task owning the lock operates
11217 at a priority equal to the highest priority of any task currently
11218 requesting the lock. On targets that support the
11219 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
11220 read/write lock allowing multiple propected object functions to enter
11221 concurrently.
11222
11223 @sp 1
11224 @cartouche
11225 @noindent
11226 @strong{102}. Default ceiling priorities. See D.3(10).
11227 @end cartouche
11228 @noindent
11229 The ceiling priority of protected objects of the type
11230 @code{System.Interrupt_Priority'Last} as described in the Ada
11231 Reference Manual D.3(10),
11232
11233 @sp 1
11234 @cartouche
11235 @noindent
11236 @strong{103}. The ceiling of any protected object used internally by
11237 the implementation. See D.3(16).
11238 @end cartouche
11239 @noindent
11240 The ceiling priority of internal protected objects is
11241 @code{System.Priority'Last}.
11242
11243 @sp 1
11244 @cartouche
11245 @noindent
11246 @strong{104}. Implementation-defined queuing policies. See D.4(1).
11247 @end cartouche
11248 @noindent
11249 There are no implementation-defined queuing policies.
11250
11251 @sp 1
11252 @cartouche
11253 @noindent
11254 @strong{105}. On a multiprocessor, any conditions that cause the
11255 completion of an aborted construct to be delayed later than what is
11256 specified for a single processor. See D.6(3).
11257 @end cartouche
11258 @noindent
11259 The semantics for abort on a multi-processor is the same as on a single
11260 processor, there are no further delays.
11261
11262 @sp 1
11263 @cartouche
11264 @noindent
11265 @strong{106}. Any operations that implicitly require heap storage
11266 allocation. See D.7(8).
11267 @end cartouche
11268 @noindent
11269 The only operation that implicitly requires heap storage allocation is
11270 task creation.
11271
11272 @sp 1
11273 @cartouche
11274 @noindent
11275 @strong{107}. Implementation-defined aspects of pragma
11276 @code{Restrictions}. See D.7(20).
11277 @end cartouche
11278 @noindent
11279 There are no such implementation-defined aspects.
11280
11281 @sp 1
11282 @cartouche
11283 @noindent
11284 @strong{108}. Implementation-defined aspects of package
11285 @code{Real_Time}. See D.8(17).
11286 @end cartouche
11287 @noindent
11288 There are no implementation defined aspects of package @code{Real_Time}.
11289
11290 @sp 1
11291 @cartouche
11292 @noindent
11293 @strong{109}. Implementation-defined aspects of
11294 @code{delay_statements}. See D.9(8).
11295 @end cartouche
11296 @noindent
11297 Any difference greater than one microsecond will cause the task to be
11298 delayed (see D.9(7)).
11299
11300 @sp 1
11301 @cartouche
11302 @noindent
11303 @strong{110}. The upper bound on the duration of interrupt blocking
11304 caused by the implementation. See D.12(5).
11305 @end cartouche
11306 @noindent
11307 The upper bound is determined by the underlying operating system. In
11308 no cases is it more than 10 milliseconds.
11309
11310 @sp 1
11311 @cartouche
11312 @noindent
11313 @strong{111}. The means for creating and executing distributed
11314 programs. See E(5).
11315 @end cartouche
11316 @noindent
11317 The GLADE package provides a utility GNATDIST for creating and executing
11318 distributed programs. See the GLADE reference manual for further details.
11319
11320 @sp 1
11321 @cartouche
11322 @noindent
11323 @strong{112}. Any events that can result in a partition becoming
11324 inaccessible. See E.1(7).
11325 @end cartouche
11326 @noindent
11327 See the GLADE reference manual for full details on such events.
11328
11329 @sp 1
11330 @cartouche
11331 @noindent
11332 @strong{113}. The scheduling policies, treatment of priorities, and
11333 management of shared resources between partitions in certain cases. See
11334 E.1(11).
11335 @end cartouche
11336 @noindent
11337 See the GLADE reference manual for full details on these aspects of
11338 multi-partition execution.
11339
11340 @sp 1
11341 @cartouche
11342 @noindent
11343 @strong{114}. Events that cause the version of a compilation unit to
11344 change. See E.3(5).
11345 @end cartouche
11346 @noindent
11347 Editing the source file of a compilation unit, or the source files of
11348 any units on which it is dependent in a significant way cause the version
11349 to change. No other actions cause the version number to change. All changes
11350 are significant except those which affect only layout, capitalization or
11351 comments.
11352
11353 @sp 1
11354 @cartouche
11355 @noindent
11356 @strong{115}. Whether the execution of the remote subprogram is
11357 immediately aborted as a result of cancellation. See E.4(13).
11358 @end cartouche
11359 @noindent
11360 See the GLADE reference manual for details on the effect of abort in
11361 a distributed application.
11362
11363 @sp 1
11364 @cartouche
11365 @noindent
11366 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
11367 @end cartouche
11368 @noindent
11369 See the GLADE reference manual for a full description of all implementation
11370 defined aspects of the PCS@.
11371
11372 @sp 1
11373 @cartouche
11374 @noindent
11375 @strong{117}. Implementation-defined interfaces in the PCS@. See
11376 E.5(26).
11377 @end cartouche
11378 @noindent
11379 See the GLADE reference manual for a full description of all
11380 implementation defined interfaces.
11381
11382 @sp 1
11383 @cartouche
11384 @noindent
11385 @strong{118}. The values of named numbers in the package
11386 @code{Decimal}. See F.2(7).
11387 @end cartouche
11388 @noindent
11389 @table @code
11390 @item Max_Scale
11391 +18
11392 @item Min_Scale
11393 -18
11394 @item Min_Delta
11395 1.0E-18
11396 @item Max_Delta
11397 1.0E+18
11398 @item Max_Decimal_Digits
11399 18
11400 @end table
11401
11402 @sp 1
11403 @cartouche
11404 @noindent
11405 @strong{119}. The value of @code{Max_Picture_Length} in the package
11406 @code{Text_IO.Editing}. See F.3.3(16).
11407 @end cartouche
11408 @noindent
11409 64
11410
11411 @sp 1
11412 @cartouche
11413 @noindent
11414 @strong{120}. The value of @code{Max_Picture_Length} in the package
11415 @code{Wide_Text_IO.Editing}. See F.3.4(5).
11416 @end cartouche
11417 @noindent
11418 64
11419
11420 @sp 1
11421 @cartouche
11422 @noindent
11423 @strong{121}. The accuracy actually achieved by the complex elementary
11424 functions and by other complex arithmetic operations. See G.1(1).
11425 @end cartouche
11426 @noindent
11427 Standard library functions are used for the complex arithmetic
11428 operations. Only fast math mode is currently supported.
11429
11430 @sp 1
11431 @cartouche
11432 @noindent
11433 @strong{122}. The sign of a zero result (or a component thereof) from
11434 any operator or function in @code{Numerics.Generic_Complex_Types}, when
11435 @code{Real'Signed_Zeros} is True. See G.1.1(53).
11436 @end cartouche
11437 @noindent
11438 The signs of zero values are as recommended by the relevant
11439 implementation advice.
11440
11441 @sp 1
11442 @cartouche
11443 @noindent
11444 @strong{123}. The sign of a zero result (or a component thereof) from
11445 any operator or function in
11446 @code{Numerics.Generic_Complex_Elementary_Functions}, when
11447 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
11448 @end cartouche
11449 @noindent
11450 The signs of zero values are as recommended by the relevant
11451 implementation advice.
11452
11453 @sp 1
11454 @cartouche
11455 @noindent
11456 @strong{124}. Whether the strict mode or the relaxed mode is the
11457 default. See G.2(2).
11458 @end cartouche
11459 @noindent
11460 The strict mode is the default. There is no separate relaxed mode. GNAT
11461 provides a highly efficient implementation of strict mode.
11462
11463 @sp 1
11464 @cartouche
11465 @noindent
11466 @strong{125}. The result interval in certain cases of fixed-to-float
11467 conversion. See G.2.1(10).
11468 @end cartouche
11469 @noindent
11470 For cases where the result interval is implementation dependent, the
11471 accuracy is that provided by performing all operations in 64-bit IEEE
11472 floating-point format.
11473
11474 @sp 1
11475 @cartouche
11476 @noindent
11477 @strong{126}. The result of a floating point arithmetic operation in
11478 overflow situations, when the @code{Machine_Overflows} attribute of the
11479 result type is @code{False}. See G.2.1(13).
11480 @end cartouche
11481 @noindent
11482 Infinite and NaN values are produced as dictated by the IEEE
11483 floating-point standard.
11484
11485 Note that on machines that are not fully compliant with the IEEE
11486 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11487 must be used for achieving IEEE conforming behavior (although at the cost
11488 of a significant performance penalty), so infinite and NaN values are
11489 properly generated.
11490
11491 @sp 1
11492 @cartouche
11493 @noindent
11494 @strong{127}. The result interval for division (or exponentiation by a
11495 negative exponent), when the floating point hardware implements division
11496 as multiplication by a reciprocal. See G.2.1(16).
11497 @end cartouche
11498 @noindent
11499 Not relevant, division is IEEE exact.
11500
11501 @sp 1
11502 @cartouche
11503 @noindent
11504 @strong{128}. The definition of close result set, which determines the
11505 accuracy of certain fixed point multiplications and divisions. See
11506 G.2.3(5).
11507 @end cartouche
11508 @noindent
11509 Operations in the close result set are performed using IEEE long format
11510 floating-point arithmetic. The input operands are converted to
11511 floating-point, the operation is done in floating-point, and the result
11512 is converted to the target type.
11513
11514 @sp 1
11515 @cartouche
11516 @noindent
11517 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11518 point multiplication or division for which the result shall be in the
11519 perfect result set. See G.2.3(22).
11520 @end cartouche
11521 @noindent
11522 The result is only defined to be in the perfect result set if the result
11523 can be computed by a single scaling operation involving a scale factor
11524 representable in 64-bits.
11525
11526 @sp 1
11527 @cartouche
11528 @noindent
11529 @strong{130}. The result of a fixed point arithmetic operation in
11530 overflow situations, when the @code{Machine_Overflows} attribute of the
11531 result type is @code{False}. See G.2.3(27).
11532 @end cartouche
11533 @noindent
11534 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11535 types.
11536
11537 @sp 1
11538 @cartouche
11539 @noindent
11540 @strong{131}. The result of an elementary function reference in
11541 overflow situations, when the @code{Machine_Overflows} attribute of the
11542 result type is @code{False}. See G.2.4(4).
11543 @end cartouche
11544 @noindent
11545 IEEE infinite and Nan values are produced as appropriate.
11546
11547 @sp 1
11548 @cartouche
11549 @noindent
11550 @strong{132}. The value of the angle threshold, within which certain
11551 elementary functions, complex arithmetic operations, and complex
11552 elementary functions yield results conforming to a maximum relative
11553 error bound. See G.2.4(10).
11554 @end cartouche
11555 @noindent
11556 Information on this subject is not yet available.
11557
11558 @sp 1
11559 @cartouche
11560 @noindent
11561 @strong{133}. The accuracy of certain elementary functions for
11562 parameters beyond the angle threshold. See G.2.4(10).
11563 @end cartouche
11564 @noindent
11565 Information on this subject is not yet available.
11566
11567 @sp 1
11568 @cartouche
11569 @noindent
11570 @strong{134}. The result of a complex arithmetic operation or complex
11571 elementary function reference in overflow situations, when the
11572 @code{Machine_Overflows} attribute of the corresponding real type is
11573 @code{False}. See G.2.6(5).
11574 @end cartouche
11575 @noindent
11576 IEEE infinite and Nan values are produced as appropriate.
11577
11578 @sp 1
11579 @cartouche
11580 @noindent
11581 @strong{135}. The accuracy of certain complex arithmetic operations and
11582 certain complex elementary functions for parameters (or components
11583 thereof) beyond the angle threshold. See G.2.6(8).
11584 @end cartouche
11585 @noindent
11586 Information on those subjects is not yet available.
11587
11588 @sp 1
11589 @cartouche
11590 @noindent
11591 @strong{136}. Information regarding bounded errors and erroneous
11592 execution. See H.2(1).
11593 @end cartouche
11594 @noindent
11595 Information on this subject is not yet available.
11596
11597 @sp 1
11598 @cartouche
11599 @noindent
11600 @strong{137}. Implementation-defined aspects of pragma
11601 @code{Inspection_Point}. See H.3.2(8).
11602 @end cartouche
11603 @noindent
11604 Pragma @code{Inspection_Point} ensures that the variable is live and can
11605 be examined by the debugger at the inspection point.
11606
11607 @sp 1
11608 @cartouche
11609 @noindent
11610 @strong{138}. Implementation-defined aspects of pragma
11611 @code{Restrictions}. See H.4(25).
11612 @end cartouche
11613 @noindent
11614 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11615 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11616 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11617
11618 @sp 1
11619 @cartouche
11620 @noindent
11621 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11622 H.4(27).
11623 @end cartouche
11624 @noindent
11625 There are no restrictions on pragma @code{Restrictions}.
11626
11627 @node Intrinsic Subprograms
11628 @chapter Intrinsic Subprograms
11629 @cindex Intrinsic Subprograms
11630
11631 @menu
11632 * Intrinsic Operators::
11633 * Enclosing_Entity::
11634 * Exception_Information::
11635 * Exception_Message::
11636 * Exception_Name::
11637 * File::
11638 * Line::
11639 * Shifts and Rotates::
11640 * Source_Location::
11641 @end menu
11642
11643 @noindent
11644 GNAT allows a user application program to write the declaration:
11645
11646 @smallexample @c ada
11647 pragma Import (Intrinsic, name);
11648 @end smallexample
11649
11650 @noindent
11651 providing that the name corresponds to one of the implemented intrinsic
11652 subprograms in GNAT, and that the parameter profile of the referenced
11653 subprogram meets the requirements. This chapter describes the set of
11654 implemented intrinsic subprograms, and the requirements on parameter profiles.
11655 Note that no body is supplied; as with other uses of pragma Import, the
11656 body is supplied elsewhere (in this case by the compiler itself). Note
11657 that any use of this feature is potentially non-portable, since the
11658 Ada standard does not require Ada compilers to implement this feature.
11659
11660 @node Intrinsic Operators
11661 @section Intrinsic Operators
11662 @cindex Intrinsic operator
11663
11664 @noindent
11665 All the predefined numeric operators in package Standard
11666 in @code{pragma Import (Intrinsic,..)}
11667 declarations. In the binary operator case, the operands must have the same
11668 size. The operand or operands must also be appropriate for
11669 the operator. For example, for addition, the operands must
11670 both be floating-point or both be fixed-point, and the
11671 right operand for @code{"**"} must have a root type of
11672 @code{Standard.Integer'Base}.
11673 You can use an intrinsic operator declaration as in the following example:
11674
11675 @smallexample @c ada
11676 type Int1 is new Integer;
11677 type Int2 is new Integer;
11678
11679 function "+" (X1 : Int1; X2 : Int2) return Int1;
11680 function "+" (X1 : Int1; X2 : Int2) return Int2;
11681 pragma Import (Intrinsic, "+");
11682 @end smallexample
11683
11684 @noindent
11685 This declaration would permit ``mixed mode'' arithmetic on items
11686 of the differing types @code{Int1} and @code{Int2}.
11687 It is also possible to specify such operators for private types, if the
11688 full views are appropriate arithmetic types.
11689
11690 @node Enclosing_Entity
11691 @section Enclosing_Entity
11692 @cindex Enclosing_Entity
11693 @noindent
11694 This intrinsic subprogram is used in the implementation of the
11695 library routine @code{GNAT.Source_Info}. The only useful use of the
11696 intrinsic import in this case is the one in this unit, so an
11697 application program should simply call the function
11698 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11699 the current subprogram, package, task, entry, or protected subprogram.
11700
11701 @node Exception_Information
11702 @section Exception_Information
11703 @cindex Exception_Information'
11704 @noindent
11705 This intrinsic subprogram is used in the implementation of the
11706 library routine @code{GNAT.Current_Exception}. The only useful
11707 use of the intrinsic import in this case is the one in this unit,
11708 so an application program should simply call the function
11709 @code{GNAT.Current_Exception.Exception_Information} to obtain
11710 the exception information associated with the current exception.
11711
11712 @node Exception_Message
11713 @section Exception_Message
11714 @cindex Exception_Message
11715 @noindent
11716 This intrinsic subprogram is used in the implementation of the
11717 library routine @code{GNAT.Current_Exception}. The only useful
11718 use of the intrinsic import in this case is the one in this unit,
11719 so an application program should simply call the function
11720 @code{GNAT.Current_Exception.Exception_Message} to obtain
11721 the message associated with the current exception.
11722
11723 @node Exception_Name
11724 @section Exception_Name
11725 @cindex Exception_Name
11726 @noindent
11727 This intrinsic subprogram is used in the implementation of the
11728 library routine @code{GNAT.Current_Exception}. The only useful
11729 use of the intrinsic import in this case is the one in this unit,
11730 so an application program should simply call the function
11731 @code{GNAT.Current_Exception.Exception_Name} to obtain
11732 the name of the current exception.
11733
11734 @node File
11735 @section File
11736 @cindex File
11737 @noindent
11738 This intrinsic subprogram is used in the implementation of the
11739 library routine @code{GNAT.Source_Info}. The only useful use of the
11740 intrinsic import in this case is the one in this unit, so an
11741 application program should simply call the function
11742 @code{GNAT.Source_Info.File} to obtain the name of the current
11743 file.
11744
11745 @node Line
11746 @section Line
11747 @cindex Line
11748 @noindent
11749 This intrinsic subprogram is used in the implementation of the
11750 library routine @code{GNAT.Source_Info}. The only useful use of the
11751 intrinsic import in this case is the one in this unit, so an
11752 application program should simply call the function
11753 @code{GNAT.Source_Info.Line} to obtain the number of the current
11754 source line.
11755
11756 @node Shifts and Rotates
11757 @section Shifts and Rotates
11758 @cindex Shift_Left
11759 @cindex Shift_Right
11760 @cindex Shift_Right_Arithmetic
11761 @cindex Rotate_Left
11762 @cindex Rotate_Right
11763 @noindent
11764 In standard Ada, the shift and rotate functions are available only
11765 for the predefined modular types in package @code{Interfaces}. However, in
11766 GNAT it is possible to define these functions for any integer
11767 type (signed or modular), as in this example:
11768
11769 @smallexample @c ada
11770 function Shift_Left
11771 (Value : T;
11772 Amount : Natural)
11773 return T;
11774 @end smallexample
11775
11776 @noindent
11777 The function name must be one of
11778 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11779 Rotate_Right. T must be an integer type. T'Size must be
11780 8, 16, 32 or 64 bits; if T is modular, the modulus
11781 must be 2**8, 2**16, 2**32 or 2**64.
11782 The result type must be the same as the type of @code{Value}.
11783 The shift amount must be Natural.
11784 The formal parameter names can be anything.
11785
11786 @node Source_Location
11787 @section Source_Location
11788 @cindex Source_Location
11789 @noindent
11790 This intrinsic subprogram is used in the implementation of the
11791 library routine @code{GNAT.Source_Info}. The only useful use of the
11792 intrinsic import in this case is the one in this unit, so an
11793 application program should simply call the function
11794 @code{GNAT.Source_Info.Source_Location} to obtain the current
11795 source file location.
11796
11797 @node Representation Clauses and Pragmas
11798 @chapter Representation Clauses and Pragmas
11799 @cindex Representation Clauses
11800
11801 @menu
11802 * Alignment Clauses::
11803 * Size Clauses::
11804 * Storage_Size Clauses::
11805 * Size of Variant Record Objects::
11806 * Biased Representation ::
11807 * Value_Size and Object_Size Clauses::
11808 * Component_Size Clauses::
11809 * Bit_Order Clauses::
11810 * Effect of Bit_Order on Byte Ordering::
11811 * Pragma Pack for Arrays::
11812 * Pragma Pack for Records::
11813 * Record Representation Clauses::
11814 * Enumeration Clauses::
11815 * Address Clauses::
11816 * Effect of Convention on Representation::
11817 * Determining the Representations chosen by GNAT::
11818 @end menu
11819
11820 @noindent
11821 @cindex Representation Clause
11822 @cindex Representation Pragma
11823 @cindex Pragma, representation
11824 This section describes the representation clauses accepted by GNAT, and
11825 their effect on the representation of corresponding data objects.
11826
11827 GNAT fully implements Annex C (Systems Programming). This means that all
11828 the implementation advice sections in chapter 13 are fully implemented.
11829 However, these sections only require a minimal level of support for
11830 representation clauses. GNAT provides much more extensive capabilities,
11831 and this section describes the additional capabilities provided.
11832
11833 @node Alignment Clauses
11834 @section Alignment Clauses
11835 @cindex Alignment Clause
11836
11837 @noindent
11838 GNAT requires that all alignment clauses specify a power of 2, and all
11839 default alignments are always a power of 2. The default alignment
11840 values are as follows:
11841
11842 @itemize @bullet
11843 @item @emph{Primitive Types}.
11844 For primitive types, the alignment is the minimum of the actual size of
11845 objects of the type divided by @code{Storage_Unit},
11846 and the maximum alignment supported by the target.
11847 (This maximum alignment is given by the GNAT-specific attribute
11848 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11849 @cindex @code{Maximum_Alignment} attribute
11850 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11851 default alignment will be 8 on any target that supports alignments
11852 this large, but on some targets, the maximum alignment may be smaller
11853 than 8, in which case objects of type @code{Long_Float} will be maximally
11854 aligned.
11855
11856 @item @emph{Arrays}.
11857 For arrays, the alignment is equal to the alignment of the component type
11858 for the normal case where no packing or component size is given. If the
11859 array is packed, and the packing is effective (see separate section on
11860 packed arrays), then the alignment will be one for long packed arrays,
11861 or arrays whose length is not known at compile time. For short packed
11862 arrays, which are handled internally as modular types, the alignment
11863 will be as described for primitive types, e.g.@: a packed array of length
11864 31 bits will have an object size of four bytes, and an alignment of 4.
11865
11866 @item @emph{Records}.
11867 For the normal non-packed case, the alignment of a record is equal to
11868 the maximum alignment of any of its components. For tagged records, this
11869 includes the implicit access type used for the tag. If a pragma @code{Pack}
11870 is used and all components are packable (see separate section on pragma
11871 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11872 record makes it profitable to increase it.
11873
11874 A special case is when:
11875 @itemize @bullet
11876 @item
11877 the size of the record is given explicitly, or a
11878 full record representation clause is given, and
11879 @item
11880 the size of the record is 2, 4, or 8 bytes.
11881 @end itemize
11882 @noindent
11883 In this case, an alignment is chosen to match the
11884 size of the record. For example, if we have:
11885
11886 @smallexample @c ada
11887 type Small is record
11888 A, B : Character;
11889 end record;
11890 for Small'Size use 16;
11891 @end smallexample
11892
11893 @noindent
11894 then the default alignment of the record type @code{Small} is 2, not 1. This
11895 leads to more efficient code when the record is treated as a unit, and also
11896 allows the type to specified as @code{Atomic} on architectures requiring
11897 strict alignment.
11898
11899 @end itemize
11900
11901 @noindent
11902 An alignment clause may specify a larger alignment than the default value
11903 up to some maximum value dependent on the target (obtainable by using the
11904 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11905 a smaller alignment than the default value for enumeration, integer and
11906 fixed point types, as well as for record types, for example
11907
11908 @smallexample @c ada
11909 type V is record
11910 A : Integer;
11911 end record;
11912
11913 for V'alignment use 1;
11914 @end smallexample
11915
11916 @noindent
11917 @cindex Alignment, default
11918 The default alignment for the type @code{V} is 4, as a result of the
11919 Integer field in the record, but it is permissible, as shown, to
11920 override the default alignment of the record with a smaller value.
11921
11922 @cindex Alignment, subtypes
11923 Note that according to the Ada standard, an alignment clause applies only
11924 to the first named subtype. If additional subtypes are declared, then the
11925 compiler is allowed to choose any alignment it likes, and there is no way
11926 to control this choice. Consider:
11927
11928 @smallexample @c ada
11929 type R is range 1 .. 10_000;
11930 for R'Alignment use 1;
11931 subtype RS is R range 1 .. 1000;
11932 @end smallexample
11933
11934 @noindent
11935 The alignment clause specifies an alignment of 1 for the first named subtype
11936 @code{R} but this does not necessarily apply to @code{RS}. When writing
11937 portable Ada code, you should avoid writing code that explicitly or
11938 implicitly relies on the alignment of such subtypes.
11939
11940 For the GNAT compiler, if an explicit alignment clause is given, this
11941 value is also used for any subsequent subtypes. So for GNAT, in the
11942 above example, you can count on the alignment of @code{RS} being 1. But this
11943 assumption is non-portable, and other compilers may choose different
11944 alignments for the subtype @code{RS}.
11945
11946 @node Size Clauses
11947 @section Size Clauses
11948 @cindex Size Clause
11949
11950 @noindent
11951 The default size for a type @code{T} is obtainable through the
11952 language-defined attribute @code{T'Size} and also through the
11953 equivalent GNAT-defined attribute @code{T'Value_Size}.
11954 For objects of type @code{T}, GNAT will generally increase the type size
11955 so that the object size (obtainable through the GNAT-defined attribute
11956 @code{T'Object_Size})
11957 is a multiple of @code{T'Alignment * Storage_Unit}.
11958 For example
11959
11960 @smallexample @c ada
11961 type Smallint is range 1 .. 6;
11962
11963 type Rec is record
11964 Y1 : integer;
11965 Y2 : boolean;
11966 end record;
11967 @end smallexample
11968
11969 @noindent
11970 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11971 as specified by the RM rules,
11972 but objects of this type will have a size of 8
11973 (@code{Smallint'Object_Size} = 8),
11974 since objects by default occupy an integral number
11975 of storage units. On some targets, notably older
11976 versions of the Digital Alpha, the size of stand
11977 alone objects of this type may be 32, reflecting
11978 the inability of the hardware to do byte load/stores.
11979
11980 Similarly, the size of type @code{Rec} is 40 bits
11981 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11982 the alignment is 4, so objects of this type will have
11983 their size increased to 64 bits so that it is a multiple
11984 of the alignment (in bits). This decision is
11985 in accordance with the specific Implementation Advice in RM 13.3(43):
11986
11987 @quotation
11988 A @code{Size} clause should be supported for an object if the specified
11989 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11990 to a size in storage elements that is a multiple of the object's
11991 @code{Alignment} (if the @code{Alignment} is nonzero).
11992 @end quotation
11993
11994 @noindent
11995 An explicit size clause may be used to override the default size by
11996 increasing it. For example, if we have:
11997
11998 @smallexample @c ada
11999 type My_Boolean is new Boolean;
12000 for My_Boolean'Size use 32;
12001 @end smallexample
12002
12003 @noindent
12004 then values of this type will always be 32 bits long. In the case of
12005 discrete types, the size can be increased up to 64 bits, with the effect
12006 that the entire specified field is used to hold the value, sign- or
12007 zero-extended as appropriate. If more than 64 bits is specified, then
12008 padding space is allocated after the value, and a warning is issued that
12009 there are unused bits.
12010
12011 Similarly the size of records and arrays may be increased, and the effect
12012 is to add padding bits after the value. This also causes a warning message
12013 to be generated.
12014
12015 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
12016 Size in bits, this corresponds to an object of size 256 megabytes (minus
12017 one). This limitation is true on all targets. The reason for this
12018 limitation is that it improves the quality of the code in many cases
12019 if it is known that a Size value can be accommodated in an object of
12020 type Integer.
12021
12022 @node Storage_Size Clauses
12023 @section Storage_Size Clauses
12024 @cindex Storage_Size Clause
12025
12026 @noindent
12027 For tasks, the @code{Storage_Size} clause specifies the amount of space
12028 to be allocated for the task stack. This cannot be extended, and if the
12029 stack is exhausted, then @code{Storage_Error} will be raised (if stack
12030 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
12031 or a @code{Storage_Size} pragma in the task definition to set the
12032 appropriate required size. A useful technique is to include in every
12033 task definition a pragma of the form:
12034
12035 @smallexample @c ada
12036 pragma Storage_Size (Default_Stack_Size);
12037 @end smallexample
12038
12039 @noindent
12040 Then @code{Default_Stack_Size} can be defined in a global package, and
12041 modified as required. Any tasks requiring stack sizes different from the
12042 default can have an appropriate alternative reference in the pragma.
12043
12044 You can also use the @option{-d} binder switch to modify the default stack
12045 size.
12046
12047 For access types, the @code{Storage_Size} clause specifies the maximum
12048 space available for allocation of objects of the type. If this space is
12049 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
12050 In the case where the access type is declared local to a subprogram, the
12051 use of a @code{Storage_Size} clause triggers automatic use of a special
12052 predefined storage pool (@code{System.Pool_Size}) that ensures that all
12053 space for the pool is automatically reclaimed on exit from the scope in
12054 which the type is declared.
12055
12056 A special case recognized by the compiler is the specification of a
12057 @code{Storage_Size} of zero for an access type. This means that no
12058 items can be allocated from the pool, and this is recognized at compile
12059 time, and all the overhead normally associated with maintaining a fixed
12060 size storage pool is eliminated. Consider the following example:
12061
12062 @smallexample @c ada
12063 procedure p is
12064 type R is array (Natural) of Character;
12065 type P is access all R;
12066 for P'Storage_Size use 0;
12067 -- Above access type intended only for interfacing purposes
12068
12069 y : P;
12070
12071 procedure g (m : P);
12072 pragma Import (C, g);
12073
12074 -- @dots{}
12075
12076 begin
12077 -- @dots{}
12078 y := new R;
12079 end;
12080 @end smallexample
12081
12082 @noindent
12083 As indicated in this example, these dummy storage pools are often useful in
12084 connection with interfacing where no object will ever be allocated. If you
12085 compile the above example, you get the warning:
12086
12087 @smallexample
12088 p.adb:16:09: warning: allocation from empty storage pool
12089 p.adb:16:09: warning: Storage_Error will be raised at run time
12090 @end smallexample
12091
12092 @noindent
12093 Of course in practice, there will not be any explicit allocators in the
12094 case of such an access declaration.
12095
12096 @node Size of Variant Record Objects
12097 @section Size of Variant Record Objects
12098 @cindex Size, variant record objects
12099 @cindex Variant record objects, size
12100
12101 @noindent
12102 In the case of variant record objects, there is a question whether Size gives
12103 information about a particular variant, or the maximum size required
12104 for any variant. Consider the following program
12105
12106 @smallexample @c ada
12107 with Text_IO; use Text_IO;
12108 procedure q is
12109 type R1 (A : Boolean := False) is record
12110 case A is
12111 when True => X : Character;
12112 when False => null;
12113 end case;
12114 end record;
12115
12116 V1 : R1 (False);
12117 V2 : R1;
12118
12119 begin
12120 Put_Line (Integer'Image (V1'Size));
12121 Put_Line (Integer'Image (V2'Size));
12122 end q;
12123 @end smallexample
12124
12125 @noindent
12126 Here we are dealing with a variant record, where the True variant
12127 requires 16 bits, and the False variant requires 8 bits.
12128 In the above example, both V1 and V2 contain the False variant,
12129 which is only 8 bits long. However, the result of running the
12130 program is:
12131
12132 @smallexample
12133 8
12134 16
12135 @end smallexample
12136
12137 @noindent
12138 The reason for the difference here is that the discriminant value of
12139 V1 is fixed, and will always be False. It is not possible to assign
12140 a True variant value to V1, therefore 8 bits is sufficient. On the
12141 other hand, in the case of V2, the initial discriminant value is
12142 False (from the default), but it is possible to assign a True
12143 variant value to V2, therefore 16 bits must be allocated for V2
12144 in the general case, even fewer bits may be needed at any particular
12145 point during the program execution.
12146
12147 As can be seen from the output of this program, the @code{'Size}
12148 attribute applied to such an object in GNAT gives the actual allocated
12149 size of the variable, which is the largest size of any of the variants.
12150 The Ada Reference Manual is not completely clear on what choice should
12151 be made here, but the GNAT behavior seems most consistent with the
12152 language in the RM@.
12153
12154 In some cases, it may be desirable to obtain the size of the current
12155 variant, rather than the size of the largest variant. This can be
12156 achieved in GNAT by making use of the fact that in the case of a
12157 subprogram parameter, GNAT does indeed return the size of the current
12158 variant (because a subprogram has no way of knowing how much space
12159 is actually allocated for the actual).
12160
12161 Consider the following modified version of the above program:
12162
12163 @smallexample @c ada
12164 with Text_IO; use Text_IO;
12165 procedure q is
12166 type R1 (A : Boolean := False) is record
12167 case A is
12168 when True => X : Character;
12169 when False => null;
12170 end case;
12171 end record;
12172
12173 V2 : R1;
12174
12175 function Size (V : R1) return Integer is
12176 begin
12177 return V'Size;
12178 end Size;
12179
12180 begin
12181 Put_Line (Integer'Image (V2'Size));
12182 Put_Line (Integer'IMage (Size (V2)));
12183 V2 := (True, 'x');
12184 Put_Line (Integer'Image (V2'Size));
12185 Put_Line (Integer'IMage (Size (V2)));
12186 end q;
12187 @end smallexample
12188
12189 @noindent
12190 The output from this program is
12191
12192 @smallexample
12193 16
12194 8
12195 16
12196 16
12197 @end smallexample
12198
12199 @noindent
12200 Here we see that while the @code{'Size} attribute always returns
12201 the maximum size, regardless of the current variant value, the
12202 @code{Size} function does indeed return the size of the current
12203 variant value.
12204
12205 @node Biased Representation
12206 @section Biased Representation
12207 @cindex Size for biased representation
12208 @cindex Biased representation
12209
12210 @noindent
12211 In the case of scalars with a range starting at other than zero, it is
12212 possible in some cases to specify a size smaller than the default minimum
12213 value, and in such cases, GNAT uses an unsigned biased representation,
12214 in which zero is used to represent the lower bound, and successive values
12215 represent successive values of the type.
12216
12217 For example, suppose we have the declaration:
12218
12219 @smallexample @c ada
12220 type Small is range -7 .. -4;
12221 for Small'Size use 2;
12222 @end smallexample
12223
12224 @noindent
12225 Although the default size of type @code{Small} is 4, the @code{Size}
12226 clause is accepted by GNAT and results in the following representation
12227 scheme:
12228
12229 @smallexample
12230 -7 is represented as 2#00#
12231 -6 is represented as 2#01#
12232 -5 is represented as 2#10#
12233 -4 is represented as 2#11#
12234 @end smallexample
12235
12236 @noindent
12237 Biased representation is only used if the specified @code{Size} clause
12238 cannot be accepted in any other manner. These reduced sizes that force
12239 biased representation can be used for all discrete types except for
12240 enumeration types for which a representation clause is given.
12241
12242 @node Value_Size and Object_Size Clauses
12243 @section Value_Size and Object_Size Clauses
12244 @findex Value_Size
12245 @findex Object_Size
12246 @cindex Size, of objects
12247
12248 @noindent
12249 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
12250 number of bits required to hold values of type @code{T}.
12251 Although this interpretation was allowed in Ada 83, it was not required,
12252 and this requirement in practice can cause some significant difficulties.
12253 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
12254 However, in Ada 95 and Ada 2005,
12255 @code{Natural'Size} is
12256 typically 31. This means that code may change in behavior when moving
12257 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
12258
12259 @smallexample @c ada
12260 type Rec is record;
12261 A : Natural;
12262 B : Natural;
12263 end record;
12264
12265 for Rec use record
12266 at 0 range 0 .. Natural'Size - 1;
12267 at 0 range Natural'Size .. 2 * Natural'Size - 1;
12268 end record;
12269 @end smallexample
12270
12271 @noindent
12272 In the above code, since the typical size of @code{Natural} objects
12273 is 32 bits and @code{Natural'Size} is 31, the above code can cause
12274 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
12275 there are cases where the fact that the object size can exceed the
12276 size of the type causes surprises.
12277
12278 To help get around this problem GNAT provides two implementation
12279 defined attributes, @code{Value_Size} and @code{Object_Size}. When
12280 applied to a type, these attributes yield the size of the type
12281 (corresponding to the RM defined size attribute), and the size of
12282 objects of the type respectively.
12283
12284 The @code{Object_Size} is used for determining the default size of
12285 objects and components. This size value can be referred to using the
12286 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
12287 the basis of the determination of the size. The backend is free to
12288 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
12289 character might be stored in 32 bits on a machine with no efficient
12290 byte access instructions such as the Alpha.
12291
12292 The default rules for the value of @code{Object_Size} for
12293 discrete types are as follows:
12294
12295 @itemize @bullet
12296 @item
12297 The @code{Object_Size} for base subtypes reflect the natural hardware
12298 size in bits (run the compiler with @option{-gnatS} to find those values
12299 for numeric types). Enumeration types and fixed-point base subtypes have
12300 8, 16, 32 or 64 bits for this size, depending on the range of values
12301 to be stored.
12302
12303 @item
12304 The @code{Object_Size} of a subtype is the same as the
12305 @code{Object_Size} of
12306 the type from which it is obtained.
12307
12308 @item
12309 The @code{Object_Size} of a derived base type is copied from the parent
12310 base type, and the @code{Object_Size} of a derived first subtype is copied
12311 from the parent first subtype.
12312 @end itemize
12313
12314 @noindent
12315 The @code{Value_Size} attribute
12316 is the (minimum) number of bits required to store a value
12317 of the type.
12318 This value is used to determine how tightly to pack
12319 records or arrays with components of this type, and also affects
12320 the semantics of unchecked conversion (unchecked conversions where
12321 the @code{Value_Size} values differ generate a warning, and are potentially
12322 target dependent).
12323
12324 The default rules for the value of @code{Value_Size} are as follows:
12325
12326 @itemize @bullet
12327 @item
12328 The @code{Value_Size} for a base subtype is the minimum number of bits
12329 required to store all values of the type (including the sign bit
12330 only if negative values are possible).
12331
12332 @item
12333 If a subtype statically matches the first subtype of a given type, then it has
12334 by default the same @code{Value_Size} as the first subtype. This is a
12335 consequence of RM 13.1(14) (``if two subtypes statically match,
12336 then their subtype-specific aspects are the same''.)
12337
12338 @item
12339 All other subtypes have a @code{Value_Size} corresponding to the minimum
12340 number of bits required to store all values of the subtype. For
12341 dynamic bounds, it is assumed that the value can range down or up
12342 to the corresponding bound of the ancestor
12343 @end itemize
12344
12345 @noindent
12346 The RM defined attribute @code{Size} corresponds to the
12347 @code{Value_Size} attribute.
12348
12349 The @code{Size} attribute may be defined for a first-named subtype. This sets
12350 the @code{Value_Size} of
12351 the first-named subtype to the given value, and the
12352 @code{Object_Size} of this first-named subtype to the given value padded up
12353 to an appropriate boundary. It is a consequence of the default rules
12354 above that this @code{Object_Size} will apply to all further subtypes. On the
12355 other hand, @code{Value_Size} is affected only for the first subtype, any
12356 dynamic subtypes obtained from it directly, and any statically matching
12357 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
12358
12359 @code{Value_Size} and
12360 @code{Object_Size} may be explicitly set for any subtype using
12361 an attribute definition clause. Note that the use of these attributes
12362 can cause the RM 13.1(14) rule to be violated. If two access types
12363 reference aliased objects whose subtypes have differing @code{Object_Size}
12364 values as a result of explicit attribute definition clauses, then it
12365 is erroneous to convert from one access subtype to the other.
12366
12367 At the implementation level, Esize stores the Object_Size and the
12368 RM_Size field stores the @code{Value_Size} (and hence the value of the
12369 @code{Size} attribute,
12370 which, as noted above, is equivalent to @code{Value_Size}).
12371
12372 To get a feel for the difference, consider the following examples (note
12373 that in each case the base is @code{Short_Short_Integer} with a size of 8):
12374
12375 @smallexample
12376 Object_Size Value_Size
12377
12378 type x1 is range 0 .. 5; 8 3
12379
12380 type x2 is range 0 .. 5;
12381 for x2'size use 12; 16 12
12382
12383 subtype x3 is x2 range 0 .. 3; 16 2
12384
12385 subtype x4 is x2'base range 0 .. 10; 8 4
12386
12387 subtype x5 is x2 range 0 .. dynamic; 16 3*
12388
12389 subtype x6 is x2'base range 0 .. dynamic; 8 3*
12390
12391 @end smallexample
12392
12393 @noindent
12394 Note: the entries marked ``3*'' are not actually specified by the Ada
12395 Reference Manual, but it seems in the spirit of the RM rules to allocate
12396 the minimum number of bits (here 3, given the range for @code{x2})
12397 known to be large enough to hold the given range of values.
12398
12399 So far, so good, but GNAT has to obey the RM rules, so the question is
12400 under what conditions must the RM @code{Size} be used.
12401 The following is a list
12402 of the occasions on which the RM @code{Size} must be used:
12403
12404 @itemize @bullet
12405 @item
12406 Component size for packed arrays or records
12407
12408 @item
12409 Value of the attribute @code{Size} for a type
12410
12411 @item
12412 Warning about sizes not matching for unchecked conversion
12413 @end itemize
12414
12415 @noindent
12416 For record types, the @code{Object_Size} is always a multiple of the
12417 alignment of the type (this is true for all types). In some cases the
12418 @code{Value_Size} can be smaller. Consider:
12419
12420 @smallexample
12421 type R is record
12422 X : Integer;
12423 Y : Character;
12424 end record;
12425 @end smallexample
12426
12427 @noindent
12428 On a typical 32-bit architecture, the X component will be four bytes, and
12429 require four-byte alignment, and the Y component will be one byte. In this
12430 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
12431 required to store a value of this type, and for example, it is permissible
12432 to have a component of type R in an outer array whose component size is
12433 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
12434 since it must be rounded up so that this value is a multiple of the
12435 alignment (4 bytes = 32 bits).
12436
12437 @noindent
12438 For all other types, the @code{Object_Size}
12439 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
12440 Only @code{Size} may be specified for such types.
12441
12442 @node Component_Size Clauses
12443 @section Component_Size Clauses
12444 @cindex Component_Size Clause
12445
12446 @noindent
12447 Normally, the value specified in a component size clause must be consistent
12448 with the subtype of the array component with regard to size and alignment.
12449 In other words, the value specified must be at least equal to the size
12450 of this subtype, and must be a multiple of the alignment value.
12451
12452 In addition, component size clauses are allowed which cause the array
12453 to be packed, by specifying a smaller value. A first case is for
12454 component size values in the range 1 through 63. The value specified
12455 must not be smaller than the Size of the subtype. GNAT will accurately
12456 honor all packing requests in this range. For example, if we have:
12457
12458 @smallexample @c ada
12459 type r is array (1 .. 8) of Natural;
12460 for r'Component_Size use 31;
12461 @end smallexample
12462
12463 @noindent
12464 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
12465 Of course access to the components of such an array is considerably
12466 less efficient than if the natural component size of 32 is used.
12467 A second case is when the subtype of the component is a record type
12468 padded because of its default alignment. For example, if we have:
12469
12470 @smallexample @c ada
12471 type r is record
12472 i : Integer;
12473 j : Integer;
12474 b : Boolean;
12475 end record;
12476
12477 type a is array (1 .. 8) of r;
12478 for a'Component_Size use 72;
12479 @end smallexample
12480
12481 @noindent
12482 then the resulting array has a length of 72 bytes, instead of 96 bytes
12483 if the alignment of the record (4) was obeyed.
12484
12485 Note that there is no point in giving both a component size clause
12486 and a pragma Pack for the same array type. if such duplicate
12487 clauses are given, the pragma Pack will be ignored.
12488
12489 @node Bit_Order Clauses
12490 @section Bit_Order Clauses
12491 @cindex Bit_Order Clause
12492 @cindex bit ordering
12493 @cindex ordering, of bits
12494
12495 @noindent
12496 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12497 attribute. The specification may either correspond to the default bit
12498 order for the target, in which case the specification has no effect and
12499 places no additional restrictions, or it may be for the non-standard
12500 setting (that is the opposite of the default).
12501
12502 In the case where the non-standard value is specified, the effect is
12503 to renumber bits within each byte, but the ordering of bytes is not
12504 affected. There are certain
12505 restrictions placed on component clauses as follows:
12506
12507 @itemize @bullet
12508
12509 @item Components fitting within a single storage unit.
12510 @noindent
12511 These are unrestricted, and the effect is merely to renumber bits. For
12512 example if we are on a little-endian machine with @code{Low_Order_First}
12513 being the default, then the following two declarations have exactly
12514 the same effect:
12515
12516 @smallexample @c ada
12517 type R1 is record
12518 A : Boolean;
12519 B : Integer range 1 .. 120;
12520 end record;
12521
12522 for R1 use record
12523 A at 0 range 0 .. 0;
12524 B at 0 range 1 .. 7;
12525 end record;
12526
12527 type R2 is record
12528 A : Boolean;
12529 B : Integer range 1 .. 120;
12530 end record;
12531
12532 for R2'Bit_Order use High_Order_First;
12533
12534 for R2 use record
12535 A at 0 range 7 .. 7;
12536 B at 0 range 0 .. 6;
12537 end record;
12538 @end smallexample
12539
12540 @noindent
12541 The useful application here is to write the second declaration with the
12542 @code{Bit_Order} attribute definition clause, and know that it will be treated
12543 the same, regardless of whether the target is little-endian or big-endian.
12544
12545 @item Components occupying an integral number of bytes.
12546 @noindent
12547 These are components that exactly fit in two or more bytes. Such component
12548 declarations are allowed, but have no effect, since it is important to realize
12549 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12550 In particular, the following attempt at getting an endian-independent integer
12551 does not work:
12552
12553 @smallexample @c ada
12554 type R2 is record
12555 A : Integer;
12556 end record;
12557
12558 for R2'Bit_Order use High_Order_First;
12559
12560 for R2 use record
12561 A at 0 range 0 .. 31;
12562 end record;
12563 @end smallexample
12564
12565 @noindent
12566 This declaration will result in a little-endian integer on a
12567 little-endian machine, and a big-endian integer on a big-endian machine.
12568 If byte flipping is required for interoperability between big- and
12569 little-endian machines, this must be explicitly programmed. This capability
12570 is not provided by @code{Bit_Order}.
12571
12572 @item Components that are positioned across byte boundaries
12573 @noindent
12574 but do not occupy an integral number of bytes. Given that bytes are not
12575 reordered, such fields would occupy a non-contiguous sequence of bits
12576 in memory, requiring non-trivial code to reassemble. They are for this
12577 reason not permitted, and any component clause specifying such a layout
12578 will be flagged as illegal by GNAT@.
12579
12580 @end itemize
12581
12582 @noindent
12583 Since the misconception that Bit_Order automatically deals with all
12584 endian-related incompatibilities is a common one, the specification of
12585 a component field that is an integral number of bytes will always
12586 generate a warning. This warning may be suppressed using @code{pragma
12587 Warnings (Off)} if desired. The following section contains additional
12588 details regarding the issue of byte ordering.
12589
12590 @node Effect of Bit_Order on Byte Ordering
12591 @section Effect of Bit_Order on Byte Ordering
12592 @cindex byte ordering
12593 @cindex ordering, of bytes
12594
12595 @noindent
12596 In this section we will review the effect of the @code{Bit_Order} attribute
12597 definition clause on byte ordering. Briefly, it has no effect at all, but
12598 a detailed example will be helpful. Before giving this
12599 example, let us review the precise
12600 definition of the effect of defining @code{Bit_Order}. The effect of a
12601 non-standard bit order is described in section 15.5.3 of the Ada
12602 Reference Manual:
12603
12604 @quotation
12605 2 A bit ordering is a method of interpreting the meaning of
12606 the storage place attributes.
12607 @end quotation
12608
12609 @noindent
12610 To understand the precise definition of storage place attributes in
12611 this context, we visit section 13.5.1 of the manual:
12612
12613 @quotation
12614 13 A record_representation_clause (without the mod_clause)
12615 specifies the layout. The storage place attributes (see 13.5.2)
12616 are taken from the values of the position, first_bit, and last_bit
12617 expressions after normalizing those values so that first_bit is
12618 less than Storage_Unit.
12619 @end quotation
12620
12621 @noindent
12622 The critical point here is that storage places are taken from
12623 the values after normalization, not before. So the @code{Bit_Order}
12624 interpretation applies to normalized values. The interpretation
12625 is described in the later part of the 15.5.3 paragraph:
12626
12627 @quotation
12628 2 A bit ordering is a method of interpreting the meaning of
12629 the storage place attributes. High_Order_First (known in the
12630 vernacular as ``big endian'') means that the first bit of a
12631 storage element (bit 0) is the most significant bit (interpreting
12632 the sequence of bits that represent a component as an unsigned
12633 integer value). Low_Order_First (known in the vernacular as
12634 ``little endian'') means the opposite: the first bit is the
12635 least significant.
12636 @end quotation
12637
12638 @noindent
12639 Note that the numbering is with respect to the bits of a storage
12640 unit. In other words, the specification affects only the numbering
12641 of bits within a single storage unit.
12642
12643 We can make the effect clearer by giving an example.
12644
12645 Suppose that we have an external device which presents two bytes, the first
12646 byte presented, which is the first (low addressed byte) of the two byte
12647 record is called Master, and the second byte is called Slave.
12648
12649 The left most (most significant bit is called Control for each byte, and
12650 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12651 (least significant) bit.
12652
12653 On a big-endian machine, we can write the following representation clause
12654
12655 @smallexample @c ada
12656 type Data is record
12657 Master_Control : Bit;
12658 Master_V1 : Bit;
12659 Master_V2 : Bit;
12660 Master_V3 : Bit;
12661 Master_V4 : Bit;
12662 Master_V5 : Bit;
12663 Master_V6 : Bit;
12664 Master_V7 : Bit;
12665 Slave_Control : Bit;
12666 Slave_V1 : Bit;
12667 Slave_V2 : Bit;
12668 Slave_V3 : Bit;
12669 Slave_V4 : Bit;
12670 Slave_V5 : Bit;
12671 Slave_V6 : Bit;
12672 Slave_V7 : Bit;
12673 end record;
12674
12675 for Data use record
12676 Master_Control at 0 range 0 .. 0;
12677 Master_V1 at 0 range 1 .. 1;
12678 Master_V2 at 0 range 2 .. 2;
12679 Master_V3 at 0 range 3 .. 3;
12680 Master_V4 at 0 range 4 .. 4;
12681 Master_V5 at 0 range 5 .. 5;
12682 Master_V6 at 0 range 6 .. 6;
12683 Master_V7 at 0 range 7 .. 7;
12684 Slave_Control at 1 range 0 .. 0;
12685 Slave_V1 at 1 range 1 .. 1;
12686 Slave_V2 at 1 range 2 .. 2;
12687 Slave_V3 at 1 range 3 .. 3;
12688 Slave_V4 at 1 range 4 .. 4;
12689 Slave_V5 at 1 range 5 .. 5;
12690 Slave_V6 at 1 range 6 .. 6;
12691 Slave_V7 at 1 range 7 .. 7;
12692 end record;
12693 @end smallexample
12694
12695 @noindent
12696 Now if we move this to a little endian machine, then the bit ordering within
12697 the byte is backwards, so we have to rewrite the record rep clause as:
12698
12699 @smallexample @c ada
12700 for Data use record
12701 Master_Control at 0 range 7 .. 7;
12702 Master_V1 at 0 range 6 .. 6;
12703 Master_V2 at 0 range 5 .. 5;
12704 Master_V3 at 0 range 4 .. 4;
12705 Master_V4 at 0 range 3 .. 3;
12706 Master_V5 at 0 range 2 .. 2;
12707 Master_V6 at 0 range 1 .. 1;
12708 Master_V7 at 0 range 0 .. 0;
12709 Slave_Control at 1 range 7 .. 7;
12710 Slave_V1 at 1 range 6 .. 6;
12711 Slave_V2 at 1 range 5 .. 5;
12712 Slave_V3 at 1 range 4 .. 4;
12713 Slave_V4 at 1 range 3 .. 3;
12714 Slave_V5 at 1 range 2 .. 2;
12715 Slave_V6 at 1 range 1 .. 1;
12716 Slave_V7 at 1 range 0 .. 0;
12717 end record;
12718 @end smallexample
12719
12720 @noindent
12721 It is a nuisance to have to rewrite the clause, especially if
12722 the code has to be maintained on both machines. However,
12723 this is a case that we can handle with the
12724 @code{Bit_Order} attribute if it is implemented.
12725 Note that the implementation is not required on byte addressed
12726 machines, but it is indeed implemented in GNAT.
12727 This means that we can simply use the
12728 first record clause, together with the declaration
12729
12730 @smallexample @c ada
12731 for Data'Bit_Order use High_Order_First;
12732 @end smallexample
12733
12734 @noindent
12735 and the effect is what is desired, namely the layout is exactly the same,
12736 independent of whether the code is compiled on a big-endian or little-endian
12737 machine.
12738
12739 The important point to understand is that byte ordering is not affected.
12740 A @code{Bit_Order} attribute definition never affects which byte a field
12741 ends up in, only where it ends up in that byte.
12742 To make this clear, let us rewrite the record rep clause of the previous
12743 example as:
12744
12745 @smallexample @c ada
12746 for Data'Bit_Order use High_Order_First;
12747 for Data use record
12748 Master_Control at 0 range 0 .. 0;
12749 Master_V1 at 0 range 1 .. 1;
12750 Master_V2 at 0 range 2 .. 2;
12751 Master_V3 at 0 range 3 .. 3;
12752 Master_V4 at 0 range 4 .. 4;
12753 Master_V5 at 0 range 5 .. 5;
12754 Master_V6 at 0 range 6 .. 6;
12755 Master_V7 at 0 range 7 .. 7;
12756 Slave_Control at 0 range 8 .. 8;
12757 Slave_V1 at 0 range 9 .. 9;
12758 Slave_V2 at 0 range 10 .. 10;
12759 Slave_V3 at 0 range 11 .. 11;
12760 Slave_V4 at 0 range 12 .. 12;
12761 Slave_V5 at 0 range 13 .. 13;
12762 Slave_V6 at 0 range 14 .. 14;
12763 Slave_V7 at 0 range 15 .. 15;
12764 end record;
12765 @end smallexample
12766
12767 @noindent
12768 This is exactly equivalent to saying (a repeat of the first example):
12769
12770 @smallexample @c ada
12771 for Data'Bit_Order use High_Order_First;
12772 for Data use record
12773 Master_Control at 0 range 0 .. 0;
12774 Master_V1 at 0 range 1 .. 1;
12775 Master_V2 at 0 range 2 .. 2;
12776 Master_V3 at 0 range 3 .. 3;
12777 Master_V4 at 0 range 4 .. 4;
12778 Master_V5 at 0 range 5 .. 5;
12779 Master_V6 at 0 range 6 .. 6;
12780 Master_V7 at 0 range 7 .. 7;
12781 Slave_Control at 1 range 0 .. 0;
12782 Slave_V1 at 1 range 1 .. 1;
12783 Slave_V2 at 1 range 2 .. 2;
12784 Slave_V3 at 1 range 3 .. 3;
12785 Slave_V4 at 1 range 4 .. 4;
12786 Slave_V5 at 1 range 5 .. 5;
12787 Slave_V6 at 1 range 6 .. 6;
12788 Slave_V7 at 1 range 7 .. 7;
12789 end record;
12790 @end smallexample
12791
12792 @noindent
12793 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12794 field. The storage place attributes are obtained by normalizing the
12795 values given so that the @code{First_Bit} value is less than 8. After
12796 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12797 we specified in the other case.
12798
12799 Now one might expect that the @code{Bit_Order} attribute might affect
12800 bit numbering within the entire record component (two bytes in this
12801 case, thus affecting which byte fields end up in), but that is not
12802 the way this feature is defined, it only affects numbering of bits,
12803 not which byte they end up in.
12804
12805 Consequently it never makes sense to specify a starting bit number
12806 greater than 7 (for a byte addressable field) if an attribute
12807 definition for @code{Bit_Order} has been given, and indeed it
12808 may be actively confusing to specify such a value, so the compiler
12809 generates a warning for such usage.
12810
12811 If you do need to control byte ordering then appropriate conditional
12812 values must be used. If in our example, the slave byte came first on
12813 some machines we might write:
12814
12815 @smallexample @c ada
12816 Master_Byte_First constant Boolean := @dots{};
12817
12818 Master_Byte : constant Natural :=
12819 1 - Boolean'Pos (Master_Byte_First);
12820 Slave_Byte : constant Natural :=
12821 Boolean'Pos (Master_Byte_First);
12822
12823 for Data'Bit_Order use High_Order_First;
12824 for Data use record
12825 Master_Control at Master_Byte range 0 .. 0;
12826 Master_V1 at Master_Byte range 1 .. 1;
12827 Master_V2 at Master_Byte range 2 .. 2;
12828 Master_V3 at Master_Byte range 3 .. 3;
12829 Master_V4 at Master_Byte range 4 .. 4;
12830 Master_V5 at Master_Byte range 5 .. 5;
12831 Master_V6 at Master_Byte range 6 .. 6;
12832 Master_V7 at Master_Byte range 7 .. 7;
12833 Slave_Control at Slave_Byte range 0 .. 0;
12834 Slave_V1 at Slave_Byte range 1 .. 1;
12835 Slave_V2 at Slave_Byte range 2 .. 2;
12836 Slave_V3 at Slave_Byte range 3 .. 3;
12837 Slave_V4 at Slave_Byte range 4 .. 4;
12838 Slave_V5 at Slave_Byte range 5 .. 5;
12839 Slave_V6 at Slave_Byte range 6 .. 6;
12840 Slave_V7 at Slave_Byte range 7 .. 7;
12841 end record;
12842 @end smallexample
12843
12844 @noindent
12845 Now to switch between machines, all that is necessary is
12846 to set the boolean constant @code{Master_Byte_First} in
12847 an appropriate manner.
12848
12849 @node Pragma Pack for Arrays
12850 @section Pragma Pack for Arrays
12851 @cindex Pragma Pack (for arrays)
12852
12853 @noindent
12854 Pragma @code{Pack} applied to an array has no effect unless the component type
12855 is packable. For a component type to be packable, it must be one of the
12856 following cases:
12857
12858 @itemize @bullet
12859 @item
12860 Any scalar type
12861 @item
12862 Any type whose size is specified with a size clause
12863 @item
12864 Any packed array type with a static size
12865 @item
12866 Any record type padded because of its default alignment
12867 @end itemize
12868
12869 @noindent
12870 For all these cases, if the component subtype size is in the range
12871 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12872 component size were specified giving the component subtype size.
12873 For example if we have:
12874
12875 @smallexample @c ada
12876 type r is range 0 .. 17;
12877
12878 type ar is array (1 .. 8) of r;
12879 pragma Pack (ar);
12880 @end smallexample
12881
12882 @noindent
12883 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12884 and the size of the array @code{ar} will be exactly 40 bits.
12885
12886 Note that in some cases this rather fierce approach to packing can produce
12887 unexpected effects. For example, in Ada 95 and Ada 2005,
12888 subtype @code{Natural} typically has a size of 31, meaning that if you
12889 pack an array of @code{Natural}, you get 31-bit
12890 close packing, which saves a few bits, but results in far less efficient
12891 access. Since many other Ada compilers will ignore such a packing request,
12892 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12893 might not be what is intended. You can easily remove this warning by
12894 using an explicit @code{Component_Size} setting instead, which never generates
12895 a warning, since the intention of the programmer is clear in this case.
12896
12897 GNAT treats packed arrays in one of two ways. If the size of the array is
12898 known at compile time and is less than 64 bits, then internally the array
12899 is represented as a single modular type, of exactly the appropriate number
12900 of bits. If the length is greater than 63 bits, or is not known at compile
12901 time, then the packed array is represented as an array of bytes, and the
12902 length is always a multiple of 8 bits.
12903
12904 Note that to represent a packed array as a modular type, the alignment must
12905 be suitable for the modular type involved. For example, on typical machines
12906 a 32-bit packed array will be represented by a 32-bit modular integer with
12907 an alignment of four bytes. If you explicitly override the default alignment
12908 with an alignment clause that is too small, the modular representation
12909 cannot be used. For example, consider the following set of declarations:
12910
12911 @smallexample @c ada
12912 type R is range 1 .. 3;
12913 type S is array (1 .. 31) of R;
12914 for S'Component_Size use 2;
12915 for S'Size use 62;
12916 for S'Alignment use 1;
12917 @end smallexample
12918
12919 @noindent
12920 If the alignment clause were not present, then a 62-bit modular
12921 representation would be chosen (typically with an alignment of 4 or 8
12922 bytes depending on the target). But the default alignment is overridden
12923 with the explicit alignment clause. This means that the modular
12924 representation cannot be used, and instead the array of bytes
12925 representation must be used, meaning that the length must be a multiple
12926 of 8. Thus the above set of declarations will result in a diagnostic
12927 rejecting the size clause and noting that the minimum size allowed is 64.
12928
12929 @cindex Pragma Pack (for type Natural)
12930 @cindex Pragma Pack warning
12931
12932 One special case that is worth noting occurs when the base type of the
12933 component size is 8/16/32 and the subtype is one bit less. Notably this
12934 occurs with subtype @code{Natural}. Consider:
12935
12936 @smallexample @c ada
12937 type Arr is array (1 .. 32) of Natural;
12938 pragma Pack (Arr);
12939 @end smallexample
12940
12941 @noindent
12942 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12943 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12944 Ada 83 compilers did not attempt 31 bit packing.
12945
12946 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12947 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12948 substantial unintended performance penalty when porting legacy Ada 83 code.
12949 To help prevent this, GNAT generates a warning in such cases. If you really
12950 want 31 bit packing in a case like this, you can set the component size
12951 explicitly:
12952
12953 @smallexample @c ada
12954 type Arr is array (1 .. 32) of Natural;
12955 for Arr'Component_Size use 31;
12956 @end smallexample
12957
12958 @noindent
12959 Here 31-bit packing is achieved as required, and no warning is generated,
12960 since in this case the programmer intention is clear.
12961
12962 @node Pragma Pack for Records
12963 @section Pragma Pack for Records
12964 @cindex Pragma Pack (for records)
12965
12966 @noindent
12967 Pragma @code{Pack} applied to a record will pack the components to reduce
12968 wasted space from alignment gaps and by reducing the amount of space
12969 taken by components. We distinguish between @emph{packable} components and
12970 @emph{non-packable} components.
12971 Components of the following types are considered packable:
12972 @itemize @bullet
12973 @item
12974 All primitive types are packable.
12975
12976 @item
12977 Small packed arrays, whose size does not exceed 64 bits, and where the
12978 size is statically known at compile time, are represented internally
12979 as modular integers, and so they are also packable.
12980
12981 @end itemize
12982
12983 @noindent
12984 All packable components occupy the exact number of bits corresponding to
12985 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12986 can start on an arbitrary bit boundary.
12987
12988 All other types are non-packable, they occupy an integral number of
12989 storage units, and
12990 are placed at a boundary corresponding to their alignment requirements.
12991
12992 For example, consider the record
12993
12994 @smallexample @c ada
12995 type Rb1 is array (1 .. 13) of Boolean;
12996 pragma Pack (rb1);
12997
12998 type Rb2 is array (1 .. 65) of Boolean;
12999 pragma Pack (rb2);
13000
13001 type x2 is record
13002 l1 : Boolean;
13003 l2 : Duration;
13004 l3 : Float;
13005 l4 : Boolean;
13006 l5 : Rb1;
13007 l6 : Rb2;
13008 end record;
13009 pragma Pack (x2);
13010 @end smallexample
13011
13012 @noindent
13013 The representation for the record x2 is as follows:
13014
13015 @smallexample @c ada
13016 for x2'Size use 224;
13017 for x2 use record
13018 l1 at 0 range 0 .. 0;
13019 l2 at 0 range 1 .. 64;
13020 l3 at 12 range 0 .. 31;
13021 l4 at 16 range 0 .. 0;
13022 l5 at 16 range 1 .. 13;
13023 l6 at 18 range 0 .. 71;
13024 end record;
13025 @end smallexample
13026
13027 @noindent
13028 Studying this example, we see that the packable fields @code{l1}
13029 and @code{l2} are
13030 of length equal to their sizes, and placed at specific bit boundaries (and
13031 not byte boundaries) to
13032 eliminate padding. But @code{l3} is of a non-packable float type, so
13033 it is on the next appropriate alignment boundary.
13034
13035 The next two fields are fully packable, so @code{l4} and @code{l5} are
13036 minimally packed with no gaps. However, type @code{Rb2} is a packed
13037 array that is longer than 64 bits, so it is itself non-packable. Thus
13038 the @code{l6} field is aligned to the next byte boundary, and takes an
13039 integral number of bytes, i.e.@: 72 bits.
13040
13041 @node Record Representation Clauses
13042 @section Record Representation Clauses
13043 @cindex Record Representation Clause
13044
13045 @noindent
13046 Record representation clauses may be given for all record types, including
13047 types obtained by record extension. Component clauses are allowed for any
13048 static component. The restrictions on component clauses depend on the type
13049 of the component.
13050
13051 @cindex Component Clause
13052 For all components of an elementary type, the only restriction on component
13053 clauses is that the size must be at least the 'Size value of the type
13054 (actually the Value_Size). There are no restrictions due to alignment,
13055 and such components may freely cross storage boundaries.
13056
13057 Packed arrays with a size up to and including 64 bits are represented
13058 internally using a modular type with the appropriate number of bits, and
13059 thus the same lack of restriction applies. For example, if you declare:
13060
13061 @smallexample @c ada
13062 type R is array (1 .. 49) of Boolean;
13063 pragma Pack (R);
13064 for R'Size use 49;
13065 @end smallexample
13066
13067 @noindent
13068 then a component clause for a component of type R may start on any
13069 specified bit boundary, and may specify a value of 49 bits or greater.
13070
13071 For packed bit arrays that are longer than 64 bits, there are two
13072 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
13073 including the important case of single bits or boolean values, then
13074 there are no limitations on placement of such components, and they
13075 may start and end at arbitrary bit boundaries.
13076
13077 If the component size is not a power of 2 (e.g.@: 3 or 5), then
13078 an array of this type longer than 64 bits must always be placed on
13079 on a storage unit (byte) boundary and occupy an integral number
13080 of storage units (bytes). Any component clause that does not
13081 meet this requirement will be rejected.
13082
13083 Any aliased component, or component of an aliased type, must
13084 have its normal alignment and size. A component clause that
13085 does not meet this requirement will be rejected.
13086
13087 The tag field of a tagged type always occupies an address sized field at
13088 the start of the record. No component clause may attempt to overlay this
13089 tag. When a tagged type appears as a component, the tag field must have
13090 proper alignment
13091
13092 In the case of a record extension T1, of a type T, no component clause applied
13093 to the type T1 can specify a storage location that would overlap the first
13094 T'Size bytes of the record.
13095
13096 For all other component types, including non-bit-packed arrays,
13097 the component can be placed at an arbitrary bit boundary,
13098 so for example, the following is permitted:
13099
13100 @smallexample @c ada
13101 type R is array (1 .. 10) of Boolean;
13102 for R'Size use 80;
13103
13104 type Q is record
13105 G, H : Boolean;
13106 L, M : R;
13107 end record;
13108
13109 for Q use record
13110 G at 0 range 0 .. 0;
13111 H at 0 range 1 .. 1;
13112 L at 0 range 2 .. 81;
13113 R at 0 range 82 .. 161;
13114 end record;
13115 @end smallexample
13116
13117 @noindent
13118 Note: the above rules apply to recent releases of GNAT 5.
13119 In GNAT 3, there are more severe restrictions on larger components.
13120 For non-primitive types, including packed arrays with a size greater than
13121 64 bits, component clauses must respect the alignment requirement of the
13122 type, in particular, always starting on a byte boundary, and the length
13123 must be a multiple of the storage unit.
13124
13125 @node Enumeration Clauses
13126 @section Enumeration Clauses
13127
13128 The only restriction on enumeration clauses is that the range of values
13129 must be representable. For the signed case, if one or more of the
13130 representation values are negative, all values must be in the range:
13131
13132 @smallexample @c ada
13133 System.Min_Int .. System.Max_Int
13134 @end smallexample
13135
13136 @noindent
13137 For the unsigned case, where all values are nonnegative, the values must
13138 be in the range:
13139
13140 @smallexample @c ada
13141 0 .. System.Max_Binary_Modulus;
13142 @end smallexample
13143
13144 @noindent
13145 A @emph{confirming} representation clause is one in which the values range
13146 from 0 in sequence, i.e.@: a clause that confirms the default representation
13147 for an enumeration type.
13148 Such a confirming representation
13149 is permitted by these rules, and is specially recognized by the compiler so
13150 that no extra overhead results from the use of such a clause.
13151
13152 If an array has an index type which is an enumeration type to which an
13153 enumeration clause has been applied, then the array is stored in a compact
13154 manner. Consider the declarations:
13155
13156 @smallexample @c ada
13157 type r is (A, B, C);
13158 for r use (A => 1, B => 5, C => 10);
13159 type t is array (r) of Character;
13160 @end smallexample
13161
13162 @noindent
13163 The array type t corresponds to a vector with exactly three elements and
13164 has a default size equal to @code{3*Character'Size}. This ensures efficient
13165 use of space, but means that accesses to elements of the array will incur
13166 the overhead of converting representation values to the corresponding
13167 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
13168
13169 @node Address Clauses
13170 @section Address Clauses
13171 @cindex Address Clause
13172
13173 The reference manual allows a general restriction on representation clauses,
13174 as found in RM 13.1(22):
13175
13176 @quotation
13177 An implementation need not support representation
13178 items containing nonstatic expressions, except that
13179 an implementation should support a representation item
13180 for a given entity if each nonstatic expression in the
13181 representation item is a name that statically denotes
13182 a constant declared before the entity.
13183 @end quotation
13184
13185 @noindent
13186 In practice this is applicable only to address clauses, since this is the
13187 only case in which a non-static expression is permitted by the syntax. As
13188 the AARM notes in sections 13.1 (22.a-22.h):
13189
13190 @display
13191 22.a Reason: This is to avoid the following sort of thing:
13192
13193 22.b X : Integer := F(@dots{});
13194 Y : Address := G(@dots{});
13195 for X'Address use Y;
13196
13197 22.c In the above, we have to evaluate the
13198 initialization expression for X before we
13199 know where to put the result. This seems
13200 like an unreasonable implementation burden.
13201
13202 22.d The above code should instead be written
13203 like this:
13204
13205 22.e Y : constant Address := G(@dots{});
13206 X : Integer := F(@dots{});
13207 for X'Address use Y;
13208
13209 22.f This allows the expression ``Y'' to be safely
13210 evaluated before X is created.
13211
13212 22.g The constant could be a formal parameter of mode in.
13213
13214 22.h An implementation can support other nonstatic
13215 expressions if it wants to. Expressions of type
13216 Address are hardly ever static, but their value
13217 might be known at compile time anyway in many
13218 cases.
13219 @end display
13220
13221 @noindent
13222 GNAT does indeed permit many additional cases of non-static expressions. In
13223 particular, if the type involved is elementary there are no restrictions
13224 (since in this case, holding a temporary copy of the initialization value,
13225 if one is present, is inexpensive). In addition, if there is no implicit or
13226 explicit initialization, then there are no restrictions. GNAT will reject
13227 only the case where all three of these conditions hold:
13228
13229 @itemize @bullet
13230
13231 @item
13232 The type of the item is non-elementary (e.g.@: a record or array).
13233
13234 @item
13235 There is explicit or implicit initialization required for the object.
13236 Note that access values are always implicitly initialized.
13237
13238 @item
13239 The address value is non-static. Here GNAT is more permissive than the
13240 RM, and allows the address value to be the address of a previously declared
13241 stand-alone variable, as long as it does not itself have an address clause.
13242
13243 @smallexample @c ada
13244 Anchor : Some_Initialized_Type;
13245 Overlay : Some_Initialized_Type;
13246 for Overlay'Address use Anchor'Address;
13247 @end smallexample
13248
13249 @noindent
13250 However, the prefix of the address clause cannot be an array component, or
13251 a component of a discriminated record.
13252
13253 @end itemize
13254
13255 @noindent
13256 As noted above in section 22.h, address values are typically non-static. In
13257 particular the To_Address function, even if applied to a literal value, is
13258 a non-static function call. To avoid this minor annoyance, GNAT provides
13259 the implementation defined attribute 'To_Address. The following two
13260 expressions have identical values:
13261
13262 @findex Attribute
13263 @findex To_Address
13264 @smallexample @c ada
13265 To_Address (16#1234_0000#)
13266 System'To_Address (16#1234_0000#);
13267 @end smallexample
13268
13269 @noindent
13270 except that the second form is considered to be a static expression, and
13271 thus when used as an address clause value is always permitted.
13272
13273 @noindent
13274 Additionally, GNAT treats as static an address clause that is an
13275 unchecked_conversion of a static integer value. This simplifies the porting
13276 of legacy code, and provides a portable equivalent to the GNAT attribute
13277 @code{To_Address}.
13278
13279 Another issue with address clauses is the interaction with alignment
13280 requirements. When an address clause is given for an object, the address
13281 value must be consistent with the alignment of the object (which is usually
13282 the same as the alignment of the type of the object). If an address clause
13283 is given that specifies an inappropriately aligned address value, then the
13284 program execution is erroneous.
13285
13286 Since this source of erroneous behavior can have unfortunate effects, GNAT
13287 checks (at compile time if possible, generating a warning, or at execution
13288 time with a run-time check) that the alignment is appropriate. If the
13289 run-time check fails, then @code{Program_Error} is raised. This run-time
13290 check is suppressed if range checks are suppressed, or if the special GNAT
13291 check Alignment_Check is suppressed, or if
13292 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
13293
13294 Finally, GNAT does not permit overlaying of objects of controlled types or
13295 composite types containing a controlled component. In most cases, the compiler
13296 can detect an attempt at such overlays and will generate a warning at compile
13297 time and a Program_Error exception at run time.
13298
13299 @findex Export
13300 An address clause cannot be given for an exported object. More
13301 understandably the real restriction is that objects with an address
13302 clause cannot be exported. This is because such variables are not
13303 defined by the Ada program, so there is no external object to export.
13304
13305 @findex Import
13306 It is permissible to give an address clause and a pragma Import for the
13307 same object. In this case, the variable is not really defined by the
13308 Ada program, so there is no external symbol to be linked. The link name
13309 and the external name are ignored in this case. The reason that we allow this
13310 combination is that it provides a useful idiom to avoid unwanted
13311 initializations on objects with address clauses.
13312
13313 When an address clause is given for an object that has implicit or
13314 explicit initialization, then by default initialization takes place. This
13315 means that the effect of the object declaration is to overwrite the
13316 memory at the specified address. This is almost always not what the
13317 programmer wants, so GNAT will output a warning:
13318
13319 @smallexample
13320 with System;
13321 package G is
13322 type R is record
13323 M : Integer := 0;
13324 end record;
13325
13326 Ext : R;
13327 for Ext'Address use System'To_Address (16#1234_1234#);
13328 |
13329 >>> warning: implicit initialization of "Ext" may
13330 modify overlaid storage
13331 >>> warning: use pragma Import for "Ext" to suppress
13332 initialization (RM B(24))
13333
13334 end G;
13335 @end smallexample
13336
13337 @noindent
13338 As indicated by the warning message, the solution is to use a (dummy) pragma
13339 Import to suppress this initialization. The pragma tell the compiler that the
13340 object is declared and initialized elsewhere. The following package compiles
13341 without warnings (and the initialization is suppressed):
13342
13343 @smallexample @c ada
13344 with System;
13345 package G is
13346 type R is record
13347 M : Integer := 0;
13348 end record;
13349
13350 Ext : R;
13351 for Ext'Address use System'To_Address (16#1234_1234#);
13352 pragma Import (Ada, Ext);
13353 end G;
13354 @end smallexample
13355
13356 @noindent
13357 A final issue with address clauses involves their use for overlaying
13358 variables, as in the following example:
13359 @cindex Overlaying of objects
13360
13361 @smallexample @c ada
13362 A : Integer;
13363 B : Integer;
13364 for B'Address use A'Address;
13365 @end smallexample
13366
13367 @noindent
13368 or alternatively, using the form recommended by the RM:
13369
13370 @smallexample @c ada
13371 A : Integer;
13372 Addr : constant Address := A'Address;
13373 B : Integer;
13374 for B'Address use Addr;
13375 @end smallexample
13376
13377 @noindent
13378 In both of these cases, @code{A}
13379 and @code{B} become aliased to one another via the
13380 address clause. This use of address clauses to overlay
13381 variables, achieving an effect similar to unchecked
13382 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
13383 the effect is implementation defined. Furthermore, the
13384 Ada RM specifically recommends that in a situation
13385 like this, @code{B} should be subject to the following
13386 implementation advice (RM 13.3(19)):
13387
13388 @quotation
13389 19 If the Address of an object is specified, or it is imported
13390 or exported, then the implementation should not perform
13391 optimizations based on assumptions of no aliases.
13392 @end quotation
13393
13394 @noindent
13395 GNAT follows this recommendation, and goes further by also applying
13396 this recommendation to the overlaid variable (@code{A}
13397 in the above example) in this case. This means that the overlay
13398 works "as expected", in that a modification to one of the variables
13399 will affect the value of the other.
13400
13401 @node Effect of Convention on Representation
13402 @section Effect of Convention on Representation
13403 @cindex Convention, effect on representation
13404
13405 @noindent
13406 Normally the specification of a foreign language convention for a type or
13407 an object has no effect on the chosen representation. In particular, the
13408 representation chosen for data in GNAT generally meets the standard system
13409 conventions, and for example records are laid out in a manner that is
13410 consistent with C@. This means that specifying convention C (for example)
13411 has no effect.
13412
13413 There are four exceptions to this general rule:
13414
13415 @itemize @bullet
13416
13417 @item Convention Fortran and array subtypes
13418 If pragma Convention Fortran is specified for an array subtype, then in
13419 accordance with the implementation advice in section 3.6.2(11) of the
13420 Ada Reference Manual, the array will be stored in a Fortran-compatible
13421 column-major manner, instead of the normal default row-major order.
13422
13423 @item Convention C and enumeration types
13424 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
13425 to accommodate all values of the type. For example, for the enumeration
13426 type declared by:
13427
13428 @smallexample @c ada
13429 type Color is (Red, Green, Blue);
13430 @end smallexample
13431
13432 @noindent
13433 8 bits is sufficient to store all values of the type, so by default, objects
13434 of type @code{Color} will be represented using 8 bits. However, normal C
13435 convention is to use 32 bits for all enum values in C, since enum values
13436 are essentially of type int. If pragma @code{Convention C} is specified for an
13437 Ada enumeration type, then the size is modified as necessary (usually to
13438 32 bits) to be consistent with the C convention for enum values.
13439
13440 Note that this treatment applies only to types. If Convention C is given for
13441 an enumeration object, where the enumeration type is not Convention C, then
13442 Object_Size bits are allocated. For example, for a normal enumeration type,
13443 with less than 256 elements, only 8 bits will be allocated for the object.
13444 Since this may be a surprise in terms of what C expects, GNAT will issue a
13445 warning in this situation. The warning can be suppressed by giving an explicit
13446 size clause specifying the desired size.
13447
13448 @item Convention C/Fortran and Boolean types
13449 In C, the usual convention for boolean values, that is values used for
13450 conditions, is that zero represents false, and nonzero values represent
13451 true. In Ada, the normal convention is that two specific values, typically
13452 0/1, are used to represent false/true respectively.
13453
13454 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
13455 value represents true).
13456
13457 To accommodate the Fortran and C conventions, if a pragma Convention specifies
13458 C or Fortran convention for a derived Boolean, as in the following example:
13459
13460 @smallexample @c ada
13461 type C_Switch is new Boolean;
13462 pragma Convention (C, C_Switch);
13463 @end smallexample
13464
13465 @noindent
13466 then the GNAT generated code will treat any nonzero value as true. For truth
13467 values generated by GNAT, the conventional value 1 will be used for True, but
13468 when one of these values is read, any nonzero value is treated as True.
13469
13470 @item Access types on OpenVMS
13471 For 64-bit OpenVMS systems, access types (other than those for unconstrained
13472 arrays) are 64-bits long. An exception to this rule is for the case of
13473 C-convention access types where there is no explicit size clause present (or
13474 inherited for derived types). In this case, GNAT chooses to make these
13475 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
13476 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
13477
13478 @end itemize
13479
13480 @node Determining the Representations chosen by GNAT
13481 @section Determining the Representations chosen by GNAT
13482 @cindex Representation, determination of
13483 @cindex @option{-gnatR} switch
13484
13485 @noindent
13486 Although the descriptions in this section are intended to be complete, it is
13487 often easier to simply experiment to see what GNAT accepts and what the
13488 effect is on the layout of types and objects.
13489
13490 As required by the Ada RM, if a representation clause is not accepted, then
13491 it must be rejected as illegal by the compiler. However, when a
13492 representation clause or pragma is accepted, there can still be questions
13493 of what the compiler actually does. For example, if a partial record
13494 representation clause specifies the location of some components and not
13495 others, then where are the non-specified components placed? Or if pragma
13496 @code{Pack} is used on a record, then exactly where are the resulting
13497 fields placed? The section on pragma @code{Pack} in this chapter can be
13498 used to answer the second question, but it is often easier to just see
13499 what the compiler does.
13500
13501 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13502 with this option, then the compiler will output information on the actual
13503 representations chosen, in a format similar to source representation
13504 clauses. For example, if we compile the package:
13505
13506 @smallexample @c ada
13507 package q is
13508 type r (x : boolean) is tagged record
13509 case x is
13510 when True => S : String (1 .. 100);
13511 when False => null;
13512 end case;
13513 end record;
13514
13515 type r2 is new r (false) with record
13516 y2 : integer;
13517 end record;
13518
13519 for r2 use record
13520 y2 at 16 range 0 .. 31;
13521 end record;
13522
13523 type x is record
13524 y : character;
13525 end record;
13526
13527 type x1 is array (1 .. 10) of x;
13528 for x1'component_size use 11;
13529
13530 type ia is access integer;
13531
13532 type Rb1 is array (1 .. 13) of Boolean;
13533 pragma Pack (rb1);
13534
13535 type Rb2 is array (1 .. 65) of Boolean;
13536 pragma Pack (rb2);
13537
13538 type x2 is record
13539 l1 : Boolean;
13540 l2 : Duration;
13541 l3 : Float;
13542 l4 : Boolean;
13543 l5 : Rb1;
13544 l6 : Rb2;
13545 end record;
13546 pragma Pack (x2);
13547 end q;
13548 @end smallexample
13549
13550 @noindent
13551 using the switch @option{-gnatR} we obtain the following output:
13552
13553 @smallexample
13554 Representation information for unit q
13555 -------------------------------------
13556
13557 for r'Size use ??;
13558 for r'Alignment use 4;
13559 for r use record
13560 x at 4 range 0 .. 7;
13561 _tag at 0 range 0 .. 31;
13562 s at 5 range 0 .. 799;
13563 end record;
13564
13565 for r2'Size use 160;
13566 for r2'Alignment use 4;
13567 for r2 use record
13568 x at 4 range 0 .. 7;
13569 _tag at 0 range 0 .. 31;
13570 _parent at 0 range 0 .. 63;
13571 y2 at 16 range 0 .. 31;
13572 end record;
13573
13574 for x'Size use 8;
13575 for x'Alignment use 1;
13576 for x use record
13577 y at 0 range 0 .. 7;
13578 end record;
13579
13580 for x1'Size use 112;
13581 for x1'Alignment use 1;
13582 for x1'Component_Size use 11;
13583
13584 for rb1'Size use 13;
13585 for rb1'Alignment use 2;
13586 for rb1'Component_Size use 1;
13587
13588 for rb2'Size use 72;
13589 for rb2'Alignment use 1;
13590 for rb2'Component_Size use 1;
13591
13592 for x2'Size use 224;
13593 for x2'Alignment use 4;
13594 for x2 use record
13595 l1 at 0 range 0 .. 0;
13596 l2 at 0 range 1 .. 64;
13597 l3 at 12 range 0 .. 31;
13598 l4 at 16 range 0 .. 0;
13599 l5 at 16 range 1 .. 13;
13600 l6 at 18 range 0 .. 71;
13601 end record;
13602 @end smallexample
13603
13604 @noindent
13605 The Size values are actually the Object_Size, i.e.@: the default size that
13606 will be allocated for objects of the type.
13607 The ?? size for type r indicates that we have a variant record, and the
13608 actual size of objects will depend on the discriminant value.
13609
13610 The Alignment values show the actual alignment chosen by the compiler
13611 for each record or array type.
13612
13613 The record representation clause for type r shows where all fields
13614 are placed, including the compiler generated tag field (whose location
13615 cannot be controlled by the programmer).
13616
13617 The record representation clause for the type extension r2 shows all the
13618 fields present, including the parent field, which is a copy of the fields
13619 of the parent type of r2, i.e.@: r1.
13620
13621 The component size and size clauses for types rb1 and rb2 show
13622 the exact effect of pragma @code{Pack} on these arrays, and the record
13623 representation clause for type x2 shows how pragma @code{Pack} affects
13624 this record type.
13625
13626 In some cases, it may be useful to cut and paste the representation clauses
13627 generated by the compiler into the original source to fix and guarantee
13628 the actual representation to be used.
13629
13630 @node Standard Library Routines
13631 @chapter Standard Library Routines
13632
13633 @noindent
13634 The Ada Reference Manual contains in Annex A a full description of an
13635 extensive set of standard library routines that can be used in any Ada
13636 program, and which must be provided by all Ada compilers. They are
13637 analogous to the standard C library used by C programs.
13638
13639 GNAT implements all of the facilities described in annex A, and for most
13640 purposes the description in the Ada Reference Manual, or appropriate Ada
13641 text book, will be sufficient for making use of these facilities.
13642
13643 In the case of the input-output facilities,
13644 @xref{The Implementation of Standard I/O},
13645 gives details on exactly how GNAT interfaces to the
13646 file system. For the remaining packages, the Ada Reference Manual
13647 should be sufficient. The following is a list of the packages included,
13648 together with a brief description of the functionality that is provided.
13649
13650 For completeness, references are included to other predefined library
13651 routines defined in other sections of the Ada Reference Manual (these are
13652 cross-indexed from Annex A).
13653
13654 @table @code
13655 @item Ada (A.2)
13656 This is a parent package for all the standard library packages. It is
13657 usually included implicitly in your program, and itself contains no
13658 useful data or routines.
13659
13660 @item Ada.Calendar (9.6)
13661 @code{Calendar} provides time of day access, and routines for
13662 manipulating times and durations.
13663
13664 @item Ada.Characters (A.3.1)
13665 This is a dummy parent package that contains no useful entities
13666
13667 @item Ada.Characters.Handling (A.3.2)
13668 This package provides some basic character handling capabilities,
13669 including classification functions for classes of characters (e.g.@: test
13670 for letters, or digits).
13671
13672 @item Ada.Characters.Latin_1 (A.3.3)
13673 This package includes a complete set of definitions of the characters
13674 that appear in type CHARACTER@. It is useful for writing programs that
13675 will run in international environments. For example, if you want an
13676 upper case E with an acute accent in a string, it is often better to use
13677 the definition of @code{UC_E_Acute} in this package. Then your program
13678 will print in an understandable manner even if your environment does not
13679 support these extended characters.
13680
13681 @item Ada.Command_Line (A.15)
13682 This package provides access to the command line parameters and the name
13683 of the current program (analogous to the use of @code{argc} and @code{argv}
13684 in C), and also allows the exit status for the program to be set in a
13685 system-independent manner.
13686
13687 @item Ada.Decimal (F.2)
13688 This package provides constants describing the range of decimal numbers
13689 implemented, and also a decimal divide routine (analogous to the COBOL
13690 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13691
13692 @item Ada.Direct_IO (A.8.4)
13693 This package provides input-output using a model of a set of records of
13694 fixed-length, containing an arbitrary definite Ada type, indexed by an
13695 integer record number.
13696
13697 @item Ada.Dynamic_Priorities (D.5)
13698 This package allows the priorities of a task to be adjusted dynamically
13699 as the task is running.
13700
13701 @item Ada.Exceptions (11.4.1)
13702 This package provides additional information on exceptions, and also
13703 contains facilities for treating exceptions as data objects, and raising
13704 exceptions with associated messages.
13705
13706 @item Ada.Finalization (7.6)
13707 This package contains the declarations and subprograms to support the
13708 use of controlled types, providing for automatic initialization and
13709 finalization (analogous to the constructors and destructors of C++)
13710
13711 @item Ada.Interrupts (C.3.2)
13712 This package provides facilities for interfacing to interrupts, which
13713 includes the set of signals or conditions that can be raised and
13714 recognized as interrupts.
13715
13716 @item Ada.Interrupts.Names (C.3.2)
13717 This package provides the set of interrupt names (actually signal
13718 or condition names) that can be handled by GNAT@.
13719
13720 @item Ada.IO_Exceptions (A.13)
13721 This package defines the set of exceptions that can be raised by use of
13722 the standard IO packages.
13723
13724 @item Ada.Numerics
13725 This package contains some standard constants and exceptions used
13726 throughout the numerics packages. Note that the constants pi and e are
13727 defined here, and it is better to use these definitions than rolling
13728 your own.
13729
13730 @item Ada.Numerics.Complex_Elementary_Functions
13731 Provides the implementation of standard elementary functions (such as
13732 log and trigonometric functions) operating on complex numbers using the
13733 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13734 created by the package @code{Numerics.Complex_Types}.
13735
13736 @item Ada.Numerics.Complex_Types
13737 This is a predefined instantiation of
13738 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13739 build the type @code{Complex} and @code{Imaginary}.
13740
13741 @item Ada.Numerics.Discrete_Random
13742 This generic package provides a random number generator suitable for generating
13743 uniformly distributed values of a specified discrete subtype.
13744
13745 @item Ada.Numerics.Float_Random
13746 This package provides a random number generator suitable for generating
13747 uniformly distributed floating point values in the unit interval.
13748
13749 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13750 This is a generic version of the package that provides the
13751 implementation of standard elementary functions (such as log and
13752 trigonometric functions) for an arbitrary complex type.
13753
13754 The following predefined instantiations of this package are provided:
13755
13756 @table @code
13757 @item Short_Float
13758 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13759 @item Float
13760 @code{Ada.Numerics.Complex_Elementary_Functions}
13761 @item Long_Float
13762 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13763 @end table
13764
13765 @item Ada.Numerics.Generic_Complex_Types
13766 This is a generic package that allows the creation of complex types,
13767 with associated complex arithmetic operations.
13768
13769 The following predefined instantiations of this package exist
13770 @table @code
13771 @item Short_Float
13772 @code{Ada.Numerics.Short_Complex_Complex_Types}
13773 @item Float
13774 @code{Ada.Numerics.Complex_Complex_Types}
13775 @item Long_Float
13776 @code{Ada.Numerics.Long_Complex_Complex_Types}
13777 @end table
13778
13779 @item Ada.Numerics.Generic_Elementary_Functions
13780 This is a generic package that provides the implementation of standard
13781 elementary functions (such as log an trigonometric functions) for an
13782 arbitrary float type.
13783
13784 The following predefined instantiations of this package exist
13785
13786 @table @code
13787 @item Short_Float
13788 @code{Ada.Numerics.Short_Elementary_Functions}
13789 @item Float
13790 @code{Ada.Numerics.Elementary_Functions}
13791 @item Long_Float
13792 @code{Ada.Numerics.Long_Elementary_Functions}
13793 @end table
13794
13795 @item Ada.Real_Time (D.8)
13796 This package provides facilities similar to those of @code{Calendar}, but
13797 operating with a finer clock suitable for real time control. Note that
13798 annex D requires that there be no backward clock jumps, and GNAT generally
13799 guarantees this behavior, but of course if the external clock on which
13800 the GNAT runtime depends is deliberately reset by some external event,
13801 then such a backward jump may occur.
13802
13803 @item Ada.Sequential_IO (A.8.1)
13804 This package provides input-output facilities for sequential files,
13805 which can contain a sequence of values of a single type, which can be
13806 any Ada type, including indefinite (unconstrained) types.
13807
13808 @item Ada.Storage_IO (A.9)
13809 This package provides a facility for mapping arbitrary Ada types to and
13810 from a storage buffer. It is primarily intended for the creation of new
13811 IO packages.
13812
13813 @item Ada.Streams (13.13.1)
13814 This is a generic package that provides the basic support for the
13815 concept of streams as used by the stream attributes (@code{Input},
13816 @code{Output}, @code{Read} and @code{Write}).
13817
13818 @item Ada.Streams.Stream_IO (A.12.1)
13819 This package is a specialization of the type @code{Streams} defined in
13820 package @code{Streams} together with a set of operations providing
13821 Stream_IO capability. The Stream_IO model permits both random and
13822 sequential access to a file which can contain an arbitrary set of values
13823 of one or more Ada types.
13824
13825 @item Ada.Strings (A.4.1)
13826 This package provides some basic constants used by the string handling
13827 packages.
13828
13829 @item Ada.Strings.Bounded (A.4.4)
13830 This package provides facilities for handling variable length
13831 strings. The bounded model requires a maximum length. It is thus
13832 somewhat more limited than the unbounded model, but avoids the use of
13833 dynamic allocation or finalization.
13834
13835 @item Ada.Strings.Fixed (A.4.3)
13836 This package provides facilities for handling fixed length strings.
13837
13838 @item Ada.Strings.Maps (A.4.2)
13839 This package provides facilities for handling character mappings and
13840 arbitrarily defined subsets of characters. For instance it is useful in
13841 defining specialized translation tables.
13842
13843 @item Ada.Strings.Maps.Constants (A.4.6)
13844 This package provides a standard set of predefined mappings and
13845 predefined character sets. For example, the standard upper to lower case
13846 conversion table is found in this package. Note that upper to lower case
13847 conversion is non-trivial if you want to take the entire set of
13848 characters, including extended characters like E with an acute accent,
13849 into account. You should use the mappings in this package (rather than
13850 adding 32 yourself) to do case mappings.
13851
13852 @item Ada.Strings.Unbounded (A.4.5)
13853 This package provides facilities for handling variable length
13854 strings. The unbounded model allows arbitrary length strings, but
13855 requires the use of dynamic allocation and finalization.
13856
13857 @item Ada.Strings.Wide_Bounded (A.4.7)
13858 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13859 @itemx Ada.Strings.Wide_Maps (A.4.7)
13860 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13861 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13862 These packages provide analogous capabilities to the corresponding
13863 packages without @samp{Wide_} in the name, but operate with the types
13864 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13865 and @code{Character}.
13866
13867 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13868 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13869 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13870 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13871 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13872 These packages provide analogous capabilities to the corresponding
13873 packages without @samp{Wide_} in the name, but operate with the types
13874 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13875 of @code{String} and @code{Character}.
13876
13877 @item Ada.Synchronous_Task_Control (D.10)
13878 This package provides some standard facilities for controlling task
13879 communication in a synchronous manner.
13880
13881 @item Ada.Tags
13882 This package contains definitions for manipulation of the tags of tagged
13883 values.
13884
13885 @item Ada.Task_Attributes
13886 This package provides the capability of associating arbitrary
13887 task-specific data with separate tasks.
13888
13889 @item Ada.Text_IO
13890 This package provides basic text input-output capabilities for
13891 character, string and numeric data. The subpackages of this
13892 package are listed next.
13893
13894 @item Ada.Text_IO.Decimal_IO
13895 Provides input-output facilities for decimal fixed-point types
13896
13897 @item Ada.Text_IO.Enumeration_IO
13898 Provides input-output facilities for enumeration types.
13899
13900 @item Ada.Text_IO.Fixed_IO
13901 Provides input-output facilities for ordinary fixed-point types.
13902
13903 @item Ada.Text_IO.Float_IO
13904 Provides input-output facilities for float types. The following
13905 predefined instantiations of this generic package are available:
13906
13907 @table @code
13908 @item Short_Float
13909 @code{Short_Float_Text_IO}
13910 @item Float
13911 @code{Float_Text_IO}
13912 @item Long_Float
13913 @code{Long_Float_Text_IO}
13914 @end table
13915
13916 @item Ada.Text_IO.Integer_IO
13917 Provides input-output facilities for integer types. The following
13918 predefined instantiations of this generic package are available:
13919
13920 @table @code
13921 @item Short_Short_Integer
13922 @code{Ada.Short_Short_Integer_Text_IO}
13923 @item Short_Integer
13924 @code{Ada.Short_Integer_Text_IO}
13925 @item Integer
13926 @code{Ada.Integer_Text_IO}
13927 @item Long_Integer
13928 @code{Ada.Long_Integer_Text_IO}
13929 @item Long_Long_Integer
13930 @code{Ada.Long_Long_Integer_Text_IO}
13931 @end table
13932
13933 @item Ada.Text_IO.Modular_IO
13934 Provides input-output facilities for modular (unsigned) types
13935
13936 @item Ada.Text_IO.Complex_IO (G.1.3)
13937 This package provides basic text input-output capabilities for complex
13938 data.
13939
13940 @item Ada.Text_IO.Editing (F.3.3)
13941 This package contains routines for edited output, analogous to the use
13942 of pictures in COBOL@. The picture formats used by this package are a
13943 close copy of the facility in COBOL@.
13944
13945 @item Ada.Text_IO.Text_Streams (A.12.2)
13946 This package provides a facility that allows Text_IO files to be treated
13947 as streams, so that the stream attributes can be used for writing
13948 arbitrary data, including binary data, to Text_IO files.
13949
13950 @item Ada.Unchecked_Conversion (13.9)
13951 This generic package allows arbitrary conversion from one type to
13952 another of the same size, providing for breaking the type safety in
13953 special circumstances.
13954
13955 If the types have the same Size (more accurately the same Value_Size),
13956 then the effect is simply to transfer the bits from the source to the
13957 target type without any modification. This usage is well defined, and
13958 for simple types whose representation is typically the same across
13959 all implementations, gives a portable method of performing such
13960 conversions.
13961
13962 If the types do not have the same size, then the result is implementation
13963 defined, and thus may be non-portable. The following describes how GNAT
13964 handles such unchecked conversion cases.
13965
13966 If the types are of different sizes, and are both discrete types, then
13967 the effect is of a normal type conversion without any constraint checking.
13968 In particular if the result type has a larger size, the result will be
13969 zero or sign extended. If the result type has a smaller size, the result
13970 will be truncated by ignoring high order bits.
13971
13972 If the types are of different sizes, and are not both discrete types,
13973 then the conversion works as though pointers were created to the source
13974 and target, and the pointer value is converted. The effect is that bits
13975 are copied from successive low order storage units and bits of the source
13976 up to the length of the target type.
13977
13978 A warning is issued if the lengths differ, since the effect in this
13979 case is implementation dependent, and the above behavior may not match
13980 that of some other compiler.
13981
13982 A pointer to one type may be converted to a pointer to another type using
13983 unchecked conversion. The only case in which the effect is undefined is
13984 when one or both pointers are pointers to unconstrained array types. In
13985 this case, the bounds information may get incorrectly transferred, and in
13986 particular, GNAT uses double size pointers for such types, and it is
13987 meaningless to convert between such pointer types. GNAT will issue a
13988 warning if the alignment of the target designated type is more strict
13989 than the alignment of the source designated type (since the result may
13990 be unaligned in this case).
13991
13992 A pointer other than a pointer to an unconstrained array type may be
13993 converted to and from System.Address. Such usage is common in Ada 83
13994 programs, but note that Ada.Address_To_Access_Conversions is the
13995 preferred method of performing such conversions in Ada 95 and Ada 2005.
13996 Neither
13997 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13998 used in conjunction with pointers to unconstrained objects, since
13999 the bounds information cannot be handled correctly in this case.
14000
14001 @item Ada.Unchecked_Deallocation (13.11.2)
14002 This generic package allows explicit freeing of storage previously
14003 allocated by use of an allocator.
14004
14005 @item Ada.Wide_Text_IO (A.11)
14006 This package is similar to @code{Ada.Text_IO}, except that the external
14007 file supports wide character representations, and the internal types are
14008 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14009 and @code{String}. It contains generic subpackages listed next.
14010
14011 @item Ada.Wide_Text_IO.Decimal_IO
14012 Provides input-output facilities for decimal fixed-point types
14013
14014 @item Ada.Wide_Text_IO.Enumeration_IO
14015 Provides input-output facilities for enumeration types.
14016
14017 @item Ada.Wide_Text_IO.Fixed_IO
14018 Provides input-output facilities for ordinary fixed-point types.
14019
14020 @item Ada.Wide_Text_IO.Float_IO
14021 Provides input-output facilities for float types. The following
14022 predefined instantiations of this generic package are available:
14023
14024 @table @code
14025 @item Short_Float
14026 @code{Short_Float_Wide_Text_IO}
14027 @item Float
14028 @code{Float_Wide_Text_IO}
14029 @item Long_Float
14030 @code{Long_Float_Wide_Text_IO}
14031 @end table
14032
14033 @item Ada.Wide_Text_IO.Integer_IO
14034 Provides input-output facilities for integer types. The following
14035 predefined instantiations of this generic package are available:
14036
14037 @table @code
14038 @item Short_Short_Integer
14039 @code{Ada.Short_Short_Integer_Wide_Text_IO}
14040 @item Short_Integer
14041 @code{Ada.Short_Integer_Wide_Text_IO}
14042 @item Integer
14043 @code{Ada.Integer_Wide_Text_IO}
14044 @item Long_Integer
14045 @code{Ada.Long_Integer_Wide_Text_IO}
14046 @item Long_Long_Integer
14047 @code{Ada.Long_Long_Integer_Wide_Text_IO}
14048 @end table
14049
14050 @item Ada.Wide_Text_IO.Modular_IO
14051 Provides input-output facilities for modular (unsigned) types
14052
14053 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
14054 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14055 external file supports wide character representations.
14056
14057 @item Ada.Wide_Text_IO.Editing (F.3.4)
14058 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14059 types are @code{Wide_Character} and @code{Wide_String} instead of
14060 @code{Character} and @code{String}.
14061
14062 @item Ada.Wide_Text_IO.Streams (A.12.3)
14063 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14064 types are @code{Wide_Character} and @code{Wide_String} instead of
14065 @code{Character} and @code{String}.
14066
14067 @item Ada.Wide_Wide_Text_IO (A.11)
14068 This package is similar to @code{Ada.Text_IO}, except that the external
14069 file supports wide character representations, and the internal types are
14070 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14071 and @code{String}. It contains generic subpackages listed next.
14072
14073 @item Ada.Wide_Wide_Text_IO.Decimal_IO
14074 Provides input-output facilities for decimal fixed-point types
14075
14076 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
14077 Provides input-output facilities for enumeration types.
14078
14079 @item Ada.Wide_Wide_Text_IO.Fixed_IO
14080 Provides input-output facilities for ordinary fixed-point types.
14081
14082 @item Ada.Wide_Wide_Text_IO.Float_IO
14083 Provides input-output facilities for float types. The following
14084 predefined instantiations of this generic package are available:
14085
14086 @table @code
14087 @item Short_Float
14088 @code{Short_Float_Wide_Wide_Text_IO}
14089 @item Float
14090 @code{Float_Wide_Wide_Text_IO}
14091 @item Long_Float
14092 @code{Long_Float_Wide_Wide_Text_IO}
14093 @end table
14094
14095 @item Ada.Wide_Wide_Text_IO.Integer_IO
14096 Provides input-output facilities for integer types. The following
14097 predefined instantiations of this generic package are available:
14098
14099 @table @code
14100 @item Short_Short_Integer
14101 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
14102 @item Short_Integer
14103 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
14104 @item Integer
14105 @code{Ada.Integer_Wide_Wide_Text_IO}
14106 @item Long_Integer
14107 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
14108 @item Long_Long_Integer
14109 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
14110 @end table
14111
14112 @item Ada.Wide_Wide_Text_IO.Modular_IO
14113 Provides input-output facilities for modular (unsigned) types
14114
14115 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
14116 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14117 external file supports wide character representations.
14118
14119 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
14120 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14121 types are @code{Wide_Character} and @code{Wide_String} instead of
14122 @code{Character} and @code{String}.
14123
14124 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
14125 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14126 types are @code{Wide_Character} and @code{Wide_String} instead of
14127 @code{Character} and @code{String}.
14128 @end table
14129
14130 @node The Implementation of Standard I/O
14131 @chapter The Implementation of Standard I/O
14132
14133 @noindent
14134 GNAT implements all the required input-output facilities described in
14135 A.6 through A.14. These sections of the Ada Reference Manual describe the
14136 required behavior of these packages from the Ada point of view, and if
14137 you are writing a portable Ada program that does not need to know the
14138 exact manner in which Ada maps to the outside world when it comes to
14139 reading or writing external files, then you do not need to read this
14140 chapter. As long as your files are all regular files (not pipes or
14141 devices), and as long as you write and read the files only from Ada, the
14142 description in the Ada Reference Manual is sufficient.
14143
14144 However, if you want to do input-output to pipes or other devices, such
14145 as the keyboard or screen, or if the files you are dealing with are
14146 either generated by some other language, or to be read by some other
14147 language, then you need to know more about the details of how the GNAT
14148 implementation of these input-output facilities behaves.
14149
14150 In this chapter we give a detailed description of exactly how GNAT
14151 interfaces to the file system. As always, the sources of the system are
14152 available to you for answering questions at an even more detailed level,
14153 but for most purposes the information in this chapter will suffice.
14154
14155 Another reason that you may need to know more about how input-output is
14156 implemented arises when you have a program written in mixed languages
14157 where, for example, files are shared between the C and Ada sections of
14158 the same program. GNAT provides some additional facilities, in the form
14159 of additional child library packages, that facilitate this sharing, and
14160 these additional facilities are also described in this chapter.
14161
14162 @menu
14163 * Standard I/O Packages::
14164 * FORM Strings::
14165 * Direct_IO::
14166 * Sequential_IO::
14167 * Text_IO::
14168 * Wide_Text_IO::
14169 * Wide_Wide_Text_IO::
14170 * Stream_IO::
14171 * Text Translation::
14172 * Shared Files::
14173 * Filenames encoding::
14174 * Open Modes::
14175 * Operations on C Streams::
14176 * Interfacing to C Streams::
14177 @end menu
14178
14179 @node Standard I/O Packages
14180 @section Standard I/O Packages
14181
14182 @noindent
14183 The Standard I/O packages described in Annex A for
14184
14185 @itemize @bullet
14186 @item
14187 Ada.Text_IO
14188 @item
14189 Ada.Text_IO.Complex_IO
14190 @item
14191 Ada.Text_IO.Text_Streams
14192 @item
14193 Ada.Wide_Text_IO
14194 @item
14195 Ada.Wide_Text_IO.Complex_IO
14196 @item
14197 Ada.Wide_Text_IO.Text_Streams
14198 @item
14199 Ada.Wide_Wide_Text_IO
14200 @item
14201 Ada.Wide_Wide_Text_IO.Complex_IO
14202 @item
14203 Ada.Wide_Wide_Text_IO.Text_Streams
14204 @item
14205 Ada.Stream_IO
14206 @item
14207 Ada.Sequential_IO
14208 @item
14209 Ada.Direct_IO
14210 @end itemize
14211
14212 @noindent
14213 are implemented using the C
14214 library streams facility; where
14215
14216 @itemize @bullet
14217 @item
14218 All files are opened using @code{fopen}.
14219 @item
14220 All input/output operations use @code{fread}/@code{fwrite}.
14221 @end itemize
14222
14223 @noindent
14224 There is no internal buffering of any kind at the Ada library level. The only
14225 buffering is that provided at the system level in the implementation of the
14226 library routines that support streams. This facilitates shared use of these
14227 streams by mixed language programs. Note though that system level buffering is
14228 explicitly enabled at elaboration of the standard I/O packages and that can
14229 have an impact on mixed language programs, in particular those using I/O before
14230 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
14231 the Ada elaboration routine before performing any I/O or when impractical,
14232 flush the common I/O streams and in particular Standard_Output before
14233 elaborating the Ada code.
14234
14235 @node FORM Strings
14236 @section FORM Strings
14237
14238 @noindent
14239 The format of a FORM string in GNAT is:
14240
14241 @smallexample
14242 "keyword=value,keyword=value,@dots{},keyword=value"
14243 @end smallexample
14244
14245 @noindent
14246 where letters may be in upper or lower case, and there are no spaces
14247 between values. The order of the entries is not important. Currently
14248 the following keywords defined.
14249
14250 @smallexample
14251 TEXT_TRANSLATION=[YES|NO]
14252 SHARED=[YES|NO]
14253 WCEM=[n|h|u|s|e|8|b]
14254 ENCODING=[UTF8|8BITS]
14255 @end smallexample
14256
14257 @noindent
14258 The use of these parameters is described later in this section. If an
14259 unrecognized keyword appears in a form string, it is silently ignored
14260 and not considered invalid.
14261
14262 @node Direct_IO
14263 @section Direct_IO
14264
14265 @noindent
14266 Direct_IO can only be instantiated for definite types. This is a
14267 restriction of the Ada language, which means that the records are fixed
14268 length (the length being determined by @code{@var{type}'Size}, rounded
14269 up to the next storage unit boundary if necessary).
14270
14271 The records of a Direct_IO file are simply written to the file in index
14272 sequence, with the first record starting at offset zero, and subsequent
14273 records following. There is no control information of any kind. For
14274 example, if 32-bit integers are being written, each record takes
14275 4-bytes, so the record at index @var{K} starts at offset
14276 (@var{K}@minus{}1)*4.
14277
14278 There is no limit on the size of Direct_IO files, they are expanded as
14279 necessary to accommodate whatever records are written to the file.
14280
14281 @node Sequential_IO
14282 @section Sequential_IO
14283
14284 @noindent
14285 Sequential_IO may be instantiated with either a definite (constrained)
14286 or indefinite (unconstrained) type.
14287
14288 For the definite type case, the elements written to the file are simply
14289 the memory images of the data values with no control information of any
14290 kind. The resulting file should be read using the same type, no validity
14291 checking is performed on input.
14292
14293 For the indefinite type case, the elements written consist of two
14294 parts. First is the size of the data item, written as the memory image
14295 of a @code{Interfaces.C.size_t} value, followed by the memory image of
14296 the data value. The resulting file can only be read using the same
14297 (unconstrained) type. Normal assignment checks are performed on these
14298 read operations, and if these checks fail, @code{Data_Error} is
14299 raised. In particular, in the array case, the lengths must match, and in
14300 the variant record case, if the variable for a particular read operation
14301 is constrained, the discriminants must match.
14302
14303 Note that it is not possible to use Sequential_IO to write variable
14304 length array items, and then read the data back into different length
14305 arrays. For example, the following will raise @code{Data_Error}:
14306
14307 @smallexample @c ada
14308 package IO is new Sequential_IO (String);
14309 F : IO.File_Type;
14310 S : String (1..4);
14311 @dots{}
14312 IO.Create (F)
14313 IO.Write (F, "hello!")
14314 IO.Reset (F, Mode=>In_File);
14315 IO.Read (F, S);
14316 Put_Line (S);
14317
14318 @end smallexample
14319
14320 @noindent
14321 On some Ada implementations, this will print @code{hell}, but the program is
14322 clearly incorrect, since there is only one element in the file, and that
14323 element is the string @code{hello!}.
14324
14325 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
14326 using Stream_IO, and this is the preferred mechanism. In particular, the
14327 above program fragment rewritten to use Stream_IO will work correctly.
14328
14329 @node Text_IO
14330 @section Text_IO
14331
14332 @noindent
14333 Text_IO files consist of a stream of characters containing the following
14334 special control characters:
14335
14336 @smallexample
14337 LF (line feed, 16#0A#) Line Mark
14338 FF (form feed, 16#0C#) Page Mark
14339 @end smallexample
14340
14341 @noindent
14342 A canonical Text_IO file is defined as one in which the following
14343 conditions are met:
14344
14345 @itemize @bullet
14346 @item
14347 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
14348 of the line.
14349
14350 @item
14351 The character @code{FF} is used only as a page mark, i.e.@: to mark the
14352 end of a page and consequently can appear only immediately following a
14353 @code{LF} (line mark) character.
14354
14355 @item
14356 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
14357 (line mark, page mark). In the former case, the page mark is implicitly
14358 assumed to be present.
14359 @end itemize
14360
14361 @noindent
14362 A file written using Text_IO will be in canonical form provided that no
14363 explicit @code{LF} or @code{FF} characters are written using @code{Put}
14364 or @code{Put_Line}. There will be no @code{FF} character at the end of
14365 the file unless an explicit @code{New_Page} operation was performed
14366 before closing the file.
14367
14368 A canonical Text_IO file that is a regular file (i.e., not a device or a
14369 pipe) can be read using any of the routines in Text_IO@. The
14370 semantics in this case will be exactly as defined in the Ada Reference
14371 Manual, and all the routines in Text_IO are fully implemented.
14372
14373 A text file that does not meet the requirements for a canonical Text_IO
14374 file has one of the following:
14375
14376 @itemize @bullet
14377 @item
14378 The file contains @code{FF} characters not immediately following a
14379 @code{LF} character.
14380
14381 @item
14382 The file contains @code{LF} or @code{FF} characters written by
14383 @code{Put} or @code{Put_Line}, which are not logically considered to be
14384 line marks or page marks.
14385
14386 @item
14387 The file ends in a character other than @code{LF} or @code{FF},
14388 i.e.@: there is no explicit line mark or page mark at the end of the file.
14389 @end itemize
14390
14391 @noindent
14392 Text_IO can be used to read such non-standard text files but subprograms
14393 to do with line or page numbers do not have defined meanings. In
14394 particular, a @code{FF} character that does not follow a @code{LF}
14395 character may or may not be treated as a page mark from the point of
14396 view of page and line numbering. Every @code{LF} character is considered
14397 to end a line, and there is an implied @code{LF} character at the end of
14398 the file.
14399
14400 @menu
14401 * Text_IO Stream Pointer Positioning::
14402 * Text_IO Reading and Writing Non-Regular Files::
14403 * Get_Immediate::
14404 * Treating Text_IO Files as Streams::
14405 * Text_IO Extensions::
14406 * Text_IO Facilities for Unbounded Strings::
14407 @end menu
14408
14409 @node Text_IO Stream Pointer Positioning
14410 @subsection Stream Pointer Positioning
14411
14412 @noindent
14413 @code{Ada.Text_IO} has a definition of current position for a file that
14414 is being read. No internal buffering occurs in Text_IO, and usually the
14415 physical position in the stream used to implement the file corresponds
14416 to this logical position defined by Text_IO@. There are two exceptions:
14417
14418 @itemize @bullet
14419 @item
14420 After a call to @code{End_Of_Page} that returns @code{True}, the stream
14421 is positioned past the @code{LF} (line mark) that precedes the page
14422 mark. Text_IO maintains an internal flag so that subsequent read
14423 operations properly handle the logical position which is unchanged by
14424 the @code{End_Of_Page} call.
14425
14426 @item
14427 After a call to @code{End_Of_File} that returns @code{True}, if the
14428 Text_IO file was positioned before the line mark at the end of file
14429 before the call, then the logical position is unchanged, but the stream
14430 is physically positioned right at the end of file (past the line mark,
14431 and past a possible page mark following the line mark. Again Text_IO
14432 maintains internal flags so that subsequent read operations properly
14433 handle the logical position.
14434 @end itemize
14435
14436 @noindent
14437 These discrepancies have no effect on the observable behavior of
14438 Text_IO, but if a single Ada stream is shared between a C program and
14439 Ada program, or shared (using @samp{shared=yes} in the form string)
14440 between two Ada files, then the difference may be observable in some
14441 situations.
14442
14443 @node Text_IO Reading and Writing Non-Regular Files
14444 @subsection Reading and Writing Non-Regular Files
14445
14446 @noindent
14447 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
14448 can be used for reading and writing. Writing is not affected and the
14449 sequence of characters output is identical to the normal file case, but
14450 for reading, the behavior of Text_IO is modified to avoid undesirable
14451 look-ahead as follows:
14452
14453 An input file that is not a regular file is considered to have no page
14454 marks. Any @code{Ascii.FF} characters (the character normally used for a
14455 page mark) appearing in the file are considered to be data
14456 characters. In particular:
14457
14458 @itemize @bullet
14459 @item
14460 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
14461 following a line mark. If a page mark appears, it will be treated as a
14462 data character.
14463
14464 @item
14465 This avoids the need to wait for an extra character to be typed or
14466 entered from the pipe to complete one of these operations.
14467
14468 @item
14469 @code{End_Of_Page} always returns @code{False}
14470
14471 @item
14472 @code{End_Of_File} will return @code{False} if there is a page mark at
14473 the end of the file.
14474 @end itemize
14475
14476 @noindent
14477 Output to non-regular files is the same as for regular files. Page marks
14478 may be written to non-regular files using @code{New_Page}, but as noted
14479 above they will not be treated as page marks on input if the output is
14480 piped to another Ada program.
14481
14482 Another important discrepancy when reading non-regular files is that the end
14483 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
14484 pressing the @key{EOT} key,
14485 then end of file
14486 is signaled once (i.e.@: the test @code{End_Of_File}
14487 will yield @code{True}, or a read will
14488 raise @code{End_Error}), but then reading can resume
14489 to read data past that end of
14490 file indication, until another end of file indication is entered.
14491
14492 @node Get_Immediate
14493 @subsection Get_Immediate
14494 @cindex Get_Immediate
14495
14496 @noindent
14497 Get_Immediate returns the next character (including control characters)
14498 from the input file. In particular, Get_Immediate will return LF or FF
14499 characters used as line marks or page marks. Such operations leave the
14500 file positioned past the control character, and it is thus not treated
14501 as having its normal function. This means that page, line and column
14502 counts after this kind of Get_Immediate call are set as though the mark
14503 did not occur. In the case where a Get_Immediate leaves the file
14504 positioned between the line mark and page mark (which is not normally
14505 possible), it is undefined whether the FF character will be treated as a
14506 page mark.
14507
14508 @node Treating Text_IO Files as Streams
14509 @subsection Treating Text_IO Files as Streams
14510 @cindex Stream files
14511
14512 @noindent
14513 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14514 as a stream. Data written to a Text_IO file in this stream mode is
14515 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14516 16#0C# (@code{FF}), the resulting file may have non-standard
14517 format. Similarly if read operations are used to read from a Text_IO
14518 file treated as a stream, then @code{LF} and @code{FF} characters may be
14519 skipped and the effect is similar to that described above for
14520 @code{Get_Immediate}.
14521
14522 @node Text_IO Extensions
14523 @subsection Text_IO Extensions
14524 @cindex Text_IO extensions
14525
14526 @noindent
14527 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14528 to the standard @code{Text_IO} package:
14529
14530 @itemize @bullet
14531 @item function File_Exists (Name : String) return Boolean;
14532 Determines if a file of the given name exists.
14533
14534 @item function Get_Line return String;
14535 Reads a string from the standard input file. The value returned is exactly
14536 the length of the line that was read.
14537
14538 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14539 Similar, except that the parameter File specifies the file from which
14540 the string is to be read.
14541
14542 @end itemize
14543
14544 @node Text_IO Facilities for Unbounded Strings
14545 @subsection Text_IO Facilities for Unbounded Strings
14546 @cindex Text_IO for unbounded strings
14547 @cindex Unbounded_String, Text_IO operations
14548
14549 @noindent
14550 The package @code{Ada.Strings.Unbounded.Text_IO}
14551 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14552 subprograms useful for Text_IO operations on unbounded strings:
14553
14554 @itemize @bullet
14555
14556 @item function Get_Line (File : File_Type) return Unbounded_String;
14557 Reads a line from the specified file
14558 and returns the result as an unbounded string.
14559
14560 @item procedure Put (File : File_Type; U : Unbounded_String);
14561 Writes the value of the given unbounded string to the specified file
14562 Similar to the effect of
14563 @code{Put (To_String (U))} except that an extra copy is avoided.
14564
14565 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14566 Writes the value of the given unbounded string to the specified file,
14567 followed by a @code{New_Line}.
14568 Similar to the effect of @code{Put_Line (To_String (U))} except
14569 that an extra copy is avoided.
14570 @end itemize
14571
14572 @noindent
14573 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14574 and is optional. If the parameter is omitted, then the standard input or
14575 output file is referenced as appropriate.
14576
14577 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14578 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14579 @code{Wide_Text_IO} functionality for unbounded wide strings.
14580
14581 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14582 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14583 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14584
14585 @node Wide_Text_IO
14586 @section Wide_Text_IO
14587
14588 @noindent
14589 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14590 both input and output files may contain special sequences that represent
14591 wide character values. The encoding scheme for a given file may be
14592 specified using a FORM parameter:
14593
14594 @smallexample
14595 WCEM=@var{x}
14596 @end smallexample
14597
14598 @noindent
14599 as part of the FORM string (WCEM = wide character encoding method),
14600 where @var{x} is one of the following characters
14601
14602 @table @samp
14603 @item h
14604 Hex ESC encoding
14605 @item u
14606 Upper half encoding
14607 @item s
14608 Shift-JIS encoding
14609 @item e
14610 EUC Encoding
14611 @item 8
14612 UTF-8 encoding
14613 @item b
14614 Brackets encoding
14615 @end table
14616
14617 @noindent
14618 The encoding methods match those that
14619 can be used in a source
14620 program, but there is no requirement that the encoding method used for
14621 the source program be the same as the encoding method used for files,
14622 and different files may use different encoding methods.
14623
14624 The default encoding method for the standard files, and for opened files
14625 for which no WCEM parameter is given in the FORM string matches the
14626 wide character encoding specified for the main program (the default
14627 being brackets encoding if no coding method was specified with -gnatW).
14628
14629 @table @asis
14630 @item Hex Coding
14631 In this encoding, a wide character is represented by a five character
14632 sequence:
14633
14634 @smallexample
14635 ESC a b c d
14636 @end smallexample
14637
14638 @noindent
14639 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14640 characters (using upper case letters) of the wide character code. For
14641 example, ESC A345 is used to represent the wide character with code
14642 16#A345#. This scheme is compatible with use of the full
14643 @code{Wide_Character} set.
14644
14645 @item Upper Half Coding
14646 The wide character with encoding 16#abcd#, where the upper bit is on
14647 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14648 16#cd#. The second byte may never be a format control character, but is
14649 not required to be in the upper half. This method can be also used for
14650 shift-JIS or EUC where the internal coding matches the external coding.
14651
14652 @item Shift JIS Coding
14653 A wide character is represented by a two character sequence 16#ab# and
14654 16#cd#, with the restrictions described for upper half encoding as
14655 described above. The internal character code is the corresponding JIS
14656 character according to the standard algorithm for Shift-JIS
14657 conversion. Only characters defined in the JIS code set table can be
14658 used with this encoding method.
14659
14660 @item EUC Coding
14661 A wide character is represented by a two character sequence 16#ab# and
14662 16#cd#, with both characters being in the upper half. The internal
14663 character code is the corresponding JIS character according to the EUC
14664 encoding algorithm. Only characters defined in the JIS code set table
14665 can be used with this encoding method.
14666
14667 @item UTF-8 Coding
14668 A wide character is represented using
14669 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14670 10646-1/Am.2. Depending on the character value, the representation
14671 is a one, two, or three byte sequence:
14672
14673 @smallexample
14674 16#0000#-16#007f#: 2#0xxxxxxx#
14675 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14676 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14677 @end smallexample
14678
14679 @noindent
14680 where the @var{xxx} bits correspond to the left-padded bits of the
14681 16-bit character value. Note that all lower half ASCII characters
14682 are represented as ASCII bytes and all upper half characters and
14683 other wide characters are represented as sequences of upper-half
14684 (The full UTF-8 scheme allows for encoding 31-bit characters as
14685 6-byte sequences, but in this implementation, all UTF-8 sequences
14686 of four or more bytes length will raise a Constraint_Error, as
14687 will all invalid UTF-8 sequences.)
14688
14689 @item Brackets Coding
14690 In this encoding, a wide character is represented by the following eight
14691 character sequence:
14692
14693 @smallexample
14694 [ " a b c d " ]
14695 @end smallexample
14696
14697 @noindent
14698 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14699 characters (using uppercase letters) of the wide character code. For
14700 example, @code{["A345"]} is used to represent the wide character with code
14701 @code{16#A345#}.
14702 This scheme is compatible with use of the full Wide_Character set.
14703 On input, brackets coding can also be used for upper half characters,
14704 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14705 is only used for wide characters with a code greater than @code{16#FF#}.
14706
14707 Note that brackets coding is not normally used in the context of
14708 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14709 a portable way of encoding source files. In the context of Wide_Text_IO
14710 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14711 any instance of the left bracket character other than to encode wide
14712 character values using the brackets encoding method. In practice it is
14713 expected that some standard wide character encoding method such
14714 as UTF-8 will be used for text input output.
14715
14716 If brackets notation is used, then any occurrence of a left bracket
14717 in the input file which is not the start of a valid wide character
14718 sequence will cause Constraint_Error to be raised. It is possible to
14719 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14720 input will interpret this as a left bracket.
14721
14722 However, when a left bracket is output, it will be output as a left bracket
14723 and not as ["5B"]. We make this decision because for normal use of
14724 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14725 brackets. For example, if we write:
14726
14727 @smallexample
14728 Put_Line ("Start of output [first run]");
14729 @end smallexample
14730
14731 @noindent
14732 we really do not want to have the left bracket in this message clobbered so
14733 that the output reads:
14734
14735 @smallexample
14736 Start of output ["5B"]first run]
14737 @end smallexample
14738
14739 @noindent
14740 In practice brackets encoding is reasonably useful for normal Put_Line use
14741 since we won't get confused between left brackets and wide character
14742 sequences in the output. But for input, or when files are written out
14743 and read back in, it really makes better sense to use one of the standard
14744 encoding methods such as UTF-8.
14745
14746 @end table
14747
14748 @noindent
14749 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14750 not all wide character
14751 values can be represented. An attempt to output a character that cannot
14752 be represented using the encoding scheme for the file causes
14753 Constraint_Error to be raised. An invalid wide character sequence on
14754 input also causes Constraint_Error to be raised.
14755
14756 @menu
14757 * Wide_Text_IO Stream Pointer Positioning::
14758 * Wide_Text_IO Reading and Writing Non-Regular Files::
14759 @end menu
14760
14761 @node Wide_Text_IO Stream Pointer Positioning
14762 @subsection Stream Pointer Positioning
14763
14764 @noindent
14765 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14766 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14767 case:
14768
14769 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14770 normal lower ASCII set (i.e.@: a character in the range:
14771
14772 @smallexample @c ada
14773 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14774 @end smallexample
14775
14776 @noindent
14777 then although the logical position of the file pointer is unchanged by
14778 the @code{Look_Ahead} call, the stream is physically positioned past the
14779 wide character sequence. Again this is to avoid the need for buffering
14780 or backup, and all @code{Wide_Text_IO} routines check the internal
14781 indication that this situation has occurred so that this is not visible
14782 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14783 can be observed if the wide text file shares a stream with another file.
14784
14785 @node Wide_Text_IO Reading and Writing Non-Regular Files
14786 @subsection Reading and Writing Non-Regular Files
14787
14788 @noindent
14789 As in the case of Text_IO, when a non-regular file is read, it is
14790 assumed that the file contains no page marks (any form characters are
14791 treated as data characters), and @code{End_Of_Page} always returns
14792 @code{False}. Similarly, the end of file indication is not sticky, so
14793 it is possible to read beyond an end of file.
14794
14795 @node Wide_Wide_Text_IO
14796 @section Wide_Wide_Text_IO
14797
14798 @noindent
14799 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14800 both input and output files may contain special sequences that represent
14801 wide wide character values. The encoding scheme for a given file may be
14802 specified using a FORM parameter:
14803
14804 @smallexample
14805 WCEM=@var{x}
14806 @end smallexample
14807
14808 @noindent
14809 as part of the FORM string (WCEM = wide character encoding method),
14810 where @var{x} is one of the following characters
14811
14812 @table @samp
14813 @item h
14814 Hex ESC encoding
14815 @item u
14816 Upper half encoding
14817 @item s
14818 Shift-JIS encoding
14819 @item e
14820 EUC Encoding
14821 @item 8
14822 UTF-8 encoding
14823 @item b
14824 Brackets encoding
14825 @end table
14826
14827 @noindent
14828 The encoding methods match those that
14829 can be used in a source
14830 program, but there is no requirement that the encoding method used for
14831 the source program be the same as the encoding method used for files,
14832 and different files may use different encoding methods.
14833
14834 The default encoding method for the standard files, and for opened files
14835 for which no WCEM parameter is given in the FORM string matches the
14836 wide character encoding specified for the main program (the default
14837 being brackets encoding if no coding method was specified with -gnatW).
14838
14839 @table @asis
14840
14841 @item UTF-8 Coding
14842 A wide character is represented using
14843 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14844 10646-1/Am.2. Depending on the character value, the representation
14845 is a one, two, three, or four byte sequence:
14846
14847 @smallexample
14848 16#000000#-16#00007f#: 2#0xxxxxxx#
14849 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14850 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14851 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14852 @end smallexample
14853
14854 @noindent
14855 where the @var{xxx} bits correspond to the left-padded bits of the
14856 21-bit character value. Note that all lower half ASCII characters
14857 are represented as ASCII bytes and all upper half characters and
14858 other wide characters are represented as sequences of upper-half
14859 characters.
14860
14861 @item Brackets Coding
14862 In this encoding, a wide wide character is represented by the following eight
14863 character sequence if is in wide character range
14864
14865 @smallexample
14866 [ " a b c d " ]
14867 @end smallexample
14868
14869 and by the following ten character sequence if not
14870
14871 @smallexample
14872 [ " a b c d e f " ]
14873 @end smallexample
14874
14875 @noindent
14876 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14877 are the four or six hexadecimal
14878 characters (using uppercase letters) of the wide wide character code. For
14879 example, @code{["01A345"]} is used to represent the wide wide character
14880 with code @code{16#01A345#}.
14881
14882 This scheme is compatible with use of the full Wide_Wide_Character set.
14883 On input, brackets coding can also be used for upper half characters,
14884 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14885 is only used for wide characters with a code greater than @code{16#FF#}.
14886
14887 @end table
14888
14889 @noindent
14890 If is also possible to use the other Wide_Character encoding methods,
14891 such as Shift-JIS, but the other schemes cannot support the full range
14892 of wide wide characters.
14893 An attempt to output a character that cannot
14894 be represented using the encoding scheme for the file causes
14895 Constraint_Error to be raised. An invalid wide character sequence on
14896 input also causes Constraint_Error to be raised.
14897
14898 @menu
14899 * Wide_Wide_Text_IO Stream Pointer Positioning::
14900 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14901 @end menu
14902
14903 @node Wide_Wide_Text_IO Stream Pointer Positioning
14904 @subsection Stream Pointer Positioning
14905
14906 @noindent
14907 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14908 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14909 case:
14910
14911 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14912 normal lower ASCII set (i.e.@: a character in the range:
14913
14914 @smallexample @c ada
14915 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14916 @end smallexample
14917
14918 @noindent
14919 then although the logical position of the file pointer is unchanged by
14920 the @code{Look_Ahead} call, the stream is physically positioned past the
14921 wide character sequence. Again this is to avoid the need for buffering
14922 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14923 indication that this situation has occurred so that this is not visible
14924 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14925 can be observed if the wide text file shares a stream with another file.
14926
14927 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14928 @subsection Reading and Writing Non-Regular Files
14929
14930 @noindent
14931 As in the case of Text_IO, when a non-regular file is read, it is
14932 assumed that the file contains no page marks (any form characters are
14933 treated as data characters), and @code{End_Of_Page} always returns
14934 @code{False}. Similarly, the end of file indication is not sticky, so
14935 it is possible to read beyond an end of file.
14936
14937 @node Stream_IO
14938 @section Stream_IO
14939
14940 @noindent
14941 A stream file is a sequence of bytes, where individual elements are
14942 written to the file as described in the Ada Reference Manual. The type
14943 @code{Stream_Element} is simply a byte. There are two ways to read or
14944 write a stream file.
14945
14946 @itemize @bullet
14947 @item
14948 The operations @code{Read} and @code{Write} directly read or write a
14949 sequence of stream elements with no control information.
14950
14951 @item
14952 The stream attributes applied to a stream file transfer data in the
14953 manner described for stream attributes.
14954 @end itemize
14955
14956 @node Text Translation
14957 @section Text Translation
14958
14959 @noindent
14960 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14961 passed to Text_IO.Create and Text_IO.Open:
14962 @samp{Text_Translation=@var{Yes}} is the default, which means to
14963 translate LF to/from CR/LF on Windows systems.
14964 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14965 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14966 may be used to create Unix-style files on
14967 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14968 systems.
14969
14970 @node Shared Files
14971 @section Shared Files
14972
14973 @noindent
14974 Section A.14 of the Ada Reference Manual allows implementations to
14975 provide a wide variety of behavior if an attempt is made to access the
14976 same external file with two or more internal files.
14977
14978 To provide a full range of functionality, while at the same time
14979 minimizing the problems of portability caused by this implementation
14980 dependence, GNAT handles file sharing as follows:
14981
14982 @itemize @bullet
14983 @item
14984 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14985 to open two or more files with the same full name is considered an error
14986 and is not supported. The exception @code{Use_Error} will be
14987 raised. Note that a file that is not explicitly closed by the program
14988 remains open until the program terminates.
14989
14990 @item
14991 If the form parameter @samp{shared=no} appears in the form string, the
14992 file can be opened or created with its own separate stream identifier,
14993 regardless of whether other files sharing the same external file are
14994 opened. The exact effect depends on how the C stream routines handle
14995 multiple accesses to the same external files using separate streams.
14996
14997 @item
14998 If the form parameter @samp{shared=yes} appears in the form string for
14999 each of two or more files opened using the same full name, the same
15000 stream is shared between these files, and the semantics are as described
15001 in Ada Reference Manual, Section A.14.
15002 @end itemize
15003
15004 @noindent
15005 When a program that opens multiple files with the same name is ported
15006 from another Ada compiler to GNAT, the effect will be that
15007 @code{Use_Error} is raised.
15008
15009 The documentation of the original compiler and the documentation of the
15010 program should then be examined to determine if file sharing was
15011 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
15012 and @code{Create} calls as required.
15013
15014 When a program is ported from GNAT to some other Ada compiler, no
15015 special attention is required unless the @samp{shared=@var{xxx}} form
15016 parameter is used in the program. In this case, you must examine the
15017 documentation of the new compiler to see if it supports the required
15018 file sharing semantics, and form strings modified appropriately. Of
15019 course it may be the case that the program cannot be ported if the
15020 target compiler does not support the required functionality. The best
15021 approach in writing portable code is to avoid file sharing (and hence
15022 the use of the @samp{shared=@var{xxx}} parameter in the form string)
15023 completely.
15024
15025 One common use of file sharing in Ada 83 is the use of instantiations of
15026 Sequential_IO on the same file with different types, to achieve
15027 heterogeneous input-output. Although this approach will work in GNAT if
15028 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
15029 for this purpose (using the stream attributes)
15030
15031 @node Filenames encoding
15032 @section Filenames encoding
15033
15034 @noindent
15035 An encoding form parameter can be used to specify the filename
15036 encoding @samp{encoding=@var{xxx}}.
15037
15038 @itemize @bullet
15039 @item
15040 If the form parameter @samp{encoding=utf8} appears in the form string, the
15041 filename must be encoded in UTF-8.
15042
15043 @item
15044 If the form parameter @samp{encoding=8bits} appears in the form
15045 string, the filename must be a standard 8bits string.
15046 @end itemize
15047
15048 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
15049 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
15050 variable. And if not set @samp{utf8} is assumed.
15051
15052 @table @samp
15053 @item CP_ACP
15054 The current system Windows ANSI code page.
15055 @item CP_UTF8
15056 UTF-8 encoding
15057 @end table
15058
15059 This encoding form parameter is only supported on the Windows
15060 platform. On the other Operating Systems the run-time is supporting
15061 UTF-8 natively.
15062
15063 @node Open Modes
15064 @section Open Modes
15065
15066 @noindent
15067 @code{Open} and @code{Create} calls result in a call to @code{fopen}
15068 using the mode shown in the following table:
15069
15070 @sp 2
15071 @center @code{Open} and @code{Create} Call Modes
15072 @smallexample
15073 @b{OPEN } @b{CREATE}
15074 Append_File "r+" "w+"
15075 In_File "r" "w+"
15076 Out_File (Direct_IO) "r+" "w"
15077 Out_File (all other cases) "w" "w"
15078 Inout_File "r+" "w+"
15079 @end smallexample
15080
15081 @noindent
15082 If text file translation is required, then either @samp{b} or @samp{t}
15083 is added to the mode, depending on the setting of Text. Text file
15084 translation refers to the mapping of CR/LF sequences in an external file
15085 to LF characters internally. This mapping only occurs in DOS and
15086 DOS-like systems, and is not relevant to other systems.
15087
15088 A special case occurs with Stream_IO@. As shown in the above table, the
15089 file is initially opened in @samp{r} or @samp{w} mode for the
15090 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
15091 subsequently requires switching from reading to writing or vice-versa,
15092 then the file is reopened in @samp{r+} mode to permit the required operation.
15093
15094 @node Operations on C Streams
15095 @section Operations on C Streams
15096 The package @code{Interfaces.C_Streams} provides an Ada program with direct
15097 access to the C library functions for operations on C streams:
15098
15099 @smallexample @c adanocomment
15100 package Interfaces.C_Streams is
15101 -- Note: the reason we do not use the types that are in
15102 -- Interfaces.C is that we want to avoid dragging in the
15103 -- code in this unit if possible.
15104 subtype chars is System.Address;
15105 -- Pointer to null-terminated array of characters
15106 subtype FILEs is System.Address;
15107 -- Corresponds to the C type FILE*
15108 subtype voids is System.Address;
15109 -- Corresponds to the C type void*
15110 subtype int is Integer;
15111 subtype long is Long_Integer;
15112 -- Note: the above types are subtypes deliberately, and it
15113 -- is part of this spec that the above correspondences are
15114 -- guaranteed. This means that it is legitimate to, for
15115 -- example, use Integer instead of int. We provide these
15116 -- synonyms for clarity, but in some cases it may be
15117 -- convenient to use the underlying types (for example to
15118 -- avoid an unnecessary dependency of a spec on the spec
15119 -- of this unit).
15120 type size_t is mod 2 ** Standard'Address_Size;
15121 NULL_Stream : constant FILEs;
15122 -- Value returned (NULL in C) to indicate an
15123 -- fdopen/fopen/tmpfile error
15124 ----------------------------------
15125 -- Constants Defined in stdio.h --
15126 ----------------------------------
15127 EOF : constant int;
15128 -- Used by a number of routines to indicate error or
15129 -- end of file
15130 IOFBF : constant int;
15131 IOLBF : constant int;
15132 IONBF : constant int;
15133 -- Used to indicate buffering mode for setvbuf call
15134 SEEK_CUR : constant int;
15135 SEEK_END : constant int;
15136 SEEK_SET : constant int;
15137 -- Used to indicate origin for fseek call
15138 function stdin return FILEs;
15139 function stdout return FILEs;
15140 function stderr return FILEs;
15141 -- Streams associated with standard files
15142 --------------------------
15143 -- Standard C functions --
15144 --------------------------
15145 -- The functions selected below are ones that are
15146 -- available in UNIX (but not necessarily in ANSI C).
15147 -- These are very thin interfaces
15148 -- which copy exactly the C headers. For more
15149 -- documentation on these functions, see the Microsoft C
15150 -- "Run-Time Library Reference" (Microsoft Press, 1990,
15151 -- ISBN 1-55615-225-6), which includes useful information
15152 -- on system compatibility.
15153 procedure clearerr (stream : FILEs);
15154 function fclose (stream : FILEs) return int;
15155 function fdopen (handle : int; mode : chars) return FILEs;
15156 function feof (stream : FILEs) return int;
15157 function ferror (stream : FILEs) return int;
15158 function fflush (stream : FILEs) return int;
15159 function fgetc (stream : FILEs) return int;
15160 function fgets (strng : chars; n : int; stream : FILEs)
15161 return chars;
15162 function fileno (stream : FILEs) return int;
15163 function fopen (filename : chars; Mode : chars)
15164 return FILEs;
15165 -- Note: to maintain target independence, use
15166 -- text_translation_required, a boolean variable defined in
15167 -- a-sysdep.c to deal with the target dependent text
15168 -- translation requirement. If this variable is set,
15169 -- then b/t should be appended to the standard mode
15170 -- argument to set the text translation mode off or on
15171 -- as required.
15172 function fputc (C : int; stream : FILEs) return int;
15173 function fputs (Strng : chars; Stream : FILEs) return int;
15174 function fread
15175 (buffer : voids;
15176 size : size_t;
15177 count : size_t;
15178 stream : FILEs)
15179 return size_t;
15180 function freopen
15181 (filename : chars;
15182 mode : chars;
15183 stream : FILEs)
15184 return FILEs;
15185 function fseek
15186 (stream : FILEs;
15187 offset : long;
15188 origin : int)
15189 return int;
15190 function ftell (stream : FILEs) return long;
15191 function fwrite
15192 (buffer : voids;
15193 size : size_t;
15194 count : size_t;
15195 stream : FILEs)
15196 return size_t;
15197 function isatty (handle : int) return int;
15198 procedure mktemp (template : chars);
15199 -- The return value (which is just a pointer to template)
15200 -- is discarded
15201 procedure rewind (stream : FILEs);
15202 function rmtmp return int;
15203 function setvbuf
15204 (stream : FILEs;
15205 buffer : chars;
15206 mode : int;
15207 size : size_t)
15208 return int;
15209
15210 function tmpfile return FILEs;
15211 function ungetc (c : int; stream : FILEs) return int;
15212 function unlink (filename : chars) return int;
15213 ---------------------
15214 -- Extra functions --
15215 ---------------------
15216 -- These functions supply slightly thicker bindings than
15217 -- those above. They are derived from functions in the
15218 -- C Run-Time Library, but may do a bit more work than
15219 -- just directly calling one of the Library functions.
15220 function is_regular_file (handle : int) return int;
15221 -- Tests if given handle is for a regular file (result 1)
15222 -- or for a non-regular file (pipe or device, result 0).
15223 ---------------------------------
15224 -- Control of Text/Binary Mode --
15225 ---------------------------------
15226 -- If text_translation_required is true, then the following
15227 -- functions may be used to dynamically switch a file from
15228 -- binary to text mode or vice versa. These functions have
15229 -- no effect if text_translation_required is false (i.e.@: in
15230 -- normal UNIX mode). Use fileno to get a stream handle.
15231 procedure set_binary_mode (handle : int);
15232 procedure set_text_mode (handle : int);
15233 ----------------------------
15234 -- Full Path Name support --
15235 ----------------------------
15236 procedure full_name (nam : chars; buffer : chars);
15237 -- Given a NUL terminated string representing a file
15238 -- name, returns in buffer a NUL terminated string
15239 -- representing the full path name for the file name.
15240 -- On systems where it is relevant the drive is also
15241 -- part of the full path name. It is the responsibility
15242 -- of the caller to pass an actual parameter for buffer
15243 -- that is big enough for any full path name. Use
15244 -- max_path_len given below as the size of buffer.
15245 max_path_len : integer;
15246 -- Maximum length of an allowable full path name on the
15247 -- system, including a terminating NUL character.
15248 end Interfaces.C_Streams;
15249 @end smallexample
15250
15251 @node Interfacing to C Streams
15252 @section Interfacing to C Streams
15253
15254 @noindent
15255 The packages in this section permit interfacing Ada files to C Stream
15256 operations.
15257
15258 @smallexample @c ada
15259 with Interfaces.C_Streams;
15260 package Ada.Sequential_IO.C_Streams is
15261 function C_Stream (F : File_Type)
15262 return Interfaces.C_Streams.FILEs;
15263 procedure Open
15264 (File : in out File_Type;
15265 Mode : in File_Mode;
15266 C_Stream : in Interfaces.C_Streams.FILEs;
15267 Form : in String := "");
15268 end Ada.Sequential_IO.C_Streams;
15269
15270 with Interfaces.C_Streams;
15271 package Ada.Direct_IO.C_Streams is
15272 function C_Stream (F : File_Type)
15273 return Interfaces.C_Streams.FILEs;
15274 procedure Open
15275 (File : in out File_Type;
15276 Mode : in File_Mode;
15277 C_Stream : in Interfaces.C_Streams.FILEs;
15278 Form : in String := "");
15279 end Ada.Direct_IO.C_Streams;
15280
15281 with Interfaces.C_Streams;
15282 package Ada.Text_IO.C_Streams is
15283 function C_Stream (F : File_Type)
15284 return Interfaces.C_Streams.FILEs;
15285 procedure Open
15286 (File : in out File_Type;
15287 Mode : in File_Mode;
15288 C_Stream : in Interfaces.C_Streams.FILEs;
15289 Form : in String := "");
15290 end Ada.Text_IO.C_Streams;
15291
15292 with Interfaces.C_Streams;
15293 package Ada.Wide_Text_IO.C_Streams is
15294 function C_Stream (F : File_Type)
15295 return Interfaces.C_Streams.FILEs;
15296 procedure Open
15297 (File : in out File_Type;
15298 Mode : in File_Mode;
15299 C_Stream : in Interfaces.C_Streams.FILEs;
15300 Form : in String := "");
15301 end Ada.Wide_Text_IO.C_Streams;
15302
15303 with Interfaces.C_Streams;
15304 package Ada.Wide_Wide_Text_IO.C_Streams is
15305 function C_Stream (F : File_Type)
15306 return Interfaces.C_Streams.FILEs;
15307 procedure Open
15308 (File : in out File_Type;
15309 Mode : in File_Mode;
15310 C_Stream : in Interfaces.C_Streams.FILEs;
15311 Form : in String := "");
15312 end Ada.Wide_Wide_Text_IO.C_Streams;
15313
15314 with Interfaces.C_Streams;
15315 package Ada.Stream_IO.C_Streams is
15316 function C_Stream (F : File_Type)
15317 return Interfaces.C_Streams.FILEs;
15318 procedure Open
15319 (File : in out File_Type;
15320 Mode : in File_Mode;
15321 C_Stream : in Interfaces.C_Streams.FILEs;
15322 Form : in String := "");
15323 end Ada.Stream_IO.C_Streams;
15324 @end smallexample
15325
15326 @noindent
15327 In each of these six packages, the @code{C_Stream} function obtains the
15328 @code{FILE} pointer from a currently opened Ada file. It is then
15329 possible to use the @code{Interfaces.C_Streams} package to operate on
15330 this stream, or the stream can be passed to a C program which can
15331 operate on it directly. Of course the program is responsible for
15332 ensuring that only appropriate sequences of operations are executed.
15333
15334 One particular use of relevance to an Ada program is that the
15335 @code{setvbuf} function can be used to control the buffering of the
15336 stream used by an Ada file. In the absence of such a call the standard
15337 default buffering is used.
15338
15339 The @code{Open} procedures in these packages open a file giving an
15340 existing C Stream instead of a file name. Typically this stream is
15341 imported from a C program, allowing an Ada file to operate on an
15342 existing C file.
15343
15344 @node The GNAT Library
15345 @chapter The GNAT Library
15346
15347 @noindent
15348 The GNAT library contains a number of general and special purpose packages.
15349 It represents functionality that the GNAT developers have found useful, and
15350 which is made available to GNAT users. The packages described here are fully
15351 supported, and upwards compatibility will be maintained in future releases,
15352 so you can use these facilities with the confidence that the same functionality
15353 will be available in future releases.
15354
15355 The chapter here simply gives a brief summary of the facilities available.
15356 The full documentation is found in the spec file for the package. The full
15357 sources of these library packages, including both spec and body, are provided
15358 with all GNAT releases. For example, to find out the full specifications of
15359 the SPITBOL pattern matching capability, including a full tutorial and
15360 extensive examples, look in the @file{g-spipat.ads} file in the library.
15361
15362 For each entry here, the package name (as it would appear in a @code{with}
15363 clause) is given, followed by the name of the corresponding spec file in
15364 parentheses. The packages are children in four hierarchies, @code{Ada},
15365 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
15366 GNAT-specific hierarchy.
15367
15368 Note that an application program should only use packages in one of these
15369 four hierarchies if the package is defined in the Ada Reference Manual,
15370 or is listed in this section of the GNAT Programmers Reference Manual.
15371 All other units should be considered internal implementation units and
15372 should not be directly @code{with}'ed by application code. The use of
15373 a @code{with} statement that references one of these internal implementation
15374 units makes an application potentially dependent on changes in versions
15375 of GNAT, and will generate a warning message.
15376
15377 @menu
15378 * Ada.Characters.Latin_9 (a-chlat9.ads)::
15379 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
15380 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
15381 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
15382 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
15383 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
15384 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
15385 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
15386 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
15387 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
15388 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
15389 * Ada.Command_Line.Environment (a-colien.ads)::
15390 * Ada.Command_Line.Remove (a-colire.ads)::
15391 * Ada.Command_Line.Response_File (a-clrefi.ads)::
15392 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
15393 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
15394 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
15395 * Ada.Exceptions.Traceback (a-exctra.ads)::
15396 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
15397 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
15398 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
15399 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
15400 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
15401 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
15402 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
15403 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
15404 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
15405 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
15406 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
15407 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
15408 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
15409 * GNAT.Altivec (g-altive.ads)::
15410 * GNAT.Altivec.Conversions (g-altcon.ads)::
15411 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
15412 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
15413 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
15414 * GNAT.Array_Split (g-arrspl.ads)::
15415 * GNAT.AWK (g-awk.ads)::
15416 * GNAT.Bounded_Buffers (g-boubuf.ads)::
15417 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
15418 * GNAT.Bubble_Sort (g-bubsor.ads)::
15419 * GNAT.Bubble_Sort_A (g-busora.ads)::
15420 * GNAT.Bubble_Sort_G (g-busorg.ads)::
15421 * GNAT.Byte_Order_Mark (g-byorma.ads)::
15422 * GNAT.Byte_Swapping (g-bytswa.ads)::
15423 * GNAT.Calendar (g-calend.ads)::
15424 * GNAT.Calendar.Time_IO (g-catiio.ads)::
15425 * GNAT.Case_Util (g-casuti.ads)::
15426 * GNAT.CGI (g-cgi.ads)::
15427 * GNAT.CGI.Cookie (g-cgicoo.ads)::
15428 * GNAT.CGI.Debug (g-cgideb.ads)::
15429 * GNAT.Command_Line (g-comlin.ads)::
15430 * GNAT.Compiler_Version (g-comver.ads)::
15431 * GNAT.Ctrl_C (g-ctrl_c.ads)::
15432 * GNAT.CRC32 (g-crc32.ads)::
15433 * GNAT.Current_Exception (g-curexc.ads)::
15434 * GNAT.Debug_Pools (g-debpoo.ads)::
15435 * GNAT.Debug_Utilities (g-debuti.ads)::
15436 * GNAT.Decode_String (g-decstr.ads)::
15437 * GNAT.Decode_UTF8_String (g-deutst.ads)::
15438 * GNAT.Directory_Operations (g-dirope.ads)::
15439 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
15440 * GNAT.Dynamic_HTables (g-dynhta.ads)::
15441 * GNAT.Dynamic_Tables (g-dyntab.ads)::
15442 * GNAT.Encode_String (g-encstr.ads)::
15443 * GNAT.Encode_UTF8_String (g-enutst.ads)::
15444 * GNAT.Exception_Actions (g-excact.ads)::
15445 * GNAT.Exception_Traces (g-exctra.ads)::
15446 * GNAT.Exceptions (g-except.ads)::
15447 * GNAT.Expect (g-expect.ads)::
15448 * GNAT.Expect.TTY (g-exptty.ads)::
15449 * GNAT.Float_Control (g-flocon.ads)::
15450 * GNAT.Heap_Sort (g-heasor.ads)::
15451 * GNAT.Heap_Sort_A (g-hesora.ads)::
15452 * GNAT.Heap_Sort_G (g-hesorg.ads)::
15453 * GNAT.HTable (g-htable.ads)::
15454 * GNAT.IO (g-io.ads)::
15455 * GNAT.IO_Aux (g-io_aux.ads)::
15456 * GNAT.Lock_Files (g-locfil.ads)::
15457 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
15458 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
15459 * GNAT.MD5 (g-md5.ads)::
15460 * GNAT.Memory_Dump (g-memdum.ads)::
15461 * GNAT.Most_Recent_Exception (g-moreex.ads)::
15462 * GNAT.OS_Lib (g-os_lib.ads)::
15463 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
15464 * GNAT.Random_Numbers (g-rannum.ads)::
15465 * GNAT.Regexp (g-regexp.ads)::
15466 * GNAT.Registry (g-regist.ads)::
15467 * GNAT.Regpat (g-regpat.ads)::
15468 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
15469 * GNAT.Semaphores (g-semaph.ads)::
15470 * GNAT.Serial_Communications (g-sercom.ads)::
15471 * GNAT.SHA1 (g-sha1.ads)::
15472 * GNAT.SHA224 (g-sha224.ads)::
15473 * GNAT.SHA256 (g-sha256.ads)::
15474 * GNAT.SHA384 (g-sha384.ads)::
15475 * GNAT.SHA512 (g-sha512.ads)::
15476 * GNAT.Signals (g-signal.ads)::
15477 * GNAT.Sockets (g-socket.ads)::
15478 * GNAT.Source_Info (g-souinf.ads)::
15479 * GNAT.Spelling_Checker (g-speche.ads)::
15480 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
15481 * GNAT.Spitbol.Patterns (g-spipat.ads)::
15482 * GNAT.Spitbol (g-spitbo.ads)::
15483 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
15484 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
15485 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
15486 * GNAT.SSE (g-sse.ads)::
15487 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
15488 * GNAT.Strings (g-string.ads)::
15489 * GNAT.String_Split (g-strspl.ads)::
15490 * GNAT.Table (g-table.ads)::
15491 * GNAT.Task_Lock (g-tasloc.ads)::
15492 * GNAT.Threads (g-thread.ads)::
15493 * GNAT.Time_Stamp (g-timsta.ads)::
15494 * GNAT.Traceback (g-traceb.ads)::
15495 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15496 * GNAT.UTF_32 (g-utf_32.ads)::
15497 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15498 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15499 * GNAT.Wide_String_Split (g-wistsp.ads)::
15500 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15501 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15502 * Interfaces.C.Extensions (i-cexten.ads)::
15503 * Interfaces.C.Streams (i-cstrea.ads)::
15504 * Interfaces.CPP (i-cpp.ads)::
15505 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15506 * Interfaces.VxWorks (i-vxwork.ads)::
15507 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15508 * System.Address_Image (s-addima.ads)::
15509 * System.Assertions (s-assert.ads)::
15510 * System.Memory (s-memory.ads)::
15511 * System.Partition_Interface (s-parint.ads)::
15512 * System.Pool_Global (s-pooglo.ads)::
15513 * System.Pool_Local (s-pooloc.ads)::
15514 * System.Restrictions (s-restri.ads)::
15515 * System.Rident (s-rident.ads)::
15516 * System.Strings.Stream_Ops (s-ststop.ads)::
15517 * System.Task_Info (s-tasinf.ads)::
15518 * System.Wch_Cnv (s-wchcnv.ads)::
15519 * System.Wch_Con (s-wchcon.ads)::
15520 @end menu
15521
15522 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15523 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15524 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15525 @cindex Latin_9 constants for Character
15526
15527 @noindent
15528 This child of @code{Ada.Characters}
15529 provides a set of definitions corresponding to those in the
15530 RM-defined package @code{Ada.Characters.Latin_1} but with the
15531 few modifications required for @code{Latin-9}
15532 The provision of such a package
15533 is specifically authorized by the Ada Reference Manual
15534 (RM A.3.3(27)).
15535
15536 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15537 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15538 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15539 @cindex Latin_1 constants for Wide_Character
15540
15541 @noindent
15542 This child of @code{Ada.Characters}
15543 provides a set of definitions corresponding to those in the
15544 RM-defined package @code{Ada.Characters.Latin_1} but with the
15545 types of the constants being @code{Wide_Character}
15546 instead of @code{Character}. The provision of such a package
15547 is specifically authorized by the Ada Reference Manual
15548 (RM A.3.3(27)).
15549
15550 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15551 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15552 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15553 @cindex Latin_9 constants for Wide_Character
15554
15555 @noindent
15556 This child of @code{Ada.Characters}
15557 provides a set of definitions corresponding to those in the
15558 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15559 types of the constants being @code{Wide_Character}
15560 instead of @code{Character}. The provision of such a package
15561 is specifically authorized by the Ada Reference Manual
15562 (RM A.3.3(27)).
15563
15564 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15565 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15566 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15567 @cindex Latin_1 constants for Wide_Wide_Character
15568
15569 @noindent
15570 This child of @code{Ada.Characters}
15571 provides a set of definitions corresponding to those in the
15572 RM-defined package @code{Ada.Characters.Latin_1} but with the
15573 types of the constants being @code{Wide_Wide_Character}
15574 instead of @code{Character}. The provision of such a package
15575 is specifically authorized by the Ada Reference Manual
15576 (RM A.3.3(27)).
15577
15578 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15579 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15580 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15581 @cindex Latin_9 constants for Wide_Wide_Character
15582
15583 @noindent
15584 This child of @code{Ada.Characters}
15585 provides a set of definitions corresponding to those in the
15586 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15587 types of the constants being @code{Wide_Wide_Character}
15588 instead of @code{Character}. The provision of such a package
15589 is specifically authorized by the Ada Reference Manual
15590 (RM A.3.3(27)).
15591
15592 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15593 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15594 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15595 @cindex Formal container for doubly linked lists
15596
15597 @noindent
15598 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15599 container for doubly linked lists, meant to facilitate formal verification of
15600 code using such containers.
15601
15602 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15603 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15604 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15605 @cindex Formal container for hashed maps
15606
15607 @noindent
15608 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15609 container for hashed maps, meant to facilitate formal verification of
15610 code using such containers.
15611
15612 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15613 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15614 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15615 @cindex Formal container for hashed sets
15616
15617 @noindent
15618 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15619 container for hashed sets, meant to facilitate formal verification of
15620 code using such containers.
15621
15622 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15623 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15624 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15625 @cindex Formal container for ordered maps
15626
15627 @noindent
15628 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15629 container for ordered maps, meant to facilitate formal verification of
15630 code using such containers.
15631
15632 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15633 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15634 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15635 @cindex Formal container for ordered sets
15636
15637 @noindent
15638 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15639 container for ordered sets, meant to facilitate formal verification of
15640 code using such containers.
15641
15642 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15643 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15644 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15645 @cindex Formal container for vectors
15646
15647 @noindent
15648 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15649 container for vectors, meant to facilitate formal verification of
15650 code using such containers.
15651
15652 @node Ada.Command_Line.Environment (a-colien.ads)
15653 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15654 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15655 @cindex Environment entries
15656
15657 @noindent
15658 This child of @code{Ada.Command_Line}
15659 provides a mechanism for obtaining environment values on systems
15660 where this concept makes sense.
15661
15662 @node Ada.Command_Line.Remove (a-colire.ads)
15663 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15664 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15665 @cindex Removing command line arguments
15666 @cindex Command line, argument removal
15667
15668 @noindent
15669 This child of @code{Ada.Command_Line}
15670 provides a mechanism for logically removing
15671 arguments from the argument list. Once removed, an argument is not visible
15672 to further calls on the subprograms in @code{Ada.Command_Line} will not
15673 see the removed argument.
15674
15675 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15676 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15677 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15678 @cindex Response file for command line
15679 @cindex Command line, response file
15680 @cindex Command line, handling long command lines
15681
15682 @noindent
15683 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15684 getting command line arguments from a text file, called a "response file".
15685 Using a response file allow passing a set of arguments to an executable longer
15686 than the maximum allowed by the system on the command line.
15687
15688 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15689 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15690 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15691 @cindex C Streams, Interfacing with Direct_IO
15692
15693 @noindent
15694 This package provides subprograms that allow interfacing between
15695 C streams and @code{Direct_IO}. The stream identifier can be
15696 extracted from a file opened on the Ada side, and an Ada file
15697 can be constructed from a stream opened on the C side.
15698
15699 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15700 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15701 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15702 @cindex Null_Occurrence, testing for
15703
15704 @noindent
15705 This child subprogram provides a way of testing for the null
15706 exception occurrence (@code{Null_Occurrence}) without raising
15707 an exception.
15708
15709 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15710 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15711 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15712 @cindex Null_Occurrence, testing for
15713
15714 @noindent
15715 This child subprogram is used for handling otherwise unhandled
15716 exceptions (hence the name last chance), and perform clean ups before
15717 terminating the program. Note that this subprogram never returns.
15718
15719 @node Ada.Exceptions.Traceback (a-exctra.ads)
15720 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15721 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15722 @cindex Traceback for Exception Occurrence
15723
15724 @noindent
15725 This child package provides the subprogram (@code{Tracebacks}) to
15726 give a traceback array of addresses based on an exception
15727 occurrence.
15728
15729 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15730 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15731 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15732 @cindex C Streams, Interfacing with Sequential_IO
15733
15734 @noindent
15735 This package provides subprograms that allow interfacing between
15736 C streams and @code{Sequential_IO}. The stream identifier can be
15737 extracted from a file opened on the Ada side, and an Ada file
15738 can be constructed from a stream opened on the C side.
15739
15740 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15741 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15742 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15743 @cindex C Streams, Interfacing with Stream_IO
15744
15745 @noindent
15746 This package provides subprograms that allow interfacing between
15747 C streams and @code{Stream_IO}. The stream identifier can be
15748 extracted from a file opened on the Ada side, and an Ada file
15749 can be constructed from a stream opened on the C side.
15750
15751 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15752 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15753 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15754 @cindex @code{Unbounded_String}, IO support
15755 @cindex @code{Text_IO}, extensions for unbounded strings
15756
15757 @noindent
15758 This package provides subprograms for Text_IO for unbounded
15759 strings, avoiding the necessity for an intermediate operation
15760 with ordinary strings.
15761
15762 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15763 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15764 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15765 @cindex @code{Unbounded_Wide_String}, IO support
15766 @cindex @code{Text_IO}, extensions for unbounded wide strings
15767
15768 @noindent
15769 This package provides subprograms for Text_IO for unbounded
15770 wide strings, avoiding the necessity for an intermediate operation
15771 with ordinary wide strings.
15772
15773 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15774 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15775 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15776 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15777 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15778
15779 @noindent
15780 This package provides subprograms for Text_IO for unbounded
15781 wide wide strings, avoiding the necessity for an intermediate operation
15782 with ordinary wide wide strings.
15783
15784 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15785 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15786 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15787 @cindex C Streams, Interfacing with @code{Text_IO}
15788
15789 @noindent
15790 This package provides subprograms that allow interfacing between
15791 C streams and @code{Text_IO}. The stream identifier can be
15792 extracted from a file opened on the Ada side, and an Ada file
15793 can be constructed from a stream opened on the C side.
15794
15795 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15796 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15797 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15798 @cindex @code{Text_IO} resetting standard files
15799
15800 @noindent
15801 This procedure is used to reset the status of the standard files used
15802 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15803 embedded application) where the status of the files may change during
15804 execution (for example a standard input file may be redefined to be
15805 interactive).
15806
15807 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15808 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15809 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15810 @cindex Unicode categorization, Wide_Character
15811
15812 @noindent
15813 This package provides subprograms that allow categorization of
15814 Wide_Character values according to Unicode categories.
15815
15816 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15817 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15818 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15819 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15820
15821 @noindent
15822 This package provides subprograms that allow interfacing between
15823 C streams and @code{Wide_Text_IO}. The stream identifier can be
15824 extracted from a file opened on the Ada side, and an Ada file
15825 can be constructed from a stream opened on the C side.
15826
15827 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15828 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15829 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15830 @cindex @code{Wide_Text_IO} resetting standard files
15831
15832 @noindent
15833 This procedure is used to reset the status of the standard files used
15834 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15835 embedded application) where the status of the files may change during
15836 execution (for example a standard input file may be redefined to be
15837 interactive).
15838
15839 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15840 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15841 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15842 @cindex Unicode categorization, Wide_Wide_Character
15843
15844 @noindent
15845 This package provides subprograms that allow categorization of
15846 Wide_Wide_Character values according to Unicode categories.
15847
15848 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15849 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15850 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15851 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15852
15853 @noindent
15854 This package provides subprograms that allow interfacing between
15855 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15856 extracted from a file opened on the Ada side, and an Ada file
15857 can be constructed from a stream opened on the C side.
15858
15859 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15860 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15861 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15862 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15863
15864 @noindent
15865 This procedure is used to reset the status of the standard files used
15866 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15867 restart in an embedded application) where the status of the files may
15868 change during execution (for example a standard input file may be
15869 redefined to be interactive).
15870
15871 @node GNAT.Altivec (g-altive.ads)
15872 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15873 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15874 @cindex AltiVec
15875
15876 @noindent
15877 This is the root package of the GNAT AltiVec binding. It provides
15878 definitions of constants and types common to all the versions of the
15879 binding.
15880
15881 @node GNAT.Altivec.Conversions (g-altcon.ads)
15882 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15883 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15884 @cindex AltiVec
15885
15886 @noindent
15887 This package provides the Vector/View conversion routines.
15888
15889 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15890 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15891 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15892 @cindex AltiVec
15893
15894 @noindent
15895 This package exposes the Ada interface to the AltiVec operations on
15896 vector objects. A soft emulation is included by default in the GNAT
15897 library. The hard binding is provided as a separate package. This unit
15898 is common to both bindings.
15899
15900 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15901 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15902 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15903 @cindex AltiVec
15904
15905 @noindent
15906 This package exposes the various vector types part of the Ada binding
15907 to AltiVec facilities.
15908
15909 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15910 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15911 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15912 @cindex AltiVec
15913
15914 @noindent
15915 This package provides public 'View' data types from/to which private
15916 vector representations can be converted via
15917 GNAT.Altivec.Conversions. This allows convenient access to individual
15918 vector elements and provides a simple way to initialize vector
15919 objects.
15920
15921 @node GNAT.Array_Split (g-arrspl.ads)
15922 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15923 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15924 @cindex Array splitter
15925
15926 @noindent
15927 Useful array-manipulation routines: given a set of separators, split
15928 an array wherever the separators appear, and provide direct access
15929 to the resulting slices.
15930
15931 @node GNAT.AWK (g-awk.ads)
15932 @section @code{GNAT.AWK} (@file{g-awk.ads})
15933 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15934 @cindex Parsing
15935 @cindex AWK
15936
15937 @noindent
15938 Provides AWK-like parsing functions, with an easy interface for parsing one
15939 or more files containing formatted data. The file is viewed as a database
15940 where each record is a line and a field is a data element in this line.
15941
15942 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15943 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15944 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15945 @cindex Parsing
15946 @cindex Bounded Buffers
15947
15948 @noindent
15949 Provides a concurrent generic bounded buffer abstraction. Instances are
15950 useful directly or as parts of the implementations of other abstractions,
15951 such as mailboxes.
15952
15953 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15954 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15955 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15956 @cindex Parsing
15957 @cindex Mailboxes
15958
15959 @noindent
15960 Provides a thread-safe asynchronous intertask mailbox communication facility.
15961
15962 @node GNAT.Bubble_Sort (g-bubsor.ads)
15963 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15964 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15965 @cindex Sorting
15966 @cindex Bubble sort
15967
15968 @noindent
15969 Provides a general implementation of bubble sort usable for sorting arbitrary
15970 data items. Exchange and comparison procedures are provided by passing
15971 access-to-procedure values.
15972
15973 @node GNAT.Bubble_Sort_A (g-busora.ads)
15974 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15975 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15976 @cindex Sorting
15977 @cindex Bubble sort
15978
15979 @noindent
15980 Provides a general implementation of bubble sort usable for sorting arbitrary
15981 data items. Move and comparison procedures are provided by passing
15982 access-to-procedure values. This is an older version, retained for
15983 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15984
15985 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15986 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15987 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15988 @cindex Sorting
15989 @cindex Bubble sort
15990
15991 @noindent
15992 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15993 are provided as generic parameters, this improves efficiency, especially
15994 if the procedures can be inlined, at the expense of duplicating code for
15995 multiple instantiations.
15996
15997 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15998 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15999 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16000 @cindex UTF-8 representation
16001 @cindex Wide characte representations
16002
16003 @noindent
16004 Provides a routine which given a string, reads the start of the string to
16005 see whether it is one of the standard byte order marks (BOM's) which signal
16006 the encoding of the string. The routine includes detection of special XML
16007 sequences for various UCS input formats.
16008
16009 @node GNAT.Byte_Swapping (g-bytswa.ads)
16010 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16011 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16012 @cindex Byte swapping
16013 @cindex Endianness
16014
16015 @noindent
16016 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
16017 Machine-specific implementations are available in some cases.
16018
16019 @node GNAT.Calendar (g-calend.ads)
16020 @section @code{GNAT.Calendar} (@file{g-calend.ads})
16021 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
16022 @cindex @code{Calendar}
16023
16024 @noindent
16025 Extends the facilities provided by @code{Ada.Calendar} to include handling
16026 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
16027 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
16028 C @code{timeval} format.
16029
16030 @node GNAT.Calendar.Time_IO (g-catiio.ads)
16031 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16032 @cindex @code{Calendar}
16033 @cindex Time
16034 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16035
16036 @node GNAT.CRC32 (g-crc32.ads)
16037 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
16038 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
16039 @cindex CRC32
16040 @cindex Cyclic Redundancy Check
16041
16042 @noindent
16043 This package implements the CRC-32 algorithm. For a full description
16044 of this algorithm see
16045 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
16046 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
16047 Aug.@: 1988. Sarwate, D.V@.
16048
16049 @node GNAT.Case_Util (g-casuti.ads)
16050 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
16051 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
16052 @cindex Casing utilities
16053 @cindex Character handling (@code{GNAT.Case_Util})
16054
16055 @noindent
16056 A set of simple routines for handling upper and lower casing of strings
16057 without the overhead of the full casing tables
16058 in @code{Ada.Characters.Handling}.
16059
16060 @node GNAT.CGI (g-cgi.ads)
16061 @section @code{GNAT.CGI} (@file{g-cgi.ads})
16062 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
16063 @cindex CGI (Common Gateway Interface)
16064
16065 @noindent
16066 This is a package for interfacing a GNAT program with a Web server via the
16067 Common Gateway Interface (CGI)@. Basically this package parses the CGI
16068 parameters, which are a set of key/value pairs sent by the Web server. It
16069 builds a table whose index is the key and provides some services to deal
16070 with this table.
16071
16072 @node GNAT.CGI.Cookie (g-cgicoo.ads)
16073 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16074 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16075 @cindex CGI (Common Gateway Interface) cookie support
16076 @cindex Cookie support in CGI
16077
16078 @noindent
16079 This is a package to interface a GNAT program with a Web server via the
16080 Common Gateway Interface (CGI). It exports services to deal with Web
16081 cookies (piece of information kept in the Web client software).
16082
16083 @node GNAT.CGI.Debug (g-cgideb.ads)
16084 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16085 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16086 @cindex CGI (Common Gateway Interface) debugging
16087
16088 @noindent
16089 This is a package to help debugging CGI (Common Gateway Interface)
16090 programs written in Ada.
16091
16092 @node GNAT.Command_Line (g-comlin.ads)
16093 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
16094 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
16095 @cindex Command line
16096
16097 @noindent
16098 Provides a high level interface to @code{Ada.Command_Line} facilities,
16099 including the ability to scan for named switches with optional parameters
16100 and expand file names using wild card notations.
16101
16102 @node GNAT.Compiler_Version (g-comver.ads)
16103 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16104 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16105 @cindex Compiler Version
16106 @cindex Version, of compiler
16107
16108 @noindent
16109 Provides a routine for obtaining the version of the compiler used to
16110 compile the program. More accurately this is the version of the binder
16111 used to bind the program (this will normally be the same as the version
16112 of the compiler if a consistent tool set is used to compile all units
16113 of a partition).
16114
16115 @node GNAT.Ctrl_C (g-ctrl_c.ads)
16116 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16117 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16118 @cindex Interrupt
16119
16120 @noindent
16121 Provides a simple interface to handle Ctrl-C keyboard events.
16122
16123 @node GNAT.Current_Exception (g-curexc.ads)
16124 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16125 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16126 @cindex Current exception
16127 @cindex Exception retrieval
16128
16129 @noindent
16130 Provides access to information on the current exception that has been raised
16131 without the need for using the Ada 95 / Ada 2005 exception choice parameter
16132 specification syntax.
16133 This is particularly useful in simulating typical facilities for
16134 obtaining information about exceptions provided by Ada 83 compilers.
16135
16136 @node GNAT.Debug_Pools (g-debpoo.ads)
16137 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16138 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16139 @cindex Debugging
16140 @cindex Debug pools
16141 @cindex Memory corruption debugging
16142
16143 @noindent
16144 Provide a debugging storage pools that helps tracking memory corruption
16145 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
16146 @value{EDITION} User's Guide}.
16147
16148 @node GNAT.Debug_Utilities (g-debuti.ads)
16149 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16150 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16151 @cindex Debugging
16152
16153 @noindent
16154 Provides a few useful utilities for debugging purposes, including conversion
16155 to and from string images of address values. Supports both C and Ada formats
16156 for hexadecimal literals.
16157
16158 @node GNAT.Decode_String (g-decstr.ads)
16159 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
16160 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
16161 @cindex Decoding strings
16162 @cindex String decoding
16163 @cindex Wide character encoding
16164 @cindex UTF-8
16165 @cindex Unicode
16166
16167 @noindent
16168 A generic package providing routines for decoding wide character and wide wide
16169 character strings encoded as sequences of 8-bit characters using a specified
16170 encoding method. Includes validation routines, and also routines for stepping
16171 to next or previous encoded character in an encoded string.
16172 Useful in conjunction with Unicode character coding. Note there is a
16173 preinstantiation for UTF-8. See next entry.
16174
16175 @node GNAT.Decode_UTF8_String (g-deutst.ads)
16176 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16177 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16178 @cindex Decoding strings
16179 @cindex Decoding UTF-8 strings
16180 @cindex UTF-8 string decoding
16181 @cindex Wide character decoding
16182 @cindex UTF-8
16183 @cindex Unicode
16184
16185 @noindent
16186 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
16187
16188 @node GNAT.Directory_Operations (g-dirope.ads)
16189 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16190 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16191 @cindex Directory operations
16192
16193 @noindent
16194 Provides a set of routines for manipulating directories, including changing
16195 the current directory, making new directories, and scanning the files in a
16196 directory.
16197
16198 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
16199 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16200 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16201 @cindex Directory operations iteration
16202
16203 @noindent
16204 A child unit of GNAT.Directory_Operations providing additional operations
16205 for iterating through directories.
16206
16207 @node GNAT.Dynamic_HTables (g-dynhta.ads)
16208 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16209 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16210 @cindex Hash tables
16211
16212 @noindent
16213 A generic implementation of hash tables that can be used to hash arbitrary
16214 data. Provided in two forms, a simple form with built in hash functions,
16215 and a more complex form in which the hash function is supplied.
16216
16217 @noindent
16218 This package provides a facility similar to that of @code{GNAT.HTable},
16219 except that this package declares a type that can be used to define
16220 dynamic instances of the hash table, while an instantiation of
16221 @code{GNAT.HTable} creates a single instance of the hash table.
16222
16223 @node GNAT.Dynamic_Tables (g-dyntab.ads)
16224 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16225 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16226 @cindex Table implementation
16227 @cindex Arrays, extendable
16228
16229 @noindent
16230 A generic package providing a single dimension array abstraction where the
16231 length of the array can be dynamically modified.
16232
16233 @noindent
16234 This package provides a facility similar to that of @code{GNAT.Table},
16235 except that this package declares a type that can be used to define
16236 dynamic instances of the table, while an instantiation of
16237 @code{GNAT.Table} creates a single instance of the table type.
16238
16239 @node GNAT.Encode_String (g-encstr.ads)
16240 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
16241 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
16242 @cindex Encoding strings
16243 @cindex String encoding
16244 @cindex Wide character encoding
16245 @cindex UTF-8
16246 @cindex Unicode
16247
16248 @noindent
16249 A generic package providing routines for encoding wide character and wide
16250 wide character strings as sequences of 8-bit characters using a specified
16251 encoding method. Useful in conjunction with Unicode character coding.
16252 Note there is a preinstantiation for UTF-8. See next entry.
16253
16254 @node GNAT.Encode_UTF8_String (g-enutst.ads)
16255 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16256 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16257 @cindex Encoding strings
16258 @cindex Encoding UTF-8 strings
16259 @cindex UTF-8 string encoding
16260 @cindex Wide character encoding
16261 @cindex UTF-8
16262 @cindex Unicode
16263
16264 @noindent
16265 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
16266
16267 @node GNAT.Exception_Actions (g-excact.ads)
16268 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16269 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16270 @cindex Exception actions
16271
16272 @noindent
16273 Provides callbacks when an exception is raised. Callbacks can be registered
16274 for specific exceptions, or when any exception is raised. This
16275 can be used for instance to force a core dump to ease debugging.
16276
16277 @node GNAT.Exception_Traces (g-exctra.ads)
16278 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16279 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16280 @cindex Exception traces
16281 @cindex Debugging
16282
16283 @noindent
16284 Provides an interface allowing to control automatic output upon exception
16285 occurrences.
16286
16287 @node GNAT.Exceptions (g-except.ads)
16288 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
16289 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
16290 @cindex Exceptions, Pure
16291 @cindex Pure packages, exceptions
16292
16293 @noindent
16294 Normally it is not possible to raise an exception with
16295 a message from a subprogram in a pure package, since the
16296 necessary types and subprograms are in @code{Ada.Exceptions}
16297 which is not a pure unit. @code{GNAT.Exceptions} provides a
16298 facility for getting around this limitation for a few
16299 predefined exceptions, and for example allow raising
16300 @code{Constraint_Error} with a message from a pure subprogram.
16301
16302 @node GNAT.Expect (g-expect.ads)
16303 @section @code{GNAT.Expect} (@file{g-expect.ads})
16304 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
16305
16306 @noindent
16307 Provides a set of subprograms similar to what is available
16308 with the standard Tcl Expect tool.
16309 It allows you to easily spawn and communicate with an external process.
16310 You can send commands or inputs to the process, and compare the output
16311 with some expected regular expression. Currently @code{GNAT.Expect}
16312 is implemented on all native GNAT ports except for OpenVMS@.
16313 It is not implemented for cross ports, and in particular is not
16314 implemented for VxWorks or LynxOS@.
16315
16316 @node GNAT.Expect.TTY (g-exptty.ads)
16317 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16318 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16319
16320 @noindent
16321 As GNAT.Expect but using pseudo-terminal.
16322 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
16323 ports except for OpenVMS@. It is not implemented for cross ports, and
16324 in particular is not implemented for VxWorks or LynxOS@.
16325
16326 @node GNAT.Float_Control (g-flocon.ads)
16327 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
16328 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
16329 @cindex Floating-Point Processor
16330
16331 @noindent
16332 Provides an interface for resetting the floating-point processor into the
16333 mode required for correct semantic operation in Ada. Some third party
16334 library calls may cause this mode to be modified, and the Reset procedure
16335 in this package can be used to reestablish the required mode.
16336
16337 @node GNAT.Heap_Sort (g-heasor.ads)
16338 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16339 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16340 @cindex Sorting
16341
16342 @noindent
16343 Provides a general implementation of heap sort usable for sorting arbitrary
16344 data items. Exchange and comparison procedures are provided by passing
16345 access-to-procedure values. The algorithm used is a modified heap sort
16346 that performs approximately N*log(N) comparisons in the worst case.
16347
16348 @node GNAT.Heap_Sort_A (g-hesora.ads)
16349 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16350 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16351 @cindex Sorting
16352
16353 @noindent
16354 Provides a general implementation of heap sort usable for sorting arbitrary
16355 data items. Move and comparison procedures are provided by passing
16356 access-to-procedure values. The algorithm used is a modified heap sort
16357 that performs approximately N*log(N) comparisons in the worst case.
16358 This differs from @code{GNAT.Heap_Sort} in having a less convenient
16359 interface, but may be slightly more efficient.
16360
16361 @node GNAT.Heap_Sort_G (g-hesorg.ads)
16362 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16363 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16364 @cindex Sorting
16365
16366 @noindent
16367 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
16368 are provided as generic parameters, this improves efficiency, especially
16369 if the procedures can be inlined, at the expense of duplicating code for
16370 multiple instantiations.
16371
16372 @node GNAT.HTable (g-htable.ads)
16373 @section @code{GNAT.HTable} (@file{g-htable.ads})
16374 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
16375 @cindex Hash tables
16376
16377 @noindent
16378 A generic implementation of hash tables that can be used to hash arbitrary
16379 data. Provides two approaches, one a simple static approach, and the other
16380 allowing arbitrary dynamic hash tables.
16381
16382 @node GNAT.IO (g-io.ads)
16383 @section @code{GNAT.IO} (@file{g-io.ads})
16384 @cindex @code{GNAT.IO} (@file{g-io.ads})
16385 @cindex Simple I/O
16386 @cindex Input/Output facilities
16387
16388 @noindent
16389 A simple preelaborable input-output package that provides a subset of
16390 simple Text_IO functions for reading characters and strings from
16391 Standard_Input, and writing characters, strings and integers to either
16392 Standard_Output or Standard_Error.
16393
16394 @node GNAT.IO_Aux (g-io_aux.ads)
16395 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16396 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16397 @cindex Text_IO
16398 @cindex Input/Output facilities
16399
16400 Provides some auxiliary functions for use with Text_IO, including a test
16401 for whether a file exists, and functions for reading a line of text.
16402
16403 @node GNAT.Lock_Files (g-locfil.ads)
16404 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16405 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16406 @cindex File locking
16407 @cindex Locking using files
16408
16409 @noindent
16410 Provides a general interface for using files as locks. Can be used for
16411 providing program level synchronization.
16412
16413 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
16414 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16415 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16416 @cindex Random number generation
16417
16418 @noindent
16419 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
16420 a modified version of the Blum-Blum-Shub generator.
16421
16422 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
16423 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16424 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16425 @cindex Random number generation
16426
16427 @noindent
16428 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
16429 a modified version of the Blum-Blum-Shub generator.
16430
16431 @node GNAT.MD5 (g-md5.ads)
16432 @section @code{GNAT.MD5} (@file{g-md5.ads})
16433 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
16434 @cindex Message Digest MD5
16435
16436 @noindent
16437 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
16438
16439 @node GNAT.Memory_Dump (g-memdum.ads)
16440 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16441 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16442 @cindex Dump Memory
16443
16444 @noindent
16445 Provides a convenient routine for dumping raw memory to either the
16446 standard output or standard error files. Uses GNAT.IO for actual
16447 output.
16448
16449 @node GNAT.Most_Recent_Exception (g-moreex.ads)
16450 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16451 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16452 @cindex Exception, obtaining most recent
16453
16454 @noindent
16455 Provides access to the most recently raised exception. Can be used for
16456 various logging purposes, including duplicating functionality of some
16457 Ada 83 implementation dependent extensions.
16458
16459 @node GNAT.OS_Lib (g-os_lib.ads)
16460 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16461 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16462 @cindex Operating System interface
16463 @cindex Spawn capability
16464
16465 @noindent
16466 Provides a range of target independent operating system interface functions,
16467 including time/date management, file operations, subprocess management,
16468 including a portable spawn procedure, and access to environment variables
16469 and error return codes.
16470
16471 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
16472 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16473 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16474 @cindex Hash functions
16475
16476 @noindent
16477 Provides a generator of static minimal perfect hash functions. No
16478 collisions occur and each item can be retrieved from the table in one
16479 probe (perfect property). The hash table size corresponds to the exact
16480 size of the key set and no larger (minimal property). The key set has to
16481 be know in advance (static property). The hash functions are also order
16482 preserving. If w2 is inserted after w1 in the generator, their
16483 hashcode are in the same order. These hashing functions are very
16484 convenient for use with realtime applications.
16485
16486 @node GNAT.Random_Numbers (g-rannum.ads)
16487 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16488 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16489 @cindex Random number generation
16490
16491 @noindent
16492 Provides random number capabilities which extend those available in the
16493 standard Ada library and are more convenient to use.
16494
16495 @node GNAT.Regexp (g-regexp.ads)
16496 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16497 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16498 @cindex Regular expressions
16499 @cindex Pattern matching
16500
16501 @noindent
16502 A simple implementation of regular expressions, using a subset of regular
16503 expression syntax copied from familiar Unix style utilities. This is the
16504 simples of the three pattern matching packages provided, and is particularly
16505 suitable for ``file globbing'' applications.
16506
16507 @node GNAT.Registry (g-regist.ads)
16508 @section @code{GNAT.Registry} (@file{g-regist.ads})
16509 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16510 @cindex Windows Registry
16511
16512 @noindent
16513 This is a high level binding to the Windows registry. It is possible to
16514 do simple things like reading a key value, creating a new key. For full
16515 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16516 package provided with the Win32Ada binding
16517
16518 @node GNAT.Regpat (g-regpat.ads)
16519 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16520 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16521 @cindex Regular expressions
16522 @cindex Pattern matching
16523
16524 @noindent
16525 A complete implementation of Unix-style regular expression matching, copied
16526 from the original V7 style regular expression library written in C by
16527 Henry Spencer (and binary compatible with this C library).
16528
16529 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16530 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16531 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16532 @cindex Secondary Stack Info
16533
16534 @noindent
16535 Provide the capability to query the high water mark of the current task's
16536 secondary stack.
16537
16538 @node GNAT.Semaphores (g-semaph.ads)
16539 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16540 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16541 @cindex Semaphores
16542
16543 @noindent
16544 Provides classic counting and binary semaphores using protected types.
16545
16546 @node GNAT.Serial_Communications (g-sercom.ads)
16547 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16548 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16549 @cindex Serial_Communications
16550
16551 @noindent
16552 Provides a simple interface to send and receive data over a serial
16553 port. This is only supported on GNU/Linux and Windows.
16554
16555 @node GNAT.SHA1 (g-sha1.ads)
16556 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16557 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16558 @cindex Secure Hash Algorithm SHA-1
16559
16560 @noindent
16561 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16562 and RFC 3174.
16563
16564 @node GNAT.SHA224 (g-sha224.ads)
16565 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16566 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16567 @cindex Secure Hash Algorithm SHA-224
16568
16569 @noindent
16570 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16571
16572 @node GNAT.SHA256 (g-sha256.ads)
16573 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16574 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16575 @cindex Secure Hash Algorithm SHA-256
16576
16577 @noindent
16578 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16579
16580 @node GNAT.SHA384 (g-sha384.ads)
16581 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16582 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16583 @cindex Secure Hash Algorithm SHA-384
16584
16585 @noindent
16586 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16587
16588 @node GNAT.SHA512 (g-sha512.ads)
16589 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16590 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16591 @cindex Secure Hash Algorithm SHA-512
16592
16593 @noindent
16594 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16595
16596 @node GNAT.Signals (g-signal.ads)
16597 @section @code{GNAT.Signals} (@file{g-signal.ads})
16598 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16599 @cindex Signals
16600
16601 @noindent
16602 Provides the ability to manipulate the blocked status of signals on supported
16603 targets.
16604
16605 @node GNAT.Sockets (g-socket.ads)
16606 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16607 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16608 @cindex Sockets
16609
16610 @noindent
16611 A high level and portable interface to develop sockets based applications.
16612 This package is based on the sockets thin binding found in
16613 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16614 on all native GNAT ports except for OpenVMS@. It is not implemented
16615 for the LynxOS@ cross port.
16616
16617 @node GNAT.Source_Info (g-souinf.ads)
16618 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16619 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16620 @cindex Source Information
16621
16622 @noindent
16623 Provides subprograms that give access to source code information known at
16624 compile time, such as the current file name and line number.
16625
16626 @node GNAT.Spelling_Checker (g-speche.ads)
16627 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16628 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16629 @cindex Spell checking
16630
16631 @noindent
16632 Provides a function for determining whether one string is a plausible
16633 near misspelling of another string.
16634
16635 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16636 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16637 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16638 @cindex Spell checking
16639
16640 @noindent
16641 Provides a generic function that can be instantiated with a string type for
16642 determining whether one string is a plausible near misspelling of another
16643 string.
16644
16645 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16646 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16647 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16648 @cindex SPITBOL pattern matching
16649 @cindex Pattern matching
16650
16651 @noindent
16652 A complete implementation of SNOBOL4 style pattern matching. This is the
16653 most elaborate of the pattern matching packages provided. It fully duplicates
16654 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16655 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16656
16657 @node GNAT.Spitbol (g-spitbo.ads)
16658 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16659 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16660 @cindex SPITBOL interface
16661
16662 @noindent
16663 The top level package of the collection of SPITBOL-style functionality, this
16664 package provides basic SNOBOL4 string manipulation functions, such as
16665 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16666 useful for constructing arbitrary mappings from strings in the style of
16667 the SNOBOL4 TABLE function.
16668
16669 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16670 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16671 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16672 @cindex Sets of strings
16673 @cindex SPITBOL Tables
16674
16675 @noindent
16676 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16677 for type @code{Standard.Boolean}, giving an implementation of sets of
16678 string values.
16679
16680 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16681 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16682 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16683 @cindex Integer maps
16684 @cindex Maps
16685 @cindex SPITBOL Tables
16686
16687 @noindent
16688 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16689 for type @code{Standard.Integer}, giving an implementation of maps
16690 from string to integer values.
16691
16692 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16693 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16694 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16695 @cindex String maps
16696 @cindex Maps
16697 @cindex SPITBOL Tables
16698
16699 @noindent
16700 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16701 a variable length string type, giving an implementation of general
16702 maps from strings to strings.
16703
16704 @node GNAT.SSE (g-sse.ads)
16705 @section @code{GNAT.SSE} (@file{g-sse.ads})
16706 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16707
16708 @noindent
16709 Root of a set of units aimed at offering Ada bindings to a subset of
16710 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16711 targets. It exposes vector component types together with a general
16712 introduction to the binding contents and use.
16713
16714 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16715 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16716 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16717
16718 @noindent
16719 SSE vector types for use with SSE related intrinsics.
16720
16721 @node GNAT.Strings (g-string.ads)
16722 @section @code{GNAT.Strings} (@file{g-string.ads})
16723 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16724
16725 @noindent
16726 Common String access types and related subprograms. Basically it
16727 defines a string access and an array of string access types.
16728
16729 @node GNAT.String_Split (g-strspl.ads)
16730 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16731 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16732 @cindex String splitter
16733
16734 @noindent
16735 Useful string manipulation routines: given a set of separators, split
16736 a string wherever the separators appear, and provide direct access
16737 to the resulting slices. This package is instantiated from
16738 @code{GNAT.Array_Split}.
16739
16740 @node GNAT.Table (g-table.ads)
16741 @section @code{GNAT.Table} (@file{g-table.ads})
16742 @cindex @code{GNAT.Table} (@file{g-table.ads})
16743 @cindex Table implementation
16744 @cindex Arrays, extendable
16745
16746 @noindent
16747 A generic package providing a single dimension array abstraction where the
16748 length of the array can be dynamically modified.
16749
16750 @noindent
16751 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16752 except that this package declares a single instance of the table type,
16753 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16754 used to define dynamic instances of the table.
16755
16756 @node GNAT.Task_Lock (g-tasloc.ads)
16757 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16758 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16759 @cindex Task synchronization
16760 @cindex Task locking
16761 @cindex Locking
16762
16763 @noindent
16764 A very simple facility for locking and unlocking sections of code using a
16765 single global task lock. Appropriate for use in situations where contention
16766 between tasks is very rarely expected.
16767
16768 @node GNAT.Time_Stamp (g-timsta.ads)
16769 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16770 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16771 @cindex Time stamp
16772 @cindex Current time
16773
16774 @noindent
16775 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16776 represents the current date and time in ISO 8601 format. This is a very simple
16777 routine with minimal code and there are no dependencies on any other unit.
16778
16779 @node GNAT.Threads (g-thread.ads)
16780 @section @code{GNAT.Threads} (@file{g-thread.ads})
16781 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16782 @cindex Foreign threads
16783 @cindex Threads, foreign
16784
16785 @noindent
16786 Provides facilities for dealing with foreign threads which need to be known
16787 by the GNAT run-time system. Consult the documentation of this package for
16788 further details if your program has threads that are created by a non-Ada
16789 environment which then accesses Ada code.
16790
16791 @node GNAT.Traceback (g-traceb.ads)
16792 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16793 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16794 @cindex Trace back facilities
16795
16796 @noindent
16797 Provides a facility for obtaining non-symbolic traceback information, useful
16798 in various debugging situations.
16799
16800 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16801 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16802 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16803 @cindex Trace back facilities
16804
16805 @node GNAT.UTF_32 (g-utf_32.ads)
16806 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16807 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16808 @cindex Wide character codes
16809
16810 @noindent
16811 This is a package intended to be used in conjunction with the
16812 @code{Wide_Character} type in Ada 95 and the
16813 @code{Wide_Wide_Character} type in Ada 2005 (available
16814 in @code{GNAT} in Ada 2005 mode). This package contains
16815 Unicode categorization routines, as well as lexical
16816 categorization routines corresponding to the Ada 2005
16817 lexical rules for identifiers and strings, and also a
16818 lower case to upper case fold routine corresponding to
16819 the Ada 2005 rules for identifier equivalence.
16820
16821 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16822 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16823 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16824 @cindex Spell checking
16825
16826 @noindent
16827 Provides a function for determining whether one wide wide string is a plausible
16828 near misspelling of another wide wide string, where the strings are represented
16829 using the UTF_32_String type defined in System.Wch_Cnv.
16830
16831 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16832 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16833 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16834 @cindex Spell checking
16835
16836 @noindent
16837 Provides a function for determining whether one wide string is a plausible
16838 near misspelling of another wide string.
16839
16840 @node GNAT.Wide_String_Split (g-wistsp.ads)
16841 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16842 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16843 @cindex Wide_String splitter
16844
16845 @noindent
16846 Useful wide string manipulation routines: given a set of separators, split
16847 a wide string wherever the separators appear, and provide direct access
16848 to the resulting slices. This package is instantiated from
16849 @code{GNAT.Array_Split}.
16850
16851 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16852 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16853 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16854 @cindex Spell checking
16855
16856 @noindent
16857 Provides a function for determining whether one wide wide string is a plausible
16858 near misspelling of another wide wide string.
16859
16860 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16861 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16862 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16863 @cindex Wide_Wide_String splitter
16864
16865 @noindent
16866 Useful wide wide string manipulation routines: given a set of separators, split
16867 a wide wide string wherever the separators appear, and provide direct access
16868 to the resulting slices. This package is instantiated from
16869 @code{GNAT.Array_Split}.
16870
16871 @node Interfaces.C.Extensions (i-cexten.ads)
16872 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16873 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16874
16875 @noindent
16876 This package contains additional C-related definitions, intended
16877 for use with either manually or automatically generated bindings
16878 to C libraries.
16879
16880 @node Interfaces.C.Streams (i-cstrea.ads)
16881 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16882 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16883 @cindex C streams, interfacing
16884
16885 @noindent
16886 This package is a binding for the most commonly used operations
16887 on C streams.
16888
16889 @node Interfaces.CPP (i-cpp.ads)
16890 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16891 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16892 @cindex C++ interfacing
16893 @cindex Interfacing, to C++
16894
16895 @noindent
16896 This package provides facilities for use in interfacing to C++. It
16897 is primarily intended to be used in connection with automated tools
16898 for the generation of C++ interfaces.
16899
16900 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16901 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16902 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16903 @cindex IBM Packed Format
16904 @cindex Packed Decimal
16905
16906 @noindent
16907 This package provides a set of routines for conversions to and
16908 from a packed decimal format compatible with that used on IBM
16909 mainframes.
16910
16911 @node Interfaces.VxWorks (i-vxwork.ads)
16912 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16913 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16914 @cindex Interfacing to VxWorks
16915 @cindex VxWorks, interfacing
16916
16917 @noindent
16918 This package provides a limited binding to the VxWorks API.
16919 In particular, it interfaces with the
16920 VxWorks hardware interrupt facilities.
16921
16922 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16923 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16924 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16925 @cindex Interfacing to VxWorks' I/O
16926 @cindex VxWorks, I/O interfacing
16927 @cindex VxWorks, Get_Immediate
16928 @cindex Get_Immediate, VxWorks
16929
16930 @noindent
16931 This package provides a binding to the ioctl (IO/Control)
16932 function of VxWorks, defining a set of option values and
16933 function codes. A particular use of this package is
16934 to enable the use of Get_Immediate under VxWorks.
16935
16936 @node System.Address_Image (s-addima.ads)
16937 @section @code{System.Address_Image} (@file{s-addima.ads})
16938 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16939 @cindex Address image
16940 @cindex Image, of an address
16941
16942 @noindent
16943 This function provides a useful debugging
16944 function that gives an (implementation dependent)
16945 string which identifies an address.
16946
16947 @node System.Assertions (s-assert.ads)
16948 @section @code{System.Assertions} (@file{s-assert.ads})
16949 @cindex @code{System.Assertions} (@file{s-assert.ads})
16950 @cindex Assertions
16951 @cindex Assert_Failure, exception
16952
16953 @noindent
16954 This package provides the declaration of the exception raised
16955 by an run-time assertion failure, as well as the routine that
16956 is used internally to raise this assertion.
16957
16958 @node System.Memory (s-memory.ads)
16959 @section @code{System.Memory} (@file{s-memory.ads})
16960 @cindex @code{System.Memory} (@file{s-memory.ads})
16961 @cindex Memory allocation
16962
16963 @noindent
16964 This package provides the interface to the low level routines used
16965 by the generated code for allocation and freeing storage for the
16966 default storage pool (analogous to the C routines malloc and free.
16967 It also provides a reallocation interface analogous to the C routine
16968 realloc. The body of this unit may be modified to provide alternative
16969 allocation mechanisms for the default pool, and in addition, direct
16970 calls to this unit may be made for low level allocation uses (for
16971 example see the body of @code{GNAT.Tables}).
16972
16973 @node System.Partition_Interface (s-parint.ads)
16974 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16975 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16976 @cindex Partition interfacing functions
16977
16978 @noindent
16979 This package provides facilities for partition interfacing. It
16980 is used primarily in a distribution context when using Annex E
16981 with @code{GLADE}.
16982
16983 @node System.Pool_Global (s-pooglo.ads)
16984 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16985 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16986 @cindex Storage pool, global
16987 @cindex Global storage pool
16988
16989 @noindent
16990 This package provides a storage pool that is equivalent to the default
16991 storage pool used for access types for which no pool is specifically
16992 declared. It uses malloc/free to allocate/free and does not attempt to
16993 do any automatic reclamation.
16994
16995 @node System.Pool_Local (s-pooloc.ads)
16996 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16997 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16998 @cindex Storage pool, local
16999 @cindex Local storage pool
17000
17001 @noindent
17002 This package provides a storage pool that is intended for use with locally
17003 defined access types. It uses malloc/free for allocate/free, and maintains
17004 a list of allocated blocks, so that all storage allocated for the pool can
17005 be freed automatically when the pool is finalized.
17006
17007 @node System.Restrictions (s-restri.ads)
17008 @section @code{System.Restrictions} (@file{s-restri.ads})
17009 @cindex @code{System.Restrictions} (@file{s-restri.ads})
17010 @cindex Run-time restrictions access
17011
17012 @noindent
17013 This package provides facilities for accessing at run time
17014 the status of restrictions specified at compile time for
17015 the partition. Information is available both with regard
17016 to actual restrictions specified, and with regard to
17017 compiler determined information on which restrictions
17018 are violated by one or more packages in the partition.
17019
17020 @node System.Rident (s-rident.ads)
17021 @section @code{System.Rident} (@file{s-rident.ads})
17022 @cindex @code{System.Rident} (@file{s-rident.ads})
17023 @cindex Restrictions definitions
17024
17025 @noindent
17026 This package provides definitions of the restrictions
17027 identifiers supported by GNAT, and also the format of
17028 the restrictions provided in package System.Restrictions.
17029 It is not normally necessary to @code{with} this generic package
17030 since the necessary instantiation is included in
17031 package System.Restrictions.
17032
17033 @node System.Strings.Stream_Ops (s-ststop.ads)
17034 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17035 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17036 @cindex Stream operations
17037 @cindex String stream operations
17038
17039 @noindent
17040 This package provides a set of stream subprograms for standard string types.
17041 It is intended primarily to support implicit use of such subprograms when
17042 stream attributes are applied to string types, but the subprograms in this
17043 package can be used directly by application programs.
17044
17045 @node System.Task_Info (s-tasinf.ads)
17046 @section @code{System.Task_Info} (@file{s-tasinf.ads})
17047 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
17048 @cindex Task_Info pragma
17049
17050 @noindent
17051 This package provides target dependent functionality that is used
17052 to support the @code{Task_Info} pragma
17053
17054 @node System.Wch_Cnv (s-wchcnv.ads)
17055 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17056 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17057 @cindex Wide Character, Representation
17058 @cindex Wide String, Conversion
17059 @cindex Representation of wide characters
17060
17061 @noindent
17062 This package provides routines for converting between
17063 wide and wide wide characters and a representation as a value of type
17064 @code{Standard.String}, using a specified wide character
17065 encoding method. It uses definitions in
17066 package @code{System.Wch_Con}.
17067
17068 @node System.Wch_Con (s-wchcon.ads)
17069 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
17070 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
17071
17072 @noindent
17073 This package provides definitions and descriptions of
17074 the various methods used for encoding wide characters
17075 in ordinary strings. These definitions are used by
17076 the package @code{System.Wch_Cnv}.
17077
17078 @node Interfacing to Other Languages
17079 @chapter Interfacing to Other Languages
17080 @noindent
17081 The facilities in annex B of the Ada Reference Manual are fully
17082 implemented in GNAT, and in addition, a full interface to C++ is
17083 provided.
17084
17085 @menu
17086 * Interfacing to C::
17087 * Interfacing to C++::
17088 * Interfacing to COBOL::
17089 * Interfacing to Fortran::
17090 * Interfacing to non-GNAT Ada code::
17091 @end menu
17092
17093 @node Interfacing to C
17094 @section Interfacing to C
17095
17096 @noindent
17097 Interfacing to C with GNAT can use one of two approaches:
17098
17099 @itemize @bullet
17100 @item
17101 The types in the package @code{Interfaces.C} may be used.
17102 @item
17103 Standard Ada types may be used directly. This may be less portable to
17104 other compilers, but will work on all GNAT compilers, which guarantee
17105 correspondence between the C and Ada types.
17106 @end itemize
17107
17108 @noindent
17109 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
17110 effect, since this is the default. The following table shows the
17111 correspondence between Ada scalar types and the corresponding C types.
17112
17113 @table @code
17114 @item Integer
17115 @code{int}
17116 @item Short_Integer
17117 @code{short}
17118 @item Short_Short_Integer
17119 @code{signed char}
17120 @item Long_Integer
17121 @code{long}
17122 @item Long_Long_Integer
17123 @code{long long}
17124 @item Short_Float
17125 @code{float}
17126 @item Float
17127 @code{float}
17128 @item Long_Float
17129 @code{double}
17130 @item Long_Long_Float
17131 This is the longest floating-point type supported by the hardware.
17132 @end table
17133
17134 @noindent
17135 Additionally, there are the following general correspondences between Ada
17136 and C types:
17137 @itemize @bullet
17138 @item
17139 Ada enumeration types map to C enumeration types directly if pragma
17140 @code{Convention C} is specified, which causes them to have int
17141 length. Without pragma @code{Convention C}, Ada enumeration types map to
17142 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
17143 @code{int}, respectively) depending on the number of values passed.
17144 This is the only case in which pragma @code{Convention C} affects the
17145 representation of an Ada type.
17146
17147 @item
17148 Ada access types map to C pointers, except for the case of pointers to
17149 unconstrained types in Ada, which have no direct C equivalent.
17150
17151 @item
17152 Ada arrays map directly to C arrays.
17153
17154 @item
17155 Ada records map directly to C structures.
17156
17157 @item
17158 Packed Ada records map to C structures where all members are bit fields
17159 of the length corresponding to the @code{@var{type}'Size} value in Ada.
17160 @end itemize
17161
17162 @node Interfacing to C++
17163 @section Interfacing to C++
17164
17165 @noindent
17166 The interface to C++ makes use of the following pragmas, which are
17167 primarily intended to be constructed automatically using a binding generator
17168 tool, although it is possible to construct them by hand.
17169
17170 Using these pragmas it is possible to achieve complete
17171 inter-operability between Ada tagged types and C++ class definitions.
17172 See @ref{Implementation Defined Pragmas}, for more details.
17173
17174 @table @code
17175 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
17176 The argument denotes an entity in the current declarative region that is
17177 declared as a tagged or untagged record type. It indicates that the type
17178 corresponds to an externally declared C++ class type, and is to be laid
17179 out the same way that C++ would lay out the type.
17180
17181 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
17182 for backward compatibility but its functionality is available
17183 using pragma @code{Import} with @code{Convention} = @code{CPP}.
17184
17185 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
17186 This pragma identifies an imported function (imported in the usual way
17187 with pragma @code{Import}) as corresponding to a C++ constructor.
17188 @end table
17189
17190 A few restrictions are placed on the use of the @code{Access} attribute
17191 in conjunction with subprograms subject to convention @code{CPP}: the
17192 attribute may be used neither on primitive operations of a tagged
17193 record type with convention @code{CPP}, imported or not, nor on
17194 subprograms imported with pragma @code{CPP_Constructor}.
17195
17196 In addition, C++ exceptions are propagated and can be handled in an
17197 @code{others} choice of an exception handler. The corresponding Ada
17198 occurrence has no message, and the simple name of the exception identity
17199 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
17200 tasks works properly when such foreign exceptions are propagated.
17201
17202 @node Interfacing to COBOL
17203 @section Interfacing to COBOL
17204
17205 @noindent
17206 Interfacing to COBOL is achieved as described in section B.4 of
17207 the Ada Reference Manual.
17208
17209 @node Interfacing to Fortran
17210 @section Interfacing to Fortran
17211
17212 @noindent
17213 Interfacing to Fortran is achieved as described in section B.5 of the
17214 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
17215 multi-dimensional array causes the array to be stored in column-major
17216 order as required for convenient interface to Fortran.
17217
17218 @node Interfacing to non-GNAT Ada code
17219 @section Interfacing to non-GNAT Ada code
17220
17221 It is possible to specify the convention @code{Ada} in a pragma
17222 @code{Import} or pragma @code{Export}. However this refers to
17223 the calling conventions used by GNAT, which may or may not be
17224 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
17225 compiler to allow interoperation.
17226
17227 If arguments types are kept simple, and if the foreign compiler generally
17228 follows system calling conventions, then it may be possible to integrate
17229 files compiled by other Ada compilers, provided that the elaboration
17230 issues are adequately addressed (for example by eliminating the
17231 need for any load time elaboration).
17232
17233 In particular, GNAT running on VMS is designed to
17234 be highly compatible with the DEC Ada 83 compiler, so this is one
17235 case in which it is possible to import foreign units of this type,
17236 provided that the data items passed are restricted to simple scalar
17237 values or simple record types without variants, or simple array
17238 types with fixed bounds.
17239
17240 @node Specialized Needs Annexes
17241 @chapter Specialized Needs Annexes
17242
17243 @noindent
17244 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
17245 required in all implementations. However, as described in this chapter,
17246 GNAT implements all of these annexes:
17247
17248 @table @asis
17249 @item Systems Programming (Annex C)
17250 The Systems Programming Annex is fully implemented.
17251
17252 @item Real-Time Systems (Annex D)
17253 The Real-Time Systems Annex is fully implemented.
17254
17255 @item Distributed Systems (Annex E)
17256 Stub generation is fully implemented in the GNAT compiler. In addition,
17257 a complete compatible PCS is available as part of the GLADE system,
17258 a separate product. When the two
17259 products are used in conjunction, this annex is fully implemented.
17260
17261 @item Information Systems (Annex F)
17262 The Information Systems annex is fully implemented.
17263
17264 @item Numerics (Annex G)
17265 The Numerics Annex is fully implemented.
17266
17267 @item Safety and Security / High-Integrity Systems (Annex H)
17268 The Safety and Security Annex (termed the High-Integrity Systems Annex
17269 in Ada 2005) is fully implemented.
17270 @end table
17271
17272 @node Implementation of Specific Ada Features
17273 @chapter Implementation of Specific Ada Features
17274
17275 @noindent
17276 This chapter describes the GNAT implementation of several Ada language
17277 facilities.
17278
17279 @menu
17280 * Machine Code Insertions::
17281 * GNAT Implementation of Tasking::
17282 * GNAT Implementation of Shared Passive Packages::
17283 * Code Generation for Array Aggregates::
17284 * The Size of Discriminated Records with Default Discriminants::
17285 * Strict Conformance to the Ada Reference Manual::
17286 @end menu
17287
17288 @node Machine Code Insertions
17289 @section Machine Code Insertions
17290 @cindex Machine Code insertions
17291
17292 @noindent
17293 Package @code{Machine_Code} provides machine code support as described
17294 in the Ada Reference Manual in two separate forms:
17295 @itemize @bullet
17296 @item
17297 Machine code statements, consisting of qualified expressions that
17298 fit the requirements of RM section 13.8.
17299 @item
17300 An intrinsic callable procedure, providing an alternative mechanism of
17301 including machine instructions in a subprogram.
17302 @end itemize
17303
17304 @noindent
17305 The two features are similar, and both are closely related to the mechanism
17306 provided by the asm instruction in the GNU C compiler. Full understanding
17307 and use of the facilities in this package requires understanding the asm
17308 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
17309 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
17310
17311 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
17312 semantic restrictions and effects as described below. Both are provided so
17313 that the procedure call can be used as a statement, and the function call
17314 can be used to form a code_statement.
17315
17316 The first example given in the GCC documentation is the C @code{asm}
17317 instruction:
17318 @smallexample
17319 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
17320 @end smallexample
17321
17322 @noindent
17323 The equivalent can be written for GNAT as:
17324
17325 @smallexample @c ada
17326 Asm ("fsinx %1 %0",
17327 My_Float'Asm_Output ("=f", result),
17328 My_Float'Asm_Input ("f", angle));
17329 @end smallexample
17330
17331 @noindent
17332 The first argument to @code{Asm} is the assembler template, and is
17333 identical to what is used in GNU C@. This string must be a static
17334 expression. The second argument is the output operand list. It is
17335 either a single @code{Asm_Output} attribute reference, or a list of such
17336 references enclosed in parentheses (technically an array aggregate of
17337 such references).
17338
17339 The @code{Asm_Output} attribute denotes a function that takes two
17340 parameters. The first is a string, the second is the name of a variable
17341 of the type designated by the attribute prefix. The first (string)
17342 argument is required to be a static expression and designates the
17343 constraint for the parameter (e.g.@: what kind of register is
17344 required). The second argument is the variable to be updated with the
17345 result. The possible values for constraint are the same as those used in
17346 the RTL, and are dependent on the configuration file used to build the
17347 GCC back end. If there are no output operands, then this argument may
17348 either be omitted, or explicitly given as @code{No_Output_Operands}.
17349
17350 The second argument of @code{@var{my_float}'Asm_Output} functions as
17351 though it were an @code{out} parameter, which is a little curious, but
17352 all names have the form of expressions, so there is no syntactic
17353 irregularity, even though normally functions would not be permitted
17354 @code{out} parameters. The third argument is the list of input
17355 operands. It is either a single @code{Asm_Input} attribute reference, or
17356 a list of such references enclosed in parentheses (technically an array
17357 aggregate of such references).
17358
17359 The @code{Asm_Input} attribute denotes a function that takes two
17360 parameters. The first is a string, the second is an expression of the
17361 type designated by the prefix. The first (string) argument is required
17362 to be a static expression, and is the constraint for the parameter,
17363 (e.g.@: what kind of register is required). The second argument is the
17364 value to be used as the input argument. The possible values for the
17365 constant are the same as those used in the RTL, and are dependent on
17366 the configuration file used to built the GCC back end.
17367
17368 If there are no input operands, this argument may either be omitted, or
17369 explicitly given as @code{No_Input_Operands}. The fourth argument, not
17370 present in the above example, is a list of register names, called the
17371 @dfn{clobber} argument. This argument, if given, must be a static string
17372 expression, and is a space or comma separated list of names of registers
17373 that must be considered destroyed as a result of the @code{Asm} call. If
17374 this argument is the null string (the default value), then the code
17375 generator assumes that no additional registers are destroyed.
17376
17377 The fifth argument, not present in the above example, called the
17378 @dfn{volatile} argument, is by default @code{False}. It can be set to
17379 the literal value @code{True} to indicate to the code generator that all
17380 optimizations with respect to the instruction specified should be
17381 suppressed, and that in particular, for an instruction that has outputs,
17382 the instruction will still be generated, even if none of the outputs are
17383 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
17384 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
17385 Generally it is strongly advisable to use Volatile for any ASM statement
17386 that is missing either input or output operands, or when two or more ASM
17387 statements appear in sequence, to avoid unwanted optimizations. A warning
17388 is generated if this advice is not followed.
17389
17390 The @code{Asm} subprograms may be used in two ways. First the procedure
17391 forms can be used anywhere a procedure call would be valid, and
17392 correspond to what the RM calls ``intrinsic'' routines. Such calls can
17393 be used to intersperse machine instructions with other Ada statements.
17394 Second, the function forms, which return a dummy value of the limited
17395 private type @code{Asm_Insn}, can be used in code statements, and indeed
17396 this is the only context where such calls are allowed. Code statements
17397 appear as aggregates of the form:
17398
17399 @smallexample @c ada
17400 Asm_Insn'(Asm (@dots{}));
17401 Asm_Insn'(Asm_Volatile (@dots{}));
17402 @end smallexample
17403
17404 @noindent
17405 In accordance with RM rules, such code statements are allowed only
17406 within subprograms whose entire body consists of such statements. It is
17407 not permissible to intermix such statements with other Ada statements.
17408
17409 Typically the form using intrinsic procedure calls is more convenient
17410 and more flexible. The code statement form is provided to meet the RM
17411 suggestion that such a facility should be made available. The following
17412 is the exact syntax of the call to @code{Asm}. As usual, if named notation
17413 is used, the arguments may be given in arbitrary order, following the
17414 normal rules for use of positional and named arguments)
17415
17416 @smallexample
17417 ASM_CALL ::= Asm (
17418 [Template =>] static_string_EXPRESSION
17419 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
17420 [,[Inputs =>] INPUT_OPERAND_LIST ]
17421 [,[Clobber =>] static_string_EXPRESSION ]
17422 [,[Volatile =>] static_boolean_EXPRESSION] )
17423
17424 OUTPUT_OPERAND_LIST ::=
17425 [PREFIX.]No_Output_Operands
17426 | OUTPUT_OPERAND_ATTRIBUTE
17427 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
17428
17429 OUTPUT_OPERAND_ATTRIBUTE ::=
17430 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
17431
17432 INPUT_OPERAND_LIST ::=
17433 [PREFIX.]No_Input_Operands
17434 | INPUT_OPERAND_ATTRIBUTE
17435 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
17436
17437 INPUT_OPERAND_ATTRIBUTE ::=
17438 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
17439 @end smallexample
17440
17441 @noindent
17442 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
17443 are declared in the package @code{Machine_Code} and must be referenced
17444 according to normal visibility rules. In particular if there is no
17445 @code{use} clause for this package, then appropriate package name
17446 qualification is required.
17447
17448 @node GNAT Implementation of Tasking
17449 @section GNAT Implementation of Tasking
17450
17451 @noindent
17452 This chapter outlines the basic GNAT approach to tasking (in particular,
17453 a multi-layered library for portability) and discusses issues related
17454 to compliance with the Real-Time Systems Annex.
17455
17456 @menu
17457 * Mapping Ada Tasks onto the Underlying Kernel Threads::
17458 * Ensuring Compliance with the Real-Time Annex::
17459 @end menu
17460
17461 @node Mapping Ada Tasks onto the Underlying Kernel Threads
17462 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
17463
17464 @noindent
17465 GNAT's run-time support comprises two layers:
17466
17467 @itemize @bullet
17468 @item GNARL (GNAT Run-time Layer)
17469 @item GNULL (GNAT Low-level Library)
17470 @end itemize
17471
17472 @noindent
17473 In GNAT, Ada's tasking services rely on a platform and OS independent
17474 layer known as GNARL@. This code is responsible for implementing the
17475 correct semantics of Ada's task creation, rendezvous, protected
17476 operations etc.
17477
17478 GNARL decomposes Ada's tasking semantics into simpler lower level
17479 operations such as create a thread, set the priority of a thread,
17480 yield, create a lock, lock/unlock, etc. The spec for these low-level
17481 operations constitutes GNULLI, the GNULL Interface. This interface is
17482 directly inspired from the POSIX real-time API@.
17483
17484 If the underlying executive or OS implements the POSIX standard
17485 faithfully, the GNULL Interface maps as is to the services offered by
17486 the underlying kernel. Otherwise, some target dependent glue code maps
17487 the services offered by the underlying kernel to the semantics expected
17488 by GNARL@.
17489
17490 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
17491 key point is that each Ada task is mapped on a thread in the underlying
17492 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
17493
17494 In addition Ada task priorities map onto the underlying thread priorities.
17495 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17496
17497 @itemize @bullet
17498 @item
17499 The underlying scheduler is used to schedule the Ada tasks. This
17500 makes Ada tasks as efficient as kernel threads from a scheduling
17501 standpoint.
17502
17503 @item
17504 Interaction with code written in C containing threads is eased
17505 since at the lowest level Ada tasks and C threads map onto the same
17506 underlying kernel concept.
17507
17508 @item
17509 When an Ada task is blocked during I/O the remaining Ada tasks are
17510 able to proceed.
17511
17512 @item
17513 On multiprocessor systems Ada tasks can execute in parallel.
17514 @end itemize
17515
17516 @noindent
17517 Some threads libraries offer a mechanism to fork a new process, with the
17518 child process duplicating the threads from the parent.
17519 GNAT does not
17520 support this functionality when the parent contains more than one task.
17521 @cindex Forking a new process
17522
17523 @node Ensuring Compliance with the Real-Time Annex
17524 @subsection Ensuring Compliance with the Real-Time Annex
17525 @cindex Real-Time Systems Annex compliance
17526
17527 @noindent
17528 Although mapping Ada tasks onto
17529 the underlying threads has significant advantages, it does create some
17530 complications when it comes to respecting the scheduling semantics
17531 specified in the real-time annex (Annex D).
17532
17533 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17534 scheduling policy states:
17535
17536 @quotation
17537 @emph{When the active priority of a ready task that is not running
17538 changes, or the setting of its base priority takes effect, the
17539 task is removed from the ready queue for its old active priority
17540 and is added at the tail of the ready queue for its new active
17541 priority, except in the case where the active priority is lowered
17542 due to the loss of inherited priority, in which case the task is
17543 added at the head of the ready queue for its new active priority.}
17544 @end quotation
17545
17546 @noindent
17547 While most kernels do put tasks at the end of the priority queue when
17548 a task changes its priority, (which respects the main
17549 FIFO_Within_Priorities requirement), almost none keep a thread at the
17550 beginning of its priority queue when its priority drops from the loss
17551 of inherited priority.
17552
17553 As a result most vendors have provided incomplete Annex D implementations.
17554
17555 The GNAT run-time, has a nice cooperative solution to this problem
17556 which ensures that accurate FIFO_Within_Priorities semantics are
17557 respected.
17558
17559 The principle is as follows. When an Ada task T is about to start
17560 running, it checks whether some other Ada task R with the same
17561 priority as T has been suspended due to the loss of priority
17562 inheritance. If this is the case, T yields and is placed at the end of
17563 its priority queue. When R arrives at the front of the queue it
17564 executes.
17565
17566 Note that this simple scheme preserves the relative order of the tasks
17567 that were ready to execute in the priority queue where R has been
17568 placed at the end.
17569
17570 @node GNAT Implementation of Shared Passive Packages
17571 @section GNAT Implementation of Shared Passive Packages
17572 @cindex Shared passive packages
17573
17574 @noindent
17575 GNAT fully implements the pragma @code{Shared_Passive} for
17576 @cindex pragma @code{Shared_Passive}
17577 the purpose of designating shared passive packages.
17578 This allows the use of passive partitions in the
17579 context described in the Ada Reference Manual; i.e., for communication
17580 between separate partitions of a distributed application using the
17581 features in Annex E.
17582 @cindex Annex E
17583 @cindex Distribution Systems Annex
17584
17585 However, the implementation approach used by GNAT provides for more
17586 extensive usage as follows:
17587
17588 @table @emph
17589 @item Communication between separate programs
17590
17591 This allows separate programs to access the data in passive
17592 partitions, using protected objects for synchronization where
17593 needed. The only requirement is that the two programs have a
17594 common shared file system. It is even possible for programs
17595 running on different machines with different architectures
17596 (e.g.@: different endianness) to communicate via the data in
17597 a passive partition.
17598
17599 @item Persistence between program runs
17600
17601 The data in a passive package can persist from one run of a
17602 program to another, so that a later program sees the final
17603 values stored by a previous run of the same program.
17604
17605 @end table
17606
17607 @noindent
17608 The implementation approach used is to store the data in files. A
17609 separate stream file is created for each object in the package, and
17610 an access to an object causes the corresponding file to be read or
17611 written.
17612
17613 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17614 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17615 set to the directory to be used for these files.
17616 The files in this directory
17617 have names that correspond to their fully qualified names. For
17618 example, if we have the package
17619
17620 @smallexample @c ada
17621 package X is
17622 pragma Shared_Passive (X);
17623 Y : Integer;
17624 Z : Float;
17625 end X;
17626 @end smallexample
17627
17628 @noindent
17629 and the environment variable is set to @code{/stemp/}, then the files created
17630 will have the names:
17631
17632 @smallexample
17633 /stemp/x.y
17634 /stemp/x.z
17635 @end smallexample
17636
17637 @noindent
17638 These files are created when a value is initially written to the object, and
17639 the files are retained until manually deleted. This provides the persistence
17640 semantics. If no file exists, it means that no partition has assigned a value
17641 to the variable; in this case the initial value declared in the package
17642 will be used. This model ensures that there are no issues in synchronizing
17643 the elaboration process, since elaboration of passive packages elaborates the
17644 initial values, but does not create the files.
17645
17646 The files are written using normal @code{Stream_IO} access.
17647 If you want to be able
17648 to communicate between programs or partitions running on different
17649 architectures, then you should use the XDR versions of the stream attribute
17650 routines, since these are architecture independent.
17651
17652 If active synchronization is required for access to the variables in the
17653 shared passive package, then as described in the Ada Reference Manual, the
17654 package may contain protected objects used for this purpose. In this case
17655 a lock file (whose name is @file{___lock} (three underscores)
17656 is created in the shared memory directory.
17657 @cindex @file{___lock} file (for shared passive packages)
17658 This is used to provide the required locking
17659 semantics for proper protected object synchronization.
17660
17661 As of January 2003, GNAT supports shared passive packages on all platforms
17662 except for OpenVMS.
17663
17664 @node Code Generation for Array Aggregates
17665 @section Code Generation for Array Aggregates
17666
17667 @menu
17668 * Static constant aggregates with static bounds::
17669 * Constant aggregates with unconstrained nominal types::
17670 * Aggregates with static bounds::
17671 * Aggregates with non-static bounds::
17672 * Aggregates in assignment statements::
17673 @end menu
17674
17675 @noindent
17676 Aggregates have a rich syntax and allow the user to specify the values of
17677 complex data structures by means of a single construct. As a result, the
17678 code generated for aggregates can be quite complex and involve loops, case
17679 statements and multiple assignments. In the simplest cases, however, the
17680 compiler will recognize aggregates whose components and constraints are
17681 fully static, and in those cases the compiler will generate little or no
17682 executable code. The following is an outline of the code that GNAT generates
17683 for various aggregate constructs. For further details, you will find it
17684 useful to examine the output produced by the -gnatG flag to see the expanded
17685 source that is input to the code generator. You may also want to examine
17686 the assembly code generated at various levels of optimization.
17687
17688 The code generated for aggregates depends on the context, the component values,
17689 and the type. In the context of an object declaration the code generated is
17690 generally simpler than in the case of an assignment. As a general rule, static
17691 component values and static subtypes also lead to simpler code.
17692
17693 @node Static constant aggregates with static bounds
17694 @subsection Static constant aggregates with static bounds
17695
17696 @noindent
17697 For the declarations:
17698 @smallexample @c ada
17699 type One_Dim is array (1..10) of integer;
17700 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17701 @end smallexample
17702
17703 @noindent
17704 GNAT generates no executable code: the constant ar0 is placed in static memory.
17705 The same is true for constant aggregates with named associations:
17706
17707 @smallexample @c ada
17708 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17709 Cr3 : constant One_Dim := (others => 7777);
17710 @end smallexample
17711
17712 @noindent
17713 The same is true for multidimensional constant arrays such as:
17714
17715 @smallexample @c ada
17716 type two_dim is array (1..3, 1..3) of integer;
17717 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17718 @end smallexample
17719
17720 @noindent
17721 The same is true for arrays of one-dimensional arrays: the following are
17722 static:
17723
17724 @smallexample @c ada
17725 type ar1b is array (1..3) of boolean;
17726 type ar_ar is array (1..3) of ar1b;
17727 None : constant ar1b := (others => false); -- fully static
17728 None2 : constant ar_ar := (1..3 => None); -- fully static
17729 @end smallexample
17730
17731 @noindent
17732 However, for multidimensional aggregates with named associations, GNAT will
17733 generate assignments and loops, even if all associations are static. The
17734 following two declarations generate a loop for the first dimension, and
17735 individual component assignments for the second dimension:
17736
17737 @smallexample @c ada
17738 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17739 Zero2: constant two_dim := (others => (others => 0));
17740 @end smallexample
17741
17742 @node Constant aggregates with unconstrained nominal types
17743 @subsection Constant aggregates with unconstrained nominal types
17744
17745 @noindent
17746 In such cases the aggregate itself establishes the subtype, so that
17747 associations with @code{others} cannot be used. GNAT determines the
17748 bounds for the actual subtype of the aggregate, and allocates the
17749 aggregate statically as well. No code is generated for the following:
17750
17751 @smallexample @c ada
17752 type One_Unc is array (natural range <>) of integer;
17753 Cr_Unc : constant One_Unc := (12,24,36);
17754 @end smallexample
17755
17756 @node Aggregates with static bounds
17757 @subsection Aggregates with static bounds
17758
17759 @noindent
17760 In all previous examples the aggregate was the initial (and immutable) value
17761 of a constant. If the aggregate initializes a variable, then code is generated
17762 for it as a combination of individual assignments and loops over the target
17763 object. The declarations
17764
17765 @smallexample @c ada
17766 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17767 Cr_Var2 : One_Dim := (others > -1);
17768 @end smallexample
17769
17770 @noindent
17771 generate the equivalent of
17772
17773 @smallexample @c ada
17774 Cr_Var1 (1) := 2;
17775 Cr_Var1 (2) := 3;
17776 Cr_Var1 (3) := 5;
17777 Cr_Var1 (4) := 11;
17778
17779 for I in Cr_Var2'range loop
17780 Cr_Var2 (I) := -1;
17781 end loop;
17782 @end smallexample
17783
17784 @node Aggregates with non-static bounds
17785 @subsection Aggregates with non-static bounds
17786
17787 @noindent
17788 If the bounds of the aggregate are not statically compatible with the bounds
17789 of the nominal subtype of the target, then constraint checks have to be
17790 generated on the bounds. For a multidimensional array, constraint checks may
17791 have to be applied to sub-arrays individually, if they do not have statically
17792 compatible subtypes.
17793
17794 @node Aggregates in assignment statements
17795 @subsection Aggregates in assignment statements
17796
17797 @noindent
17798 In general, aggregate assignment requires the construction of a temporary,
17799 and a copy from the temporary to the target of the assignment. This is because
17800 it is not always possible to convert the assignment into a series of individual
17801 component assignments. For example, consider the simple case:
17802
17803 @smallexample @c ada
17804 A := (A(2), A(1));
17805 @end smallexample
17806
17807 @noindent
17808 This cannot be converted into:
17809
17810 @smallexample @c ada
17811 A(1) := A(2);
17812 A(2) := A(1);
17813 @end smallexample
17814
17815 @noindent
17816 So the aggregate has to be built first in a separate location, and then
17817 copied into the target. GNAT recognizes simple cases where this intermediate
17818 step is not required, and the assignments can be performed in place, directly
17819 into the target. The following sufficient criteria are applied:
17820
17821 @itemize @bullet
17822 @item
17823 The bounds of the aggregate are static, and the associations are static.
17824 @item
17825 The components of the aggregate are static constants, names of
17826 simple variables that are not renamings, or expressions not involving
17827 indexed components whose operands obey these rules.
17828 @end itemize
17829
17830 @noindent
17831 If any of these conditions are violated, the aggregate will be built in
17832 a temporary (created either by the front-end or the code generator) and then
17833 that temporary will be copied onto the target.
17834
17835 @node The Size of Discriminated Records with Default Discriminants
17836 @section The Size of Discriminated Records with Default Discriminants
17837
17838 @noindent
17839 If a discriminated type @code{T} has discriminants with default values, it is
17840 possible to declare an object of this type without providing an explicit
17841 constraint:
17842
17843 @smallexample @c ada
17844 @group
17845 type Size is range 1..100;
17846
17847 type Rec (D : Size := 15) is record
17848 Name : String (1..D);
17849 end T;
17850
17851 Word : Rec;
17852 @end group
17853 @end smallexample
17854
17855 @noindent
17856 Such an object is said to be @emph{unconstrained}.
17857 The discriminant of the object
17858 can be modified by a full assignment to the object, as long as it preserves the
17859 relation between the value of the discriminant, and the value of the components
17860 that depend on it:
17861
17862 @smallexample @c ada
17863 @group
17864 Word := (3, "yes");
17865
17866 Word := (5, "maybe");
17867
17868 Word := (5, "no"); -- raises Constraint_Error
17869 @end group
17870 @end smallexample
17871
17872 @noindent
17873 In order to support this behavior efficiently, an unconstrained object is
17874 given the maximum size that any value of the type requires. In the case
17875 above, @code{Word} has storage for the discriminant and for
17876 a @code{String} of length 100.
17877 It is important to note that unconstrained objects do not require dynamic
17878 allocation. It would be an improper implementation to place on the heap those
17879 components whose size depends on discriminants. (This improper implementation
17880 was used by some Ada83 compilers, where the @code{Name} component above
17881 would have
17882 been stored as a pointer to a dynamic string). Following the principle that
17883 dynamic storage management should never be introduced implicitly,
17884 an Ada compiler should reserve the full size for an unconstrained declared
17885 object, and place it on the stack.
17886
17887 This maximum size approach
17888 has been a source of surprise to some users, who expect the default
17889 values of the discriminants to determine the size reserved for an
17890 unconstrained object: ``If the default is 15, why should the object occupy
17891 a larger size?''
17892 The answer, of course, is that the discriminant may be later modified,
17893 and its full range of values must be taken into account. This is why the
17894 declaration:
17895
17896 @smallexample
17897 @group
17898 type Rec (D : Positive := 15) is record
17899 Name : String (1..D);
17900 end record;
17901
17902 Too_Large : Rec;
17903 @end group
17904 @end smallexample
17905
17906 @noindent
17907 is flagged by the compiler with a warning:
17908 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17909 because the required size includes @code{Positive'Last}
17910 bytes. As the first example indicates, the proper approach is to declare an
17911 index type of ``reasonable'' range so that unconstrained objects are not too
17912 large.
17913
17914 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17915 created in the heap by means of an allocator, then it is @emph{not}
17916 unconstrained:
17917 it is constrained by the default values of the discriminants, and those values
17918 cannot be modified by full assignment. This is because in the presence of
17919 aliasing all views of the object (which may be manipulated by different tasks,
17920 say) must be consistent, so it is imperative that the object, once created,
17921 remain invariant.
17922
17923 @node Strict Conformance to the Ada Reference Manual
17924 @section Strict Conformance to the Ada Reference Manual
17925
17926 @noindent
17927 The dynamic semantics defined by the Ada Reference Manual impose a set of
17928 run-time checks to be generated. By default, the GNAT compiler will insert many
17929 run-time checks into the compiled code, including most of those required by the
17930 Ada Reference Manual. However, there are three checks that are not enabled
17931 in the default mode for efficiency reasons: arithmetic overflow checking for
17932 integer operations (including division by zero), checks for access before
17933 elaboration on subprogram calls, and stack overflow checking (most operating
17934 systems do not perform this check by default).
17935
17936 Strict conformance to the Ada Reference Manual can be achieved by adding
17937 three compiler options for overflow checking for integer operations
17938 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17939 calls and generic instantiations (@option{-gnatE}), and stack overflow
17940 checking (@option{-fstack-check}).
17941
17942 Note that the result of a floating point arithmetic operation in overflow and
17943 invalid situations, when the @code{Machine_Overflows} attribute of the result
17944 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17945 case for machines compliant with the IEEE floating-point standard, but on
17946 machines that are not fully compliant with this standard, such as Alpha, the
17947 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17948 behavior (although at the cost of a significant performance penalty), so
17949 infinite and NaN values are properly generated.
17950
17951
17952 @node Implementation of Ada 2012 Features
17953 @chapter Implementation of Ada 2012 Features
17954 @cindex Ada 2012 implementation status
17955
17956 This chapter contains a complete list of Ada 2012 features that have been
17957 implemented as of GNAT version 6.4. Generally, these features are only
17958 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17959 @cindex @option{-gnat12} option
17960 or if the configuration pragma @code{Ada_2012} is used.
17961 @cindex pragma @code{Ada_2012}
17962 @cindex configuration pragma @code{Ada_2012}
17963 @cindex @code{Ada_2012} configuration pragma
17964 However, new pragmas, attributes, and restrictions are
17965 unconditionally available, since the Ada 95 standard allows the addition of
17966 new pragmas, attributes, and restrictions (there are exceptions, which are
17967 documented in the individual descriptions), and also certain packages
17968 were made available in earlier versions of Ada.
17969
17970 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17971 This date shows the implementation date of the feature. Any wavefront
17972 subsequent to this date will contain the indicated feature, as will any
17973 subsequent releases. A date of 0000-00-00 means that GNAT has always
17974 implemented the feature, or implemented it as soon as it appeared as a
17975 binding interpretation.
17976
17977 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17978 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17979 The features are ordered based on the relevant sections of the Ada
17980 Reference Manual (``RM''). When a given AI relates to multiple points
17981 in the RM, the earliest is used.
17982
17983 A complete description of the AIs may be found in
17984 @url{www.ada-auth.org/ai05-summary.html}.
17985
17986 @itemize @bullet
17987
17988 @item
17989 @emph{AI-0176 Quantified expressions (2010-09-29)}
17990 @cindex AI-0176 (Ada 2012 feature)
17991
17992 @noindent
17993 Both universally and existentially quantified expressions are implemented.
17994 They use the new syntax for iterators proposed in AI05-139-2, as well as
17995 the standard Ada loop syntax.
17996
17997 @noindent
17998 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17999
18000 @item
18001 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
18002 @cindex AI-0079 (Ada 2012 feature)
18003
18004 @noindent
18005 Wide characters in the unicode category @i{other_format} are now allowed in
18006 source programs between tokens, but not within a token such as an identifier.
18007
18008 @noindent
18009 RM References: 2.01 (4/2) 2.02 (7)
18010
18011 @item
18012 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
18013 @cindex AI-0091 (Ada 2012 feature)
18014
18015 @noindent
18016 Wide characters in the unicode category @i{other_format} are not permitted
18017 within an identifier, since this can be a security problem. The error
18018 message for this case has been improved to be more specific, but GNAT has
18019 never allowed such characters to appear in identifiers.
18020
18021 @noindent
18022 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)
18023
18024 @item
18025 @emph{AI-0100 Placement of pragmas (2010-07-01)}
18026 @cindex AI-0100 (Ada 2012 feature)
18027
18028 @noindent
18029 This AI is an earlier version of AI-163. It simplifies the rules
18030 for legal placement of pragmas. In the case of lists that allow pragmas, if
18031 the list may have no elements, then the list may consist solely of pragmas.
18032
18033 @noindent
18034 RM References: 2.08 (7)
18035
18036 @item
18037 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
18038 @cindex AI-0163 (Ada 2012 feature)
18039
18040 @noindent
18041 A statement sequence may be composed entirely of pragmas. It is no longer
18042 necessary to add a dummy @code{null} statement to make the sequence legal.
18043
18044 @noindent
18045 RM References: 2.08 (7) 2.08 (16)
18046
18047
18048 @item
18049 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
18050 @cindex AI-0080 (Ada 2012 feature)
18051
18052 @noindent
18053 This is an editorial change only, described as non-testable in the AI.
18054
18055 @noindent
18056 RM References: 3.01 (7)
18057
18058
18059 @item
18060 @emph{AI-0183 Aspect specifications (2010-08-16)}
18061 @cindex AI-0183 (Ada 2012 feature)
18062
18063 @noindent
18064 Aspect specifications have been fully implemented except for pre and post-
18065 conditions, and type invariants, which have their own separate AI's. All
18066 forms of declarations listed in the AI are supported. The following is a
18067 list of the aspects supported (with GNAT implementation aspects marked)
18068
18069 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
18070 @item @code{Ada_2005} @tab -- GNAT
18071 @item @code{Ada_2012} @tab -- GNAT
18072 @item @code{Address} @tab
18073 @item @code{Alignment} @tab
18074 @item @code{Atomic} @tab
18075 @item @code{Atomic_Components} @tab
18076 @item @code{Bit_Order} @tab
18077 @item @code{Component_Size} @tab
18078 @item @code{Contract_Case} @tab -- GNAT
18079 @item @code{Discard_Names} @tab
18080 @item @code{External_Tag} @tab
18081 @item @code{Favor_Top_Level} @tab -- GNAT
18082 @item @code{Inline} @tab
18083 @item @code{Inline_Always} @tab -- GNAT
18084 @item @code{Invariant} @tab -- GNAT
18085 @item @code{Machine_Radix} @tab
18086 @item @code{No_Return} @tab
18087 @item @code{Object_Size} @tab -- GNAT
18088 @item @code{Pack} @tab
18089 @item @code{Persistent_BSS} @tab -- GNAT
18090 @item @code{Post} @tab
18091 @item @code{Pre} @tab
18092 @item @code{Predicate} @tab
18093 @item @code{Preelaborable_Initialization} @tab
18094 @item @code{Pure_Function} @tab -- GNAT
18095 @item @code{Remote_Access_Type} @tab -- GNAT
18096 @item @code{Shared} @tab -- GNAT
18097 @item @code{Size} @tab
18098 @item @code{Storage_Pool} @tab
18099 @item @code{Storage_Size} @tab
18100 @item @code{Stream_Size} @tab
18101 @item @code{Suppress} @tab
18102 @item @code{Suppress_Debug_Info} @tab -- GNAT
18103 @item @code{Test_Case} @tab -- GNAT
18104 @item @code{Type_Invariant} @tab
18105 @item @code{Unchecked_Union} @tab
18106 @item @code{Universal_Aliasing} @tab -- GNAT
18107 @item @code{Unmodified} @tab -- GNAT
18108 @item @code{Unreferenced} @tab -- GNAT
18109 @item @code{Unreferenced_Objects} @tab -- GNAT
18110 @item @code{Unsuppress} @tab
18111 @item @code{Value_Size} @tab -- GNAT
18112 @item @code{Volatile} @tab
18113 @item @code{Volatile_Components}
18114 @item @code{Warnings} @tab -- GNAT
18115 @end multitable
18116
18117 @noindent
18118 Note that for aspects with an expression, e.g. @code{Size}, the expression is
18119 treated like a default expression (visibility is analyzed at the point of
18120 occurrence of the aspect, but evaluation of the expression occurs at the
18121 freeze point of the entity involved.
18122
18123 @noindent
18124 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
18125 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
18126 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
18127 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
18128 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
18129 13.03.01 (0)
18130
18131
18132 @item
18133 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
18134 @cindex AI-0128 (Ada 2012 feature)
18135
18136 @noindent
18137 If an equality operator ("=") is declared for a type, then the implicitly
18138 declared inequality operator ("/=") is a primitive operation of the type.
18139 This is the only reasonable interpretation, and is the one always implemented
18140 by GNAT, but the RM was not entirely clear in making this point.
18141
18142 @noindent
18143 RM References: 3.02.03 (6) 6.06 (6)
18144
18145 @item
18146 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
18147 @cindex AI-0003 (Ada 2012 feature)
18148
18149 @noindent
18150 In Ada 2012, a qualified expression is considered to be syntactically a name,
18151 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
18152 useful in disambiguating some cases of overloading.
18153
18154 @noindent
18155 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
18156 5.04 (7)
18157
18158 @item
18159 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
18160 @cindex AI-0120 (Ada 2012 feature)
18161
18162 @noindent
18163 This is an RM editorial change only. The section that lists objects that are
18164 constant failed to include the current instance of a protected object
18165 within a protected function. This has always been treated as a constant
18166 in GNAT.
18167
18168 @noindent
18169 RM References: 3.03 (21)
18170
18171 @item
18172 @emph{AI-0008 General access to constrained objects (0000-00-00)}
18173 @cindex AI-0008 (Ada 2012 feature)
18174
18175 @noindent
18176 The wording in the RM implied that if you have a general access to a
18177 constrained object, it could be used to modify the discriminants. This was
18178 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
18179 has always done so in this situation.
18180
18181 @noindent
18182 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
18183
18184
18185 @item
18186 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
18187 @cindex AI-0093 (Ada 2012 feature)
18188
18189 @noindent
18190 This is an editorial change only, to make more widespread use of the Ada 2012
18191 ``immutably limited''.
18192
18193 @noindent
18194 RM References: 3.03 (23.4/3)
18195
18196
18197
18198 @item
18199 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
18200 @cindex AI-0096 (Ada 2012 feature)
18201
18202 @noindent
18203 In general it is illegal for a type derived from a formal limited type to be
18204 nonlimited. This AI makes an exception to this rule: derivation is legal
18205 if it appears in the private part of the generic, and the formal type is not
18206 tagged. If the type is tagged, the legality check must be applied to the
18207 private part of the package.
18208
18209 @noindent
18210 RM References: 3.04 (5.1/2) 6.02 (7)
18211
18212
18213 @item
18214 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
18215 @cindex AI-0181 (Ada 2012 feature)
18216
18217 @noindent
18218 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
18219 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
18220 @code{Image} and @code{Value} attributes for the character types. Strictly
18221 speaking this is an inconsistency with Ada 95, but in practice the use of
18222 these attributes is so obscure that it will not cause problems.
18223
18224 @noindent
18225 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
18226
18227
18228 @item
18229 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
18230 @cindex AI-0182 (Ada 2012 feature)
18231
18232 @noindent
18233 This AI allows @code{Character'Value} to accept the string @code{'?'} where
18234 @code{?} is any character including non-graphic control characters. GNAT has
18235 always accepted such strings. It also allows strings such as
18236 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
18237 permission and raises @code{Constraint_Error}, as is certainly still
18238 permitted.
18239
18240 @noindent
18241 RM References: 3.05 (56/2)
18242
18243
18244 @item
18245 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
18246 @cindex AI-0214 (Ada 2012 feature)
18247
18248 @noindent
18249 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
18250 to have default expressions by allowing them when the type is limited. It
18251 is often useful to define a default value for a discriminant even though
18252 it can't be changed by assignment.
18253
18254 @noindent
18255 RM References: 3.07 (9.1/2) 3.07.02 (3)
18256
18257
18258 @item
18259 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
18260 @cindex AI-0102 (Ada 2012 feature)
18261
18262 @noindent
18263 It is illegal to assign an anonymous access constant to an anonymous access
18264 variable. The RM did not have a clear rule to prevent this, but GNAT has
18265 always generated an error for this usage.
18266
18267 @noindent
18268 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
18269
18270
18271 @item
18272 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
18273 @cindex AI-0158 (Ada 2012 feature)
18274
18275 @noindent
18276 This AI extends the syntax of membership tests to simplify complex conditions
18277 that can be expressed as membership in a subset of values of any type. It
18278 introduces syntax for a list of expressions that may be used in loop contexts
18279 as well.
18280
18281 @noindent
18282 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
18283
18284
18285 @item
18286 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
18287 @cindex AI-0173 (Ada 2012 feature)
18288
18289 @noindent
18290 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
18291 with the tag of an abstract type, and @code{False} otherwise.
18292
18293 @noindent
18294 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
18295
18296
18297
18298 @item
18299 @emph{AI-0076 function with controlling result (0000-00-00)}
18300 @cindex AI-0076 (Ada 2012 feature)
18301
18302 @noindent
18303 This is an editorial change only. The RM defines calls with controlling
18304 results, but uses the term ``function with controlling result'' without an
18305 explicit definition.
18306
18307 @noindent
18308 RM References: 3.09.02 (2/2)
18309
18310
18311 @item
18312 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
18313 @cindex AI-0126 (Ada 2012 feature)
18314
18315 @noindent
18316 This AI clarifies dispatching rules, and simply confirms that dispatching
18317 executes the operation of the parent type when there is no explicitly or
18318 implicitly declared operation for the descendant type. This has always been
18319 the case in all versions of GNAT.
18320
18321 @noindent
18322 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
18323
18324
18325 @item
18326 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
18327 @cindex AI-0097 (Ada 2012 feature)
18328
18329 @noindent
18330 The RM as written implied that in some cases it was possible to create an
18331 object of an abstract type, by having an abstract extension inherit a non-
18332 abstract constructor from its parent type. This mistake has been corrected
18333 in GNAT and in the RM, and this construct is now illegal.
18334
18335 @noindent
18336 RM References: 3.09.03 (4/2)
18337
18338
18339 @item
18340 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
18341 @cindex AI-0203 (Ada 2012 feature)
18342
18343 @noindent
18344 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
18345 permitted such usage.
18346
18347 @noindent
18348 RM References: 3.09.03 (8/3)
18349
18350
18351 @item
18352 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
18353 @cindex AI-0198 (Ada 2012 feature)
18354
18355 @noindent
18356 This AI resolves a conflict between two rules involving inherited abstract
18357 operations and predefined operators. If a derived numeric type inherits
18358 an abstract operator, it overrides the predefined one. This interpretation
18359 was always the one implemented in GNAT.
18360
18361 @noindent
18362 RM References: 3.09.03 (4/3)
18363
18364 @item
18365 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
18366 @cindex AI-0073 (Ada 2012 feature)
18367
18368 @noindent
18369 This AI covers a number of issues regarding returning abstract types. In
18370 particular generic functions cannot have abstract result types or access
18371 result types designated an abstract type. There are some other cases which
18372 are detailed in the AI. Note that this binding interpretation has not been
18373 retrofitted to operate before Ada 2012 mode, since it caused a significant
18374 number of regressions.
18375
18376 @noindent
18377 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
18378
18379
18380 @item
18381 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
18382 @cindex AI-0070 (Ada 2012 feature)
18383
18384 @noindent
18385 This is an editorial change only, there are no testable consequences short of
18386 checking for the absence of generated code for an interface declaration.
18387
18388 @noindent
18389 RM References: 3.09.04 (18/2)
18390
18391
18392 @item
18393 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
18394 @cindex AI-0208 (Ada 2012 feature)
18395
18396 @noindent
18397 The wording in the Ada 2005 RM concerning characteristics of incomplete views
18398 was incorrect and implied that some programs intended to be legal were now
18399 illegal. GNAT had never considered such programs illegal, so it has always
18400 implemented the intent of this AI.
18401
18402 @noindent
18403 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
18404
18405
18406 @item
18407 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
18408 @cindex AI-0162 (Ada 2012 feature)
18409
18410 @noindent
18411 Incomplete types are made more useful by allowing them to be completed by
18412 private types and private extensions.
18413
18414 @noindent
18415 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
18416
18417
18418
18419 @item
18420 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
18421 @cindex AI-0098 (Ada 2012 feature)
18422
18423 @noindent
18424 An unintentional omission in the RM implied some inconsistent restrictions on
18425 the use of anonymous access to subprogram values. These restrictions were not
18426 intentional, and have never been enforced by GNAT.
18427
18428 @noindent
18429 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
18430
18431
18432 @item
18433 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
18434 @cindex AI-0199 (Ada 2012 feature)
18435
18436 @noindent
18437 A choice list in a record aggregate can include several components of
18438 (distinct) anonymous access types as long as they have matching designated
18439 subtypes.
18440
18441 @noindent
18442 RM References: 4.03.01 (16)
18443
18444
18445 @item
18446 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
18447 @cindex AI-0220 (Ada 2012 feature)
18448
18449 @noindent
18450 This AI addresses a wording problem in the RM that appears to permit some
18451 complex cases of aggregates with non-static discriminants. GNAT has always
18452 implemented the intended semantics.
18453
18454 @noindent
18455 RM References: 4.03.01 (17)
18456
18457 @item
18458 @emph{AI-0147 Conditional expressions (2009-03-29)}
18459 @cindex AI-0147 (Ada 2012 feature)
18460
18461 @noindent
18462 Conditional expressions are permitted. The form of such an expression is:
18463
18464 @smallexample
18465 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
18466 @end smallexample
18467
18468 The parentheses can be omitted in contexts where parentheses are present
18469 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
18470 clause is omitted, @b{else True} is assumed;
18471 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
18472 @emph{(A implies B)} in standard logic.
18473
18474 @noindent
18475 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
18476 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
18477
18478
18479 @item
18480 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
18481 @cindex AI-0037 (Ada 2012 feature)
18482
18483 @noindent
18484 This AI confirms that an association of the form @code{Indx => <>} in an
18485 array aggregate must raise @code{Constraint_Error} if @code{Indx}
18486 is out of range. The RM specified a range check on other associations, but
18487 not when the value of the association was defaulted. GNAT has always inserted
18488 a constraint check on the index value.
18489
18490 @noindent
18491 RM References: 4.03.03 (29)
18492
18493
18494 @item
18495 @emph{AI-0123 Composability of equality (2010-04-13)}
18496 @cindex AI-0123 (Ada 2012 feature)
18497
18498 @noindent
18499 Equality of untagged record composes, so that the predefined equality for a
18500 composite type that includes a component of some untagged record type
18501 @code{R} uses the equality operation of @code{R} (which may be user-defined
18502 or predefined). This makes the behavior of untagged records identical to that
18503 of tagged types in this respect.
18504
18505 This change is an incompatibility with previous versions of Ada, but it
18506 corrects a non-uniformity that was often a source of confusion. Analysis of
18507 a large number of industrial programs indicates that in those rare cases
18508 where a composite type had an untagged record component with a user-defined
18509 equality, either there was no use of the composite equality, or else the code
18510 expected the same composability as for tagged types, and thus had a bug that
18511 would be fixed by this change.
18512
18513 @noindent
18514 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18515 8.05.04 (8)
18516
18517
18518 @item
18519 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18520 @cindex AI-0088 (Ada 2012 feature)
18521
18522 @noindent
18523 This AI clarifies the equivalence rule given for the dynamic semantics of
18524 exponentiation: the value of the operation can be obtained by repeated
18525 multiplication, but the operation can be implemented otherwise (for example
18526 using the familiar divide-by-two-and-square algorithm, even if this is less
18527 accurate), and does not imply repeated reads of a volatile base.
18528
18529 @noindent
18530 RM References: 4.05.06 (11)
18531
18532 @item
18533 @emph{AI-0188 Case expressions (2010-01-09)}
18534 @cindex AI-0188 (Ada 2012 feature)
18535
18536 @noindent
18537 Case expressions are permitted. This allows use of constructs such as:
18538 @smallexample
18539 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18540 @end smallexample
18541
18542 @noindent
18543 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18544
18545 @item
18546 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18547 @cindex AI-0104 (Ada 2012 feature)
18548
18549 @noindent
18550 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18551 @code{Constraint_Error} because the default value of the allocated object is
18552 @b{null}. This useless construct is illegal in Ada 2012.
18553
18554 @noindent
18555 RM References: 4.08 (2)
18556
18557 @item
18558 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18559 @cindex AI-0157 (Ada 2012 feature)
18560
18561 @noindent
18562 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18563 deallocation of a pointer for which a static storage size clause of zero
18564 has been given) is now illegal and is detected as such. GNAT
18565 previously gave a warning but not an error.
18566
18567 @noindent
18568 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18569
18570 @item
18571 @emph{AI-0179 Statement not required after label (2010-04-10)}
18572 @cindex AI-0179 (Ada 2012 feature)
18573
18574 @noindent
18575 It is not necessary to have a statement following a label, so a label
18576 can appear at the end of a statement sequence without the need for putting a
18577 null statement afterwards, but it is not allowable to have only labels and
18578 no real statements in a statement sequence.
18579
18580 @noindent
18581 RM References: 5.01 (2)
18582
18583
18584 @item
18585 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18586 @cindex AI-139-2 (Ada 2012 feature)
18587
18588 @noindent
18589 The new syntax for iterating over arrays and containers is now implemented.
18590 Iteration over containers is for now limited to read-only iterators. Only
18591 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18592
18593 @noindent
18594 RM References: 5.05
18595
18596 @item
18597 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18598 @cindex AI-0134 (Ada 2012 feature)
18599
18600 @noindent
18601 For full conformance, the profiles of anonymous-access-to-subprogram
18602 parameters must match. GNAT has always enforced this rule.
18603
18604 @noindent
18605 RM References: 6.03.01 (18)
18606
18607 @item
18608 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18609 @cindex AI-0207 (Ada 2012 feature)
18610
18611 @noindent
18612 This AI confirms that access_to_constant indication must match for mode
18613 conformance. This was implemented in GNAT when the qualifier was originally
18614 introduced in Ada 2005.
18615
18616 @noindent
18617 RM References: 6.03.01 (16/2)
18618
18619
18620 @item
18621 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18622 @cindex AI-0046 (Ada 2012 feature)
18623
18624 @noindent
18625 For full conformance, in the case of access parameters, the null exclusion
18626 must match (either both or neither must have @code{@b{not null}}).
18627
18628 @noindent
18629 RM References: 6.03.02 (18)
18630
18631
18632 @item
18633 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18634 @cindex AI-0118 (Ada 2012 feature)
18635
18636 @noindent
18637 This AI clarifies the rules for named associations in subprogram calls and
18638 generic instantiations. The rules have been in place since Ada 83.
18639
18640 @noindent
18641 RM References: 6.04.01 (2) 12.03 (9)
18642
18643
18644 @item
18645 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18646 @cindex AI-0196 (Ada 2012 feature)
18647
18648 @noindent
18649 Null exclusion checks are not made for @code{@b{out}} parameters when
18650 evaluating the actual parameters. GNAT has never generated these checks.
18651
18652 @noindent
18653 RM References: 6.04.01 (13)
18654
18655 @item
18656 @emph{AI-0015 Constant return objects (0000-00-00)}
18657 @cindex AI-0015 (Ada 2012 feature)
18658
18659 @noindent
18660 The return object declared in an @i{extended_return_statement} may be
18661 declared constant. This was always intended, and GNAT has always allowed it.
18662
18663 @noindent
18664 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18665 6.05 (5.7/2)
18666
18667
18668 @item
18669 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18670 @cindex AI-0032 (Ada 2012 feature)
18671
18672 @noindent
18673 If a function returns a class-wide type, the object of an extended return
18674 statement can be declared with a specific type that is covered by the class-
18675 wide type. This has been implemented in GNAT since the introduction of
18676 extended returns. Note AI-0103 complements this AI by imposing matching
18677 rules for constrained return types.
18678
18679 @noindent
18680 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18681 6.05 (8/2)
18682
18683 @item
18684 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18685 @cindex AI-0103 (Ada 2012 feature)
18686
18687 @noindent
18688 If the return subtype of a function is an elementary type or a constrained
18689 type, the subtype indication in an extended return statement must match
18690 statically this return subtype.
18691
18692 @noindent
18693 RM References: 6.05 (5.2/2)
18694
18695
18696 @item
18697 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18698 @cindex AI-0058 (Ada 2012 feature)
18699
18700 @noindent
18701 The RM had some incorrect wording implying wrong treatment of abnormal
18702 completion in an extended return. GNAT has always implemented the intended
18703 correct semantics as described by this AI.
18704
18705 @noindent
18706 RM References: 6.05 (22/2)
18707
18708
18709 @item
18710 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18711 @cindex AI-0050 (Ada 2012 feature)
18712
18713 @noindent
18714 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
18715 not take advantage of these incorrect permissions in any case.
18716
18717 @noindent
18718 RM References: 6.05 (24/2)
18719
18720
18721 @item
18722 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18723 @cindex AI-0125 (Ada 2012 feature)
18724
18725 @noindent
18726 In Ada 2012, the declaration of a primitive operation of a type extension
18727 or private extension can also override an inherited primitive that is not
18728 visible at the point of this declaration.
18729
18730 @noindent
18731 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18732
18733 @item
18734 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18735 @cindex AI-0062 (Ada 2012 feature)
18736
18737 @noindent
18738 A full constant may have a null exclusion even if its associated deferred
18739 constant does not. GNAT has always allowed this.
18740
18741 @noindent
18742 RM References: 7.04 (6/2) 7.04 (7.1/2)
18743
18744
18745 @item
18746 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18747 @cindex AI-0178 (Ada 2012 feature)
18748
18749 @noindent
18750 This AI clarifies the role of incomplete views and plugs an omission in the
18751 RM. GNAT always correctly restricted the use of incomplete views and types.
18752
18753 @noindent
18754 RM References: 7.05 (3/2) 7.05 (6/2)
18755
18756 @item
18757 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18758 @cindex AI-0087 (Ada 2012 feature)
18759
18760 @noindent
18761 The actual for a formal nonlimited derived type cannot be limited. In
18762 particular, a formal derived type that extends a limited interface but which
18763 is not explicitly limited cannot be instantiated with a limited type.
18764
18765 @noindent
18766 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18767
18768 @item
18769 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18770 @cindex AI-0099 (Ada 2012 feature)
18771
18772 @noindent
18773 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18774 and therefore depends on the run-time characteristics of an object (i.e. its
18775 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18776 this to affect any implementation''.
18777
18778 @noindent
18779 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18780
18781
18782
18783 @item
18784 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18785 @cindex AI-0064 (Ada 2012 feature)
18786
18787 @noindent
18788 This is an editorial change only. The intended behavior is already checked
18789 by an existing ACATS test, which GNAT has always executed correctly.
18790
18791 @noindent
18792 RM References: 7.06.01 (17.1/1)
18793
18794 @item
18795 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18796 @cindex AI-0026 (Ada 2012 feature)
18797
18798 @noindent
18799 Record representation clauses concerning Unchecked_Union types cannot mention
18800 the discriminant of the type. The type of a component declared in the variant
18801 part of an Unchecked_Union cannot be controlled, have controlled components,
18802 nor have protected or task parts. If an Unchecked_Union type is declared
18803 within the body of a generic unit or its descendants, then the type of a
18804 component declared in the variant part cannot be a formal private type or a
18805 formal private extension declared within the same generic unit.
18806
18807 @noindent
18808 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18809
18810
18811 @item
18812 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18813 @cindex AI-0205 (Ada 2012 feature)
18814
18815 @noindent
18816 This AI corrects a simple omission in the RM. Return objects have always
18817 been visible within an extended return statement.
18818
18819 @noindent
18820 RM References: 8.03 (17)
18821
18822
18823 @item
18824 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18825 @cindex AI-0042 (Ada 2012 feature)
18826
18827 @noindent
18828 This AI fixes a wording gap in the RM. An operation of a synchronized
18829 interface can be implemented by a protected or task entry, but the abstract
18830 operation is not being overridden in the usual sense, and it must be stated
18831 separately that this implementation is legal. This has always been the case
18832 in GNAT.
18833
18834 @noindent
18835 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18836
18837 @item
18838 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18839 @cindex AI-0030 (Ada 2012 feature)
18840
18841 @noindent
18842 Requeue is permitted to a protected, synchronized or task interface primitive
18843 providing it is known that the overriding operation is an entry. Otherwise
18844 the requeue statement has the same effect as a procedure call. Use of pragma
18845 @code{Implemented} provides a way to impose a static requirement on the
18846 overriding operation by adhering to one of the implementation kinds: entry,
18847 protected procedure or any of the above.
18848
18849 @noindent
18850 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18851 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18852
18853
18854 @item
18855 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18856 @cindex AI-0201 (Ada 2012 feature)
18857
18858 @noindent
18859 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18860 attribute, then individual components may not be addressable by independent
18861 tasks. However, if the representation clause has no effect (is confirming),
18862 then independence is not compromised. Furthermore, in GNAT, specification of
18863 other appropriately addressable component sizes (e.g. 16 for 8-bit
18864 characters) also preserves independence. GNAT now gives very clear warnings
18865 both for the declaration of such a type, and for any assignment to its components.
18866
18867 @noindent
18868 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18869
18870 @item
18871 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18872 @cindex AI-0009 (Ada 2012 feature)
18873
18874 @noindent
18875 This AI introduces the new pragmas @code{Independent} and
18876 @code{Independent_Components},
18877 which control guaranteeing independence of access to objects and components.
18878 The AI also requires independence not unaffected by confirming rep clauses.
18879
18880 @noindent
18881 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18882 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18883
18884
18885 @item
18886 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18887 @cindex AI-0072 (Ada 2012 feature)
18888
18889 @noindent
18890 This AI clarifies that task signalling for reading @code{'Terminated} only
18891 occurs if the result is True. GNAT semantics has always been consistent with
18892 this notion of task signalling.
18893
18894 @noindent
18895 RM References: 9.10 (6.1/1)
18896
18897 @item
18898 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18899 @cindex AI-0108 (Ada 2012 feature)
18900
18901 @noindent
18902 This AI confirms that an incomplete type from a limited view does not have
18903 discriminants. This has always been the case in GNAT.
18904
18905 @noindent
18906 RM References: 10.01.01 (12.3/2)
18907
18908 @item
18909 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18910 @cindex AI-0129 (Ada 2012 feature)
18911
18912 @noindent
18913 This AI clarifies the description of limited views: a limited view of a
18914 package includes only one view of a type that has an incomplete declaration
18915 and a full declaration (there is no possible ambiguity in a client package).
18916 This AI also fixes an omission: a nested package in the private part has no
18917 limited view. GNAT always implemented this correctly.
18918
18919 @noindent
18920 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18921
18922
18923
18924 @item
18925 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18926 @cindex AI-0077 (Ada 2012 feature)
18927
18928 @noindent
18929 This AI clarifies that a declaration does not include a context clause,
18930 and confirms that it is illegal to have a context in which both a limited
18931 and a nonlimited view of a package are accessible. Such double visibility
18932 was always rejected by GNAT.
18933
18934 @noindent
18935 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18936
18937 @item
18938 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18939 @cindex AI-0122 (Ada 2012 feature)
18940
18941 @noindent
18942 This AI clarifies the visibility of private children of generic units within
18943 instantiations of a parent. GNAT has always handled this correctly.
18944
18945 @noindent
18946 RM References: 10.01.02 (12/2)
18947
18948
18949
18950 @item
18951 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18952 @cindex AI-0040 (Ada 2012 feature)
18953
18954 @noindent
18955 This AI confirms that a limited with clause in a child unit cannot name
18956 an ancestor of the unit. This has always been checked in GNAT.
18957
18958 @noindent
18959 RM References: 10.01.02 (20/2)
18960
18961 @item
18962 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18963 @cindex AI-0132 (Ada 2012 feature)
18964
18965 @noindent
18966 This AI fills a gap in the description of library unit pragmas. The pragma
18967 clearly must apply to a library unit, even if it does not carry the name
18968 of the enclosing unit. GNAT has always enforced the required check.
18969
18970 @noindent
18971 RM References: 10.01.05 (7)
18972
18973
18974 @item
18975 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18976 @cindex AI-0034 (Ada 2012 feature)
18977
18978 @noindent
18979 The RM makes certain limited with clauses illegal because of categorization
18980 considerations, when the corresponding normal with would be legal. This is
18981 not intended, and GNAT has always implemented the recommended behavior.
18982
18983 @noindent
18984 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18985
18986
18987 @item
18988 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18989 @cindex AI-0035 (Ada 2012 feature)
18990
18991 @noindent
18992 This AI remedies some inconsistencies in the legality rules for Pure units.
18993 Derived access types are legal in a pure unit (on the assumption that the
18994 rule for a zero storage pool size has been enforced on the ancestor type).
18995 The rules are enforced in generic instances and in subunits. GNAT has always
18996 implemented the recommended behavior.
18997
18998 @noindent
18999 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)
19000
19001
19002 @item
19003 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
19004 @cindex AI-0219 (Ada 2012 feature)
19005
19006 @noindent
19007 This AI refines the rules for the cases with limited parameters which do not
19008 allow the implementations to omit ``redundant''. GNAT now properly conforms
19009 to the requirements of this binding interpretation.
19010
19011 @noindent
19012 RM References: 10.02.01 (18/2)
19013
19014 @item
19015 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
19016 @cindex AI-0043 (Ada 2012 feature)
19017
19018 @noindent
19019 This AI covers various omissions in the RM regarding the raising of
19020 exceptions. GNAT has always implemented the intended semantics.
19021
19022 @noindent
19023 RM References: 11.04.01 (10.1/2) 11 (2)
19024
19025
19026 @item
19027 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
19028 @cindex AI-0200 (Ada 2012 feature)
19029
19030 @noindent
19031 This AI plugs a gap in the RM which appeared to allow some obviously intended
19032 illegal instantiations. GNAT has never allowed these instantiations.
19033
19034 @noindent
19035 RM References: 12.07 (16)
19036
19037
19038 @item
19039 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
19040 @cindex AI-0112 (Ada 2012 feature)
19041
19042 @noindent
19043 This AI concerns giving names to various representation aspects, but the
19044 practical effect is simply to make the use of duplicate
19045 @code{Atomic}[@code{_Components}],
19046 @code{Volatile}[@code{_Components}] and
19047 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
19048 now performs this required check.
19049
19050 @noindent
19051 RM References: 13.01 (8)
19052
19053 @item
19054 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
19055 @cindex AI-0106 (Ada 2012 feature)
19056
19057 @noindent
19058 The RM appeared to allow representation pragmas on generic formal parameters,
19059 but this was not intended, and GNAT has never permitted this usage.
19060
19061 @noindent
19062 RM References: 13.01 (9.1/1)
19063
19064
19065 @item
19066 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
19067 @cindex AI-0012 (Ada 2012 feature)
19068
19069 @noindent
19070 It is now illegal to give an inappropriate component size or a pragma
19071 @code{Pack} that attempts to change the component size in the case of atomic
19072 or aliased components. Previously GNAT ignored such an attempt with a
19073 warning.
19074
19075 @noindent
19076 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
19077
19078
19079 @item
19080 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
19081 @cindex AI-0039 (Ada 2012 feature)
19082
19083 @noindent
19084 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
19085 for stream attributes, but these were never useful and are now illegal. GNAT
19086 has always regarded such expressions as illegal.
19087
19088 @noindent
19089 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
19090
19091
19092 @item
19093 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
19094 @cindex AI-0095 (Ada 2012 feature)
19095
19096 @noindent
19097 The prefix of @code{'Address} cannot statically denote a subprogram with
19098 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
19099 @code{Program_Error} if the prefix denotes a subprogram with convention
19100 @code{Intrinsic}.
19101
19102 @noindent
19103 RM References: 13.03 (11/1)
19104
19105
19106 @item
19107 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
19108 @cindex AI-0116 (Ada 2012 feature)
19109
19110 @noindent
19111 This AI requires that the alignment of a class-wide object be no greater
19112 than the alignment of any type in the class. GNAT has always followed this
19113 recommendation.
19114
19115 @noindent
19116 RM References: 13.03 (29) 13.11 (16)
19117
19118
19119 @item
19120 @emph{AI-0146 Type invariants (2009-09-21)}
19121 @cindex AI-0146 (Ada 2012 feature)
19122
19123 @noindent
19124 Type invariants may be specified for private types using the aspect notation.
19125 Aspect @code{Type_Invariant} may be specified for any private type,
19126 @code{Type_Invariant'Class} can
19127 only be specified for tagged types, and is inherited by any descendent of the
19128 tagged types. The invariant is a boolean expression that is tested for being
19129 true in the following situations: conversions to the private type, object
19130 declarations for the private type that are default initialized, and
19131 [@b{in}] @b{out}
19132 parameters and returned result on return from any primitive operation for
19133 the type that is visible to a client.
19134 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
19135 @code{Invariant'Class} for @code{Type_Invariant'Class}.
19136
19137 @noindent
19138 RM References: 13.03.03 (00)
19139
19140 @item
19141 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
19142 @cindex AI-0078 (Ada 2012 feature)
19143
19144 @noindent
19145 In Ada 2012, compilers are required to support unchecked conversion where the
19146 target alignment is a multiple of the source alignment. GNAT always supported
19147 this case (and indeed all cases of differing alignments, doing copies where
19148 required if the alignment was reduced).
19149
19150 @noindent
19151 RM References: 13.09 (7)
19152
19153
19154 @item
19155 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
19156 @cindex AI-0195 (Ada 2012 feature)
19157
19158 @noindent
19159 The handling of invalid values is now designated to be implementation
19160 defined. This is a documentation change only, requiring Annex M in the GNAT
19161 Reference Manual to document this handling.
19162 In GNAT, checks for invalid values are made
19163 only when necessary to avoid erroneous behavior. Operations like assignments
19164 which cannot cause erroneous behavior ignore the possibility of invalid
19165 values and do not do a check. The date given above applies only to the
19166 documentation change, this behavior has always been implemented by GNAT.
19167
19168 @noindent
19169 RM References: 13.09.01 (10)
19170
19171 @item
19172 @emph{AI-0193 Alignment of allocators (2010-09-16)}
19173 @cindex AI-0193 (Ada 2012 feature)
19174
19175 @noindent
19176 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
19177 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
19178 of size.
19179
19180 @noindent
19181 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
19182 13.11.01 (2) 13.11.01 (3)
19183
19184
19185 @item
19186 @emph{AI-0177 Parameterized expressions (2010-07-10)}
19187 @cindex AI-0177 (Ada 2012 feature)
19188
19189 @noindent
19190 The new Ada 2012 notion of parameterized expressions is implemented. The form
19191 is:
19192 @smallexample
19193 @i{function specification} @b{is} (@i{expression})
19194 @end smallexample
19195
19196 @noindent
19197 This is exactly equivalent to the
19198 corresponding function body that returns the expression, but it can appear
19199 in a package spec. Note that the expression must be parenthesized.
19200
19201 @noindent
19202 RM References: 13.11.01 (3/2)
19203
19204 @item
19205 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
19206 @cindex AI-0033 (Ada 2012 feature)
19207
19208 @noindent
19209 Neither of these two pragmas may appear within a generic template, because
19210 the generic might be instantiated at other than the library level.
19211
19212 @noindent
19213 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
19214
19215
19216 @item
19217 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
19218 @cindex AI-0161 (Ada 2012 feature)
19219
19220 @noindent
19221 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
19222 of the default stream attributes for elementary types. If this restriction is
19223 in force, then it is necessary to provide explicit subprograms for any
19224 stream attributes used.
19225
19226 @noindent
19227 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
19228
19229 @item
19230 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
19231 @cindex AI-0194 (Ada 2012 feature)
19232
19233 @noindent
19234 The @code{Stream_Size} attribute returns the default number of bits in the
19235 stream representation of the given type.
19236 This value is not affected by the presence
19237 of stream subprogram attributes for the type. GNAT has always implemented
19238 this interpretation.
19239
19240 @noindent
19241 RM References: 13.13.02 (1.2/2)
19242
19243 @item
19244 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
19245 @cindex AI-0109 (Ada 2012 feature)
19246
19247 @noindent
19248 This AI is an editorial change only. It removes the need for a tag check
19249 that can never fail.
19250
19251 @noindent
19252 RM References: 13.13.02 (34/2)
19253
19254 @item
19255 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
19256 @cindex AI-0007 (Ada 2012 feature)
19257
19258 @noindent
19259 The RM as written appeared to limit the possibilities of declaring read
19260 attribute procedures for private scalar types. This limitation was not
19261 intended, and has never been enforced by GNAT.
19262
19263 @noindent
19264 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
19265
19266
19267 @item
19268 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
19269 @cindex AI-0065 (Ada 2012 feature)
19270
19271 @noindent
19272 This AI clarifies the fact that all remote access types support external
19273 streaming. This fixes an obvious oversight in the definition of the
19274 language, and GNAT always implemented the intended correct rules.
19275
19276 @noindent
19277 RM References: 13.13.02 (52/2)
19278
19279 @item
19280 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
19281 @cindex AI-0019 (Ada 2012 feature)
19282
19283 @noindent
19284 The RM suggests that primitive subprograms of a specific tagged type are
19285 frozen when the tagged type is frozen. This would be an incompatible change
19286 and is not intended. GNAT has never attempted this kind of freezing and its
19287 behavior is consistent with the recommendation of this AI.
19288
19289 @noindent
19290 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)
19291
19292 @item
19293 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
19294 @cindex AI-0017 (Ada 2012 feature)
19295
19296 @noindent
19297 So-called ``Taft-amendment types'' (i.e., types that are completed in package
19298 bodies) are not frozen by the occurrence of bodies in the
19299 enclosing declarative part. GNAT always implemented this properly.
19300
19301 @noindent
19302 RM References: 13.14 (3/1)
19303
19304
19305 @item
19306 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
19307 @cindex AI-0060 (Ada 2012 feature)
19308
19309 @noindent
19310 This AI extends the definition of remote access types to include access
19311 to limited, synchronized, protected or task class-wide interface types.
19312 GNAT already implemented this extension.
19313
19314 @noindent
19315 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
19316
19317 @item
19318 @emph{AI-0114 Classification of letters (0000-00-00)}
19319 @cindex AI-0114 (Ada 2012 feature)
19320
19321 @noindent
19322 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
19323 181 (@code{MICRO SIGN}), and
19324 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
19325 lower case letters by Unicode.
19326 However, they are not allowed in identifiers, and they
19327 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
19328 This behavior is consistent with that defined in Ada 95.
19329
19330 @noindent
19331 RM References: A.03.02 (59) A.04.06 (7)
19332
19333
19334 @item
19335 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
19336 @cindex AI-0185 (Ada 2012 feature)
19337
19338 @noindent
19339 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
19340 classification functions for @code{Wide_Character} and
19341 @code{Wide_Wide_Character}, as well as providing
19342 case folding routines for @code{Wide_[Wide_]Character} and
19343 @code{Wide_[Wide_]String}.
19344
19345 @noindent
19346 RM References: A.03.05 (0) A.03.06 (0)
19347
19348
19349 @item
19350 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
19351 @cindex AI-0031 (Ada 2012 feature)
19352
19353 @noindent
19354 A new version of @code{Find_Token} is added to all relevant string packages,
19355 with an extra parameter @code{From}. Instead of starting at the first
19356 character of the string, the search for a matching Token starts at the
19357 character indexed by the value of @code{From}.
19358 These procedures are available in all versions of Ada
19359 but if used in versions earlier than Ada 2012 they will generate a warning
19360 that an Ada 2012 subprogram is being used.
19361
19362 @noindent
19363 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
19364 A.04.05 (46)
19365
19366
19367 @item
19368 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
19369 @cindex AI-0056 (Ada 2012 feature)
19370
19371 @noindent
19372 The wording in the Ada 2005 RM implied an incompatible handling of the
19373 @code{Index} functions, resulting in raising an exception instead of
19374 returning zero in some situations.
19375 This was not intended and has been corrected.
19376 GNAT always returned zero, and is thus consistent with this AI.
19377
19378 @noindent
19379 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
19380
19381
19382 @item
19383 @emph{AI-0137 String encoding package (2010-03-25)}
19384 @cindex AI-0137 (Ada 2012 feature)
19385
19386 @noindent
19387 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
19388 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
19389 and @code{Wide_Wide_Strings} have been
19390 implemented. These packages (whose documentation can be found in the spec
19391 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
19392 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
19393 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
19394 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
19395 UTF-16), as well as conversions between the different UTF encodings. With
19396 the exception of @code{Wide_Wide_Strings}, these packages are available in
19397 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
19398 The @code{Wide_Wide_Strings package}
19399 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
19400 mode since it uses @code{Wide_Wide_Character}).
19401
19402 @noindent
19403 RM References: A.04.11
19404
19405 @item
19406 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
19407 @cindex AI-0038 (Ada 2012 feature)
19408
19409 @noindent
19410 These are minor errors in the description on three points. The intent on
19411 all these points has always been clear, and GNAT has always implemented the
19412 correct intended semantics.
19413
19414 @noindent
19415 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)
19416
19417 @item
19418 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
19419 @cindex AI-0044 (Ada 2012 feature)
19420
19421 @noindent
19422 This AI places restrictions on allowed instantiations of generic containers.
19423 These restrictions are not checked by the compiler, so there is nothing to
19424 change in the implementation. This affects only the RM documentation.
19425
19426 @noindent
19427 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)
19428
19429 @item
19430 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
19431 @cindex AI-0127 (Ada 2012 feature)
19432
19433 @noindent
19434 This package provides an interface for identifying the current locale.
19435
19436 @noindent
19437 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
19438 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
19439
19440
19441
19442 @item
19443 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
19444 @cindex AI-0002 (Ada 2012 feature)
19445
19446 @noindent
19447 The compiler is not required to support exporting an Ada subprogram with
19448 convention C if there are parameters or a return type of an unconstrained
19449 array type (such as @code{String}). GNAT allows such declarations but
19450 generates warnings. It is possible, but complicated, to write the
19451 corresponding C code and certainly such code would be specific to GNAT and
19452 non-portable.
19453
19454 @noindent
19455 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
19456
19457
19458 @item
19459 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
19460 @cindex AI05-0216 (Ada 2012 feature)
19461
19462 @noindent
19463 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
19464 forbid tasks declared locally within subprograms, or functions returning task
19465 objects, and that is the implementation that GNAT has always provided.
19466 However the language in the RM was not sufficiently clear on this point.
19467 Thus this is a documentation change in the RM only.
19468
19469 @noindent
19470 RM References: D.07 (3/3)
19471
19472 @item
19473 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
19474 @cindex AI-0211 (Ada 2012 feature)
19475
19476 @noindent
19477 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
19478 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
19479
19480 @noindent
19481 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
19482
19483 @item
19484 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
19485 @cindex AI-0190 (Ada 2012 feature)
19486
19487 @noindent
19488 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
19489 used to control storage pools globally.
19490 In particular, you can force every access
19491 type that is used for allocation (@b{new}) to have an explicit storage pool,
19492 or you can declare a pool globally to be used for all access types that lack
19493 an explicit one.
19494
19495 @noindent
19496 RM References: D.07 (8)
19497
19498 @item
19499 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19500 @cindex AI-0189 (Ada 2012 feature)
19501
19502 @noindent
19503 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19504 which says that no dynamic allocation will occur once elaboration is
19505 completed.
19506 In general this requires a run-time check, which is not required, and which
19507 GNAT does not attempt. But the static cases of allocators in a task body or
19508 in the body of the main program are detected and flagged at compile or bind
19509 time.
19510
19511 @noindent
19512 RM References: D.07 (19.1/2) H.04 (23.3/2)
19513
19514 @item
19515 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19516 @cindex AI-0171 (Ada 2012 feature)
19517
19518 @noindent
19519 A new package @code{System.Multiprocessors} is added, together with the
19520 definition of pragma @code{CPU} for controlling task affinity. A new no
19521 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19522 is added to the Ravenscar profile.
19523
19524 @noindent
19525 RM References: D.13.01 (4/2) D.16
19526
19527
19528 @item
19529 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19530 @cindex AI-0210 (Ada 2012 feature)
19531
19532 @noindent
19533 This is a documentation only issue regarding wording of metric requirements,
19534 that does not affect the implementation of the compiler.
19535
19536 @noindent
19537 RM References: D.15 (24/2)
19538
19539
19540 @item
19541 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19542 @cindex AI-0206 (Ada 2012 feature)
19543
19544 @noindent
19545 Remote types packages are now allowed to depend on preelaborated packages.
19546 This was formerly considered illegal.
19547
19548 @noindent
19549 RM References: E.02.02 (6)
19550
19551
19552
19553 @item
19554 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19555 @cindex AI-0152 (Ada 2012 feature)
19556
19557 @noindent
19558 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19559 where the type of the returned value is an anonymous access type.
19560
19561 @noindent
19562 RM References: H.04 (8/1)
19563 @end itemize
19564
19565
19566 @node Obsolescent Features
19567 @chapter Obsolescent Features
19568
19569 @noindent
19570 This chapter describes features that are provided by GNAT, but are
19571 considered obsolescent since there are preferred ways of achieving
19572 the same effect. These features are provided solely for historical
19573 compatibility purposes.
19574
19575 @menu
19576 * pragma No_Run_Time::
19577 * pragma Ravenscar::
19578 * pragma Restricted_Run_Time::
19579 @end menu
19580
19581 @node pragma No_Run_Time
19582 @section pragma No_Run_Time
19583
19584 The pragma @code{No_Run_Time} is used to achieve an affect similar
19585 to the use of the "Zero Foot Print" configurable run time, but without
19586 requiring a specially configured run time. The result of using this
19587 pragma, which must be used for all units in a partition, is to restrict
19588 the use of any language features requiring run-time support code. The
19589 preferred usage is to use an appropriately configured run-time that
19590 includes just those features that are to be made accessible.
19591
19592 @node pragma Ravenscar
19593 @section pragma Ravenscar
19594
19595 The pragma @code{Ravenscar} has exactly the same effect as pragma
19596 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19597 is part of the new Ada 2005 standard.
19598
19599 @node pragma Restricted_Run_Time
19600 @section pragma Restricted_Run_Time
19601
19602 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19603 pragma @code{Profile (Restricted)}. The latter usage is
19604 preferred since the Ada 2005 pragma @code{Profile} is intended for
19605 this kind of implementation dependent addition.
19606
19607 @include fdl.texi
19608 @c GNU Free Documentation License
19609
19610 @node Index,,GNU Free Documentation License, Top
19611 @unnumbered Index
19612
19613 @printindex cp
19614
19615 @contents
19616
19617 @bye