[multiple changes]
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c o
7 @c GNAT DOCUMENTATION o
8 @c o
9 @c G N A T _ RM o
10 @c o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
12 @c o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Standard and Implementation Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
81 * The GNAT Library::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
88 * Index::
89
90 --- The Detailed Node Listing ---
91
92 About This Guide
93
94 * What This Reference Manual Contains::
95 * Related Information::
96
97 Implementation Defined Pragmas
98
99 * Pragma Abort_Defer::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
110 * Pragma Attribute_Definition::
111 * Pragma Ast_Entry::
112 * Pragma C_Pass_By_Copy::
113 * Pragma Check::
114 * Pragma Check_Float_Overflow::
115 * Pragma Check_Name::
116 * Pragma Check_Policy::
117 * Pragma Comment::
118 * Pragma Common_Object::
119 * Pragma Compile_Time_Error::
120 * Pragma Compile_Time_Warning::
121 * Pragma Compiler_Unit::
122 * Pragma Complete_Representation::
123 * Pragma Complex_Representation::
124 * Pragma Component_Alignment::
125 * Pragma Contract_Case::
126 * Pragma Convention_Identifier::
127 * Pragma CPP_Class::
128 * Pragma CPP_Constructor::
129 * Pragma CPP_Virtual::
130 * Pragma CPP_Vtable::
131 * Pragma CPU::
132 * Pragma Debug::
133 * Pragma Debug_Policy::
134 * Pragma Default_Storage_Pool::
135 * Pragma Detect_Blocking::
136 * Pragma Dispatching_Domain::
137 * Pragma Elaboration_Checks::
138 * Pragma Eliminate::
139 * Pragma Export_Exception::
140 * Pragma Export_Function::
141 * Pragma Export_Object::
142 * Pragma Export_Procedure::
143 * Pragma Export_Value::
144 * Pragma Export_Valued_Procedure::
145 * Pragma Extend_System::
146 * Pragma Extensions_Allowed::
147 * Pragma External::
148 * Pragma External_Name_Casing::
149 * Pragma Fast_Math::
150 * Pragma Favor_Top_Level::
151 * Pragma Finalize_Storage_Only::
152 * Pragma Float_Representation::
153 * Pragma Ident::
154 * Pragma Implementation_Defined::
155 * Pragma Implemented::
156 * Pragma Implicit_Packing::
157 * Pragma Import_Exception::
158 * Pragma Import_Function::
159 * Pragma Import_Object::
160 * Pragma Import_Procedure::
161 * Pragma Import_Valued_Procedure::
162 * Pragma Independent::
163 * Pragma Independent_Components::
164 * Pragma Initialize_Scalars::
165 * Pragma Inline_Always::
166 * Pragma Inline_Generic::
167 * Pragma Interface::
168 * Pragma Interface_Name::
169 * Pragma Interrupt_Handler::
170 * Pragma Interrupt_State::
171 * Pragma Invariant::
172 * Pragma Keep_Names::
173 * Pragma License::
174 * Pragma Link_With::
175 * Pragma Linker_Alias::
176 * Pragma Linker_Constructor::
177 * Pragma Linker_Destructor::
178 * Pragma Linker_Section::
179 * Pragma Long_Float::
180 * Pragma Loop_Optimize::
181 * Pragma Machine_Attribute::
182 * Pragma Main::
183 * Pragma Main_Storage::
184 * Pragma No_Body::
185 * Pragma No_Inline::
186 * Pragma No_Return::
187 * Pragma No_Strict_Aliasing ::
188 * Pragma Normalize_Scalars::
189 * Pragma Obsolescent::
190 * Pragma Optimize_Alignment::
191 * Pragma Ordered::
192 * Pragma Overflow_Mode::
193 * Pragma Partition_Elaboration_Policy::
194 * Pragma Passive::
195 * Pragma Persistent_BSS::
196 * Pragma Polling::
197 * Pragma Postcondition::
198 * Pragma Precondition::
199 * Pragma Preelaborable_Initialization::
200 * Pragma Priority_Specific_Dispatching::
201 * Pragma Profile (Ravenscar)::
202 * Pragma Profile (Restricted)::
203 * Pragma Profile (Rational)::
204 * Pragma Psect_Object::
205 * Pragma Pure_Function::
206 * Pragma Relative_Deadline::
207 * Pragma Remote_Access_Type::
208 * Pragma Restriction_Warnings::
209 * Pragma Shared::
210 * Pragma Short_Circuit_And_Or::
211 * Pragma Short_Descriptors::
212 * Pragma Simple_Storage_Pool_Type::
213 * Pragma Source_File_Name::
214 * Pragma Source_File_Name_Project::
215 * Pragma Source_Reference::
216 * Pragma Static_Elaboration_Desired::
217 * Pragma Stream_Convert::
218 * Pragma Style_Checks::
219 * Pragma Subtitle::
220 * Pragma Suppress::
221 * Pragma Suppress_All::
222 * Pragma Suppress_Exception_Locations::
223 * Pragma Suppress_Initialization::
224 * Pragma Task_Info::
225 * Pragma Task_Name::
226 * Pragma Task_Storage::
227 * Pragma Test_Case::
228 * Pragma Thread_Local_Storage::
229 * Pragma Time_Slice::
230 * Pragma Title::
231 * Pragma Unchecked_Union::
232 * Pragma Unimplemented_Unit::
233 * Pragma Universal_Aliasing ::
234 * Pragma Universal_Data::
235 * Pragma Unmodified::
236 * Pragma Unreferenced::
237 * Pragma Unreferenced_Objects::
238 * Pragma Unreserve_All_Interrupts::
239 * Pragma Unsuppress::
240 * Pragma Use_VADS_Size::
241 * Pragma Validity_Checks::
242 * Pragma Volatile::
243 * Pragma Warnings::
244 * Pragma Weak_External::
245 * Pragma Wide_Character_Encoding::
246
247 Implementation Defined Attributes
248
249 * Abort_Signal::
250 * Address_Size::
251 * Asm_Input::
252 * Asm_Output::
253 * AST_Entry::
254 * Bit::
255 * Bit_Position::
256 * Compiler_Version::
257 * Code_Address::
258 * Default_Bit_Order::
259 * Descriptor_Size::
260 * Elaborated::
261 * Elab_Body::
262 * Elab_Spec::
263 * Elab_Subp_Body::
264 * Emax::
265 * Enabled::
266 * Enum_Rep::
267 * Enum_Val::
268 * Epsilon::
269 * Fixed_Value::
270 * Has_Access_Values::
271 * Has_Discriminants::
272 * Img::
273 * Integer_Value::
274 * Invalid_Value::
275 * Large::
276 * Machine_Size::
277 * Mantissa::
278 * Max_Interrupt_Priority::
279 * Max_Priority::
280 * Maximum_Alignment::
281 * Mechanism_Code::
282 * Null_Parameter::
283 * Object_Size::
284 * Passed_By_Reference::
285 * Pool_Address::
286 * Range_Length::
287 * Result::
288 * Safe_Emax::
289 * Safe_Large::
290 * Scalar_Storage_Order::
291 * Simple_Storage_Pool::
292 * Small::
293 * Storage_Unit::
294 * Stub_Type::
295 * System_Allocator_Alignment::
296 * Target_Name::
297 * Tick::
298 * To_Address::
299 * Type_Class::
300 * UET_Address::
301 * Unconstrained_Array::
302 * Universal_Literal_String::
303 * Unrestricted_Access::
304 * Valid_Scalars::
305 * VADS_Size::
306 * Value_Size::
307 * Wchar_T_Size::
308 * Word_Size::
309
310 Standard and Implementation Defined Restrictions
311
312 * Partition-Wide Restrictions::
313 * Program Unit Level Restrictions::
314
315 Partition-Wide Restrictions
316
317 * Immediate_Reclamation::
318 * Max_Asynchronous_Select_Nesting::
319 * Max_Entry_Queue_Length::
320 * Max_Protected_Entries::
321 * Max_Select_Alternatives::
322 * Max_Storage_At_Blocking::
323 * Max_Task_Entries::
324 * Max_Tasks::
325 * No_Abort_Statements::
326 * No_Access_Parameter_Allocators::
327 * No_Access_Subprograms::
328 * No_Allocators::
329 * No_Anonymous_Allocators::
330 * No_Calendar::
331 * No_Coextensions::
332 * No_Default_Initialization::
333 * No_Delay::
334 * No_Dependence::
335 * No_Direct_Boolean_Operators::
336 * No_Dispatch::
337 * No_Dispatching_Calls::
338 * No_Dynamic_Attachment::
339 * No_Dynamic_Priorities::
340 * No_Entry_Calls_In_Elaboration_Code::
341 * No_Enumeration_Maps::
342 * No_Exception_Handlers::
343 * No_Exception_Propagation::
344 * No_Exception_Registration::
345 * No_Exceptions::
346 * No_Finalization::
347 * No_Fixed_Point::
348 * No_Floating_Point::
349 * No_Implicit_Conditionals::
350 * No_Implicit_Dynamic_Code::
351 * No_Implicit_Heap_Allocations::
352 * No_Implicit_Loops::
353 * No_Initialize_Scalars::
354 * No_IO::
355 * No_Local_Allocators::
356 * No_Local_Protected_Objects::
357 * No_Local_Timing_Events::
358 * No_Nested_Finalization::
359 * No_Protected_Type_Allocators::
360 * No_Protected_Types::
361 * No_Recursion::
362 * No_Reentrancy::
363 * No_Relative_Delay::
364 * No_Requeue_Statements::
365 * No_Secondary_Stack::
366 * No_Select_Statements::
367 * No_Specific_Termination_Handlers::
368 * No_Specification_of_Aspect::
369 * No_Standard_Allocators_After_Elaboration::
370 * No_Standard_Storage_Pools::
371 * No_Stream_Optimizations::
372 * No_Streams::
373 * No_Task_Allocators::
374 * No_Task_Attributes_Package::
375 * No_Task_Hierarchy::
376 * No_Task_Termination::
377 * No_Tasking::
378 * No_Terminate_Alternatives::
379 * No_Unchecked_Access::
380 * Simple_Barriers::
381 * Static_Priorities::
382 * Static_Storage_Size::
383
384 Program Unit Level Restrictions
385
386 * No_Elaboration_Code::
387 * No_Entry_Queue::
388 * No_Implementation_Aspect_Specifications::
389 * No_Implementation_Attributes::
390 * No_Implementation_Identifiers::
391 * No_Implementation_Pragmas::
392 * No_Implementation_Restrictions::
393 * No_Implementation_Units::
394 * No_Implicit_Aliasing::
395 * No_Obsolescent_Features::
396 * No_Wide_Characters::
397 * SPARK::
398
399 The Implementation of Standard I/O
400
401 * Standard I/O Packages::
402 * FORM Strings::
403 * Direct_IO::
404 * Sequential_IO::
405 * Text_IO::
406 * Wide_Text_IO::
407 * Wide_Wide_Text_IO::
408 * Stream_IO::
409 * Text Translation::
410 * Shared Files::
411 * Filenames encoding::
412 * Open Modes::
413 * Operations on C Streams::
414 * Interfacing to C Streams::
415
416 The GNAT Library
417
418 * Ada.Characters.Latin_9 (a-chlat9.ads)::
419 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
420 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
421 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
422 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
423 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
424 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
425 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
426 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
427 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
428 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
429 * Ada.Command_Line.Environment (a-colien.ads)::
430 * Ada.Command_Line.Remove (a-colire.ads)::
431 * Ada.Command_Line.Response_File (a-clrefi.ads)::
432 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
433 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
434 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
435 * Ada.Exceptions.Traceback (a-exctra.ads)::
436 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
437 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
438 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
439 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
440 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
441 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
442 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
443 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
444 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
445 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
446 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
447 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
448 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
449 * GNAT.Altivec (g-altive.ads)::
450 * GNAT.Altivec.Conversions (g-altcon.ads)::
451 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
452 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
453 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
454 * GNAT.Array_Split (g-arrspl.ads)::
455 * GNAT.AWK (g-awk.ads)::
456 * GNAT.Bounded_Buffers (g-boubuf.ads)::
457 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
458 * GNAT.Bubble_Sort (g-bubsor.ads)::
459 * GNAT.Bubble_Sort_A (g-busora.ads)::
460 * GNAT.Bubble_Sort_G (g-busorg.ads)::
461 * GNAT.Byte_Order_Mark (g-byorma.ads)::
462 * GNAT.Byte_Swapping (g-bytswa.ads)::
463 * GNAT.Calendar (g-calend.ads)::
464 * GNAT.Calendar.Time_IO (g-catiio.ads)::
465 * GNAT.Case_Util (g-casuti.ads)::
466 * GNAT.CGI (g-cgi.ads)::
467 * GNAT.CGI.Cookie (g-cgicoo.ads)::
468 * GNAT.CGI.Debug (g-cgideb.ads)::
469 * GNAT.Command_Line (g-comlin.ads)::
470 * GNAT.Compiler_Version (g-comver.ads)::
471 * GNAT.Ctrl_C (g-ctrl_c.ads)::
472 * GNAT.CRC32 (g-crc32.ads)::
473 * GNAT.Current_Exception (g-curexc.ads)::
474 * GNAT.Debug_Pools (g-debpoo.ads)::
475 * GNAT.Debug_Utilities (g-debuti.ads)::
476 * GNAT.Decode_String (g-decstr.ads)::
477 * GNAT.Decode_UTF8_String (g-deutst.ads)::
478 * GNAT.Directory_Operations (g-dirope.ads)::
479 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
480 * GNAT.Dynamic_HTables (g-dynhta.ads)::
481 * GNAT.Dynamic_Tables (g-dyntab.ads)::
482 * GNAT.Encode_String (g-encstr.ads)::
483 * GNAT.Encode_UTF8_String (g-enutst.ads)::
484 * GNAT.Exception_Actions (g-excact.ads)::
485 * GNAT.Exception_Traces (g-exctra.ads)::
486 * GNAT.Exceptions (g-except.ads)::
487 * GNAT.Expect (g-expect.ads)::
488 * GNAT.Expect.TTY (g-exptty.ads)::
489 * GNAT.Float_Control (g-flocon.ads)::
490 * GNAT.Heap_Sort (g-heasor.ads)::
491 * GNAT.Heap_Sort_A (g-hesora.ads)::
492 * GNAT.Heap_Sort_G (g-hesorg.ads)::
493 * GNAT.HTable (g-htable.ads)::
494 * GNAT.IO (g-io.ads)::
495 * GNAT.IO_Aux (g-io_aux.ads)::
496 * GNAT.Lock_Files (g-locfil.ads)::
497 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
498 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
499 * GNAT.MD5 (g-md5.ads)::
500 * GNAT.Memory_Dump (g-memdum.ads)::
501 * GNAT.Most_Recent_Exception (g-moreex.ads)::
502 * GNAT.OS_Lib (g-os_lib.ads)::
503 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
504 * GNAT.Random_Numbers (g-rannum.ads)::
505 * GNAT.Regexp (g-regexp.ads)::
506 * GNAT.Registry (g-regist.ads)::
507 * GNAT.Regpat (g-regpat.ads)::
508 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
509 * GNAT.Semaphores (g-semaph.ads)::
510 * GNAT.Serial_Communications (g-sercom.ads)::
511 * GNAT.SHA1 (g-sha1.ads)::
512 * GNAT.SHA224 (g-sha224.ads)::
513 * GNAT.SHA256 (g-sha256.ads)::
514 * GNAT.SHA384 (g-sha384.ads)::
515 * GNAT.SHA512 (g-sha512.ads)::
516 * GNAT.Signals (g-signal.ads)::
517 * GNAT.Sockets (g-socket.ads)::
518 * GNAT.Source_Info (g-souinf.ads)::
519 * GNAT.Spelling_Checker (g-speche.ads)::
520 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
521 * GNAT.Spitbol.Patterns (g-spipat.ads)::
522 * GNAT.Spitbol (g-spitbo.ads)::
523 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
524 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
525 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
526 * GNAT.SSE (g-sse.ads)::
527 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
528 * GNAT.Strings (g-string.ads)::
529 * GNAT.String_Split (g-strspl.ads)::
530 * GNAT.Table (g-table.ads)::
531 * GNAT.Task_Lock (g-tasloc.ads)::
532 * GNAT.Threads (g-thread.ads)::
533 * GNAT.Time_Stamp (g-timsta.ads)::
534 * GNAT.Traceback (g-traceb.ads)::
535 * GNAT.Traceback.Symbolic (g-trasym.ads)::
536 * GNAT.UTF_32 (g-utf_32.ads)::
537 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
538 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
539 * GNAT.Wide_String_Split (g-wistsp.ads)::
540 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
541 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
542 * Interfaces.C.Extensions (i-cexten.ads)::
543 * Interfaces.C.Streams (i-cstrea.ads)::
544 * Interfaces.CPP (i-cpp.ads)::
545 * Interfaces.Packed_Decimal (i-pacdec.ads)::
546 * Interfaces.VxWorks (i-vxwork.ads)::
547 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
548 * System.Address_Image (s-addima.ads)::
549 * System.Assertions (s-assert.ads)::
550 * System.Memory (s-memory.ads)::
551 * System.Multiprocessors (s-multip.ads)::
552 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
553 * System.Partition_Interface (s-parint.ads)::
554 * System.Pool_Global (s-pooglo.ads)::
555 * System.Pool_Local (s-pooloc.ads)::
556 * System.Restrictions (s-restri.ads)::
557 * System.Rident (s-rident.ads)::
558 * System.Strings.Stream_Ops (s-ststop.ads)::
559 * System.Task_Info (s-tasinf.ads)::
560 * System.Wch_Cnv (s-wchcnv.ads)::
561 * System.Wch_Con (s-wchcon.ads)::
562
563 Text_IO
564
565 * Text_IO Stream Pointer Positioning::
566 * Text_IO Reading and Writing Non-Regular Files::
567 * Get_Immediate::
568 * Treating Text_IO Files as Streams::
569 * Text_IO Extensions::
570 * Text_IO Facilities for Unbounded Strings::
571
572 Wide_Text_IO
573
574 * Wide_Text_IO Stream Pointer Positioning::
575 * Wide_Text_IO Reading and Writing Non-Regular Files::
576
577 Wide_Wide_Text_IO
578
579 * Wide_Wide_Text_IO Stream Pointer Positioning::
580 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
581
582 Interfacing to Other Languages
583
584 * Interfacing to C::
585 * Interfacing to C++::
586 * Interfacing to COBOL::
587 * Interfacing to Fortran::
588 * Interfacing to non-GNAT Ada code::
589
590 Specialized Needs Annexes
591
592 Implementation of Specific Ada Features
593 * Machine Code Insertions::
594 * GNAT Implementation of Tasking::
595 * GNAT Implementation of Shared Passive Packages::
596 * Code Generation for Array Aggregates::
597 * The Size of Discriminated Records with Default Discriminants::
598 * Strict Conformance to the Ada Reference Manual::
599
600 Implementation of Ada 2012 Features
601
602 Obsolescent Features
603
604 GNU Free Documentation License
605
606 Index
607 @end menu
608
609 @end ifnottex
610
611 @node About This Guide
612 @unnumbered About This Guide
613
614 @noindent
615 This manual contains useful information in writing programs using the
616 @value{EDITION} compiler. It includes information on implementation dependent
617 characteristics of @value{EDITION}, including all the information required by
618 Annex M of the Ada language standard.
619
620 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
621 Ada 83 compatibility mode.
622 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
623 but you can override with a compiler switch
624 to explicitly specify the language version.
625 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
626 @value{EDITION} User's Guide}, for details on these switches.)
627 Throughout this manual, references to ``Ada'' without a year suffix
628 apply to both the Ada 95 and Ada 2005 versions of the language.
629
630 Ada is designed to be highly portable.
631 In general, a program will have the same effect even when compiled by
632 different compilers on different platforms.
633 However, since Ada is designed to be used in a
634 wide variety of applications, it also contains a number of system
635 dependent features to be used in interfacing to the external world.
636 @cindex Implementation-dependent features
637 @cindex Portability
638
639 Note: Any program that makes use of implementation-dependent features
640 may be non-portable. You should follow good programming practice and
641 isolate and clearly document any sections of your program that make use
642 of these features in a non-portable manner.
643
644 @ifset PROEDITION
645 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
646 ``GNAT'' in the remainder of this document.
647 @end ifset
648
649 @menu
650 * What This Reference Manual Contains::
651 * Conventions::
652 * Related Information::
653 @end menu
654
655 @node What This Reference Manual Contains
656 @unnumberedsec What This Reference Manual Contains
657
658 @noindent
659 This reference manual contains the following chapters:
660
661 @itemize @bullet
662 @item
663 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
664 pragmas, which can be used to extend and enhance the functionality of the
665 compiler.
666
667 @item
668 @ref{Implementation Defined Attributes}, lists GNAT
669 implementation-dependent attributes, which can be used to extend and
670 enhance the functionality of the compiler.
671
672 @item
673 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
674 implementation-dependent restrictions, which can be used to extend and
675 enhance the functionality of the compiler.
676
677 @item
678 @ref{Implementation Advice}, provides information on generally
679 desirable behavior which are not requirements that all compilers must
680 follow since it cannot be provided on all systems, or which may be
681 undesirable on some systems.
682
683 @item
684 @ref{Implementation Defined Characteristics}, provides a guide to
685 minimizing implementation dependent features.
686
687 @item
688 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
689 implemented by GNAT, and how they can be imported into user
690 application programs.
691
692 @item
693 @ref{Representation Clauses and Pragmas}, describes in detail the
694 way that GNAT represents data, and in particular the exact set
695 of representation clauses and pragmas that is accepted.
696
697 @item
698 @ref{Standard Library Routines}, provides a listing of packages and a
699 brief description of the functionality that is provided by Ada's
700 extensive set of standard library routines as implemented by GNAT@.
701
702 @item
703 @ref{The Implementation of Standard I/O}, details how the GNAT
704 implementation of the input-output facilities.
705
706 @item
707 @ref{The GNAT Library}, is a catalog of packages that complement
708 the Ada predefined library.
709
710 @item
711 @ref{Interfacing to Other Languages}, describes how programs
712 written in Ada using GNAT can be interfaced to other programming
713 languages.
714
715 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
716 of the specialized needs annexes.
717
718 @item
719 @ref{Implementation of Specific Ada Features}, discusses issues related
720 to GNAT's implementation of machine code insertions, tasking, and several
721 other features.
722
723 @item
724 @ref{Implementation of Ada 2012 Features}, describes the status of the
725 GNAT implementation of the Ada 2012 language standard.
726
727 @item
728 @ref{Obsolescent Features} documents implementation dependent features,
729 including pragmas and attributes, which are considered obsolescent, since
730 there are other preferred ways of achieving the same results. These
731 obsolescent forms are retained for backwards compatibility.
732
733 @end itemize
734
735 @cindex Ada 95 Language Reference Manual
736 @cindex Ada 2005 Language Reference Manual
737 @noindent
738 This reference manual assumes a basic familiarity with the Ada 95 language, as
739 described in the International Standard ANSI/ISO/IEC-8652:1995,
740 January 1995.
741 It does not require knowledge of the new features introduced by Ada 2005,
742 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
743 and Amendment 1).
744 Both reference manuals are included in the GNAT documentation
745 package.
746
747 @node Conventions
748 @unnumberedsec Conventions
749 @cindex Conventions, typographical
750 @cindex Typographical conventions
751
752 @noindent
753 Following are examples of the typographical and graphic conventions used
754 in this guide:
755
756 @itemize @bullet
757 @item
758 @code{Functions}, @code{utility program names}, @code{standard names},
759 and @code{classes}.
760
761 @item
762 @code{Option flags}
763
764 @item
765 @file{File names}, @samp{button names}, and @samp{field names}.
766
767 @item
768 @code{Variables}, @env{environment variables}, and @var{metasyntactic
769 variables}.
770
771 @item
772 @emph{Emphasis}.
773
774 @item
775 [optional information or parameters]
776
777 @item
778 Examples are described by text
779 @smallexample
780 and then shown this way.
781 @end smallexample
782 @end itemize
783
784 @noindent
785 Commands that are entered by the user are preceded in this manual by the
786 characters @samp{$ } (dollar sign followed by space). If your system uses this
787 sequence as a prompt, then the commands will appear exactly as you see them
788 in the manual. If your system uses some other prompt, then the command will
789 appear with the @samp{$} replaced by whatever prompt character you are using.
790
791 @node Related Information
792 @unnumberedsec Related Information
793 @noindent
794 See the following documents for further information on GNAT:
795
796 @itemize @bullet
797 @item
798 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
799 @value{EDITION} User's Guide}, which provides information on how to use the
800 GNAT compiler system.
801
802 @item
803 @cite{Ada 95 Reference Manual}, which contains all reference
804 material for the Ada 95 programming language.
805
806 @item
807 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
808 of the Ada 95 standard. The annotations describe
809 detailed aspects of the design decision, and in particular contain useful
810 sections on Ada 83 compatibility.
811
812 @item
813 @cite{Ada 2005 Reference Manual}, which contains all reference
814 material for the Ada 2005 programming language.
815
816 @item
817 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
818 of the Ada 2005 standard. The annotations describe
819 detailed aspects of the design decision, and in particular contain useful
820 sections on Ada 83 and Ada 95 compatibility.
821
822 @item
823 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
824 which contains specific information on compatibility between GNAT and
825 DEC Ada 83 systems.
826
827 @item
828 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
829 describes in detail the pragmas and attributes provided by the DEC Ada 83
830 compiler system.
831
832 @end itemize
833
834 @node Implementation Defined Pragmas
835 @chapter Implementation Defined Pragmas
836
837 @noindent
838 Ada defines a set of pragmas that can be used to supply additional
839 information to the compiler. These language defined pragmas are
840 implemented in GNAT and work as described in the Ada Reference Manual.
841
842 In addition, Ada allows implementations to define additional pragmas
843 whose meaning is defined by the implementation. GNAT provides a number
844 of these implementation-defined pragmas, which can be used to extend
845 and enhance the functionality of the compiler. This section of the GNAT
846 Reference Manual describes these additional pragmas.
847
848 Note that any program using these pragmas might not be portable to other
849 compilers (although GNAT implements this set of pragmas on all
850 platforms). Therefore if portability to other compilers is an important
851 consideration, the use of these pragmas should be minimized.
852
853 @menu
854 * Pragma Abort_Defer::
855 * Pragma Ada_83::
856 * Pragma Ada_95::
857 * Pragma Ada_05::
858 * Pragma Ada_2005::
859 * Pragma Ada_12::
860 * Pragma Ada_2012::
861 * Pragma Annotate::
862 * Pragma Assert::
863 * Pragma Assertion_Policy::
864 * Pragma Assume_No_Invalid_Values::
865 * Pragma Attribute_Definition::
866 * Pragma Ast_Entry::
867 * Pragma C_Pass_By_Copy::
868 * Pragma Check::
869 * Pragma Check_Float_Overflow::
870 * Pragma Check_Name::
871 * Pragma Check_Policy::
872 * Pragma Comment::
873 * Pragma Common_Object::
874 * Pragma Compile_Time_Error::
875 * Pragma Compile_Time_Warning::
876 * Pragma Compiler_Unit::
877 * Pragma Complete_Representation::
878 * Pragma Complex_Representation::
879 * Pragma Component_Alignment::
880 * Pragma Contract_Case::
881 * Pragma Convention_Identifier::
882 * Pragma CPP_Class::
883 * Pragma CPP_Constructor::
884 * Pragma CPP_Virtual::
885 * Pragma CPP_Vtable::
886 * Pragma CPU::
887 * Pragma Debug::
888 * Pragma Debug_Policy::
889 * Pragma Default_Storage_Pool::
890 * Pragma Detect_Blocking::
891 * Pragma Dispatching_Domain::
892 * Pragma Elaboration_Checks::
893 * Pragma Eliminate::
894 * Pragma Export_Exception::
895 * Pragma Export_Function::
896 * Pragma Export_Object::
897 * Pragma Export_Procedure::
898 * Pragma Export_Value::
899 * Pragma Export_Valued_Procedure::
900 * Pragma Extend_System::
901 * Pragma Extensions_Allowed::
902 * Pragma External::
903 * Pragma External_Name_Casing::
904 * Pragma Fast_Math::
905 * Pragma Favor_Top_Level::
906 * Pragma Finalize_Storage_Only::
907 * Pragma Float_Representation::
908 * Pragma Ident::
909 * Pragma Implementation_Defined::
910 * Pragma Implemented::
911 * Pragma Implicit_Packing::
912 * Pragma Import_Exception::
913 * Pragma Import_Function::
914 * Pragma Import_Object::
915 * Pragma Import_Procedure::
916 * Pragma Import_Valued_Procedure::
917 * Pragma Independent::
918 * Pragma Independent_Components::
919 * Pragma Initialize_Scalars::
920 * Pragma Inline_Always::
921 * Pragma Inline_Generic::
922 * Pragma Interface::
923 * Pragma Interface_Name::
924 * Pragma Interrupt_Handler::
925 * Pragma Interrupt_State::
926 * Pragma Invariant::
927 * Pragma Keep_Names::
928 * Pragma License::
929 * Pragma Link_With::
930 * Pragma Linker_Alias::
931 * Pragma Linker_Constructor::
932 * Pragma Linker_Destructor::
933 * Pragma Linker_Section::
934 * Pragma Long_Float::
935 * Pragma Loop_Optimize::
936 * Pragma Machine_Attribute::
937 * Pragma Main::
938 * Pragma Main_Storage::
939 * Pragma No_Body::
940 * Pragma No_Inline::
941 * Pragma No_Return::
942 * Pragma No_Strict_Aliasing::
943 * Pragma Normalize_Scalars::
944 * Pragma Obsolescent::
945 * Pragma Optimize_Alignment::
946 * Pragma Ordered::
947 * Pragma Overflow_Mode::
948 * Pragma Partition_Elaboration_Policy::
949 * Pragma Passive::
950 * Pragma Persistent_BSS::
951 * Pragma Polling::
952 * Pragma Postcondition::
953 * Pragma Precondition::
954 * Pragma Preelaborable_Initialization::
955 * Pragma Priority_Specific_Dispatching::
956 * Pragma Profile (Ravenscar)::
957 * Pragma Profile (Restricted)::
958 * Pragma Profile (Rational)::
959 * Pragma Psect_Object::
960 * Pragma Pure_Function::
961 * Pragma Relative_Deadline::
962 * Pragma Remote_Access_Type::
963 * Pragma Restriction_Warnings::
964 * Pragma Shared::
965 * Pragma Short_Circuit_And_Or::
966 * Pragma Short_Descriptors::
967 * Pragma Simple_Storage_Pool_Type::
968 * Pragma Source_File_Name::
969 * Pragma Source_File_Name_Project::
970 * Pragma Source_Reference::
971 * Pragma Static_Elaboration_Desired::
972 * Pragma Stream_Convert::
973 * Pragma Style_Checks::
974 * Pragma Subtitle::
975 * Pragma Suppress::
976 * Pragma Suppress_All::
977 * Pragma Suppress_Exception_Locations::
978 * Pragma Suppress_Initialization::
979 * Pragma Task_Info::
980 * Pragma Task_Name::
981 * Pragma Task_Storage::
982 * Pragma Test_Case::
983 * Pragma Thread_Local_Storage::
984 * Pragma Time_Slice::
985 * Pragma Title::
986 * Pragma Unchecked_Union::
987 * Pragma Unimplemented_Unit::
988 * Pragma Universal_Aliasing ::
989 * Pragma Universal_Data::
990 * Pragma Unmodified::
991 * Pragma Unreferenced::
992 * Pragma Unreferenced_Objects::
993 * Pragma Unreserve_All_Interrupts::
994 * Pragma Unsuppress::
995 * Pragma Use_VADS_Size::
996 * Pragma Validity_Checks::
997 * Pragma Volatile::
998 * Pragma Warnings::
999 * Pragma Weak_External::
1000 * Pragma Wide_Character_Encoding::
1001 @end menu
1002
1003 @node Pragma Abort_Defer
1004 @unnumberedsec Pragma Abort_Defer
1005 @findex Abort_Defer
1006 @cindex Deferring aborts
1007 @noindent
1008 Syntax:
1009 @smallexample
1010 pragma Abort_Defer;
1011 @end smallexample
1012
1013 @noindent
1014 This pragma must appear at the start of the statement sequence of a
1015 handled sequence of statements (right after the @code{begin}). It has
1016 the effect of deferring aborts for the sequence of statements (but not
1017 for the declarations or handlers, if any, associated with this statement
1018 sequence).
1019
1020 @node Pragma Ada_83
1021 @unnumberedsec Pragma Ada_83
1022 @findex Ada_83
1023 @noindent
1024 Syntax:
1025 @smallexample @c ada
1026 pragma Ada_83;
1027 @end smallexample
1028
1029 @noindent
1030 A configuration pragma that establishes Ada 83 mode for the unit to
1031 which it applies, regardless of the mode set by the command line
1032 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1033 the syntax and semantics of Ada 83, as defined in the original Ada
1034 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1035 and Ada 2005 are not recognized, optional package bodies are allowed,
1036 and generics may name types with unknown discriminants without using
1037 the @code{(<>)} notation. In addition, some but not all of the additional
1038 restrictions of Ada 83 are enforced.
1039
1040 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1041 Ada 83 code to be compiled and adapted to GNAT with less effort.
1042 Secondly, it aids in keeping code backwards compatible with Ada 83.
1043 However, there is no guarantee that code that is processed correctly
1044 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1045 83 compiler, since GNAT does not enforce all the additional checks
1046 required by Ada 83.
1047
1048 @node Pragma Ada_95
1049 @unnumberedsec Pragma Ada_95
1050 @findex Ada_95
1051 @noindent
1052 Syntax:
1053 @smallexample @c ada
1054 pragma Ada_95;
1055 @end smallexample
1056
1057 @noindent
1058 A configuration pragma that establishes Ada 95 mode for the unit to which
1059 it applies, regardless of the mode set by the command line switches.
1060 This mode is set automatically for the @code{Ada} and @code{System}
1061 packages and their children, so you need not specify it in these
1062 contexts. This pragma is useful when writing a reusable component that
1063 itself uses Ada 95 features, but which is intended to be usable from
1064 either Ada 83 or Ada 95 programs.
1065
1066 @node Pragma Ada_05
1067 @unnumberedsec Pragma Ada_05
1068 @findex Ada_05
1069 @noindent
1070 Syntax:
1071 @smallexample @c ada
1072 pragma Ada_05;
1073 @end smallexample
1074
1075 @noindent
1076 A configuration pragma that establishes Ada 2005 mode for the unit to which
1077 it applies, regardless of the mode set by the command line switches.
1078 This pragma is useful when writing a reusable component that
1079 itself uses Ada 2005 features, but which is intended to be usable from
1080 either Ada 83 or Ada 95 programs.
1081
1082 @node Pragma Ada_2005
1083 @unnumberedsec Pragma Ada_2005
1084 @findex Ada_2005
1085 @noindent
1086 Syntax:
1087 @smallexample @c ada
1088 pragma Ada_2005;
1089 @end smallexample
1090
1091 @noindent
1092 This configuration pragma is a synonym for pragma Ada_05 and has the
1093 same syntax and effect.
1094
1095 @node Pragma Ada_12
1096 @unnumberedsec Pragma Ada_12
1097 @findex Ada_12
1098 @noindent
1099 Syntax:
1100 @smallexample @c ada
1101 pragma Ada_12;
1102 @end smallexample
1103
1104 @noindent
1105 A configuration pragma that establishes Ada 2012 mode for the unit to which
1106 it applies, regardless of the mode set by the command line switches.
1107 This mode is set automatically for the @code{Ada} and @code{System}
1108 packages and their children, so you need not specify it in these
1109 contexts. This pragma is useful when writing a reusable component that
1110 itself uses Ada 2012 features, but which is intended to be usable from
1111 Ada 83, Ada 95, or Ada 2005 programs.
1112
1113 @node Pragma Ada_2012
1114 @unnumberedsec Pragma Ada_2012
1115 @findex Ada_2005
1116 @noindent
1117 Syntax:
1118 @smallexample @c ada
1119 pragma Ada_2012;
1120 @end smallexample
1121
1122 @noindent
1123 This configuration pragma is a synonym for pragma Ada_12 and has the
1124 same syntax and effect.
1125
1126 @node Pragma Annotate
1127 @unnumberedsec Pragma Annotate
1128 @findex Annotate
1129 @noindent
1130 Syntax:
1131 @smallexample @c ada
1132 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1133
1134 ARG ::= NAME | EXPRESSION
1135 @end smallexample
1136
1137 @noindent
1138 This pragma is used to annotate programs. @var{identifier} identifies
1139 the type of annotation. GNAT verifies that it is an identifier, but does
1140 not otherwise analyze it. The second optional identifier is also left
1141 unanalyzed, and by convention is used to control the action of the tool to
1142 which the annotation is addressed. The remaining @var{arg} arguments
1143 can be either string literals or more generally expressions.
1144 String literals are assumed to be either of type
1145 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1146 depending on the character literals they contain.
1147 All other kinds of arguments are analyzed as expressions, and must be
1148 unambiguous.
1149
1150 The analyzed pragma is retained in the tree, but not otherwise processed
1151 by any part of the GNAT compiler, except to generate corresponding note
1152 lines in the generated ALI file. For the format of these note lines, see
1153 the compiler source file lib-writ.ads. This pragma is intended for use by
1154 external tools, including ASIS@. The use of pragma Annotate does not
1155 affect the compilation process in any way. This pragma may be used as
1156 a configuration pragma.
1157
1158 @node Pragma Assert
1159 @unnumberedsec Pragma Assert
1160 @findex Assert
1161 @noindent
1162 Syntax:
1163 @smallexample @c ada
1164 pragma Assert (
1165 boolean_EXPRESSION
1166 [, string_EXPRESSION]);
1167 @end smallexample
1168
1169 @noindent
1170 The effect of this pragma depends on whether the corresponding command
1171 line switch is set to activate assertions. The pragma expands into code
1172 equivalent to the following:
1173
1174 @smallexample @c ada
1175 if assertions-enabled then
1176 if not boolean_EXPRESSION then
1177 System.Assertions.Raise_Assert_Failure
1178 (string_EXPRESSION);
1179 end if;
1180 end if;
1181 @end smallexample
1182
1183 @noindent
1184 The string argument, if given, is the message that will be associated
1185 with the exception occurrence if the exception is raised. If no second
1186 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1187 where @var{file} is the name of the source file containing the assert,
1188 and @var{nnn} is the line number of the assert. A pragma is not a
1189 statement, so if a statement sequence contains nothing but a pragma
1190 assert, then a null statement is required in addition, as in:
1191
1192 @smallexample @c ada
1193 @dots{}
1194 if J > 3 then
1195 pragma Assert (K > 3, "Bad value for K");
1196 null;
1197 end if;
1198 @end smallexample
1199
1200 @noindent
1201 Note that, as with the @code{if} statement to which it is equivalent, the
1202 type of the expression is either @code{Standard.Boolean}, or any type derived
1203 from this standard type.
1204
1205 If assertions are disabled (switch @option{-gnata} not used), then there
1206 is no run-time effect (and in particular, any side effects from the
1207 expression will not occur at run time). (The expression is still
1208 analyzed at compile time, and may cause types to be frozen if they are
1209 mentioned here for the first time).
1210
1211 If assertions are enabled, then the given expression is tested, and if
1212 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1213 which results in the raising of @code{Assert_Failure} with the given message.
1214
1215 You should generally avoid side effects in the expression arguments of
1216 this pragma, because these side effects will turn on and off with the
1217 setting of the assertions mode, resulting in assertions that have an
1218 effect on the program. However, the expressions are analyzed for
1219 semantic correctness whether or not assertions are enabled, so turning
1220 assertions on and off cannot affect the legality of a program.
1221
1222 Note that the implementation defined policy @code{DISABLE}, given in a
1223 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1224
1225 Note: this is a standard language-defined pragma in versions
1226 of Ada from 2005 on. In GNAT, it is implemented in all versions
1227 of Ada, and the DISABLE policy is an implementation-defined
1228 addition.
1229
1230 @node Pragma Assertion_Policy
1231 @unnumberedsec Pragma Assertion_Policy
1232 @findex Debug_Policy
1233 @noindent
1234 Syntax:
1235
1236 @smallexample @c ada
1237 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1238 @end smallexample
1239
1240 @noindent
1241 This is a standard Ada 2005 pragma that is available as an
1242 implementation-defined pragma in earlier versions of Ada.
1243
1244 If the argument is @code{CHECK}, then assertions are enabled.
1245 If the argument is @code{IGNORE}, then assertions are ignored.
1246 This pragma overrides the effect of the @option{-gnata} switch on the
1247 command line.
1248
1249 Assertions are of three kinds:
1250
1251 @itemize @bullet
1252 @item
1253 Pragma @code{Assert}.
1254 @item
1255 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1256 postconditions, type invariants and (sub)type predicates.
1257 @item
1258 Corresponding pragmas for type invariants and (sub)type predicates.
1259 @end itemize
1260
1261 The implementation defined policy @code{DISABLE} is like
1262 @code{IGNORE} except that it completely disables semantic
1263 checking of the argument to @code{pragma Assert}. This may
1264 be useful when the pragma argument references subprograms
1265 in a with'ed package which is replaced by a dummy package
1266 for the final build.
1267
1268 Note: this is a standard language-defined pragma in versions
1269 of Ada from 2005 on. In GNAT, it is implemented in all versions
1270 of Ada, and the DISABLE policy is an implementation-defined
1271 addition.
1272
1273 @node Pragma Assume_No_Invalid_Values
1274 @unnumberedsec Pragma Assume_No_Invalid_Values
1275 @findex Assume_No_Invalid_Values
1276 @cindex Invalid representations
1277 @cindex Invalid values
1278 @noindent
1279 Syntax:
1280 @smallexample @c ada
1281 pragma Assume_No_Invalid_Values (On | Off);
1282 @end smallexample
1283
1284 @noindent
1285 This is a configuration pragma that controls the assumptions made by the
1286 compiler about the occurrence of invalid representations (invalid values)
1287 in the code.
1288
1289 The default behavior (corresponding to an Off argument for this pragma), is
1290 to assume that values may in general be invalid unless the compiler can
1291 prove they are valid. Consider the following example:
1292
1293 @smallexample @c ada
1294 V1 : Integer range 1 .. 10;
1295 V2 : Integer range 11 .. 20;
1296 ...
1297 for J in V2 .. V1 loop
1298 ...
1299 end loop;
1300 @end smallexample
1301
1302 @noindent
1303 if V1 and V2 have valid values, then the loop is known at compile
1304 time not to execute since the lower bound must be greater than the
1305 upper bound. However in default mode, no such assumption is made,
1306 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1307 is given, the compiler will assume that any occurrence of a variable
1308 other than in an explicit @code{'Valid} test always has a valid
1309 value, and the loop above will be optimized away.
1310
1311 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1312 you know your code is free of uninitialized variables and other
1313 possible sources of invalid representations, and may result in
1314 more efficient code. A program that accesses an invalid representation
1315 with this pragma in effect is erroneous, so no guarantees can be made
1316 about its behavior.
1317
1318 It is peculiar though permissible to use this pragma in conjunction
1319 with validity checking (-gnatVa). In such cases, accessing invalid
1320 values will generally give an exception, though formally the program
1321 is erroneous so there are no guarantees that this will always be the
1322 case, and it is recommended that these two options not be used together.
1323
1324 @node Pragma Ast_Entry
1325 @unnumberedsec Pragma Ast_Entry
1326 @cindex OpenVMS
1327 @findex Ast_Entry
1328 @noindent
1329 Syntax:
1330 @smallexample @c ada
1331 pragma AST_Entry (entry_IDENTIFIER);
1332 @end smallexample
1333
1334 @noindent
1335 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1336 argument is the simple name of a single entry; at most one @code{AST_Entry}
1337 pragma is allowed for any given entry. This pragma must be used in
1338 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1339 the entry declaration and in the same task type specification or single task
1340 as the entry to which it applies. This pragma specifies that the given entry
1341 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1342 resulting from an OpenVMS system service call. The pragma does not affect
1343 normal use of the entry. For further details on this pragma, see the
1344 DEC Ada Language Reference Manual, section 9.12a.
1345
1346 @node Pragma Attribute_Definition
1347 @unnumberedsec Pragma Attribute_Definition
1348 @findex Attribute_Definition
1349 @noindent
1350 Syntax:
1351 @smallexample @c ada
1352 pragma Attribute_Definition
1353 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1354 [Entity =>] LOCAL_NAME,
1355 [Expression =>] EXPRESSION | NAME);
1356 @end smallexample
1357
1358 @noindent
1359 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1360 the attribute definition clause:
1361
1362 @smallexample @c ada
1363 for Entity'Attribute use Expression;
1364 @end smallexample
1365
1366 If @code{Attribute} is not a recognized attribute name, the pragma is
1367 ignored, and a warning is emitted. This allows source
1368 code to be written that takes advantage of some new attribute, while remaining
1369 compilable with earlier compilers.
1370
1371 @node Pragma C_Pass_By_Copy
1372 @unnumberedsec Pragma C_Pass_By_Copy
1373 @cindex Passing by copy
1374 @findex C_Pass_By_Copy
1375 @noindent
1376 Syntax:
1377 @smallexample @c ada
1378 pragma C_Pass_By_Copy
1379 ([Max_Size =>] static_integer_EXPRESSION);
1380 @end smallexample
1381
1382 @noindent
1383 Normally the default mechanism for passing C convention records to C
1384 convention subprograms is to pass them by reference, as suggested by RM
1385 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1386 this default, by requiring that record formal parameters be passed by
1387 copy if all of the following conditions are met:
1388
1389 @itemize @bullet
1390 @item
1391 The size of the record type does not exceed the value specified for
1392 @code{Max_Size}.
1393 @item
1394 The record type has @code{Convention C}.
1395 @item
1396 The formal parameter has this record type, and the subprogram has a
1397 foreign (non-Ada) convention.
1398 @end itemize
1399
1400 @noindent
1401 If these conditions are met the argument is passed by copy, i.e.@: in a
1402 manner consistent with what C expects if the corresponding formal in the
1403 C prototype is a struct (rather than a pointer to a struct).
1404
1405 You can also pass records by copy by specifying the convention
1406 @code{C_Pass_By_Copy} for the record type, or by using the extended
1407 @code{Import} and @code{Export} pragmas, which allow specification of
1408 passing mechanisms on a parameter by parameter basis.
1409
1410 @node Pragma Check
1411 @unnumberedsec Pragma Check
1412 @cindex Assertions
1413 @cindex Named assertions
1414 @findex Check
1415 @noindent
1416 Syntax:
1417 @smallexample @c ada
1418 pragma Check (
1419 [Name =>] Identifier,
1420 [Check =>] Boolean_EXPRESSION
1421 [, [Message =>] string_EXPRESSION] );
1422 @end smallexample
1423
1424 @noindent
1425 This pragma is similar to the predefined pragma @code{Assert} except that an
1426 extra identifier argument is present. In conjunction with pragma
1427 @code{Check_Policy}, this can be used to define groups of assertions that can
1428 be independently controlled. The identifier @code{Assertion} is special, it
1429 refers to the normal set of pragma @code{Assert} statements. The identifiers
1430 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1431 names, so these three names would normally not be used directly in a pragma
1432 @code{Check}.
1433
1434 Checks introduced by this pragma are normally deactivated by default. They can
1435 be activated either by the command line option @option{-gnata}, which turns on
1436 all checks, or individually controlled using pragma @code{Check_Policy}.
1437
1438 @node Pragma Check_Float_Overflow
1439 @unnumberedsec Pragma Check_Float_Overflow
1440 @cindex Floating-point overflow
1441 @findex Check_Float_Overflow
1442 @noindent
1443 Syntax:
1444 @smallexample @c ada
1445 pragma Check_Float_Overflow;
1446 @end smallexample
1447
1448 @noindent
1449 In Ada, the predefined floating-point types (@code{Short_Float},
1450 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1451 defined to be @emph{unconstrained}. This means that even though each
1452 has a well-defined base range, an operation that delivers a result
1453 outside this base range is not required to raise an exception.
1454 This implementation permission accommodates the notion
1455 of infinities in IEEE floating-point, and corresponds to the
1456 efficient execution mode on most machines. GNAT will not raise
1457 overflow exceptions on these machines; instead it will generate
1458 infinities and NaN's as defined in the IEEE standard.
1459
1460 Generating infinities, although efficient, is not always desirable.
1461 Often the preferable approach is to check for overflow, even at the
1462 (perhaps considerable) expense of run-time performance.
1463 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1464 range constraints -- and indeed such a subtype
1465 can have the same base range as its base type. For example:
1466
1467 @smallexample @c ada
1468 subtype My_Float is Float range Float'Range;
1469 @end smallexample
1470
1471 @noindent
1472 Here @code{My_Float} has the same range as
1473 @code{Float} but is constrained, so operations on
1474 @code{My_Float} values will be checked for overflow
1475 against this range.
1476
1477 This style will achieve the desired goal, but
1478 it is often more convenient to be able to simply use
1479 the standard predefined floating-point types as long
1480 as overflow checking could be guaranteed.
1481 The @code{Check_Float_Overflow}
1482 configuration pragma achieves this effect. If a unit is compiled
1483 subject to this configuration pragma, then all operations
1484 on predefined floating-point types will be treated as
1485 though those types were constrained, and overflow checks
1486 will be generated. The @code{Constraint_Error}
1487 exception is raised if the result is out of range.
1488
1489 This mode can also be set by use of the compiler
1490 switch @option{-gnateF}.
1491
1492 @node Pragma Check_Name
1493 @unnumberedsec Pragma Check_Name
1494 @cindex Defining check names
1495 @cindex Check names, defining
1496 @findex Check_Name
1497 @noindent
1498 Syntax:
1499 @smallexample @c ada
1500 pragma Check_Name (check_name_IDENTIFIER);
1501 @end smallexample
1502
1503 @noindent
1504 This is a configuration pragma that defines a new implementation
1505 defined check name (unless IDENTIFIER matches one of the predefined
1506 check names, in which case the pragma has no effect). Check names
1507 are global to a partition, so if two or more configuration pragmas
1508 are present in a partition mentioning the same name, only one new
1509 check name is introduced.
1510
1511 An implementation defined check name introduced with this pragma may
1512 be used in only three contexts: @code{pragma Suppress},
1513 @code{pragma Unsuppress},
1514 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1515 any of these three cases, the check name must be visible. A check
1516 name is visible if it is in the configuration pragmas applying to
1517 the current unit, or if it appears at the start of any unit that
1518 is part of the dependency set of the current unit (e.g., units that
1519 are mentioned in @code{with} clauses).
1520
1521 Check names introduced by this pragma are subject to control by compiler
1522 switches (in particular -gnatp) in the usual manner.
1523
1524 @node Pragma Check_Policy
1525 @unnumberedsec Pragma Check_Policy
1526 @cindex Controlling assertions
1527 @cindex Assertions, control
1528 @cindex Check pragma control
1529 @cindex Named assertions
1530 @findex Check
1531 @noindent
1532 Syntax:
1533 @smallexample @c ada
1534 pragma Check_Policy
1535 ([Name =>] Identifier,
1536 [Policy =>] POLICY_IDENTIFIER);
1537
1538 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1539 @end smallexample
1540
1541 @noindent
1542 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1543 except that it controls sets of named assertions introduced using the
1544 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1545 @code{Assertion_Policy}) can be used within a declarative part, in which case
1546 it controls the status to the end of the corresponding construct (in a manner
1547 identical to pragma @code{Suppress)}.
1548
1549 The identifier given as the first argument corresponds to a name used in
1550 associated @code{Check} pragmas. For example, if the pragma:
1551
1552 @smallexample @c ada
1553 pragma Check_Policy (Critical_Error, OFF);
1554 @end smallexample
1555
1556 @noindent
1557 is given, then subsequent @code{Check} pragmas whose first argument is also
1558 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1559 controls the behavior of normal assertions (thus a pragma
1560 @code{Check_Policy} with this identifier is similar to the normal
1561 @code{Assertion_Policy} pragma except that it can appear within a
1562 declarative part).
1563
1564 The special identifiers @code{Precondition} and @code{Postcondition} control
1565 the status of preconditions and postconditions given as pragmas.
1566 If a @code{Precondition} pragma
1567 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1568 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1569 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1570 are recognized. Note that preconditions and postconditions given as aspects
1571 are controlled differently, either by the @code{Assertion_Policy} pragma or
1572 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1573
1574 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1575 to turn on corresponding checks. The default for a set of checks for which no
1576 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1577 @option{-gnata} is given, which turns on all checks by default.
1578
1579 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1580 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1581 compatibility with the standard @code{Assertion_Policy} pragma.
1582
1583 The implementation defined policy @code{DISABLE} is like
1584 @code{OFF} except that it completely disables semantic
1585 checking of the argument to the corresponding class of
1586 pragmas. This may be useful when the pragma arguments reference
1587 subprograms in a with'ed package which is replaced by a dummy package
1588 for the final build.
1589
1590 @node Pragma Comment
1591 @unnumberedsec Pragma Comment
1592 @findex Comment
1593 @noindent
1594 Syntax:
1595
1596 @smallexample @c ada
1597 pragma Comment (static_string_EXPRESSION);
1598 @end smallexample
1599
1600 @noindent
1601 This is almost identical in effect to pragma @code{Ident}. It allows the
1602 placement of a comment into the object file and hence into the
1603 executable file if the operating system permits such usage. The
1604 difference is that @code{Comment}, unlike @code{Ident}, has
1605 no limitations on placement of the pragma (it can be placed
1606 anywhere in the main source unit), and if more than one pragma
1607 is used, all comments are retained.
1608
1609 @node Pragma Common_Object
1610 @unnumberedsec Pragma Common_Object
1611 @findex Common_Object
1612 @noindent
1613 Syntax:
1614
1615 @smallexample @c ada
1616 pragma Common_Object (
1617 [Internal =>] LOCAL_NAME
1618 [, [External =>] EXTERNAL_SYMBOL]
1619 [, [Size =>] EXTERNAL_SYMBOL] );
1620
1621 EXTERNAL_SYMBOL ::=
1622 IDENTIFIER
1623 | static_string_EXPRESSION
1624 @end smallexample
1625
1626 @noindent
1627 This pragma enables the shared use of variables stored in overlaid
1628 linker areas corresponding to the use of @code{COMMON}
1629 in Fortran. The single
1630 object @var{LOCAL_NAME} is assigned to the area designated by
1631 the @var{External} argument.
1632 You may define a record to correspond to a series
1633 of fields. The @var{Size} argument
1634 is syntax checked in GNAT, but otherwise ignored.
1635
1636 @code{Common_Object} is not supported on all platforms. If no
1637 support is available, then the code generator will issue a message
1638 indicating that the necessary attribute for implementation of this
1639 pragma is not available.
1640
1641 @node Pragma Compile_Time_Error
1642 @unnumberedsec Pragma Compile_Time_Error
1643 @findex Compile_Time_Error
1644 @noindent
1645 Syntax:
1646
1647 @smallexample @c ada
1648 pragma Compile_Time_Error
1649 (boolean_EXPRESSION, static_string_EXPRESSION);
1650 @end smallexample
1651
1652 @noindent
1653 This pragma can be used to generate additional compile time
1654 error messages. It
1655 is particularly useful in generics, where errors can be issued for
1656 specific problematic instantiations. The first parameter is a boolean
1657 expression. The pragma is effective only if the value of this expression
1658 is known at compile time, and has the value True. The set of expressions
1659 whose values are known at compile time includes all static boolean
1660 expressions, and also other values which the compiler can determine
1661 at compile time (e.g., the size of a record type set by an explicit
1662 size representation clause, or the value of a variable which was
1663 initialized to a constant and is known not to have been modified).
1664 If these conditions are met, an error message is generated using
1665 the value given as the second argument. This string value may contain
1666 embedded ASCII.LF characters to break the message into multiple lines.
1667
1668 @node Pragma Compile_Time_Warning
1669 @unnumberedsec Pragma Compile_Time_Warning
1670 @findex Compile_Time_Warning
1671 @noindent
1672 Syntax:
1673
1674 @smallexample @c ada
1675 pragma Compile_Time_Warning
1676 (boolean_EXPRESSION, static_string_EXPRESSION);
1677 @end smallexample
1678
1679 @noindent
1680 Same as pragma Compile_Time_Error, except a warning is issued instead
1681 of an error message. Note that if this pragma is used in a package that
1682 is with'ed by a client, the client will get the warning even though it
1683 is issued by a with'ed package (normally warnings in with'ed units are
1684 suppressed, but this is a special exception to that rule).
1685
1686 One typical use is within a generic where compile time known characteristics
1687 of formal parameters are tested, and warnings given appropriately. Another use
1688 with a first parameter of True is to warn a client about use of a package,
1689 for example that it is not fully implemented.
1690
1691 @node Pragma Compiler_Unit
1692 @unnumberedsec Pragma Compiler_Unit
1693 @findex Compiler_Unit
1694 @noindent
1695 Syntax:
1696
1697 @smallexample @c ada
1698 pragma Compiler_Unit;
1699 @end smallexample
1700
1701 @noindent
1702 This pragma is intended only for internal use in the GNAT run-time library.
1703 It indicates that the unit is used as part of the compiler build. The effect
1704 is to disallow constructs (raise with message, conditional expressions etc)
1705 that would cause trouble when bootstrapping using an older version of GNAT.
1706 For the exact list of restrictions, see the compiler sources and references
1707 to Is_Compiler_Unit.
1708
1709 @node Pragma Complete_Representation
1710 @unnumberedsec Pragma Complete_Representation
1711 @findex Complete_Representation
1712 @noindent
1713 Syntax:
1714
1715 @smallexample @c ada
1716 pragma Complete_Representation;
1717 @end smallexample
1718
1719 @noindent
1720 This pragma must appear immediately within a record representation
1721 clause. Typical placements are before the first component clause
1722 or after the last component clause. The effect is to give an error
1723 message if any component is missing a component clause. This pragma
1724 may be used to ensure that a record representation clause is
1725 complete, and that this invariant is maintained if fields are
1726 added to the record in the future.
1727
1728 @node Pragma Complex_Representation
1729 @unnumberedsec Pragma Complex_Representation
1730 @findex Complex_Representation
1731 @noindent
1732 Syntax:
1733
1734 @smallexample @c ada
1735 pragma Complex_Representation
1736 ([Entity =>] LOCAL_NAME);
1737 @end smallexample
1738
1739 @noindent
1740 The @var{Entity} argument must be the name of a record type which has
1741 two fields of the same floating-point type. The effect of this pragma is
1742 to force gcc to use the special internal complex representation form for
1743 this record, which may be more efficient. Note that this may result in
1744 the code for this type not conforming to standard ABI (application
1745 binary interface) requirements for the handling of record types. For
1746 example, in some environments, there is a requirement for passing
1747 records by pointer, and the use of this pragma may result in passing
1748 this type in floating-point registers.
1749
1750 @node Pragma Component_Alignment
1751 @unnumberedsec Pragma Component_Alignment
1752 @cindex Alignments of components
1753 @findex Component_Alignment
1754 @noindent
1755 Syntax:
1756
1757 @smallexample @c ada
1758 pragma Component_Alignment (
1759 [Form =>] ALIGNMENT_CHOICE
1760 [, [Name =>] type_LOCAL_NAME]);
1761
1762 ALIGNMENT_CHOICE ::=
1763 Component_Size
1764 | Component_Size_4
1765 | Storage_Unit
1766 | Default
1767 @end smallexample
1768
1769 @noindent
1770 Specifies the alignment of components in array or record types.
1771 The meaning of the @var{Form} argument is as follows:
1772
1773 @table @code
1774 @findex Component_Size
1775 @item Component_Size
1776 Aligns scalar components and subcomponents of the array or record type
1777 on boundaries appropriate to their inherent size (naturally
1778 aligned). For example, 1-byte components are aligned on byte boundaries,
1779 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1780 integer components are aligned on 4-byte boundaries and so on. These
1781 alignment rules correspond to the normal rules for C compilers on all
1782 machines except the VAX@.
1783
1784 @findex Component_Size_4
1785 @item Component_Size_4
1786 Naturally aligns components with a size of four or fewer
1787 bytes. Components that are larger than 4 bytes are placed on the next
1788 4-byte boundary.
1789
1790 @findex Storage_Unit
1791 @item Storage_Unit
1792 Specifies that array or record components are byte aligned, i.e.@:
1793 aligned on boundaries determined by the value of the constant
1794 @code{System.Storage_Unit}.
1795
1796 @cindex OpenVMS
1797 @item Default
1798 Specifies that array or record components are aligned on default
1799 boundaries, appropriate to the underlying hardware or operating system or
1800 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1801 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1802 the @code{Default} choice is the same as @code{Component_Size} (natural
1803 alignment).
1804 @end table
1805
1806 @noindent
1807 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1808 refer to a local record or array type, and the specified alignment
1809 choice applies to the specified type. The use of
1810 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1811 @code{Component_Alignment} pragma to be ignored. The use of
1812 @code{Component_Alignment} together with a record representation clause
1813 is only effective for fields not specified by the representation clause.
1814
1815 If the @code{Name} parameter is absent, the pragma can be used as either
1816 a configuration pragma, in which case it applies to one or more units in
1817 accordance with the normal rules for configuration pragmas, or it can be
1818 used within a declarative part, in which case it applies to types that
1819 are declared within this declarative part, or within any nested scope
1820 within this declarative part. In either case it specifies the alignment
1821 to be applied to any record or array type which has otherwise standard
1822 representation.
1823
1824 If the alignment for a record or array type is not specified (using
1825 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1826 clause), the GNAT uses the default alignment as described previously.
1827
1828 @node Pragma Contract_Case
1829 @unnumberedsec Pragma Contract_Case
1830 @cindex Contract cases
1831 @findex Contract_Case
1832 @noindent
1833 Syntax:
1834
1835 @smallexample @c ada
1836 pragma Contract_Case (
1837 [Name =>] static_string_Expression
1838 ,[Mode =>] (Nominal | Robustness)
1839 [, Requires => Boolean_Expression]
1840 [, Ensures => Boolean_Expression]);
1841 @end smallexample
1842
1843 @noindent
1844 The @code{Contract_Case} pragma allows defining fine-grain specifications
1845 that can complement or replace the contract given by a precondition and a
1846 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1847 by testing and formal verification tools. The compiler checks its validity and,
1848 depending on the assertion policy at the point of declaration of the pragma,
1849 it may insert a check in the executable. For code generation, the contract
1850 case
1851
1852 @smallexample @c ada
1853 pragma Contract_Case (
1854 Name => ...
1855 Mode => ...
1856 Requires => R,
1857 Ensures => E);
1858 @end smallexample
1859
1860 @noindent
1861 is equivalent to
1862
1863 @smallexample @c ada
1864 pragma Postcondition (not R'Old or else E);
1865 @end smallexample
1866
1867 @noindent
1868 which is also equivalent to (in Ada 2012)
1869
1870 @smallexample @c ada
1871 pragma Postcondition (if R'Old then E);
1872 @end smallexample
1873
1874 @noindent
1875 expressing that, whenever condition @code{R} is satisfied on entry to the
1876 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1877
1878 A precondition @code{P} and postcondition @code{Q} can also be
1879 expressed as contract cases:
1880
1881 @smallexample @c ada
1882 pragma Contract_Case (
1883 Name => "Replace precondition",
1884 Mode => Nominal,
1885 Requires => not P,
1886 Ensures => False);
1887 pragma Contract_Case (
1888 Name => "Replace postcondition",
1889 Mode => Nominal,
1890 Requires => P,
1891 Ensures => Q);
1892 @end smallexample
1893
1894 @code{Contract_Case} pragmas may only appear immediately following the
1895 (separate) declaration of a subprogram in a package declaration, inside
1896 a package spec unit. Only other pragmas may intervene (that is appear
1897 between the subprogram declaration and a contract case).
1898
1899 The compiler checks that boolean expressions given in @code{Requires} and
1900 @code{Ensures} are valid, where the rules for @code{Requires} are the
1901 same as the rule for an expression in @code{Precondition} and the rules
1902 for @code{Ensures} are the same as the rule for an expression in
1903 @code{Postcondition}. In particular, attributes @code{'Old} and
1904 @code{'Result} can only be used within the @code{Ensures}
1905 expression. The following is an example of use within a package spec:
1906
1907 @smallexample @c ada
1908 package Math_Functions is
1909 ...
1910 function Sqrt (Arg : Float) return Float;
1911 pragma Contract_Case (Name => "Small argument",
1912 Mode => Nominal,
1913 Requires => Arg < 100,
1914 Ensures => Sqrt'Result < 10);
1915 ...
1916 end Math_Functions;
1917 @end smallexample
1918
1919 @noindent
1920 The meaning of a contract case is that, whenever the associated subprogram is
1921 executed in a context where @code{Requires} holds, then @code{Ensures}
1922 should hold when the subprogram returns. Mode @code{Nominal} indicates
1923 that the input context should also satisfy the precondition of the
1924 subprogram, and the output context should also satisfy its
1925 postcondition. More @code{Robustness} indicates that the precondition and
1926 postcondition of the subprogram should be ignored for this contract case,
1927 which is mostly useful when testing such a contract using a testing tool
1928 that understands contract cases.
1929
1930 @node Pragma Convention_Identifier
1931 @unnumberedsec Pragma Convention_Identifier
1932 @findex Convention_Identifier
1933 @cindex Conventions, synonyms
1934 @noindent
1935 Syntax:
1936
1937 @smallexample @c ada
1938 pragma Convention_Identifier (
1939 [Name =>] IDENTIFIER,
1940 [Convention =>] convention_IDENTIFIER);
1941 @end smallexample
1942
1943 @noindent
1944 This pragma provides a mechanism for supplying synonyms for existing
1945 convention identifiers. The @code{Name} identifier can subsequently
1946 be used as a synonym for the given convention in other pragmas (including
1947 for example pragma @code{Import} or another @code{Convention_Identifier}
1948 pragma). As an example of the use of this, suppose you had legacy code
1949 which used Fortran77 as the identifier for Fortran. Then the pragma:
1950
1951 @smallexample @c ada
1952 pragma Convention_Identifier (Fortran77, Fortran);
1953 @end smallexample
1954
1955 @noindent
1956 would allow the use of the convention identifier @code{Fortran77} in
1957 subsequent code, avoiding the need to modify the sources. As another
1958 example, you could use this to parameterize convention requirements
1959 according to systems. Suppose you needed to use @code{Stdcall} on
1960 windows systems, and @code{C} on some other system, then you could
1961 define a convention identifier @code{Library} and use a single
1962 @code{Convention_Identifier} pragma to specify which convention
1963 would be used system-wide.
1964
1965 @node Pragma CPP_Class
1966 @unnumberedsec Pragma CPP_Class
1967 @findex CPP_Class
1968 @cindex Interfacing with C++
1969 @noindent
1970 Syntax:
1971
1972 @smallexample @c ada
1973 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1974 @end smallexample
1975
1976 @noindent
1977 The argument denotes an entity in the current declarative region that is
1978 declared as a record type. It indicates that the type corresponds to an
1979 externally declared C++ class type, and is to be laid out the same way
1980 that C++ would lay out the type. If the C++ class has virtual primitives
1981 then the record must be declared as a tagged record type.
1982
1983 Types for which @code{CPP_Class} is specified do not have assignment or
1984 equality operators defined (such operations can be imported or declared
1985 as subprograms as required). Initialization is allowed only by constructor
1986 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1987 limited if not explicitly declared as limited or derived from a limited
1988 type, and an error is issued in that case.
1989
1990 See @ref{Interfacing to C++} for related information.
1991
1992 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1993 for backward compatibility but its functionality is available
1994 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1995
1996 @node Pragma CPP_Constructor
1997 @unnumberedsec Pragma CPP_Constructor
1998 @cindex Interfacing with C++
1999 @findex CPP_Constructor
2000 @noindent
2001 Syntax:
2002
2003 @smallexample @c ada
2004 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2005 [, [External_Name =>] static_string_EXPRESSION ]
2006 [, [Link_Name =>] static_string_EXPRESSION ]);
2007 @end smallexample
2008
2009 @noindent
2010 This pragma identifies an imported function (imported in the usual way
2011 with pragma @code{Import}) as corresponding to a C++ constructor. If
2012 @code{External_Name} and @code{Link_Name} are not specified then the
2013 @code{Entity} argument is a name that must have been previously mentioned
2014 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2015 must be of one of the following forms:
2016
2017 @itemize @bullet
2018 @item
2019 @code{function @var{Fname} return @var{T}}
2020
2021 @itemize @bullet
2022 @item
2023 @code{function @var{Fname} return @var{T}'Class}
2024
2025 @item
2026 @code{function @var{Fname} (@dots{}) return @var{T}}
2027 @end itemize
2028
2029 @item
2030 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2031 @end itemize
2032
2033 @noindent
2034 where @var{T} is a limited record type imported from C++ with pragma
2035 @code{Import} and @code{Convention} = @code{CPP}.
2036
2037 The first two forms import the default constructor, used when an object
2038 of type @var{T} is created on the Ada side with no explicit constructor.
2039 The latter two forms cover all the non-default constructors of the type.
2040 See the @value{EDITION} User's Guide for details.
2041
2042 If no constructors are imported, it is impossible to create any objects
2043 on the Ada side and the type is implicitly declared abstract.
2044
2045 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2046 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2047 GCC switch).
2048 See @ref{Interfacing to C++} for more related information.
2049
2050 Note: The use of functions returning class-wide types for constructors is
2051 currently obsolete. They are supported for backward compatibility. The
2052 use of functions returning the type T leave the Ada sources more clear
2053 because the imported C++ constructors always return an object of type T;
2054 that is, they never return an object whose type is a descendant of type T.
2055
2056 @node Pragma CPP_Virtual
2057 @unnumberedsec Pragma CPP_Virtual
2058 @cindex Interfacing to C++
2059 @findex CPP_Virtual
2060 @noindent
2061 This pragma is now obsolete has has no effect because GNAT generates
2062 the same object layout than the G++ compiler.
2063
2064 See @ref{Interfacing to C++} for related information.
2065
2066 @node Pragma CPP_Vtable
2067 @unnumberedsec Pragma CPP_Vtable
2068 @cindex Interfacing with C++
2069 @findex CPP_Vtable
2070 @noindent
2071 This pragma is now obsolete has has no effect because GNAT generates
2072 the same object layout than the G++ compiler.
2073
2074 See @ref{Interfacing to C++} for related information.
2075
2076 @node Pragma CPU
2077 @unnumberedsec Pragma CPU
2078 @findex CPU
2079 @noindent
2080 Syntax:
2081
2082 @smallexample @c ada
2083 pragma CPU (EXPRESSSION);
2084 @end smallexample
2085
2086 @noindent
2087 This pragma is standard in Ada 2012, but is available in all earlier
2088 versions of Ada as an implementation-defined pragma.
2089 See Ada 2012 Reference Manual for details.
2090
2091 @node Pragma Debug
2092 @unnumberedsec Pragma Debug
2093 @findex Debug
2094 @noindent
2095 Syntax:
2096
2097 @smallexample @c ada
2098 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2099
2100 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2101 PROCEDURE_NAME
2102 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2103 @end smallexample
2104
2105 @noindent
2106 The procedure call argument has the syntactic form of an expression, meeting
2107 the syntactic requirements for pragmas.
2108
2109 If debug pragmas are not enabled or if the condition is present and evaluates
2110 to False, this pragma has no effect. If debug pragmas are enabled, the
2111 semantics of the pragma is exactly equivalent to the procedure call statement
2112 corresponding to the argument with a terminating semicolon. Pragmas are
2113 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2114 intersperse calls to debug procedures in the middle of declarations. Debug
2115 pragmas can be enabled either by use of the command line switch @option{-gnata}
2116 or by use of the configuration pragma @code{Debug_Policy}.
2117
2118 @node Pragma Debug_Policy
2119 @unnumberedsec Pragma Debug_Policy
2120 @findex Debug_Policy
2121 @noindent
2122 Syntax:
2123
2124 @smallexample @c ada
2125 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
2126 @end smallexample
2127
2128 @noindent
2129 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
2130 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2131 This pragma overrides the effect of the @option{-gnata} switch on the
2132 command line.
2133
2134 The implementation defined policy @code{DISABLE} is like
2135 @code{IGNORE} except that it completely disables semantic
2136 checking of the argument to @code{pragma Debug}. This may
2137 be useful when the pragma argument references subprograms
2138 in a with'ed package which is replaced by a dummy package
2139 for the final build.
2140
2141 @node Pragma Default_Storage_Pool
2142 @unnumberedsec Pragma Default_Storage_Pool
2143 @findex Default_Storage_Pool
2144 @noindent
2145 Syntax:
2146
2147 @smallexample @c ada
2148 pragma Default_Storage_Pool (storage_pool_NAME | null);
2149 @end smallexample
2150
2151 @noindent
2152 This pragma is standard in Ada 2012, but is available in all earlier
2153 versions of Ada as an implementation-defined pragma.
2154 See Ada 2012 Reference Manual for details.
2155
2156 @node Pragma Detect_Blocking
2157 @unnumberedsec Pragma Detect_Blocking
2158 @findex Detect_Blocking
2159 @noindent
2160 Syntax:
2161
2162 @smallexample @c ada
2163 pragma Detect_Blocking;
2164 @end smallexample
2165
2166 @noindent
2167 This is a standard pragma in Ada 2005, that is available in all earlier
2168 versions of Ada as an implementation-defined pragma.
2169
2170 This is a configuration pragma that forces the detection of potentially
2171 blocking operations within a protected operation, and to raise Program_Error
2172 if that happens.
2173
2174 @node Pragma Dispatching_Domain
2175 @unnumberedsec Pragma Dispatching_Domain
2176 @findex Dispatching_Domain
2177 @noindent
2178 Syntax:
2179
2180 @smallexample @c ada
2181 pragma Dispatching_Domain (EXPRESSION);
2182 @end smallexample
2183
2184 @noindent
2185 This pragma is standard in Ada 2012, but is available in all earlier
2186 versions of Ada as an implementation-defined pragma.
2187 See Ada 2012 Reference Manual for details.
2188
2189 @node Pragma Elaboration_Checks
2190 @unnumberedsec Pragma Elaboration_Checks
2191 @cindex Elaboration control
2192 @findex Elaboration_Checks
2193 @noindent
2194 Syntax:
2195
2196 @smallexample @c ada
2197 pragma Elaboration_Checks (Dynamic | Static);
2198 @end smallexample
2199
2200 @noindent
2201 This is a configuration pragma that provides control over the
2202 elaboration model used by the compilation affected by the
2203 pragma. If the parameter is @code{Dynamic},
2204 then the dynamic elaboration
2205 model described in the Ada Reference Manual is used, as though
2206 the @option{-gnatE} switch had been specified on the command
2207 line. If the parameter is @code{Static}, then the default GNAT static
2208 model is used. This configuration pragma overrides the setting
2209 of the command line. For full details on the elaboration models
2210 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2211 gnat_ugn, @value{EDITION} User's Guide}.
2212
2213 @node Pragma Eliminate
2214 @unnumberedsec Pragma Eliminate
2215 @cindex Elimination of unused subprograms
2216 @findex Eliminate
2217 @noindent
2218 Syntax:
2219
2220 @smallexample @c ada
2221 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2222 [Source_Location =>] STRING_LITERAL);
2223 @end smallexample
2224
2225 @noindent
2226 The string literal given for the source location is a string which
2227 specifies the line number of the occurrence of the entity, using
2228 the syntax for SOURCE_TRACE given below:
2229
2230 @smallexample @c ada
2231 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2232
2233 LBRACKET ::= [
2234 RBRACKET ::= ]
2235
2236 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2237
2238 LINE_NUMBER ::= DIGIT @{DIGIT@}
2239 @end smallexample
2240
2241 @noindent
2242 Spaces around the colon in a @code{Source_Reference} are optional.
2243
2244 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2245 explicit subprogram declaration, where the @code{entity} name in this
2246 designator appears on the source line specified by the source location.
2247
2248 The source trace that is given as the @code{Source_Location} shall obey the
2249 following rules. The @code{FILE_NAME} is the short name (with no directory
2250 information) of an Ada source file, given using exactly the required syntax
2251 for the underlying file system (e.g. case is important if the underlying
2252 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2253 number of the occurrence of the @code{entity}
2254 as a decimal literal without an exponent or point. If an @code{entity} is not
2255 declared in a generic instantiation (this includes generic subprogram
2256 instances), the source trace includes only one source reference. If an entity
2257 is declared inside a generic instantiation, its source trace (when parsing
2258 from left to right) starts with the source location of the declaration of the
2259 entity in the generic unit and ends with the source location of the
2260 instantiation (it is given in square brackets). This approach is recursively
2261 used in case of nested instantiations: the rightmost (nested most deeply in
2262 square brackets) element of the source trace is the location of the outermost
2263 instantiation, the next to left element is the location of the next (first
2264 nested) instantiation in the code of the corresponding generic unit, and so
2265 on, and the leftmost element (that is out of any square brackets) is the
2266 location of the declaration of the entity to eliminate in a generic unit.
2267
2268 Note that the @code{Source_Location} argument specifies which of a set of
2269 similarly named entities is being eliminated, dealing both with overloading,
2270 and also appearence of the same entity name in different scopes.
2271
2272 This pragma indicates that the given entity is not used in the program to be
2273 compiled and built. The effect of the pragma is to allow the compiler to
2274 eliminate the code or data associated with the named entity. Any reference to
2275 an eliminated entity causes a compile-time or link-time error.
2276
2277 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2278 in a system-independent manner, with unused entities eliminated, without
2279 needing to modify the source text. Normally the required set of
2280 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2281
2282 Any source file change that removes, splits, or
2283 adds lines may make the set of Eliminate pragmas invalid because their
2284 @code{Source_Location} argument values may get out of date.
2285
2286 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2287 operation. In this case all the subprograms to which the given operation can
2288 dispatch are considered to be unused (are never called as a result of a direct
2289 or a dispatching call).
2290
2291 @node Pragma Export_Exception
2292 @unnumberedsec Pragma Export_Exception
2293 @cindex OpenVMS
2294 @findex Export_Exception
2295 @noindent
2296 Syntax:
2297
2298 @smallexample @c ada
2299 pragma Export_Exception (
2300 [Internal =>] LOCAL_NAME
2301 [, [External =>] EXTERNAL_SYMBOL]
2302 [, [Form =>] Ada | VMS]
2303 [, [Code =>] static_integer_EXPRESSION]);
2304
2305 EXTERNAL_SYMBOL ::=
2306 IDENTIFIER
2307 | static_string_EXPRESSION
2308 @end smallexample
2309
2310 @noindent
2311 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2312 causes the specified exception to be propagated outside of the Ada program,
2313 so that it can be handled by programs written in other OpenVMS languages.
2314 This pragma establishes an external name for an Ada exception and makes the
2315 name available to the OpenVMS Linker as a global symbol. For further details
2316 on this pragma, see the
2317 DEC Ada Language Reference Manual, section 13.9a3.2.
2318
2319 @node Pragma Export_Function
2320 @unnumberedsec Pragma Export_Function
2321 @cindex Argument passing mechanisms
2322 @findex Export_Function
2323
2324 @noindent
2325 Syntax:
2326
2327 @smallexample @c ada
2328 pragma Export_Function (
2329 [Internal =>] LOCAL_NAME
2330 [, [External =>] EXTERNAL_SYMBOL]
2331 [, [Parameter_Types =>] PARAMETER_TYPES]
2332 [, [Result_Type =>] result_SUBTYPE_MARK]
2333 [, [Mechanism =>] MECHANISM]
2334 [, [Result_Mechanism =>] MECHANISM_NAME]);
2335
2336 EXTERNAL_SYMBOL ::=
2337 IDENTIFIER
2338 | static_string_EXPRESSION
2339 | ""
2340
2341 PARAMETER_TYPES ::=
2342 null
2343 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2344
2345 TYPE_DESIGNATOR ::=
2346 subtype_NAME
2347 | subtype_Name ' Access
2348
2349 MECHANISM ::=
2350 MECHANISM_NAME
2351 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2352
2353 MECHANISM_ASSOCIATION ::=
2354 [formal_parameter_NAME =>] MECHANISM_NAME
2355
2356 MECHANISM_NAME ::=
2357 Value
2358 | Reference
2359 | Descriptor [([Class =>] CLASS_NAME)]
2360 | Short_Descriptor [([Class =>] CLASS_NAME)]
2361
2362 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2363 @end smallexample
2364
2365 @noindent
2366 Use this pragma to make a function externally callable and optionally
2367 provide information on mechanisms to be used for passing parameter and
2368 result values. We recommend, for the purposes of improving portability,
2369 this pragma always be used in conjunction with a separate pragma
2370 @code{Export}, which must precede the pragma @code{Export_Function}.
2371 GNAT does not require a separate pragma @code{Export}, but if none is
2372 present, @code{Convention Ada} is assumed, which is usually
2373 not what is wanted, so it is usually appropriate to use this
2374 pragma in conjunction with a @code{Export} or @code{Convention}
2375 pragma that specifies the desired foreign convention.
2376 Pragma @code{Export_Function}
2377 (and @code{Export}, if present) must appear in the same declarative
2378 region as the function to which they apply.
2379
2380 @var{internal_name} must uniquely designate the function to which the
2381 pragma applies. If more than one function name exists of this name in
2382 the declarative part you must use the @code{Parameter_Types} and
2383 @code{Result_Type} parameters is mandatory to achieve the required
2384 unique designation. @var{subtype_mark}s in these parameters must
2385 exactly match the subtypes in the corresponding function specification,
2386 using positional notation to match parameters with subtype marks.
2387 The form with an @code{'Access} attribute can be used to match an
2388 anonymous access parameter.
2389
2390 @cindex OpenVMS
2391 @cindex Passing by descriptor
2392 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2393 The default behavior for Export_Function is to accept either 64bit or
2394 32bit descriptors unless short_descriptor is specified, then only 32bit
2395 descriptors are accepted.
2396
2397 @cindex Suppressing external name
2398 Special treatment is given if the EXTERNAL is an explicit null
2399 string or a static string expressions that evaluates to the null
2400 string. In this case, no external name is generated. This form
2401 still allows the specification of parameter mechanisms.
2402
2403 @node Pragma Export_Object
2404 @unnumberedsec Pragma Export_Object
2405 @findex Export_Object
2406 @noindent
2407 Syntax:
2408
2409 @smallexample @c ada
2410 pragma Export_Object
2411 [Internal =>] LOCAL_NAME
2412 [, [External =>] EXTERNAL_SYMBOL]
2413 [, [Size =>] EXTERNAL_SYMBOL]
2414
2415 EXTERNAL_SYMBOL ::=
2416 IDENTIFIER
2417 | static_string_EXPRESSION
2418 @end smallexample
2419
2420 @noindent
2421 This pragma designates an object as exported, and apart from the
2422 extended rules for external symbols, is identical in effect to the use of
2423 the normal @code{Export} pragma applied to an object. You may use a
2424 separate Export pragma (and you probably should from the point of view
2425 of portability), but it is not required. @var{Size} is syntax checked,
2426 but otherwise ignored by GNAT@.
2427
2428 @node Pragma Export_Procedure
2429 @unnumberedsec Pragma Export_Procedure
2430 @findex Export_Procedure
2431 @noindent
2432 Syntax:
2433
2434 @smallexample @c ada
2435 pragma Export_Procedure (
2436 [Internal =>] LOCAL_NAME
2437 [, [External =>] EXTERNAL_SYMBOL]
2438 [, [Parameter_Types =>] PARAMETER_TYPES]
2439 [, [Mechanism =>] MECHANISM]);
2440
2441 EXTERNAL_SYMBOL ::=
2442 IDENTIFIER
2443 | static_string_EXPRESSION
2444 | ""
2445
2446 PARAMETER_TYPES ::=
2447 null
2448 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2449
2450 TYPE_DESIGNATOR ::=
2451 subtype_NAME
2452 | subtype_Name ' Access
2453
2454 MECHANISM ::=
2455 MECHANISM_NAME
2456 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2457
2458 MECHANISM_ASSOCIATION ::=
2459 [formal_parameter_NAME =>] MECHANISM_NAME
2460
2461 MECHANISM_NAME ::=
2462 Value
2463 | Reference
2464 | Descriptor [([Class =>] CLASS_NAME)]
2465 | Short_Descriptor [([Class =>] CLASS_NAME)]
2466
2467 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2468 @end smallexample
2469
2470 @noindent
2471 This pragma is identical to @code{Export_Function} except that it
2472 applies to a procedure rather than a function and the parameters
2473 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2474 GNAT does not require a separate pragma @code{Export}, but if none is
2475 present, @code{Convention Ada} is assumed, which is usually
2476 not what is wanted, so it is usually appropriate to use this
2477 pragma in conjunction with a @code{Export} or @code{Convention}
2478 pragma that specifies the desired foreign convention.
2479
2480 @cindex OpenVMS
2481 @cindex Passing by descriptor
2482 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2483 The default behavior for Export_Procedure is to accept either 64bit or
2484 32bit descriptors unless short_descriptor is specified, then only 32bit
2485 descriptors are accepted.
2486
2487 @cindex Suppressing external name
2488 Special treatment is given if the EXTERNAL is an explicit null
2489 string or a static string expressions that evaluates to the null
2490 string. In this case, no external name is generated. This form
2491 still allows the specification of parameter mechanisms.
2492
2493 @node Pragma Export_Value
2494 @unnumberedsec Pragma Export_Value
2495 @findex Export_Value
2496 @noindent
2497 Syntax:
2498
2499 @smallexample @c ada
2500 pragma Export_Value (
2501 [Value =>] static_integer_EXPRESSION,
2502 [Link_Name =>] static_string_EXPRESSION);
2503 @end smallexample
2504
2505 @noindent
2506 This pragma serves to export a static integer value for external use.
2507 The first argument specifies the value to be exported. The Link_Name
2508 argument specifies the symbolic name to be associated with the integer
2509 value. This pragma is useful for defining a named static value in Ada
2510 that can be referenced in assembly language units to be linked with
2511 the application. This pragma is currently supported only for the
2512 AAMP target and is ignored for other targets.
2513
2514 @node Pragma Export_Valued_Procedure
2515 @unnumberedsec Pragma Export_Valued_Procedure
2516 @findex Export_Valued_Procedure
2517 @noindent
2518 Syntax:
2519
2520 @smallexample @c ada
2521 pragma Export_Valued_Procedure (
2522 [Internal =>] LOCAL_NAME
2523 [, [External =>] EXTERNAL_SYMBOL]
2524 [, [Parameter_Types =>] PARAMETER_TYPES]
2525 [, [Mechanism =>] MECHANISM]);
2526
2527 EXTERNAL_SYMBOL ::=
2528 IDENTIFIER
2529 | static_string_EXPRESSION
2530 | ""
2531
2532 PARAMETER_TYPES ::=
2533 null
2534 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2535
2536 TYPE_DESIGNATOR ::=
2537 subtype_NAME
2538 | subtype_Name ' Access
2539
2540 MECHANISM ::=
2541 MECHANISM_NAME
2542 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2543
2544 MECHANISM_ASSOCIATION ::=
2545 [formal_parameter_NAME =>] MECHANISM_NAME
2546
2547 MECHANISM_NAME ::=
2548 Value
2549 | Reference
2550 | Descriptor [([Class =>] CLASS_NAME)]
2551 | Short_Descriptor [([Class =>] CLASS_NAME)]
2552
2553 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2554 @end smallexample
2555
2556 @noindent
2557 This pragma is identical to @code{Export_Procedure} except that the
2558 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2559 mode @code{OUT}, and externally the subprogram is treated as a function
2560 with this parameter as the result of the function. GNAT provides for
2561 this capability to allow the use of @code{OUT} and @code{IN OUT}
2562 parameters in interfacing to external functions (which are not permitted
2563 in Ada functions).
2564 GNAT does not require a separate pragma @code{Export}, but if none is
2565 present, @code{Convention Ada} is assumed, which is almost certainly
2566 not what is wanted since the whole point of this pragma is to interface
2567 with foreign language functions, so it is usually appropriate to use this
2568 pragma in conjunction with a @code{Export} or @code{Convention}
2569 pragma that specifies the desired foreign convention.
2570
2571 @cindex OpenVMS
2572 @cindex Passing by descriptor
2573 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2574 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2575 32bit descriptors unless short_descriptor is specified, then only 32bit
2576 descriptors are accepted.
2577
2578 @cindex Suppressing external name
2579 Special treatment is given if the EXTERNAL is an explicit null
2580 string or a static string expressions that evaluates to the null
2581 string. In this case, no external name is generated. This form
2582 still allows the specification of parameter mechanisms.
2583
2584 @node Pragma Extend_System
2585 @unnumberedsec Pragma Extend_System
2586 @cindex @code{system}, extending
2587 @cindex Dec Ada 83
2588 @findex Extend_System
2589 @noindent
2590 Syntax:
2591
2592 @smallexample @c ada
2593 pragma Extend_System ([Name =>] IDENTIFIER);
2594 @end smallexample
2595
2596 @noindent
2597 This pragma is used to provide backwards compatibility with other
2598 implementations that extend the facilities of package @code{System}. In
2599 GNAT, @code{System} contains only the definitions that are present in
2600 the Ada RM@. However, other implementations, notably the DEC Ada 83
2601 implementation, provide many extensions to package @code{System}.
2602
2603 For each such implementation accommodated by this pragma, GNAT provides a
2604 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2605 implementation, which provides the required additional definitions. You
2606 can use this package in two ways. You can @code{with} it in the normal
2607 way and access entities either by selection or using a @code{use}
2608 clause. In this case no special processing is required.
2609
2610 However, if existing code contains references such as
2611 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2612 definitions provided in package @code{System}, you may use this pragma
2613 to extend visibility in @code{System} in a non-standard way that
2614 provides greater compatibility with the existing code. Pragma
2615 @code{Extend_System} is a configuration pragma whose single argument is
2616 the name of the package containing the extended definition
2617 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2618 control of this pragma will be processed using special visibility
2619 processing that looks in package @code{System.Aux_@var{xxx}} where
2620 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2621 package @code{System}, but not found in package @code{System}.
2622
2623 You can use this pragma either to access a predefined @code{System}
2624 extension supplied with the compiler, for example @code{Aux_DEC} or
2625 you can construct your own extension unit following the above
2626 definition. Note that such a package is a child of @code{System}
2627 and thus is considered part of the implementation. To compile
2628 it you will have to use the appropriate switch for compiling
2629 system units.
2630 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2631 for details.
2632
2633 @node Pragma Extensions_Allowed
2634 @unnumberedsec Pragma Extensions_Allowed
2635 @cindex Ada Extensions
2636 @cindex GNAT Extensions
2637 @findex Extensions_Allowed
2638 @noindent
2639 Syntax:
2640
2641 @smallexample @c ada
2642 pragma Extensions_Allowed (On | Off);
2643 @end smallexample
2644
2645 @noindent
2646 This configuration pragma enables or disables the implementation
2647 extension mode (the use of Off as a parameter cancels the effect
2648 of the @option{-gnatX} command switch).
2649
2650 In extension mode, the latest version of the Ada language is
2651 implemented (currently Ada 2012), and in addition a small number
2652 of GNAT specific extensions are recognized as follows:
2653
2654 @table @asis
2655 @item Constrained attribute for generic objects
2656 The @code{Constrained} attribute is permitted for objects of
2657 generic types. The result indicates if the corresponding actual
2658 is constrained.
2659
2660 @end table
2661
2662 @node Pragma External
2663 @unnumberedsec Pragma External
2664 @findex External
2665 @noindent
2666 Syntax:
2667
2668 @smallexample @c ada
2669 pragma External (
2670 [ Convention =>] convention_IDENTIFIER,
2671 [ Entity =>] LOCAL_NAME
2672 [, [External_Name =>] static_string_EXPRESSION ]
2673 [, [Link_Name =>] static_string_EXPRESSION ]);
2674 @end smallexample
2675
2676 @noindent
2677 This pragma is identical in syntax and semantics to pragma
2678 @code{Export} as defined in the Ada Reference Manual. It is
2679 provided for compatibility with some Ada 83 compilers that
2680 used this pragma for exactly the same purposes as pragma
2681 @code{Export} before the latter was standardized.
2682
2683 @node Pragma External_Name_Casing
2684 @unnumberedsec Pragma External_Name_Casing
2685 @cindex Dec Ada 83 casing compatibility
2686 @cindex External Names, casing
2687 @cindex Casing of External names
2688 @findex External_Name_Casing
2689 @noindent
2690 Syntax:
2691
2692 @smallexample @c ada
2693 pragma External_Name_Casing (
2694 Uppercase | Lowercase
2695 [, Uppercase | Lowercase | As_Is]);
2696 @end smallexample
2697
2698 @noindent
2699 This pragma provides control over the casing of external names associated
2700 with Import and Export pragmas. There are two cases to consider:
2701
2702 @table @asis
2703 @item Implicit external names
2704 Implicit external names are derived from identifiers. The most common case
2705 arises when a standard Ada Import or Export pragma is used with only two
2706 arguments, as in:
2707
2708 @smallexample @c ada
2709 pragma Import (C, C_Routine);
2710 @end smallexample
2711
2712 @noindent
2713 Since Ada is a case-insensitive language, the spelling of the identifier in
2714 the Ada source program does not provide any information on the desired
2715 casing of the external name, and so a convention is needed. In GNAT the
2716 default treatment is that such names are converted to all lower case
2717 letters. This corresponds to the normal C style in many environments.
2718 The first argument of pragma @code{External_Name_Casing} can be used to
2719 control this treatment. If @code{Uppercase} is specified, then the name
2720 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2721 then the normal default of all lower case letters will be used.
2722
2723 This same implicit treatment is also used in the case of extended DEC Ada 83
2724 compatible Import and Export pragmas where an external name is explicitly
2725 specified using an identifier rather than a string.
2726
2727 @item Explicit external names
2728 Explicit external names are given as string literals. The most common case
2729 arises when a standard Ada Import or Export pragma is used with three
2730 arguments, as in:
2731
2732 @smallexample @c ada
2733 pragma Import (C, C_Routine, "C_routine");
2734 @end smallexample
2735
2736 @noindent
2737 In this case, the string literal normally provides the exact casing required
2738 for the external name. The second argument of pragma
2739 @code{External_Name_Casing} may be used to modify this behavior.
2740 If @code{Uppercase} is specified, then the name
2741 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2742 then the name will be forced to all lowercase letters. A specification of
2743 @code{As_Is} provides the normal default behavior in which the casing is
2744 taken from the string provided.
2745 @end table
2746
2747 @noindent
2748 This pragma may appear anywhere that a pragma is valid. In particular, it
2749 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2750 case it applies to all subsequent compilations, or it can be used as a program
2751 unit pragma, in which case it only applies to the current unit, or it can
2752 be used more locally to control individual Import/Export pragmas.
2753
2754 It is primarily intended for use with OpenVMS systems, where many
2755 compilers convert all symbols to upper case by default. For interfacing to
2756 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2757 the pragma:
2758
2759 @smallexample @c ada
2760 pragma External_Name_Casing (Uppercase, Uppercase);
2761 @end smallexample
2762
2763 @noindent
2764 to enforce the upper casing of all external symbols.
2765
2766 @node Pragma Fast_Math
2767 @unnumberedsec Pragma Fast_Math
2768 @findex Fast_Math
2769 @noindent
2770 Syntax:
2771
2772 @smallexample @c ada
2773 pragma Fast_Math;
2774 @end smallexample
2775
2776 @noindent
2777 This is a configuration pragma which activates a mode in which speed is
2778 considered more important for floating-point operations than absolutely
2779 accurate adherence to the requirements of the standard. Currently the
2780 following operations are affected:
2781
2782 @table @asis
2783 @item Complex Multiplication
2784 The normal simple formula for complex multiplication can result in intermediate
2785 overflows for numbers near the end of the range. The Ada standard requires that
2786 this situation be detected and corrected by scaling, but in Fast_Math mode such
2787 cases will simply result in overflow. Note that to take advantage of this you
2788 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2789 under control of the pragma, rather than use the preinstantiated versions.
2790 @end table
2791
2792 @node Pragma Favor_Top_Level
2793 @unnumberedsec Pragma Favor_Top_Level
2794 @findex Favor_Top_Level
2795 @noindent
2796 Syntax:
2797
2798 @smallexample @c ada
2799 pragma Favor_Top_Level (type_NAME);
2800 @end smallexample
2801
2802 @noindent
2803 The named type must be an access-to-subprogram type. This pragma is an
2804 efficiency hint to the compiler, regarding the use of 'Access or
2805 'Unrestricted_Access on nested (non-library-level) subprograms. The
2806 pragma means that nested subprograms are not used with this type, or
2807 are rare, so that the generated code should be efficient in the
2808 top-level case. When this pragma is used, dynamically generated
2809 trampolines may be used on some targets for nested subprograms.
2810 See also the No_Implicit_Dynamic_Code restriction.
2811
2812 @node Pragma Finalize_Storage_Only
2813 @unnumberedsec Pragma Finalize_Storage_Only
2814 @findex Finalize_Storage_Only
2815 @noindent
2816 Syntax:
2817
2818 @smallexample @c ada
2819 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2820 @end smallexample
2821
2822 @noindent
2823 This pragma allows the compiler not to emit a Finalize call for objects
2824 defined at the library level. This is mostly useful for types where
2825 finalization is only used to deal with storage reclamation since in most
2826 environments it is not necessary to reclaim memory just before terminating
2827 execution, hence the name.
2828
2829 @node Pragma Float_Representation
2830 @unnumberedsec Pragma Float_Representation
2831 @cindex OpenVMS
2832 @findex Float_Representation
2833 @noindent
2834 Syntax:
2835
2836 @smallexample @c ada
2837 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2838
2839 FLOAT_REP ::= VAX_Float | IEEE_Float
2840 @end smallexample
2841
2842 @noindent
2843 In the one argument form, this pragma is a configuration pragma which
2844 allows control over the internal representation chosen for the predefined
2845 floating point types declared in the packages @code{Standard} and
2846 @code{System}. On all systems other than OpenVMS, the argument must
2847 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2848 argument may be @code{VAX_Float} to specify the use of the VAX float
2849 format for the floating-point types in Standard. This requires that
2850 the standard runtime libraries be recompiled.
2851
2852 The two argument form specifies the representation to be used for
2853 the specified floating-point type. On all systems other than OpenVMS,
2854 the argument must
2855 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2856 argument may be @code{VAX_Float} to specify the use of the VAX float
2857 format, as follows:
2858
2859 @itemize @bullet
2860 @item
2861 For digits values up to 6, F float format will be used.
2862 @item
2863 For digits values from 7 to 9, D float format will be used.
2864 @item
2865 For digits values from 10 to 15, G float format will be used.
2866 @item
2867 Digits values above 15 are not allowed.
2868 @end itemize
2869
2870 @node Pragma Ident
2871 @unnumberedsec Pragma Ident
2872 @findex Ident
2873 @noindent
2874 Syntax:
2875
2876 @smallexample @c ada
2877 pragma Ident (static_string_EXPRESSION);
2878 @end smallexample
2879
2880 @noindent
2881 This pragma provides a string identification in the generated object file,
2882 if the system supports the concept of this kind of identification string.
2883 This pragma is allowed only in the outermost declarative part or
2884 declarative items of a compilation unit. If more than one @code{Ident}
2885 pragma is given, only the last one processed is effective.
2886 @cindex OpenVMS
2887 On OpenVMS systems, the effect of the pragma is identical to the effect of
2888 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2889 maximum allowed length is 31 characters, so if it is important to
2890 maintain compatibility with this compiler, you should obey this length
2891 limit.
2892
2893 @node Pragma Implementation_Defined
2894 @unnumberedsec Pragma Implementation_Defined
2895 @findex Implementation_Defined
2896 @noindent
2897 Syntax:
2898
2899 @smallexample @c ada
2900 pragma Implementation_Defined (local_NAME);
2901 @end smallexample
2902
2903 @noindent
2904 This pragma marks a previously declared entioty as implementation-defined.
2905 For an overloaded entity, applies to the most recent homonym.
2906
2907 @smallexample @c ada
2908 pragma Implementation_Defined;
2909 @end smallexample
2910
2911 @noindent
2912 The form with no arguments appears anywhere within a scope, most
2913 typically a package spec, and indicates that all entities that are
2914 defined within the package spec are Implementation_Defined.
2915
2916 This pragma is used within the GNAT runtime library to identify
2917 implementation-defined entities introduced in language-defined units,
2918 for the purpose of implementing the No_Implementation_Identifiers
2919 restriction.
2920
2921 @node Pragma Implemented
2922 @unnumberedsec Pragma Implemented
2923 @findex Implemented
2924 @noindent
2925 Syntax:
2926
2927 @smallexample @c ada
2928 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2929
2930 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2931 @end smallexample
2932
2933 @noindent
2934 This is an Ada 2012 representation pragma which applies to protected, task
2935 and synchronized interface primitives. The use of pragma Implemented provides
2936 a way to impose a static requirement on the overriding operation by adhering
2937 to one of the three implementation kinds: entry, protected procedure or any of
2938 the above. This pragma is available in all earlier versions of Ada as an
2939 implementation-defined pragma.
2940
2941 @smallexample @c ada
2942 type Synch_Iface is synchronized interface;
2943 procedure Prim_Op (Obj : in out Iface) is abstract;
2944 pragma Implemented (Prim_Op, By_Protected_Procedure);
2945
2946 protected type Prot_1 is new Synch_Iface with
2947 procedure Prim_Op; -- Legal
2948 end Prot_1;
2949
2950 protected type Prot_2 is new Synch_Iface with
2951 entry Prim_Op; -- Illegal
2952 end Prot_2;
2953
2954 task type Task_Typ is new Synch_Iface with
2955 entry Prim_Op; -- Illegal
2956 end Task_Typ;
2957 @end smallexample
2958
2959 @noindent
2960 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2961 Implemented determines the runtime behavior of the requeue. Implementation kind
2962 By_Entry guarantees that the action of requeueing will proceed from an entry to
2963 another entry. Implementation kind By_Protected_Procedure transforms the
2964 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2965 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2966 the target's overriding subprogram kind.
2967
2968 @node Pragma Implicit_Packing
2969 @unnumberedsec Pragma Implicit_Packing
2970 @findex Implicit_Packing
2971 @cindex Rational Profile
2972 @noindent
2973 Syntax:
2974
2975 @smallexample @c ada
2976 pragma Implicit_Packing;
2977 @end smallexample
2978
2979 @noindent
2980 This is a configuration pragma that requests implicit packing for packed
2981 arrays for which a size clause is given but no explicit pragma Pack or
2982 specification of Component_Size is present. It also applies to records
2983 where no record representation clause is present. Consider this example:
2984
2985 @smallexample @c ada
2986 type R is array (0 .. 7) of Boolean;
2987 for R'Size use 8;
2988 @end smallexample
2989
2990 @noindent
2991 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2992 does not change the layout of a composite object. So the Size clause in the
2993 above example is normally rejected, since the default layout of the array uses
2994 8-bit components, and thus the array requires a minimum of 64 bits.
2995
2996 If this declaration is compiled in a region of code covered by an occurrence
2997 of the configuration pragma Implicit_Packing, then the Size clause in this
2998 and similar examples will cause implicit packing and thus be accepted. For
2999 this implicit packing to occur, the type in question must be an array of small
3000 components whose size is known at compile time, and the Size clause must
3001 specify the exact size that corresponds to the length of the array multiplied
3002 by the size in bits of the component type.
3003 @cindex Array packing
3004
3005 Similarly, the following example shows the use in the record case
3006
3007 @smallexample @c ada
3008 type r is record
3009 a, b, c, d, e, f, g, h : boolean;
3010 chr : character;
3011 end record;
3012 for r'size use 16;
3013 @end smallexample
3014
3015 @noindent
3016 Without a pragma Pack, each Boolean field requires 8 bits, so the
3017 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3018 sufficient. The use of pragma Implicit_Packing allows this record
3019 declaration to compile without an explicit pragma Pack.
3020 @node Pragma Import_Exception
3021 @unnumberedsec Pragma Import_Exception
3022 @cindex OpenVMS
3023 @findex Import_Exception
3024 @noindent
3025 Syntax:
3026
3027 @smallexample @c ada
3028 pragma Import_Exception (
3029 [Internal =>] LOCAL_NAME
3030 [, [External =>] EXTERNAL_SYMBOL]
3031 [, [Form =>] Ada | VMS]
3032 [, [Code =>] static_integer_EXPRESSION]);
3033
3034 EXTERNAL_SYMBOL ::=
3035 IDENTIFIER
3036 | static_string_EXPRESSION
3037 @end smallexample
3038
3039 @noindent
3040 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3041 It allows OpenVMS conditions (for example, from OpenVMS system services or
3042 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3043 The pragma specifies that the exception associated with an exception
3044 declaration in an Ada program be defined externally (in non-Ada code).
3045 For further details on this pragma, see the
3046 DEC Ada Language Reference Manual, section 13.9a.3.1.
3047
3048 @node Pragma Import_Function
3049 @unnumberedsec Pragma Import_Function
3050 @findex Import_Function
3051 @noindent
3052 Syntax:
3053
3054 @smallexample @c ada
3055 pragma Import_Function (
3056 [Internal =>] LOCAL_NAME,
3057 [, [External =>] EXTERNAL_SYMBOL]
3058 [, [Parameter_Types =>] PARAMETER_TYPES]
3059 [, [Result_Type =>] SUBTYPE_MARK]
3060 [, [Mechanism =>] MECHANISM]
3061 [, [Result_Mechanism =>] MECHANISM_NAME]
3062 [, [First_Optional_Parameter =>] IDENTIFIER]);
3063
3064 EXTERNAL_SYMBOL ::=
3065 IDENTIFIER
3066 | static_string_EXPRESSION
3067
3068 PARAMETER_TYPES ::=
3069 null
3070 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3071
3072 TYPE_DESIGNATOR ::=
3073 subtype_NAME
3074 | subtype_Name ' Access
3075
3076 MECHANISM ::=
3077 MECHANISM_NAME
3078 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3079
3080 MECHANISM_ASSOCIATION ::=
3081 [formal_parameter_NAME =>] MECHANISM_NAME
3082
3083 MECHANISM_NAME ::=
3084 Value
3085 | Reference
3086 | Descriptor [([Class =>] CLASS_NAME)]
3087 | Short_Descriptor [([Class =>] CLASS_NAME)]
3088
3089 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3090 @end smallexample
3091
3092 @noindent
3093 This pragma is used in conjunction with a pragma @code{Import} to
3094 specify additional information for an imported function. The pragma
3095 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3096 @code{Import_Function} pragma and both must appear in the same
3097 declarative part as the function specification.
3098
3099 The @var{Internal} argument must uniquely designate
3100 the function to which the
3101 pragma applies. If more than one function name exists of this name in
3102 the declarative part you must use the @code{Parameter_Types} and
3103 @var{Result_Type} parameters to achieve the required unique
3104 designation. Subtype marks in these parameters must exactly match the
3105 subtypes in the corresponding function specification, using positional
3106 notation to match parameters with subtype marks.
3107 The form with an @code{'Access} attribute can be used to match an
3108 anonymous access parameter.
3109
3110 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3111 parameters to specify passing mechanisms for the
3112 parameters and result. If you specify a single mechanism name, it
3113 applies to all parameters. Otherwise you may specify a mechanism on a
3114 parameter by parameter basis using either positional or named
3115 notation. If the mechanism is not specified, the default mechanism
3116 is used.
3117
3118 @cindex OpenVMS
3119 @cindex Passing by descriptor
3120 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3121 The default behavior for Import_Function is to pass a 64bit descriptor
3122 unless short_descriptor is specified, then a 32bit descriptor is passed.
3123
3124 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3125 It specifies that the designated parameter and all following parameters
3126 are optional, meaning that they are not passed at the generated code
3127 level (this is distinct from the notion of optional parameters in Ada
3128 where the parameters are passed anyway with the designated optional
3129 parameters). All optional parameters must be of mode @code{IN} and have
3130 default parameter values that are either known at compile time
3131 expressions, or uses of the @code{'Null_Parameter} attribute.
3132
3133 @node Pragma Import_Object
3134 @unnumberedsec Pragma Import_Object
3135 @findex Import_Object
3136 @noindent
3137 Syntax:
3138
3139 @smallexample @c ada
3140 pragma Import_Object
3141 [Internal =>] LOCAL_NAME
3142 [, [External =>] EXTERNAL_SYMBOL]
3143 [, [Size =>] EXTERNAL_SYMBOL]);
3144
3145 EXTERNAL_SYMBOL ::=
3146 IDENTIFIER
3147 | static_string_EXPRESSION
3148 @end smallexample
3149
3150 @noindent
3151 This pragma designates an object as imported, and apart from the
3152 extended rules for external symbols, is identical in effect to the use of
3153 the normal @code{Import} pragma applied to an object. Unlike the
3154 subprogram case, you need not use a separate @code{Import} pragma,
3155 although you may do so (and probably should do so from a portability
3156 point of view). @var{size} is syntax checked, but otherwise ignored by
3157 GNAT@.
3158
3159 @node Pragma Import_Procedure
3160 @unnumberedsec Pragma Import_Procedure
3161 @findex Import_Procedure
3162 @noindent
3163 Syntax:
3164
3165 @smallexample @c ada
3166 pragma Import_Procedure (
3167 [Internal =>] LOCAL_NAME
3168 [, [External =>] EXTERNAL_SYMBOL]
3169 [, [Parameter_Types =>] PARAMETER_TYPES]
3170 [, [Mechanism =>] MECHANISM]
3171 [, [First_Optional_Parameter =>] IDENTIFIER]);
3172
3173 EXTERNAL_SYMBOL ::=
3174 IDENTIFIER
3175 | static_string_EXPRESSION
3176
3177 PARAMETER_TYPES ::=
3178 null
3179 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3180
3181 TYPE_DESIGNATOR ::=
3182 subtype_NAME
3183 | subtype_Name ' Access
3184
3185 MECHANISM ::=
3186 MECHANISM_NAME
3187 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3188
3189 MECHANISM_ASSOCIATION ::=
3190 [formal_parameter_NAME =>] MECHANISM_NAME
3191
3192 MECHANISM_NAME ::=
3193 Value
3194 | Reference
3195 | Descriptor [([Class =>] CLASS_NAME)]
3196 | Short_Descriptor [([Class =>] CLASS_NAME)]
3197
3198 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3199 @end smallexample
3200
3201 @noindent
3202 This pragma is identical to @code{Import_Function} except that it
3203 applies to a procedure rather than a function and the parameters
3204 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3205
3206 @node Pragma Import_Valued_Procedure
3207 @unnumberedsec Pragma Import_Valued_Procedure
3208 @findex Import_Valued_Procedure
3209 @noindent
3210 Syntax:
3211
3212 @smallexample @c ada
3213 pragma Import_Valued_Procedure (
3214 [Internal =>] LOCAL_NAME
3215 [, [External =>] EXTERNAL_SYMBOL]
3216 [, [Parameter_Types =>] PARAMETER_TYPES]
3217 [, [Mechanism =>] MECHANISM]
3218 [, [First_Optional_Parameter =>] IDENTIFIER]);
3219
3220 EXTERNAL_SYMBOL ::=
3221 IDENTIFIER
3222 | static_string_EXPRESSION
3223
3224 PARAMETER_TYPES ::=
3225 null
3226 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3227
3228 TYPE_DESIGNATOR ::=
3229 subtype_NAME
3230 | subtype_Name ' Access
3231
3232 MECHANISM ::=
3233 MECHANISM_NAME
3234 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3235
3236 MECHANISM_ASSOCIATION ::=
3237 [formal_parameter_NAME =>] MECHANISM_NAME
3238
3239 MECHANISM_NAME ::=
3240 Value
3241 | Reference
3242 | Descriptor [([Class =>] CLASS_NAME)]
3243 | Short_Descriptor [([Class =>] CLASS_NAME)]
3244
3245 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3246 @end smallexample
3247
3248 @noindent
3249 This pragma is identical to @code{Import_Procedure} except that the
3250 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3251 mode @code{OUT}, and externally the subprogram is treated as a function
3252 with this parameter as the result of the function. The purpose of this
3253 capability is to allow the use of @code{OUT} and @code{IN OUT}
3254 parameters in interfacing to external functions (which are not permitted
3255 in Ada functions). You may optionally use the @code{Mechanism}
3256 parameters to specify passing mechanisms for the parameters.
3257 If you specify a single mechanism name, it applies to all parameters.
3258 Otherwise you may specify a mechanism on a parameter by parameter
3259 basis using either positional or named notation. If the mechanism is not
3260 specified, the default mechanism is used.
3261
3262 Note that it is important to use this pragma in conjunction with a separate
3263 pragma Import that specifies the desired convention, since otherwise the
3264 default convention is Ada, which is almost certainly not what is required.
3265
3266 @node Pragma Independent
3267 @unnumberedsec Pragma Independent
3268 @findex Independent
3269 @noindent
3270 Syntax:
3271
3272 @smallexample @c ada
3273 pragma Independent (Local_NAME);
3274 @end smallexample
3275
3276 @noindent
3277 This pragma is standard in Ada 2012 mode (which also provides an aspect
3278 of the same name). It is also available as an implementation-defined
3279 pragma in all earlier versions. It specifies that the
3280 designated object or all objects of the designated type must be
3281 independently addressable. This means that separate tasks can safely
3282 manipulate such objects. For example, if two components of a record are
3283 independent, then two separate tasks may access these two components.
3284 This may place
3285 constraints on the representation of the object (for instance prohibiting
3286 tight packing).
3287
3288 @node Pragma Independent_Components
3289 @unnumberedsec Pragma Independent_Components
3290 @findex Independent_Components
3291 @noindent
3292 Syntax:
3293
3294 @smallexample @c ada
3295 pragma Independent_Components (Local_NAME);
3296 @end smallexample
3297
3298 @noindent
3299 This pragma is standard in Ada 2012 mode (which also provides an aspect
3300 of the same name). It is also available as an implementation-defined
3301 pragma in all earlier versions. It specifies that the components of the
3302 designated object, or the components of each object of the designated
3303 type, must be
3304 independently addressable. This means that separate tasks can safely
3305 manipulate separate components in the composite object. This may place
3306 constraints on the representation of the object (for instance prohibiting
3307 tight packing).
3308
3309 @node Pragma Initialize_Scalars
3310 @unnumberedsec Pragma Initialize_Scalars
3311 @findex Initialize_Scalars
3312 @cindex debugging with Initialize_Scalars
3313 @noindent
3314 Syntax:
3315
3316 @smallexample @c ada
3317 pragma Initialize_Scalars;
3318 @end smallexample
3319
3320 @noindent
3321 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3322 two important differences. First, there is no requirement for the pragma
3323 to be used uniformly in all units of a partition, in particular, it is fine
3324 to use this just for some or all of the application units of a partition,
3325 without needing to recompile the run-time library.
3326
3327 In the case where some units are compiled with the pragma, and some without,
3328 then a declaration of a variable where the type is defined in package
3329 Standard or is locally declared will always be subject to initialization,
3330 as will any declaration of a scalar variable. For composite variables,
3331 whether the variable is initialized may also depend on whether the package
3332 in which the type of the variable is declared is compiled with the pragma.
3333
3334 The other important difference is that you can control the value used
3335 for initializing scalar objects. At bind time, you can select several
3336 options for initialization. You can
3337 initialize with invalid values (similar to Normalize_Scalars, though for
3338 Initialize_Scalars it is not always possible to determine the invalid
3339 values in complex cases like signed component fields with non-standard
3340 sizes). You can also initialize with high or
3341 low values, or with a specified bit pattern. See the @value{EDITION}
3342 User's Guide for binder options for specifying these cases.
3343
3344 This means that you can compile a program, and then without having to
3345 recompile the program, you can run it with different values being used
3346 for initializing otherwise uninitialized values, to test if your program
3347 behavior depends on the choice. Of course the behavior should not change,
3348 and if it does, then most likely you have an erroneous reference to an
3349 uninitialized value.
3350
3351 It is even possible to change the value at execution time eliminating even
3352 the need to rebind with a different switch using an environment variable.
3353 See the @value{EDITION} User's Guide for details.
3354
3355 Note that pragma @code{Initialize_Scalars} is particularly useful in
3356 conjunction with the enhanced validity checking that is now provided
3357 in GNAT, which checks for invalid values under more conditions.
3358 Using this feature (see description of the @option{-gnatV} flag in the
3359 @value{EDITION} User's Guide) in conjunction with
3360 pragma @code{Initialize_Scalars}
3361 provides a powerful new tool to assist in the detection of problems
3362 caused by uninitialized variables.
3363
3364 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3365 effect on the generated code. This may cause your code to be
3366 substantially larger. It may also cause an increase in the amount
3367 of stack required, so it is probably a good idea to turn on stack
3368 checking (see description of stack checking in the @value{EDITION}
3369 User's Guide) when using this pragma.
3370
3371 @node Pragma Inline_Always
3372 @unnumberedsec Pragma Inline_Always
3373 @findex Inline_Always
3374 @noindent
3375 Syntax:
3376
3377 @smallexample @c ada
3378 pragma Inline_Always (NAME [, NAME]);
3379 @end smallexample
3380
3381 @noindent
3382 Similar to pragma @code{Inline} except that inlining is not subject to
3383 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3384 happens regardless of whether these options are used.
3385
3386 @node Pragma Inline_Generic
3387 @unnumberedsec Pragma Inline_Generic
3388 @findex Inline_Generic
3389 @noindent
3390 Syntax:
3391
3392 @smallexample @c ada
3393 pragma Inline_Generic (generic_package_NAME);
3394 @end smallexample
3395
3396 @noindent
3397 This is implemented for compatibility with DEC Ada 83 and is recognized,
3398 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3399 by default when using GNAT@.
3400
3401 @node Pragma Interface
3402 @unnumberedsec Pragma Interface
3403 @findex Interface
3404 @noindent
3405 Syntax:
3406
3407 @smallexample @c ada
3408 pragma Interface (
3409 [Convention =>] convention_identifier,
3410 [Entity =>] local_NAME
3411 [, [External_Name =>] static_string_expression]
3412 [, [Link_Name =>] static_string_expression]);
3413 @end smallexample
3414
3415 @noindent
3416 This pragma is identical in syntax and semantics to
3417 the standard Ada pragma @code{Import}. It is provided for compatibility
3418 with Ada 83. The definition is upwards compatible both with pragma
3419 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3420 with some extended implementations of this pragma in certain Ada 83
3421 implementations. The only difference between pragma @code{Interface}
3422 and pragma @code{Import} is that there is special circuitry to allow
3423 both pragmas to appear for the same subprogram entity (normally it
3424 is illegal to have multiple @code{Import} pragmas. This is useful in
3425 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3426 Ada 83 compilers.
3427
3428 @node Pragma Interface_Name
3429 @unnumberedsec Pragma Interface_Name
3430 @findex Interface_Name
3431 @noindent
3432 Syntax:
3433
3434 @smallexample @c ada
3435 pragma Interface_Name (
3436 [Entity =>] LOCAL_NAME
3437 [, [External_Name =>] static_string_EXPRESSION]
3438 [, [Link_Name =>] static_string_EXPRESSION]);
3439 @end smallexample
3440
3441 @noindent
3442 This pragma provides an alternative way of specifying the interface name
3443 for an interfaced subprogram, and is provided for compatibility with Ada
3444 83 compilers that use the pragma for this purpose. You must provide at
3445 least one of @var{External_Name} or @var{Link_Name}.
3446
3447 @node Pragma Interrupt_Handler
3448 @unnumberedsec Pragma Interrupt_Handler
3449 @findex Interrupt_Handler
3450 @noindent
3451 Syntax:
3452
3453 @smallexample @c ada
3454 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3455 @end smallexample
3456
3457 @noindent
3458 This program unit pragma is supported for parameterless protected procedures
3459 as described in Annex C of the Ada Reference Manual. On the AAMP target
3460 the pragma can also be specified for nonprotected parameterless procedures
3461 that are declared at the library level (which includes procedures
3462 declared at the top level of a library package). In the case of AAMP,
3463 when this pragma is applied to a nonprotected procedure, the instruction
3464 @code{IERET} is generated for returns from the procedure, enabling
3465 maskable interrupts, in place of the normal return instruction.
3466
3467 @node Pragma Interrupt_State
3468 @unnumberedsec Pragma Interrupt_State
3469 @findex Interrupt_State
3470 @noindent
3471 Syntax:
3472
3473 @smallexample @c ada
3474 pragma Interrupt_State
3475 ([Name =>] value,
3476 [State =>] SYSTEM | RUNTIME | USER);
3477 @end smallexample
3478
3479 @noindent
3480 Normally certain interrupts are reserved to the implementation. Any attempt
3481 to attach an interrupt causes Program_Error to be raised, as described in
3482 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3483 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3484 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3485 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3486 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3487 Ada exceptions, or used to implement run-time functions such as the
3488 @code{abort} statement and stack overflow checking.
3489
3490 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3491 such uses of interrupts. It subsumes the functionality of pragma
3492 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3493 available on Windows or VMS. On all other platforms than VxWorks,
3494 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3495 and may be used to mark interrupts required by the board support package
3496 as reserved.
3497
3498 Interrupts can be in one of three states:
3499 @itemize @bullet
3500 @item System
3501
3502 The interrupt is reserved (no Ada handler can be installed), and the
3503 Ada run-time may not install a handler. As a result you are guaranteed
3504 standard system default action if this interrupt is raised.
3505
3506 @item Runtime
3507
3508 The interrupt is reserved (no Ada handler can be installed). The run time
3509 is allowed to install a handler for internal control purposes, but is
3510 not required to do so.
3511
3512 @item User
3513
3514 The interrupt is unreserved. The user may install a handler to provide
3515 some other action.
3516 @end itemize
3517
3518 @noindent
3519 These states are the allowed values of the @code{State} parameter of the
3520 pragma. The @code{Name} parameter is a value of the type
3521 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3522 @code{Ada.Interrupts.Names}.
3523
3524 This is a configuration pragma, and the binder will check that there
3525 are no inconsistencies between different units in a partition in how a
3526 given interrupt is specified. It may appear anywhere a pragma is legal.
3527
3528 The effect is to move the interrupt to the specified state.
3529
3530 By declaring interrupts to be SYSTEM, you guarantee the standard system
3531 action, such as a core dump.
3532
3533 By declaring interrupts to be USER, you guarantee that you can install
3534 a handler.
3535
3536 Note that certain signals on many operating systems cannot be caught and
3537 handled by applications. In such cases, the pragma is ignored. See the
3538 operating system documentation, or the value of the array @code{Reserved}
3539 declared in the spec of package @code{System.OS_Interface}.
3540
3541 Overriding the default state of signals used by the Ada runtime may interfere
3542 with an application's runtime behavior in the cases of the synchronous signals,
3543 and in the case of the signal used to implement the @code{abort} statement.
3544
3545 @node Pragma Invariant
3546 @unnumberedsec Pragma Invariant
3547 @findex Invariant
3548 @noindent
3549 Syntax:
3550
3551 @smallexample @c ada
3552 pragma Invariant
3553 ([Entity =>] private_type_LOCAL_NAME,
3554 [Check =>] EXPRESSION
3555 [,[Message =>] String_Expression]);
3556 @end smallexample
3557
3558 @noindent
3559 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3560 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3561 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3562 requires the use of the aspect syntax, which is not available except in 2012
3563 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3564 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3565 note that the aspect Invariant is a synonym in GNAT for the aspect
3566 Type_Invariant, but there is no pragma Type_Invariant.
3567
3568 The pragma must appear within the visible part of the package specification,
3569 after the type to which its Entity argument appears. As with the Invariant
3570 aspect, the Check expression is not analyzed until the end of the visible
3571 part of the package, so it may contain forward references. The Message
3572 argument, if present, provides the exception message used if the invariant
3573 is violated. If no Message parameter is provided, a default message that
3574 identifies the line on which the pragma appears is used.
3575
3576 It is permissible to have multiple Invariants for the same type entity, in
3577 which case they are and'ed together. It is permissible to use this pragma
3578 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3579 invariant pragma for the same entity.
3580
3581 For further details on the use of this pragma, see the Ada 2012 documentation
3582 of the Type_Invariant aspect.
3583
3584 @node Pragma Keep_Names
3585 @unnumberedsec Pragma Keep_Names
3586 @findex Keep_Names
3587 @noindent
3588 Syntax:
3589
3590 @smallexample @c ada
3591 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3592 @end smallexample
3593
3594 @noindent
3595 The @var{LOCAL_NAME} argument
3596 must refer to an enumeration first subtype
3597 in the current declarative part. The effect is to retain the enumeration
3598 literal names for use by @code{Image} and @code{Value} even if a global
3599 @code{Discard_Names} pragma applies. This is useful when you want to
3600 generally suppress enumeration literal names and for example you therefore
3601 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3602 want to retain the names for specific enumeration types.
3603
3604 @node Pragma License
3605 @unnumberedsec Pragma License
3606 @findex License
3607 @cindex License checking
3608 @noindent
3609 Syntax:
3610
3611 @smallexample @c ada
3612 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3613 @end smallexample
3614
3615 @noindent
3616 This pragma is provided to allow automated checking for appropriate license
3617 conditions with respect to the standard and modified GPL@. A pragma
3618 @code{License}, which is a configuration pragma that typically appears at
3619 the start of a source file or in a separate @file{gnat.adc} file, specifies
3620 the licensing conditions of a unit as follows:
3621
3622 @itemize @bullet
3623 @item Unrestricted
3624 This is used for a unit that can be freely used with no license restrictions.
3625 Examples of such units are public domain units, and units from the Ada
3626 Reference Manual.
3627
3628 @item GPL
3629 This is used for a unit that is licensed under the unmodified GPL, and which
3630 therefore cannot be @code{with}'ed by a restricted unit.
3631
3632 @item Modified_GPL
3633 This is used for a unit licensed under the GNAT modified GPL that includes
3634 a special exception paragraph that specifically permits the inclusion of
3635 the unit in programs without requiring the entire program to be released
3636 under the GPL@.
3637
3638 @item Restricted
3639 This is used for a unit that is restricted in that it is not permitted to
3640 depend on units that are licensed under the GPL@. Typical examples are
3641 proprietary code that is to be released under more restrictive license
3642 conditions. Note that restricted units are permitted to @code{with} units
3643 which are licensed under the modified GPL (this is the whole point of the
3644 modified GPL).
3645
3646 @end itemize
3647
3648 @noindent
3649 Normally a unit with no @code{License} pragma is considered to have an
3650 unknown license, and no checking is done. However, standard GNAT headers
3651 are recognized, and license information is derived from them as follows.
3652
3653 @itemize @bullet
3654
3655 A GNAT license header starts with a line containing 78 hyphens. The following
3656 comment text is searched for the appearance of any of the following strings.
3657
3658 If the string ``GNU General Public License'' is found, then the unit is assumed
3659 to have GPL license, unless the string ``As a special exception'' follows, in
3660 which case the license is assumed to be modified GPL@.
3661
3662 If one of the strings
3663 ``This specification is adapted from the Ada Semantic Interface'' or
3664 ``This specification is derived from the Ada Reference Manual'' is found
3665 then the unit is assumed to be unrestricted.
3666 @end itemize
3667
3668 @noindent
3669 These default actions means that a program with a restricted license pragma
3670 will automatically get warnings if a GPL unit is inappropriately
3671 @code{with}'ed. For example, the program:
3672
3673 @smallexample @c ada
3674 with Sem_Ch3;
3675 with GNAT.Sockets;
3676 procedure Secret_Stuff is
3677 @dots{}
3678 end Secret_Stuff
3679 @end smallexample
3680
3681 @noindent
3682 if compiled with pragma @code{License} (@code{Restricted}) in a
3683 @file{gnat.adc} file will generate the warning:
3684
3685 @smallexample
3686 1. with Sem_Ch3;
3687 |
3688 >>> license of withed unit "Sem_Ch3" is incompatible
3689
3690 2. with GNAT.Sockets;
3691 3. procedure Secret_Stuff is
3692 @end smallexample
3693
3694 @noindent
3695 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3696 compiler and is licensed under the
3697 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3698 run time, and is therefore licensed under the modified GPL@.
3699
3700 @node Pragma Link_With
3701 @unnumberedsec Pragma Link_With
3702 @findex Link_With
3703 @noindent
3704 Syntax:
3705
3706 @smallexample @c ada
3707 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3708 @end smallexample
3709
3710 @noindent
3711 This pragma is provided for compatibility with certain Ada 83 compilers.
3712 It has exactly the same effect as pragma @code{Linker_Options} except
3713 that spaces occurring within one of the string expressions are treated
3714 as separators. For example, in the following case:
3715
3716 @smallexample @c ada
3717 pragma Link_With ("-labc -ldef");
3718 @end smallexample
3719
3720 @noindent
3721 results in passing the strings @code{-labc} and @code{-ldef} as two
3722 separate arguments to the linker. In addition pragma Link_With allows
3723 multiple arguments, with the same effect as successive pragmas.
3724
3725 @node Pragma Linker_Alias
3726 @unnumberedsec Pragma Linker_Alias
3727 @findex Linker_Alias
3728 @noindent
3729 Syntax:
3730
3731 @smallexample @c ada
3732 pragma Linker_Alias (
3733 [Entity =>] LOCAL_NAME,
3734 [Target =>] static_string_EXPRESSION);
3735 @end smallexample
3736
3737 @noindent
3738 @var{LOCAL_NAME} must refer to an object that is declared at the library
3739 level. This pragma establishes the given entity as a linker alias for the
3740 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3741 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3742 @var{static_string_EXPRESSION} in the object file, that is to say no space
3743 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3744 to the same address as @var{static_string_EXPRESSION} by the linker.
3745
3746 The actual linker name for the target must be used (e.g.@: the fully
3747 encoded name with qualification in Ada, or the mangled name in C++),
3748 or it must be declared using the C convention with @code{pragma Import}
3749 or @code{pragma Export}.
3750
3751 Not all target machines support this pragma. On some of them it is accepted
3752 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3753
3754 @smallexample @c ada
3755 -- Example of the use of pragma Linker_Alias
3756
3757 package p is
3758 i : Integer := 1;
3759 pragma Export (C, i);
3760
3761 new_name_for_i : Integer;
3762 pragma Linker_Alias (new_name_for_i, "i");
3763 end p;
3764 @end smallexample
3765
3766 @node Pragma Linker_Constructor
3767 @unnumberedsec Pragma Linker_Constructor
3768 @findex Linker_Constructor
3769 @noindent
3770 Syntax:
3771
3772 @smallexample @c ada
3773 pragma Linker_Constructor (procedure_LOCAL_NAME);
3774 @end smallexample
3775
3776 @noindent
3777 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3778 is declared at the library level. A procedure to which this pragma is
3779 applied will be treated as an initialization routine by the linker.
3780 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3781 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3782 of the executable is called (or immediately after the shared library is
3783 loaded if the procedure is linked in a shared library), in particular
3784 before the Ada run-time environment is set up.
3785
3786 Because of these specific contexts, the set of operations such a procedure
3787 can perform is very limited and the type of objects it can manipulate is
3788 essentially restricted to the elementary types. In particular, it must only
3789 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3790
3791 This pragma is used by GNAT to implement auto-initialization of shared Stand
3792 Alone Libraries, which provides a related capability without the restrictions
3793 listed above. Where possible, the use of Stand Alone Libraries is preferable
3794 to the use of this pragma.
3795
3796 @node Pragma Linker_Destructor
3797 @unnumberedsec Pragma Linker_Destructor
3798 @findex Linker_Destructor
3799 @noindent
3800 Syntax:
3801
3802 @smallexample @c ada
3803 pragma Linker_Destructor (procedure_LOCAL_NAME);
3804 @end smallexample
3805
3806 @noindent
3807 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3808 is declared at the library level. A procedure to which this pragma is
3809 applied will be treated as a finalization routine by the linker.
3810 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3811 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3812 of the executable has exited (or immediately before the shared library
3813 is unloaded if the procedure is linked in a shared library), in particular
3814 after the Ada run-time environment is shut down.
3815
3816 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3817 because of these specific contexts.
3818
3819 @node Pragma Linker_Section
3820 @unnumberedsec Pragma Linker_Section
3821 @findex Linker_Section
3822 @noindent
3823 Syntax:
3824
3825 @smallexample @c ada
3826 pragma Linker_Section (
3827 [Entity =>] LOCAL_NAME,
3828 [Section =>] static_string_EXPRESSION);
3829 @end smallexample
3830
3831 @noindent
3832 @var{LOCAL_NAME} must refer to an object that is declared at the library
3833 level. This pragma specifies the name of the linker section for the given
3834 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3835 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3836 section of the executable (assuming the linker doesn't rename the section).
3837
3838 The compiler normally places library-level objects in standard sections
3839 depending on their type: procedures and functions generally go in the
3840 @code{.text} section, initialized variables in the @code{.data} section
3841 and uninitialized variables in the @code{.bss} section.
3842
3843 Other, special sections may exist on given target machines to map special
3844 hardware, for example I/O ports or flash memory. This pragma is a means to
3845 defer the final layout of the executable to the linker, thus fully working
3846 at the symbolic level with the compiler.
3847
3848 Some file formats do not support arbitrary sections so not all target
3849 machines support this pragma. The use of this pragma may cause a program
3850 execution to be erroneous if it is used to place an entity into an
3851 inappropriate section (e.g.@: a modified variable into the @code{.text}
3852 section). See also @code{pragma Persistent_BSS}.
3853
3854 @smallexample @c ada
3855 -- Example of the use of pragma Linker_Section
3856
3857 package IO_Card is
3858 Port_A : Integer;
3859 pragma Volatile (Port_A);
3860 pragma Linker_Section (Port_A, ".bss.port_a");
3861
3862 Port_B : Integer;
3863 pragma Volatile (Port_B);
3864 pragma Linker_Section (Port_B, ".bss.port_b");
3865 end IO_Card;
3866 @end smallexample
3867
3868 @node Pragma Long_Float
3869 @unnumberedsec Pragma Long_Float
3870 @cindex OpenVMS
3871 @findex Long_Float
3872 @noindent
3873 Syntax:
3874
3875 @smallexample @c ada
3876 pragma Long_Float (FLOAT_FORMAT);
3877
3878 FLOAT_FORMAT ::= D_Float | G_Float
3879 @end smallexample
3880
3881 @noindent
3882 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3883 It allows control over the internal representation chosen for the predefined
3884 type @code{Long_Float} and for floating point type representations with
3885 @code{digits} specified in the range 7 through 15.
3886 For further details on this pragma, see the
3887 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3888 this pragma, the standard runtime libraries must be recompiled.
3889
3890 @node Pragma Loop_Optimize
3891 @unnumberedsec Pragma Loop_Optimize
3892 @findex Loop_Optimize
3893 @noindent
3894 Syntax:
3895
3896 @smallexample @c ada
3897 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
3898
3899 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
3900 @end smallexample
3901
3902 @noindent
3903 This pragma must appear immediately within a loop statement. It allows the
3904 programmer to specify optimization hints for the enclosing loop. The hints
3905 are not mutually exclusive and can be freely mixed, but not all combinations
3906 will yield a sensible outcome.
3907
3908 There are four supported optimization hints for a loop:
3909 @itemize @bullet
3910 @item No_Unroll
3911
3912 The loop must not be unrolled. This is a strong hint: the compiler will not
3913 unroll a loop marked with this hint.
3914
3915 @item Unroll
3916
3917 The loop should be unrolled. This is a weak hint: the compiler will try to
3918 apply unrolling to this loop preferably to other optimizations, notably
3919 vectorization, but there is no guarantee that the loop will be unrolled.
3920
3921 @item No_Vector
3922
3923 The loop must not be vectorized. This is a strong hint: the compiler will not
3924 vectorize a loop marked with this hint.
3925
3926 @item Vector
3927
3928 The loop should be vectorized. This is a weak hint: the compiler will try to
3929 apply vectorization to this loop preferably to other optimizations, notably
3930 unrolling, but there is no guarantee that the loop will be vectorized.
3931
3932 @end itemize
3933
3934 These hints do not void the need to pass the appropriate switches to the
3935 compiler in order to enable the relevant optimizations, that is to say
3936 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
3937 vectorization.
3938
3939 @node Pragma Machine_Attribute
3940 @unnumberedsec Pragma Machine_Attribute
3941 @findex Machine_Attribute
3942 @noindent
3943 Syntax:
3944
3945 @smallexample @c ada
3946 pragma Machine_Attribute (
3947 [Entity =>] LOCAL_NAME,
3948 [Attribute_Name =>] static_string_EXPRESSION
3949 [, [Info =>] static_EXPRESSION] );
3950 @end smallexample
3951
3952 @noindent
3953 Machine-dependent attributes can be specified for types and/or
3954 declarations. This pragma is semantically equivalent to
3955 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3956 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3957 in GNU C, where @code{@var{attribute_name}} is recognized by the
3958 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3959 specific macro. A string literal for the optional parameter @var{info}
3960 is transformed into an identifier, which may make this pragma unusable
3961 for some attributes. @xref{Target Attributes,, Defining target-specific
3962 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3963 Internals}, further information.
3964
3965 @node Pragma Main
3966 @unnumberedsec Pragma Main
3967 @cindex OpenVMS
3968 @findex Main
3969 @noindent
3970 Syntax:
3971
3972 @smallexample @c ada
3973 pragma Main
3974 (MAIN_OPTION [, MAIN_OPTION]);
3975
3976 MAIN_OPTION ::=
3977 [Stack_Size =>] static_integer_EXPRESSION
3978 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3979 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3980 @end smallexample
3981
3982 @noindent
3983 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3984 no effect in GNAT, other than being syntax checked.
3985
3986 @node Pragma Main_Storage
3987 @unnumberedsec Pragma Main_Storage
3988 @cindex OpenVMS
3989 @findex Main_Storage
3990 @noindent
3991 Syntax:
3992
3993 @smallexample @c ada
3994 pragma Main_Storage
3995 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3996
3997 MAIN_STORAGE_OPTION ::=
3998 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3999 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4000 @end smallexample
4001
4002 @noindent
4003 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4004 no effect in GNAT, other than being syntax checked. Note that the pragma
4005 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4006
4007 @node Pragma No_Body
4008 @unnumberedsec Pragma No_Body
4009 @findex No_Body
4010 @noindent
4011 Syntax:
4012
4013 @smallexample @c ada
4014 pragma No_Body;
4015 @end smallexample
4016
4017 @noindent
4018 There are a number of cases in which a package spec does not require a body,
4019 and in fact a body is not permitted. GNAT will not permit the spec to be
4020 compiled if there is a body around. The pragma No_Body allows you to provide
4021 a body file, even in a case where no body is allowed. The body file must
4022 contain only comments and a single No_Body pragma. This is recognized by
4023 the compiler as indicating that no body is logically present.
4024
4025 This is particularly useful during maintenance when a package is modified in
4026 such a way that a body needed before is no longer needed. The provision of a
4027 dummy body with a No_Body pragma ensures that there is no interference from
4028 earlier versions of the package body.
4029
4030 @node Pragma No_Inline
4031 @unnumberedsec Pragma No_Inline
4032 @findex No_Inline
4033 @noindent
4034 Syntax:
4035
4036 @smallexample @c ada
4037 pragma No_Inline (NAME @{, NAME@});
4038 @end smallexample
4039
4040 @noindent
4041 This pragma suppresses inlining for the callable entity or the instances of
4042 the generic subprogram designated by @var{NAME}, including inlining that
4043 results from the use of pragma @code{Inline}. This pragma is always active,
4044 in particular it is not subject to the use of option @option{-gnatn} or
4045 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4046 pragma @code{Inline_Always} for the same @var{NAME}.
4047
4048 @node Pragma No_Return
4049 @unnumberedsec Pragma No_Return
4050 @findex No_Return
4051 @noindent
4052 Syntax:
4053
4054 @smallexample @c ada
4055 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4056 @end smallexample
4057
4058 @noindent
4059 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4060 declarations in the current declarative part. A procedure to which this
4061 pragma is applied may not contain any explicit @code{return} statements.
4062 In addition, if the procedure contains any implicit returns from falling
4063 off the end of a statement sequence, then execution of that implicit
4064 return will cause Program_Error to be raised.
4065
4066 One use of this pragma is to identify procedures whose only purpose is to raise
4067 an exception. Another use of this pragma is to suppress incorrect warnings
4068 about missing returns in functions, where the last statement of a function
4069 statement sequence is a call to such a procedure.
4070
4071 Note that in Ada 2005 mode, this pragma is part of the language. It is
4072 available in all earlier versions of Ada as an implementation-defined
4073 pragma.
4074
4075 @node Pragma No_Strict_Aliasing
4076 @unnumberedsec Pragma No_Strict_Aliasing
4077 @findex No_Strict_Aliasing
4078 @noindent
4079 Syntax:
4080
4081 @smallexample @c ada
4082 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4083 @end smallexample
4084
4085 @noindent
4086 @var{type_LOCAL_NAME} must refer to an access type
4087 declaration in the current declarative part. The effect is to inhibit
4088 strict aliasing optimization for the given type. The form with no
4089 arguments is a configuration pragma which applies to all access types
4090 declared in units to which the pragma applies. For a detailed
4091 description of the strict aliasing optimization, and the situations
4092 in which it must be suppressed, see @ref{Optimization and Strict
4093 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4094
4095 This pragma currently has no effects on access to unconstrained array types.
4096
4097 @node Pragma Normalize_Scalars
4098 @unnumberedsec Pragma Normalize_Scalars
4099 @findex Normalize_Scalars
4100 @noindent
4101 Syntax:
4102
4103 @smallexample @c ada
4104 pragma Normalize_Scalars;
4105 @end smallexample
4106
4107 @noindent
4108 This is a language defined pragma which is fully implemented in GNAT@. The
4109 effect is to cause all scalar objects that are not otherwise initialized
4110 to be initialized. The initial values are implementation dependent and
4111 are as follows:
4112
4113 @table @code
4114 @item Standard.Character
4115 @noindent
4116 Objects whose root type is Standard.Character are initialized to
4117 Character'Last unless the subtype range excludes NUL (in which case
4118 NUL is used). This choice will always generate an invalid value if
4119 one exists.
4120
4121 @item Standard.Wide_Character
4122 @noindent
4123 Objects whose root type is Standard.Wide_Character are initialized to
4124 Wide_Character'Last unless the subtype range excludes NUL (in which case
4125 NUL is used). This choice will always generate an invalid value if
4126 one exists.
4127
4128 @item Standard.Wide_Wide_Character
4129 @noindent
4130 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4131 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4132 which case NUL is used). This choice will always generate an invalid value if
4133 one exists.
4134
4135 @item Integer types
4136 @noindent
4137 Objects of an integer type are treated differently depending on whether
4138 negative values are present in the subtype. If no negative values are
4139 present, then all one bits is used as the initial value except in the
4140 special case where zero is excluded from the subtype, in which case
4141 all zero bits are used. This choice will always generate an invalid
4142 value if one exists.
4143
4144 For subtypes with negative values present, the largest negative number
4145 is used, except in the unusual case where this largest negative number
4146 is in the subtype, and the largest positive number is not, in which case
4147 the largest positive value is used. This choice will always generate
4148 an invalid value if one exists.
4149
4150 @item Floating-Point Types
4151 Objects of all floating-point types are initialized to all 1-bits. For
4152 standard IEEE format, this corresponds to a NaN (not a number) which is
4153 indeed an invalid value.
4154
4155 @item Fixed-Point Types
4156 Objects of all fixed-point types are treated as described above for integers,
4157 with the rules applying to the underlying integer value used to represent
4158 the fixed-point value.
4159
4160 @item Modular types
4161 Objects of a modular type are initialized to all one bits, except in
4162 the special case where zero is excluded from the subtype, in which
4163 case all zero bits are used. This choice will always generate an
4164 invalid value if one exists.
4165
4166 @item Enumeration types
4167 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4168 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4169 whose Pos value is zero, in which case a code of zero is used. This choice
4170 will always generate an invalid value if one exists.
4171
4172 @end table
4173
4174 @node Pragma Obsolescent
4175 @unnumberedsec Pragma Obsolescent
4176 @findex Obsolescent
4177 @noindent
4178 Syntax:
4179
4180 @smallexample @c ada
4181 pragma Obsolescent;
4182
4183 pragma Obsolescent (
4184 [Message =>] static_string_EXPRESSION
4185 [,[Version =>] Ada_05]]);
4186
4187 pragma Obsolescent (
4188 [Entity =>] NAME
4189 [,[Message =>] static_string_EXPRESSION
4190 [,[Version =>] Ada_05]] );
4191 @end smallexample
4192
4193 @noindent
4194 This pragma can occur immediately following a declaration of an entity,
4195 including the case of a record component. If no Entity argument is present,
4196 then this declaration is the one to which the pragma applies. If an Entity
4197 parameter is present, it must either match the name of the entity in this
4198 declaration, or alternatively, the pragma can immediately follow an enumeration
4199 type declaration, where the Entity argument names one of the enumeration
4200 literals.
4201
4202 This pragma is used to indicate that the named entity
4203 is considered obsolescent and should not be used. Typically this is
4204 used when an API must be modified by eventually removing or modifying
4205 existing subprograms or other entities. The pragma can be used at an
4206 intermediate stage when the entity is still present, but will be
4207 removed later.
4208
4209 The effect of this pragma is to output a warning message on a reference to
4210 an entity thus marked that the subprogram is obsolescent if the appropriate
4211 warning option in the compiler is activated. If the Message parameter is
4212 present, then a second warning message is given containing this text. In
4213 addition, a reference to the entity is considered to be a violation of pragma
4214 Restrictions (No_Obsolescent_Features).
4215
4216 This pragma can also be used as a program unit pragma for a package,
4217 in which case the entity name is the name of the package, and the
4218 pragma indicates that the entire package is considered
4219 obsolescent. In this case a client @code{with}'ing such a package
4220 violates the restriction, and the @code{with} statement is
4221 flagged with warnings if the warning option is set.
4222
4223 If the Version parameter is present (which must be exactly
4224 the identifier Ada_05, no other argument is allowed), then the
4225 indication of obsolescence applies only when compiling in Ada 2005
4226 mode. This is primarily intended for dealing with the situations
4227 in the predefined library where subprograms or packages
4228 have become defined as obsolescent in Ada 2005
4229 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4230
4231 The following examples show typical uses of this pragma:
4232
4233 @smallexample @c ada
4234 package p is
4235 pragma Obsolescent (p, Message => "use pp instead of p");
4236 end p;
4237
4238 package q is
4239 procedure q2;
4240 pragma Obsolescent ("use q2new instead");
4241
4242 type R is new integer;
4243 pragma Obsolescent
4244 (Entity => R,
4245 Message => "use RR in Ada 2005",
4246 Version => Ada_05);
4247
4248 type M is record
4249 F1 : Integer;
4250 F2 : Integer;
4251 pragma Obsolescent;
4252 F3 : Integer;
4253 end record;
4254
4255 type E is (a, bc, 'd', quack);
4256 pragma Obsolescent (Entity => bc)
4257 pragma Obsolescent (Entity => 'd')
4258
4259 function "+"
4260 (a, b : character) return character;
4261 pragma Obsolescent (Entity => "+");
4262 end;
4263 @end smallexample
4264
4265 @noindent
4266 Note that, as for all pragmas, if you use a pragma argument identifier,
4267 then all subsequent parameters must also use a pragma argument identifier.
4268 So if you specify "Entity =>" for the Entity argument, and a Message
4269 argument is present, it must be preceded by "Message =>".
4270
4271 @node Pragma Optimize_Alignment
4272 @unnumberedsec Pragma Optimize_Alignment
4273 @findex Optimize_Alignment
4274 @cindex Alignment, default settings
4275 @noindent
4276 Syntax:
4277
4278 @smallexample @c ada
4279 pragma Optimize_Alignment (TIME | SPACE | OFF);
4280 @end smallexample
4281
4282 @noindent
4283 This is a configuration pragma which affects the choice of default alignments
4284 for types where no alignment is explicitly specified. There is a time/space
4285 trade-off in the selection of these values. Large alignments result in more
4286 efficient code, at the expense of larger data space, since sizes have to be
4287 increased to match these alignments. Smaller alignments save space, but the
4288 access code is slower. The normal choice of default alignments (which is what
4289 you get if you do not use this pragma, or if you use an argument of OFF),
4290 tries to balance these two requirements.
4291
4292 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4293 First any packed record is given an alignment of 1. Second, if a size is given
4294 for the type, then the alignment is chosen to avoid increasing this size. For
4295 example, consider:
4296
4297 @smallexample @c ada
4298 type R is record
4299 X : Integer;
4300 Y : Character;
4301 end record;
4302
4303 for R'Size use 5*8;
4304 @end smallexample
4305
4306 @noindent
4307 In the default mode, this type gets an alignment of 4, so that access to the
4308 Integer field X are efficient. But this means that objects of the type end up
4309 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4310 allowed to be bigger than the size of the type, but it can waste space if for
4311 example fields of type R appear in an enclosing record. If the above type is
4312 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4313
4314 However, there is one case in which SPACE is ignored. If a variable length
4315 record (that is a discriminated record with a component which is an array
4316 whose length depends on a discriminant), has a pragma Pack, then it is not
4317 in general possible to set the alignment of such a record to one, so the
4318 pragma is ignored in this case (with a warning).
4319
4320 Specifying TIME causes larger default alignments to be chosen in the case of
4321 small types with sizes that are not a power of 2. For example, consider:
4322
4323 @smallexample @c ada
4324 type R is record
4325 A : Character;
4326 B : Character;
4327 C : Boolean;
4328 end record;
4329
4330 pragma Pack (R);
4331 for R'Size use 17;
4332 @end smallexample
4333
4334 @noindent
4335 The default alignment for this record is normally 1, but if this type is
4336 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4337 to 4, which wastes space for objects of the type, since they are now 4 bytes
4338 long, but results in more efficient access when the whole record is referenced.
4339
4340 As noted above, this is a configuration pragma, and there is a requirement
4341 that all units in a partition be compiled with a consistent setting of the
4342 optimization setting. This would normally be achieved by use of a configuration
4343 pragma file containing the appropriate setting. The exception to this rule is
4344 that units with an explicit configuration pragma in the same file as the source
4345 unit are excluded from the consistency check, as are all predefined units. The
4346 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4347 pragma appears at the start of the file.
4348
4349 @node Pragma Ordered
4350 @unnumberedsec Pragma Ordered
4351 @findex Ordered
4352 @findex pragma @code{Ordered}
4353 @noindent
4354 Syntax:
4355
4356 @smallexample @c ada
4357 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4358 @end smallexample
4359
4360 @noindent
4361 Most enumeration types are from a conceptual point of view unordered.
4362 For example, consider:
4363
4364 @smallexample @c ada
4365 type Color is (Red, Blue, Green, Yellow);
4366 @end smallexample
4367
4368 @noindent
4369 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4370 but really these relations make no sense; the enumeration type merely
4371 specifies a set of possible colors, and the order is unimportant.
4372
4373 For unordered enumeration types, it is generally a good idea if
4374 clients avoid comparisons (other than equality or inequality) and
4375 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4376 other than the unit where the type is declared, its body, and its subunits.)
4377 For example, if code buried in some client says:
4378
4379 @smallexample @c ada
4380 if Current_Color < Yellow then ...
4381 if Current_Color in Blue .. Green then ...
4382 @end smallexample
4383
4384 @noindent
4385 then the client code is relying on the order, which is undesirable.
4386 It makes the code hard to read and creates maintenance difficulties if
4387 entries have to be added to the enumeration type. Instead,
4388 the code in the client should list the possibilities, or an
4389 appropriate subtype should be declared in the unit that declares
4390 the original enumeration type. E.g., the following subtype could
4391 be declared along with the type @code{Color}:
4392
4393 @smallexample @c ada
4394 subtype RBG is Color range Red .. Green;
4395 @end smallexample
4396
4397 @noindent
4398 and then the client could write:
4399
4400 @smallexample @c ada
4401 if Current_Color in RBG then ...
4402 if Current_Color = Blue or Current_Color = Green then ...
4403 @end smallexample
4404
4405 @noindent
4406 However, some enumeration types are legitimately ordered from a conceptual
4407 point of view. For example, if you declare:
4408
4409 @smallexample @c ada
4410 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4411 @end smallexample
4412
4413 @noindent
4414 then the ordering imposed by the language is reasonable, and
4415 clients can depend on it, writing for example:
4416
4417 @smallexample @c ada
4418 if D in Mon .. Fri then ...
4419 if D < Wed then ...
4420 @end smallexample
4421
4422 @noindent
4423 The pragma @option{Ordered} is provided to mark enumeration types that
4424 are conceptually ordered, alerting the reader that clients may depend
4425 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4426 rather than one to mark them as unordered, since in our experience,
4427 the great majority of enumeration types are conceptually unordered.
4428
4429 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4430 and @code{Wide_Wide_Character}
4431 are considered to be ordered types, so each is declared with a
4432 pragma @code{Ordered} in package @code{Standard}.
4433
4434 Normally pragma @code{Ordered} serves only as documentation and a guide for
4435 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4436 requests warnings for inappropriate uses (comparisons and explicit
4437 subranges) for unordered types. If this switch is used, then any
4438 enumeration type not marked with pragma @code{Ordered} will be considered
4439 as unordered, and will generate warnings for inappropriate uses.
4440
4441 For additional information please refer to the description of the
4442 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4443
4444 @node Pragma Overflow_Mode
4445 @unnumberedsec Pragma Overflow_Mode
4446 @findex Overflow checks
4447 @findex Overflow mode
4448 @findex pragma @code{Overflow_Mode}
4449 @noindent
4450 Syntax:
4451
4452 @smallexample @c ada
4453 pragma Overflow_Mode
4454 ( [General =>] MODE
4455 [,[Assertions =>] MODE]);
4456
4457 MODE ::= STRICT | MINIMIZED | ELIMINATED
4458 @end smallexample
4459
4460 @noindent
4461 This pragma sets the current overflow mode to the given setting. For details
4462 of the meaning of these modes, please refer to the
4463 ``Overflow Check Handling in GNAT'' appendix in the
4464 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4465 the given mode applies to all expressions. If both parameters are present,
4466 the @code{General} mode applies to expressions outside assertions, and
4467 the @code{Eliminated} mode applies to expressions within assertions.
4468
4469 The case of the @code{MODE} parameter is ignored,
4470 so @code{MINIMIZED}, @code{Minimized} and
4471 @code{minimized} all have the same effect.
4472
4473 The @code{Overflow_Mode} pragma has the same scoping and placement
4474 rules as pragma @code{Suppress}, so it can occur either as a
4475 configuration pragma, specifying a default for the whole
4476 program, or in a declarative scope, where it applies to the
4477 remaining declarations and statements in that scope.
4478
4479 The pragma @code{Suppress (Overflow_Check)} suppresses
4480 overflow checking, but does not affect the overflow mode.
4481
4482 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4483 overflow checking, but does not affect the overflow mode.
4484
4485 @node Pragma Partition_Elaboration_Policy
4486 @unnumberedsec Pragma Partition_Elaboration_Policy
4487 @findex Partition_Elaboration_Policy
4488 @noindent
4489 Syntax:
4490
4491 @smallexample @c ada
4492 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4493
4494 POLICY_IDENTIFIER ::= Concurrent | Sequential
4495 @end smallexample
4496
4497 @noindent
4498 This pragma is standard in Ada 2005, but is available in all earlier
4499 versions of Ada as an implementation-defined pragma.
4500 See Ada 2012 Reference Manual for details.
4501
4502 @node Pragma Passive
4503 @unnumberedsec Pragma Passive
4504 @findex Passive
4505 @noindent
4506 Syntax:
4507
4508 @smallexample @c ada
4509 pragma Passive [(Semaphore | No)];
4510 @end smallexample
4511
4512 @noindent
4513 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4514 compatibility with DEC Ada 83 implementations, where it is used within a
4515 task definition to request that a task be made passive. If the argument
4516 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4517 treats the pragma as an assertion that the containing task is passive
4518 and that optimization of context switch with this task is permitted and
4519 desired. If the argument @code{No} is present, the task must not be
4520 optimized. GNAT does not attempt to optimize any tasks in this manner
4521 (since protected objects are available in place of passive tasks).
4522
4523 @node Pragma Persistent_BSS
4524 @unnumberedsec Pragma Persistent_BSS
4525 @findex Persistent_BSS
4526 @noindent
4527 Syntax:
4528
4529 @smallexample @c ada
4530 pragma Persistent_BSS [(LOCAL_NAME)]
4531 @end smallexample
4532
4533 @noindent
4534 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4535 section. On some targets the linker and loader provide for special
4536 treatment of this section, allowing a program to be reloaded without
4537 affecting the contents of this data (hence the name persistent).
4538
4539 There are two forms of usage. If an argument is given, it must be the
4540 local name of a library level object, with no explicit initialization
4541 and whose type is potentially persistent. If no argument is given, then
4542 the pragma is a configuration pragma, and applies to all library level
4543 objects with no explicit initialization of potentially persistent types.
4544
4545 A potentially persistent type is a scalar type, or a non-tagged,
4546 non-discriminated record, all of whose components have no explicit
4547 initialization and are themselves of a potentially persistent type,
4548 or an array, all of whose constraints are static, and whose component
4549 type is potentially persistent.
4550
4551 If this pragma is used on a target where this feature is not supported,
4552 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4553
4554 @node Pragma Polling
4555 @unnumberedsec Pragma Polling
4556 @findex Polling
4557 @noindent
4558 Syntax:
4559
4560 @smallexample @c ada
4561 pragma Polling (ON | OFF);
4562 @end smallexample
4563
4564 @noindent
4565 This pragma controls the generation of polling code. This is normally off.
4566 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4567 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4568 runtime library, and can be found in file @file{a-excpol.adb}.
4569
4570 Pragma @code{Polling} can appear as a configuration pragma (for example it
4571 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4572 can be used in the statement or declaration sequence to control polling
4573 more locally.
4574
4575 A call to the polling routine is generated at the start of every loop and
4576 at the start of every subprogram call. This guarantees that the @code{Poll}
4577 routine is called frequently, and places an upper bound (determined by
4578 the complexity of the code) on the period between two @code{Poll} calls.
4579
4580 The primary purpose of the polling interface is to enable asynchronous
4581 aborts on targets that cannot otherwise support it (for example Windows
4582 NT), but it may be used for any other purpose requiring periodic polling.
4583 The standard version is null, and can be replaced by a user program. This
4584 will require re-compilation of the @code{Ada.Exceptions} package that can
4585 be found in files @file{a-except.ads} and @file{a-except.adb}.
4586
4587 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4588 distribution) is used to enable the asynchronous abort capability on
4589 targets that do not normally support the capability. The version of
4590 @code{Poll} in this file makes a call to the appropriate runtime routine
4591 to test for an abort condition.
4592
4593 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4594 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4595 details.
4596
4597 @node Pragma Postcondition
4598 @unnumberedsec Pragma Postcondition
4599 @cindex Postconditions
4600 @cindex Checks, postconditions
4601 @findex Postconditions
4602 @noindent
4603 Syntax:
4604
4605 @smallexample @c ada
4606 pragma Postcondition (
4607 [Check =>] Boolean_Expression
4608 [,[Message =>] String_Expression]);
4609 @end smallexample
4610
4611 @noindent
4612 The @code{Postcondition} pragma allows specification of automatic
4613 postcondition checks for subprograms. These checks are similar to
4614 assertions, but are automatically inserted just prior to the return
4615 statements of the subprogram with which they are associated (including
4616 implicit returns at the end of procedure bodies and associated
4617 exception handlers).
4618
4619 In addition, the boolean expression which is the condition which
4620 must be true may contain references to function'Result in the case
4621 of a function to refer to the returned value.
4622
4623 @code{Postcondition} pragmas may appear either immediately following the
4624 (separate) declaration of a subprogram, or at the start of the
4625 declarations of a subprogram body. Only other pragmas may intervene
4626 (that is appear between the subprogram declaration and its
4627 postconditions, or appear before the postcondition in the
4628 declaration sequence in a subprogram body). In the case of a
4629 postcondition appearing after a subprogram declaration, the
4630 formal arguments of the subprogram are visible, and can be
4631 referenced in the postcondition expressions.
4632
4633 The postconditions are collected and automatically tested just
4634 before any return (implicit or explicit) in the subprogram body.
4635 A postcondition is only recognized if postconditions are active
4636 at the time the pragma is encountered. The compiler switch @option{gnata}
4637 turns on all postconditions by default, and pragma @code{Check_Policy}
4638 with an identifier of @code{Postcondition} can also be used to
4639 control whether postconditions are active.
4640
4641 The general approach is that postconditions are placed in the spec
4642 if they represent functional aspects which make sense to the client.
4643 For example we might have:
4644
4645 @smallexample @c ada
4646 function Direction return Integer;
4647 pragma Postcondition
4648 (Direction'Result = +1
4649 or else
4650 Direction'Result = -1);
4651 @end smallexample
4652
4653 @noindent
4654 which serves to document that the result must be +1 or -1, and
4655 will test that this is the case at run time if postcondition
4656 checking is active.
4657
4658 Postconditions within the subprogram body can be used to
4659 check that some internal aspect of the implementation,
4660 not visible to the client, is operating as expected.
4661 For instance if a square root routine keeps an internal
4662 counter of the number of times it is called, then we
4663 might have the following postcondition:
4664
4665 @smallexample @c ada
4666 Sqrt_Calls : Natural := 0;
4667
4668 function Sqrt (Arg : Float) return Float is
4669 pragma Postcondition
4670 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4671 ...
4672 end Sqrt
4673 @end smallexample
4674
4675 @noindent
4676 As this example, shows, the use of the @code{Old} attribute
4677 is often useful in postconditions to refer to the state on
4678 entry to the subprogram.
4679
4680 Note that postconditions are only checked on normal returns
4681 from the subprogram. If an abnormal return results from
4682 raising an exception, then the postconditions are not checked.
4683
4684 If a postcondition fails, then the exception
4685 @code{System.Assertions.Assert_Failure} is raised. If
4686 a message argument was supplied, then the given string
4687 will be used as the exception message. If no message
4688 argument was supplied, then the default message has
4689 the form "Postcondition failed at file:line". The
4690 exception is raised in the context of the subprogram
4691 body, so it is possible to catch postcondition failures
4692 within the subprogram body itself.
4693
4694 Within a package spec, normal visibility rules
4695 in Ada would prevent forward references within a
4696 postcondition pragma to functions defined later in
4697 the same package. This would introduce undesirable
4698 ordering constraints. To avoid this problem, all
4699 postcondition pragmas are analyzed at the end of
4700 the package spec, allowing forward references.
4701
4702 The following example shows that this even allows
4703 mutually recursive postconditions as in:
4704
4705 @smallexample @c ada
4706 package Parity_Functions is
4707 function Odd (X : Natural) return Boolean;
4708 pragma Postcondition
4709 (Odd'Result =
4710 (x = 1
4711 or else
4712 (x /= 0 and then Even (X - 1))));
4713
4714 function Even (X : Natural) return Boolean;
4715 pragma Postcondition
4716 (Even'Result =
4717 (x = 0
4718 or else
4719 (x /= 1 and then Odd (X - 1))));
4720
4721 end Parity_Functions;
4722 @end smallexample
4723
4724 @noindent
4725 There are no restrictions on the complexity or form of
4726 conditions used within @code{Postcondition} pragmas.
4727 The following example shows that it is even possible
4728 to verify performance behavior.
4729
4730 @smallexample @c ada
4731 package Sort is
4732
4733 Performance : constant Float;
4734 -- Performance constant set by implementation
4735 -- to match target architecture behavior.
4736
4737 procedure Treesort (Arg : String);
4738 -- Sorts characters of argument using N*logN sort
4739 pragma Postcondition
4740 (Float (Clock - Clock'Old) <=
4741 Float (Arg'Length) *
4742 log (Float (Arg'Length)) *
4743 Performance);
4744 end Sort;
4745 @end smallexample
4746
4747 @noindent
4748 Note: postcondition pragmas associated with subprograms that are
4749 marked as Inline_Always, or those marked as Inline with front-end
4750 inlining (-gnatN option set) are accepted and legality-checked
4751 by the compiler, but are ignored at run-time even if postcondition
4752 checking is enabled.
4753
4754 @node Pragma Preelaborable_Initialization
4755 @unnumberedsec Pragma Preelaborable_Initialization
4756 @findex Preelaborable_Initialization
4757 @noindent
4758 Syntax:
4759
4760 @smallexample @c ada
4761 pragma Preelaborable_Initialization (DIRECT_NAME);
4762 @end smallexample
4763
4764 @noindent
4765 This pragma is standard in Ada 2005, but is available in all earlier
4766 versions of Ada as an implementation-defined pragma.
4767 See Ada 2012 Reference Manual for details.
4768
4769 @node Pragma Priority_Specific_Dispatching
4770 @unnumberedsec Pragma Priority_Specific_Dispatching
4771 @findex Priority_Specific_Dispatching
4772 @noindent
4773 Syntax:
4774
4775 @smallexample @c ada
4776 pragma Priority_Specific_Dispatching (
4777 POLICY_IDENTIFIER,
4778 first_priority_EXPRESSION,
4779 last_priority_EXPRESSION)
4780
4781 POLICY_IDENTIFIER ::=
4782 EDF_Across_Priorities |
4783 FIFO_Within_Priorities |
4784 Non_Preemptive_Within_Priorities |
4785 Round_Robin_Within_Priorities
4786 @end smallexample
4787
4788 @noindent
4789 This pragma is standard in Ada 2005, but is available in all earlier
4790 versions of Ada as an implementation-defined pragma.
4791 See Ada 2012 Reference Manual for details.
4792
4793 @node Pragma Precondition
4794 @unnumberedsec Pragma Precondition
4795 @cindex Preconditions
4796 @cindex Checks, preconditions
4797 @findex Preconditions
4798 @noindent
4799 Syntax:
4800
4801 @smallexample @c ada
4802 pragma Precondition (
4803 [Check =>] Boolean_Expression
4804 [,[Message =>] String_Expression]);
4805 @end smallexample
4806
4807 @noindent
4808 The @code{Precondition} pragma is similar to @code{Postcondition}
4809 except that the corresponding checks take place immediately upon
4810 entry to the subprogram, and if a precondition fails, the exception
4811 is raised in the context of the caller, and the attribute 'Result
4812 cannot be used within the precondition expression.
4813
4814 Otherwise, the placement and visibility rules are identical to those
4815 described for postconditions. The following is an example of use
4816 within a package spec:
4817
4818 @smallexample @c ada
4819 package Math_Functions is
4820 ...
4821 function Sqrt (Arg : Float) return Float;
4822 pragma Precondition (Arg >= 0.0)
4823 ...
4824 end Math_Functions;
4825 @end smallexample
4826
4827 @noindent
4828 @code{Precondition} pragmas may appear either immediately following the
4829 (separate) declaration of a subprogram, or at the start of the
4830 declarations of a subprogram body. Only other pragmas may intervene
4831 (that is appear between the subprogram declaration and its
4832 postconditions, or appear before the postcondition in the
4833 declaration sequence in a subprogram body).
4834
4835 Note: postcondition pragmas associated with subprograms that are
4836 marked as Inline_Always, or those marked as Inline with front-end
4837 inlining (-gnatN option set) are accepted and legality-checked
4838 by the compiler, but are ignored at run-time even if postcondition
4839 checking is enabled.
4840
4841 @node Pragma Profile (Ravenscar)
4842 @unnumberedsec Pragma Profile (Ravenscar)
4843 @findex Ravenscar
4844 @noindent
4845 Syntax:
4846
4847 @smallexample @c ada
4848 pragma Profile (Ravenscar | Restricted);
4849 @end smallexample
4850
4851 @noindent
4852 This pragma is standard in Ada 2005, but is available in all earlier
4853 versions of Ada as an implementation-defined pragma. This is a
4854 configuration pragma that establishes the following set of configuration
4855 pragmas:
4856
4857 @table @code
4858 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4859 [RM D.2.2] Tasks are dispatched following a preemptive
4860 priority-ordered scheduling policy.
4861
4862 @item Locking_Policy (Ceiling_Locking)
4863 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4864 the ceiling priority of the corresponding protected object.
4865
4866 @item Detect_Blocking
4867 This pragma forces the detection of potentially blocking operations within a
4868 protected operation, and to raise Program_Error if that happens.
4869 @end table
4870 @noindent
4871
4872 plus the following set of restrictions:
4873
4874 @table @code
4875 @item Max_Entry_Queue_Length => 1
4876 No task can be queued on a protected entry.
4877 @item Max_Protected_Entries => 1
4878 @item Max_Task_Entries => 0
4879 No rendezvous statements are allowed.
4880 @item No_Abort_Statements
4881 @item No_Dynamic_Attachment
4882 @item No_Dynamic_Priorities
4883 @item No_Implicit_Heap_Allocations
4884 @item No_Local_Protected_Objects
4885 @item No_Local_Timing_Events
4886 @item No_Protected_Type_Allocators
4887 @item No_Relative_Delay
4888 @item No_Requeue_Statements
4889 @item No_Select_Statements
4890 @item No_Specific_Termination_Handlers
4891 @item No_Task_Allocators
4892 @item No_Task_Hierarchy
4893 @item No_Task_Termination
4894 @item Simple_Barriers
4895 @end table
4896 @noindent
4897
4898 The Ravenscar profile also includes the following restrictions that specify
4899 that there are no semantic dependences on the corresponding predefined
4900 packages:
4901
4902 @table @code
4903 @item No_Dependence => Ada.Asynchronous_Task_Control
4904 @item No_Dependence => Ada.Calendar
4905 @item No_Dependence => Ada.Execution_Time.Group_Budget
4906 @item No_Dependence => Ada.Execution_Time.Timers
4907 @item No_Dependence => Ada.Task_Attributes
4908 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4909 @end table
4910
4911 @noindent
4912
4913 This set of configuration pragmas and restrictions correspond to the
4914 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4915 published by the @cite{International Real-Time Ada Workshop}, 1997,
4916 and whose most recent description is available at
4917 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4918
4919 The original definition of the profile was revised at subsequent IRTAW
4920 meetings. It has been included in the ISO
4921 @cite{Guide for the Use of the Ada Programming Language in High
4922 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4923 the next revision of the standard. The formal definition given by
4924 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4925 AI-305) available at
4926 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4927 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4928
4929 The above set is a superset of the restrictions provided by pragma
4930 @code{Profile (Restricted)}, it includes six additional restrictions
4931 (@code{Simple_Barriers}, @code{No_Select_Statements},
4932 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4933 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4934 that pragma @code{Profile (Ravenscar)}, like the pragma
4935 @code{Profile (Restricted)},
4936 automatically causes the use of a simplified,
4937 more efficient version of the tasking run-time system.
4938
4939 @node Pragma Profile (Restricted)
4940 @unnumberedsec Pragma Profile (Restricted)
4941 @findex Restricted Run Time
4942 @noindent
4943 Syntax:
4944
4945 @smallexample @c ada
4946 pragma Profile (Restricted);
4947 @end smallexample
4948
4949 @noindent
4950 This is an implementation-defined version of the standard pragma defined
4951 in Ada 2005. It is available in all versions of Ada. It is a
4952 configuration pragma that establishes the following set of restrictions:
4953
4954 @itemize @bullet
4955 @item No_Abort_Statements
4956 @item No_Entry_Queue
4957 @item No_Task_Hierarchy
4958 @item No_Task_Allocators
4959 @item No_Dynamic_Priorities
4960 @item No_Terminate_Alternatives
4961 @item No_Dynamic_Attachment
4962 @item No_Protected_Type_Allocators
4963 @item No_Local_Protected_Objects
4964 @item No_Requeue_Statements
4965 @item No_Task_Attributes_Package
4966 @item Max_Asynchronous_Select_Nesting = 0
4967 @item Max_Task_Entries = 0
4968 @item Max_Protected_Entries = 1
4969 @item Max_Select_Alternatives = 0
4970 @end itemize
4971
4972 @noindent
4973 This set of restrictions causes the automatic selection of a simplified
4974 version of the run time that provides improved performance for the
4975 limited set of tasking functionality permitted by this set of restrictions.
4976
4977 @node Pragma Profile (Rational)
4978 @unnumberedsec Pragma Profile (Rational)
4979 @findex Rational compatibility mode
4980 @noindent
4981 Syntax:
4982
4983 @smallexample @c ada
4984 pragma Profile (Rational);
4985 @end smallexample
4986
4987 @noindent
4988 The Rational profile is intended to facilitate porting legacy code that
4989 compiles with the Rational APEX compiler, even when the code includes non-
4990 conforming Ada constructs. The profile enables the following three pragmas:
4991
4992 @itemize @bullet
4993 pragma Implicit_Packing;
4994 pragma Overriding_Renamings;
4995 pragma Use_VADS_Size;
4996 @end itemize
4997
4998 @noindent
4999 @node Pragma Psect_Object
5000 @unnumberedsec Pragma Psect_Object
5001 @findex Psect_Object
5002 @noindent
5003 Syntax:
5004
5005 @smallexample @c ada
5006 pragma Psect_Object (
5007 [Internal =>] LOCAL_NAME,
5008 [, [External =>] EXTERNAL_SYMBOL]
5009 [, [Size =>] EXTERNAL_SYMBOL]);
5010
5011 EXTERNAL_SYMBOL ::=
5012 IDENTIFIER
5013 | static_string_EXPRESSION
5014 @end smallexample
5015
5016 @noindent
5017 This pragma is identical in effect to pragma @code{Common_Object}.
5018
5019 @node Pragma Pure_Function
5020 @unnumberedsec Pragma Pure_Function
5021 @findex Pure_Function
5022 @noindent
5023 Syntax:
5024
5025 @smallexample @c ada
5026 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5027 @end smallexample
5028
5029 @noindent
5030 This pragma appears in the same declarative part as a function
5031 declaration (or a set of function declarations if more than one
5032 overloaded declaration exists, in which case the pragma applies
5033 to all entities). It specifies that the function @code{Entity} is
5034 to be considered pure for the purposes of code generation. This means
5035 that the compiler can assume that there are no side effects, and
5036 in particular that two calls with identical arguments produce the
5037 same result. It also means that the function can be used in an
5038 address clause.
5039
5040 Note that, quite deliberately, there are no static checks to try
5041 to ensure that this promise is met, so @code{Pure_Function} can be used
5042 with functions that are conceptually pure, even if they do modify
5043 global variables. For example, a square root function that is
5044 instrumented to count the number of times it is called is still
5045 conceptually pure, and can still be optimized, even though it
5046 modifies a global variable (the count). Memo functions are another
5047 example (where a table of previous calls is kept and consulted to
5048 avoid re-computation).
5049
5050 Note also that the normal rules excluding optimization of subprograms
5051 in pure units (when parameter types are descended from System.Address,
5052 or when the full view of a parameter type is limited), do not apply
5053 for the Pure_Function case. If you explicitly specify Pure_Function,
5054 the compiler may optimize away calls with identical arguments, and
5055 if that results in unexpected behavior, the proper action is not to
5056 use the pragma for subprograms that are not (conceptually) pure.
5057
5058 @findex Pure
5059 Note: Most functions in a @code{Pure} package are automatically pure, and
5060 there is no need to use pragma @code{Pure_Function} for such functions. One
5061 exception is any function that has at least one formal of type
5062 @code{System.Address} or a type derived from it. Such functions are not
5063 considered pure by default, since the compiler assumes that the
5064 @code{Address} parameter may be functioning as a pointer and that the
5065 referenced data may change even if the address value does not.
5066 Similarly, imported functions are not considered to be pure by default,
5067 since there is no way of checking that they are in fact pure. The use
5068 of pragma @code{Pure_Function} for such a function will override these default
5069 assumption, and cause the compiler to treat a designated subprogram as pure
5070 in these cases.
5071
5072 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5073 applies to the underlying renamed function. This can be used to
5074 disambiguate cases of overloading where some but not all functions
5075 in a set of overloaded functions are to be designated as pure.
5076
5077 If pragma @code{Pure_Function} is applied to a library level function, the
5078 function is also considered pure from an optimization point of view, but the
5079 unit is not a Pure unit in the categorization sense. So for example, a function
5080 thus marked is free to @code{with} non-pure units.
5081
5082 @node Pragma Relative_Deadline
5083 @unnumberedsec Pragma Relative_Deadline
5084 @findex Relative_Deadline
5085 @noindent
5086 Syntax:
5087
5088 @smallexample @c ada
5089 pragma Relative_Deadline (time_span_EXPRESSSION);
5090 @end smallexample
5091
5092 @noindent
5093 This pragma is standard in Ada 2005, but is available in all earlier
5094 versions of Ada as an implementation-defined pragma.
5095 See Ada 2012 Reference Manual for details.
5096
5097 @node Pragma Remote_Access_Type
5098 @unnumberedsec Pragma Remote_Access_Type
5099 @findex Remote_Access_Type
5100 @noindent
5101 Syntax:
5102
5103 @smallexample @c ada
5104 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5105 @end smallexample
5106
5107 @noindent
5108 This pragma appears in the formal part of a generic declaration.
5109 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5110 the use of a remote access to class-wide type as actual for a formal
5111 access type.
5112
5113 When this pragma applies to a formal access type @code{Entity}, that
5114 type is treated as a remote access to class-wide type in the generic.
5115 It must be a formal general access type, and its designated type must
5116 be the class-wide type of a formal tagged limited private type from the
5117 same generic declaration.
5118
5119 In the generic unit, the formal type is subject to all restrictions
5120 pertaining to remote access to class-wide types. At instantiation, the
5121 actual type must be a remote access to class-wide type.
5122
5123 @node Pragma Restriction_Warnings
5124 @unnumberedsec Pragma Restriction_Warnings
5125 @findex Restriction_Warnings
5126 @noindent
5127 Syntax:
5128
5129 @smallexample @c ada
5130 pragma Restriction_Warnings
5131 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5132 @end smallexample
5133
5134 @noindent
5135 This pragma allows a series of restriction identifiers to be
5136 specified (the list of allowed identifiers is the same as for
5137 pragma @code{Restrictions}). For each of these identifiers
5138 the compiler checks for violations of the restriction, but
5139 generates a warning message rather than an error message
5140 if the restriction is violated.
5141
5142 @node Pragma Shared
5143 @unnumberedsec Pragma Shared
5144 @findex Shared
5145
5146 @noindent
5147 This pragma is provided for compatibility with Ada 83. The syntax and
5148 semantics are identical to pragma Atomic.
5149
5150 @node Pragma Short_Circuit_And_Or
5151 @unnumberedsec Pragma Short_Circuit_And_Or
5152 @findex Short_Circuit_And_Or
5153
5154 @noindent
5155 This configuration pragma causes any occurrence of the AND operator applied to
5156 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5157 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5158 may be useful in the context of certification protocols requiring the use of
5159 short-circuited logical operators. If this configuration pragma occurs locally
5160 within the file being compiled, it applies only to the file being compiled.
5161 There is no requirement that all units in a partition use this option.
5162
5163 @node Pragma Short_Descriptors
5164 @unnumberedsec Pragma Short_Descriptors
5165 @findex Short_Descriptors
5166 @noindent
5167 Syntax:
5168
5169 @smallexample @c ada
5170 pragma Short_Descriptors
5171 @end smallexample
5172
5173 @noindent
5174 In VMS versions of the compiler, this configuration pragma causes all
5175 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5176 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5177 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5178 versions.
5179
5180 @node Pragma Simple_Storage_Pool_Type
5181 @unnumberedsec Pragma Simple_Storage_Pool_Type
5182 @findex Simple_Storage_Pool_Type
5183 @cindex Storage pool, simple
5184 @cindex Simple storage pool
5185 @noindent
5186 Syntax:
5187
5188 @smallexample @c ada
5189 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5190 @end smallexample
5191
5192 @noindent
5193 A type can be established as a ``simple storage pool type'' by applying
5194 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5195 A type named in the pragma must be a library-level immutably limited record
5196 type or limited tagged type declared immediately within a package declaration.
5197 The type can also be a limited private type whose full type is allowed as
5198 a simple storage pool type.
5199
5200 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5201 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5202 are subtype conformant with the following subprogram declarations:
5203
5204 @smallexample @c ada
5205 procedure Allocate
5206 (Pool : in out SSP;
5207 Storage_Address : out System.Address;
5208 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5209 Alignment : System.Storage_Elements.Storage_Count);
5210
5211 procedure Deallocate
5212 (Pool : in out SSP;
5213 Storage_Address : System.Address;
5214 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5215 Alignment : System.Storage_Elements.Storage_Count);
5216
5217 function Storage_Size (Pool : SSP)
5218 return System.Storage_Elements.Storage_Count;
5219 @end smallexample
5220
5221 @noindent
5222 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5223 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5224 applying an unchecked deallocation has no effect other than to set its actual
5225 parameter to null. If @code{Storage_Size} is not declared, then the
5226 @code{Storage_Size} attribute applied to an access type associated with
5227 a pool object of type SSP returns zero. Additional operations can be declared
5228 for a simple storage pool type (such as for supporting a mark/release
5229 storage-management discipline).
5230
5231 An object of a simple storage pool type can be associated with an access
5232 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5233
5234 @smallexample @c ada
5235
5236 My_Pool : My_Simple_Storage_Pool_Type;
5237
5238 type Acc is access My_Data_Type;
5239
5240 for Acc'Simple_Storage_Pool use My_Pool;
5241
5242 @end smallexample
5243
5244 @noindent
5245 See attribute @code{Simple_Storage_Pool} for further details.
5246
5247 @node Pragma Source_File_Name
5248 @unnumberedsec Pragma Source_File_Name
5249 @findex Source_File_Name
5250 @noindent
5251 Syntax:
5252
5253 @smallexample @c ada
5254 pragma Source_File_Name (
5255 [Unit_Name =>] unit_NAME,
5256 Spec_File_Name => STRING_LITERAL,
5257 [Index => INTEGER_LITERAL]);
5258
5259 pragma Source_File_Name (
5260 [Unit_Name =>] unit_NAME,
5261 Body_File_Name => STRING_LITERAL,
5262 [Index => INTEGER_LITERAL]);
5263 @end smallexample
5264
5265 @noindent
5266 Use this to override the normal naming convention. It is a configuration
5267 pragma, and so has the usual applicability of configuration pragmas
5268 (i.e.@: it applies to either an entire partition, or to all units in a
5269 compilation, or to a single unit, depending on how it is used.
5270 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5271 the second argument is required, and indicates whether this is the file
5272 name for the spec or for the body.
5273
5274 The optional Index argument should be used when a file contains multiple
5275 units, and when you do not want to use @code{gnatchop} to separate then
5276 into multiple files (which is the recommended procedure to limit the
5277 number of recompilations that are needed when some sources change).
5278 For instance, if the source file @file{source.ada} contains
5279
5280 @smallexample @c ada
5281 package B is
5282 ...
5283 end B;
5284
5285 with B;
5286 procedure A is
5287 begin
5288 ..
5289 end A;
5290 @end smallexample
5291
5292 you could use the following configuration pragmas:
5293
5294 @smallexample @c ada
5295 pragma Source_File_Name
5296 (B, Spec_File_Name => "source.ada", Index => 1);
5297 pragma Source_File_Name
5298 (A, Body_File_Name => "source.ada", Index => 2);
5299 @end smallexample
5300
5301 Note that the @code{gnatname} utility can also be used to generate those
5302 configuration pragmas.
5303
5304 Another form of the @code{Source_File_Name} pragma allows
5305 the specification of patterns defining alternative file naming schemes
5306 to apply to all files.
5307
5308 @smallexample @c ada
5309 pragma Source_File_Name
5310 ( [Spec_File_Name =>] STRING_LITERAL
5311 [,[Casing =>] CASING_SPEC]
5312 [,[Dot_Replacement =>] STRING_LITERAL]);
5313
5314 pragma Source_File_Name
5315 ( [Body_File_Name =>] STRING_LITERAL
5316 [,[Casing =>] CASING_SPEC]
5317 [,[Dot_Replacement =>] STRING_LITERAL]);
5318
5319 pragma Source_File_Name
5320 ( [Subunit_File_Name =>] STRING_LITERAL
5321 [,[Casing =>] CASING_SPEC]
5322 [,[Dot_Replacement =>] STRING_LITERAL]);
5323
5324 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5325 @end smallexample
5326
5327 @noindent
5328 The first argument is a pattern that contains a single asterisk indicating
5329 the point at which the unit name is to be inserted in the pattern string
5330 to form the file name. The second argument is optional. If present it
5331 specifies the casing of the unit name in the resulting file name string.
5332 The default is lower case. Finally the third argument allows for systematic
5333 replacement of any dots in the unit name by the specified string literal.
5334
5335 Note that Source_File_Name pragmas should not be used if you are using
5336 project files. The reason for this rule is that the project manager is not
5337 aware of these pragmas, and so other tools that use the projet file would not
5338 be aware of the intended naming conventions. If you are using project files,
5339 file naming is controlled by Source_File_Name_Project pragmas, which are
5340 usually supplied automatically by the project manager. A pragma
5341 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5342
5343 For more details on the use of the @code{Source_File_Name} pragma,
5344 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5345 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5346 User's Guide}.
5347
5348 @node Pragma Source_File_Name_Project
5349 @unnumberedsec Pragma Source_File_Name_Project
5350 @findex Source_File_Name_Project
5351 @noindent
5352
5353 This pragma has the same syntax and semantics as pragma Source_File_Name.
5354 It is only allowed as a stand alone configuration pragma.
5355 It cannot appear after a @ref{Pragma Source_File_Name}, and
5356 most importantly, once pragma Source_File_Name_Project appears,
5357 no further Source_File_Name pragmas are allowed.
5358
5359 The intention is that Source_File_Name_Project pragmas are always
5360 generated by the Project Manager in a manner consistent with the naming
5361 specified in a project file, and when naming is controlled in this manner,
5362 it is not permissible to attempt to modify this naming scheme using
5363 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5364 known to the project manager).
5365
5366 @node Pragma Source_Reference
5367 @unnumberedsec Pragma Source_Reference
5368 @findex Source_Reference
5369 @noindent
5370 Syntax:
5371
5372 @smallexample @c ada
5373 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5374 @end smallexample
5375
5376 @noindent
5377 This pragma must appear as the first line of a source file.
5378 @var{integer_literal} is the logical line number of the line following
5379 the pragma line (for use in error messages and debugging
5380 information). @var{string_literal} is a static string constant that
5381 specifies the file name to be used in error messages and debugging
5382 information. This is most notably used for the output of @code{gnatchop}
5383 with the @option{-r} switch, to make sure that the original unchopped
5384 source file is the one referred to.
5385
5386 The second argument must be a string literal, it cannot be a static
5387 string expression other than a string literal. This is because its value
5388 is needed for error messages issued by all phases of the compiler.
5389
5390 @node Pragma Static_Elaboration_Desired
5391 @unnumberedsec Pragma Static_Elaboration_Desired
5392 @findex Static_Elaboration_Desired
5393 @noindent
5394 Syntax:
5395
5396 @smallexample @c ada
5397 pragma Static_Elaboration_Desired;
5398 @end smallexample
5399
5400 @noindent
5401 This pragma is used to indicate that the compiler should attempt to initialize
5402 statically the objects declared in the library unit to which the pragma applies,
5403 when these objects are initialized (explicitly or implicitly) by an aggregate.
5404 In the absence of this pragma, aggregates in object declarations are expanded
5405 into assignments and loops, even when the aggregate components are static
5406 constants. When the aggregate is present the compiler builds a static expression
5407 that requires no run-time code, so that the initialized object can be placed in
5408 read-only data space. If the components are not static, or the aggregate has
5409 more that 100 components, the compiler emits a warning that the pragma cannot
5410 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5411 construction of larger aggregates with static components that include an others
5412 choice.)
5413
5414 @node Pragma Stream_Convert
5415 @unnumberedsec Pragma Stream_Convert
5416 @findex Stream_Convert
5417 @noindent
5418 Syntax:
5419
5420 @smallexample @c ada
5421 pragma Stream_Convert (
5422 [Entity =>] type_LOCAL_NAME,
5423 [Read =>] function_NAME,
5424 [Write =>] function_NAME);
5425 @end smallexample
5426
5427 @noindent
5428 This pragma provides an efficient way of providing stream functions for
5429 types defined in packages. Not only is it simpler to use than declaring
5430 the necessary functions with attribute representation clauses, but more
5431 significantly, it allows the declaration to made in such a way that the
5432 stream packages are not loaded unless they are needed. The use of
5433 the Stream_Convert pragma adds no overhead at all, unless the stream
5434 attributes are actually used on the designated type.
5435
5436 The first argument specifies the type for which stream functions are
5437 provided. The second parameter provides a function used to read values
5438 of this type. It must name a function whose argument type may be any
5439 subtype, and whose returned type must be the type given as the first
5440 argument to the pragma.
5441
5442 The meaning of the @var{Read}
5443 parameter is that if a stream attribute directly
5444 or indirectly specifies reading of the type given as the first parameter,
5445 then a value of the type given as the argument to the Read function is
5446 read from the stream, and then the Read function is used to convert this
5447 to the required target type.
5448
5449 Similarly the @var{Write} parameter specifies how to treat write attributes
5450 that directly or indirectly apply to the type given as the first parameter.
5451 It must have an input parameter of the type specified by the first parameter,
5452 and the return type must be the same as the input type of the Read function.
5453 The effect is to first call the Write function to convert to the given stream
5454 type, and then write the result type to the stream.
5455
5456 The Read and Write functions must not be overloaded subprograms. If necessary
5457 renamings can be supplied to meet this requirement.
5458 The usage of this attribute is best illustrated by a simple example, taken
5459 from the GNAT implementation of package Ada.Strings.Unbounded:
5460
5461 @smallexample @c ada
5462 function To_Unbounded (S : String)
5463 return Unbounded_String
5464 renames To_Unbounded_String;
5465
5466 pragma Stream_Convert
5467 (Unbounded_String, To_Unbounded, To_String);
5468 @end smallexample
5469
5470 @noindent
5471 The specifications of the referenced functions, as given in the Ada
5472 Reference Manual are:
5473
5474 @smallexample @c ada
5475 function To_Unbounded_String (Source : String)
5476 return Unbounded_String;
5477
5478 function To_String (Source : Unbounded_String)
5479 return String;
5480 @end smallexample
5481
5482 @noindent
5483 The effect is that if the value of an unbounded string is written to a stream,
5484 then the representation of the item in the stream is in the same format that
5485 would be used for @code{Standard.String'Output}, and this same representation
5486 is expected when a value of this type is read from the stream. Note that the
5487 value written always includes the bounds, even for Unbounded_String'Write,
5488 since Unbounded_String is not an array type.
5489
5490 @node Pragma Style_Checks
5491 @unnumberedsec Pragma Style_Checks
5492 @findex Style_Checks
5493 @noindent
5494 Syntax:
5495
5496 @smallexample @c ada
5497 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5498 On | Off [, LOCAL_NAME]);
5499 @end smallexample
5500
5501 @noindent
5502 This pragma is used in conjunction with compiler switches to control the
5503 built in style checking provided by GNAT@. The compiler switches, if set,
5504 provide an initial setting for the switches, and this pragma may be used
5505 to modify these settings, or the settings may be provided entirely by
5506 the use of the pragma. This pragma can be used anywhere that a pragma
5507 is legal, including use as a configuration pragma (including use in
5508 the @file{gnat.adc} file).
5509
5510 The form with a string literal specifies which style options are to be
5511 activated. These are additive, so they apply in addition to any previously
5512 set style check options. The codes for the options are the same as those
5513 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5514 For example the following two methods can be used to enable
5515 layout checking:
5516
5517 @itemize @bullet
5518 @item
5519 @smallexample @c ada
5520 pragma Style_Checks ("l");
5521 @end smallexample
5522
5523 @item
5524 @smallexample
5525 gcc -c -gnatyl @dots{}
5526 @end smallexample
5527 @end itemize
5528
5529 @noindent
5530 The form ALL_CHECKS activates all standard checks (its use is equivalent
5531 to the use of the @code{gnaty} switch with no options. @xref{Top,
5532 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5533 @value{EDITION} User's Guide}, for details.)
5534
5535 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5536 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5537 options (i.e. equivalent to -gnatyg).
5538
5539 The forms with @code{Off} and @code{On}
5540 can be used to temporarily disable style checks
5541 as shown in the following example:
5542
5543 @smallexample @c ada
5544 @iftex
5545 @leftskip=0cm
5546 @end iftex
5547 pragma Style_Checks ("k"); -- requires keywords in lower case
5548 pragma Style_Checks (Off); -- turn off style checks
5549 NULL; -- this will not generate an error message
5550 pragma Style_Checks (On); -- turn style checks back on
5551 NULL; -- this will generate an error message
5552 @end smallexample
5553
5554 @noindent
5555 Finally the two argument form is allowed only if the first argument is
5556 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5557 for the specified entity, as shown in the following example:
5558
5559 @smallexample @c ada
5560 @iftex
5561 @leftskip=0cm
5562 @end iftex
5563 pragma Style_Checks ("r"); -- require consistency of identifier casing
5564 Arg : Integer;
5565 Rf1 : Integer := ARG; -- incorrect, wrong case
5566 pragma Style_Checks (Off, Arg);
5567 Rf2 : Integer := ARG; -- OK, no error
5568 @end smallexample
5569
5570 @node Pragma Subtitle
5571 @unnumberedsec Pragma Subtitle
5572 @findex Subtitle
5573 @noindent
5574 Syntax:
5575
5576 @smallexample @c ada
5577 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5578 @end smallexample
5579
5580 @noindent
5581 This pragma is recognized for compatibility with other Ada compilers
5582 but is ignored by GNAT@.
5583
5584 @node Pragma Suppress
5585 @unnumberedsec Pragma Suppress
5586 @findex Suppress
5587 @noindent
5588 Syntax:
5589
5590 @smallexample @c ada
5591 pragma Suppress (Identifier [, [On =>] Name]);
5592 @end smallexample
5593
5594 @noindent
5595 This is a standard pragma, and supports all the check names required in
5596 the RM. It is included here because GNAT recognizes one additional check
5597 name: @code{Alignment_Check} which can be used to suppress alignment checks
5598 on addresses used in address clauses. Such checks can also be suppressed
5599 by suppressing range checks, but the specific use of @code{Alignment_Check}
5600 allows suppression of alignment checks without suppressing other range checks.
5601
5602 Note that pragma Suppress gives the compiler permission to omit
5603 checks, but does not require the compiler to omit checks. The compiler
5604 will generate checks if they are essentially free, even when they are
5605 suppressed. In particular, if the compiler can prove that a certain
5606 check will necessarily fail, it will generate code to do an
5607 unconditional ``raise'', even if checks are suppressed. The compiler
5608 warns in this case.
5609
5610 Of course, run-time checks are omitted whenever the compiler can prove
5611 that they will not fail, whether or not checks are suppressed.
5612
5613 @node Pragma Suppress_All
5614 @unnumberedsec Pragma Suppress_All
5615 @findex Suppress_All
5616 @noindent
5617 Syntax:
5618
5619 @smallexample @c ada
5620 pragma Suppress_All;
5621 @end smallexample
5622
5623 @noindent
5624 This pragma can appear anywhere within a unit.
5625 The effect is to apply @code{Suppress (All_Checks)} to the unit
5626 in which it appears. This pragma is implemented for compatibility with DEC
5627 Ada 83 usage where it appears at the end of a unit, and for compatibility
5628 with Rational Ada, where it appears as a program unit pragma.
5629 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5630 as a normal configuration pragma is the preferred usage in GNAT@.
5631
5632 @node Pragma Suppress_Exception_Locations
5633 @unnumberedsec Pragma Suppress_Exception_Locations
5634 @findex Suppress_Exception_Locations
5635 @noindent
5636 Syntax:
5637
5638 @smallexample @c ada
5639 pragma Suppress_Exception_Locations;
5640 @end smallexample
5641
5642 @noindent
5643 In normal mode, a raise statement for an exception by default generates
5644 an exception message giving the file name and line number for the location
5645 of the raise. This is useful for debugging and logging purposes, but this
5646 entails extra space for the strings for the messages. The configuration
5647 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5648 generation of these strings, with the result that space is saved, but the
5649 exception message for such raises is null. This configuration pragma may
5650 appear in a global configuration pragma file, or in a specific unit as
5651 usual. It is not required that this pragma be used consistently within
5652 a partition, so it is fine to have some units within a partition compiled
5653 with this pragma and others compiled in normal mode without it.
5654
5655 @node Pragma Suppress_Initialization
5656 @unnumberedsec Pragma Suppress_Initialization
5657 @findex Suppress_Initialization
5658 @cindex Suppressing initialization
5659 @cindex Initialization, suppression of
5660 @noindent
5661 Syntax:
5662
5663 @smallexample @c ada
5664 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5665 @end smallexample
5666
5667 @noindent
5668 Here subtype_Name is the name introduced by a type declaration
5669 or subtype declaration.
5670 This pragma suppresses any implicit or explicit initialization
5671 for all variables of the given type or subtype,
5672 including initialization resulting from the use of pragmas
5673 Normalize_Scalars or Initialize_Scalars.
5674
5675 This is considered a representation item, so it cannot be given after
5676 the type is frozen. It applies to all subsequent object declarations,
5677 and also any allocator that creates objects of the type.
5678
5679 If the pragma is given for the first subtype, then it is considered
5680 to apply to the base type and all its subtypes. If the pragma is given
5681 for other than a first subtype, then it applies only to the given subtype.
5682 The pragma may not be given after the type is frozen.
5683
5684 @node Pragma Task_Info
5685 @unnumberedsec Pragma Task_Info
5686 @findex Task_Info
5687 @noindent
5688 Syntax
5689
5690 @smallexample @c ada
5691 pragma Task_Info (EXPRESSION);
5692 @end smallexample
5693
5694 @noindent
5695 This pragma appears within a task definition (like pragma
5696 @code{Priority}) and applies to the task in which it appears. The
5697 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5698 The @code{Task_Info} pragma provides system dependent control over
5699 aspects of tasking implementation, for example, the ability to map
5700 tasks to specific processors. For details on the facilities available
5701 for the version of GNAT that you are using, see the documentation
5702 in the spec of package System.Task_Info in the runtime
5703 library.
5704
5705 @node Pragma Task_Name
5706 @unnumberedsec Pragma Task_Name
5707 @findex Task_Name
5708 @noindent
5709 Syntax
5710
5711 @smallexample @c ada
5712 pragma Task_Name (string_EXPRESSION);
5713 @end smallexample
5714
5715 @noindent
5716 This pragma appears within a task definition (like pragma
5717 @code{Priority}) and applies to the task in which it appears. The
5718 argument must be of type String, and provides a name to be used for
5719 the task instance when the task is created. Note that this expression
5720 is not required to be static, and in particular, it can contain
5721 references to task discriminants. This facility can be used to
5722 provide different names for different tasks as they are created,
5723 as illustrated in the example below.
5724
5725 The task name is recorded internally in the run-time structures
5726 and is accessible to tools like the debugger. In addition the
5727 routine @code{Ada.Task_Identification.Image} will return this
5728 string, with a unique task address appended.
5729
5730 @smallexample @c ada
5731 -- Example of the use of pragma Task_Name
5732
5733 with Ada.Task_Identification;
5734 use Ada.Task_Identification;
5735 with Text_IO; use Text_IO;
5736 procedure t3 is
5737
5738 type Astring is access String;
5739
5740 task type Task_Typ (Name : access String) is
5741 pragma Task_Name (Name.all);
5742 end Task_Typ;
5743
5744 task body Task_Typ is
5745 Nam : constant String := Image (Current_Task);
5746 begin
5747 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5748 end Task_Typ;
5749
5750 type Ptr_Task is access Task_Typ;
5751 Task_Var : Ptr_Task;
5752
5753 begin
5754 Task_Var :=
5755 new Task_Typ (new String'("This is task 1"));
5756 Task_Var :=
5757 new Task_Typ (new String'("This is task 2"));
5758 end;
5759 @end smallexample
5760
5761 @node Pragma Task_Storage
5762 @unnumberedsec Pragma Task_Storage
5763 @findex Task_Storage
5764 Syntax:
5765
5766 @smallexample @c ada
5767 pragma Task_Storage (
5768 [Task_Type =>] LOCAL_NAME,
5769 [Top_Guard =>] static_integer_EXPRESSION);
5770 @end smallexample
5771
5772 @noindent
5773 This pragma specifies the length of the guard area for tasks. The guard
5774 area is an additional storage area allocated to a task. A value of zero
5775 means that either no guard area is created or a minimal guard area is
5776 created, depending on the target. This pragma can appear anywhere a
5777 @code{Storage_Size} attribute definition clause is allowed for a task
5778 type.
5779
5780 @node Pragma Test_Case
5781 @unnumberedsec Pragma Test_Case
5782 @cindex Test cases
5783 @findex Test_Case
5784 @noindent
5785 Syntax:
5786
5787 @smallexample @c ada
5788 pragma Test_Case (
5789 [Name =>] static_string_Expression
5790 ,[Mode =>] (Nominal | Robustness)
5791 [, Requires => Boolean_Expression]
5792 [, Ensures => Boolean_Expression]);
5793 @end smallexample
5794
5795 @noindent
5796 The @code{Test_Case} pragma allows defining fine-grain specifications
5797 for use by testing tools. Its syntax is similar to the syntax of the
5798 @code{Contract_Case} pragma, which is used for both testing and
5799 formal verification.
5800 The compiler checks the validity of the @code{Test_Case} pragma, but its
5801 presence does not lead to any modification of the code generated by the
5802 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5803
5804 @code{Test_Case} pragmas may only appear immediately following the
5805 (separate) declaration of a subprogram in a package declaration, inside
5806 a package spec unit. Only other pragmas may intervene (that is appear
5807 between the subprogram declaration and a test case).
5808
5809 The compiler checks that boolean expressions given in @code{Requires} and
5810 @code{Ensures} are valid, where the rules for @code{Requires} are the
5811 same as the rule for an expression in @code{Precondition} and the rules
5812 for @code{Ensures} are the same as the rule for an expression in
5813 @code{Postcondition}. In particular, attributes @code{'Old} and
5814 @code{'Result} can only be used within the @code{Ensures}
5815 expression. The following is an example of use within a package spec:
5816
5817 @smallexample @c ada
5818 package Math_Functions is
5819 ...
5820 function Sqrt (Arg : Float) return Float;
5821 pragma Test_Case (Name => "Test 1",
5822 Mode => Nominal,
5823 Requires => Arg < 10000,
5824 Ensures => Sqrt'Result < 10);
5825 ...
5826 end Math_Functions;
5827 @end smallexample
5828
5829 @noindent
5830 The meaning of a test case is that there is at least one context where
5831 @code{Requires} holds such that, if the associated subprogram is executed in
5832 that context, then @code{Ensures} holds when the subprogram returns.
5833 Mode @code{Nominal} indicates that the input context should also satisfy the
5834 precondition of the subprogram, and the output context should also satisfy its
5835 postcondition. More @code{Robustness} indicates that the precondition and
5836 postcondition of the subprogram should be ignored for this test case.
5837
5838 @node Pragma Thread_Local_Storage
5839 @unnumberedsec Pragma Thread_Local_Storage
5840 @findex Thread_Local_Storage
5841 @cindex Task specific storage
5842 @cindex TLS (Thread Local Storage)
5843 Syntax:
5844
5845 @smallexample @c ada
5846 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5847 @end smallexample
5848
5849 @noindent
5850 This pragma specifies that the specified entity, which must be
5851 a variable declared in a library level package, is to be marked as
5852 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5853 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5854 (and hence each Ada task) to see a distinct copy of the variable.
5855
5856 The variable may not have default initialization, and if there is
5857 an explicit initialization, it must be either @code{null} for an
5858 access variable, or a static expression for a scalar variable.
5859 This provides a low level mechanism similar to that provided by
5860 the @code{Ada.Task_Attributes} package, but much more efficient
5861 and is also useful in writing interface code that will interact
5862 with foreign threads.
5863
5864 If this pragma is used on a system where @code{TLS} is not supported,
5865 then an error message will be generated and the program will be rejected.
5866
5867 @node Pragma Time_Slice
5868 @unnumberedsec Pragma Time_Slice
5869 @findex Time_Slice
5870 @noindent
5871 Syntax:
5872
5873 @smallexample @c ada
5874 pragma Time_Slice (static_duration_EXPRESSION);
5875 @end smallexample
5876
5877 @noindent
5878 For implementations of GNAT on operating systems where it is possible
5879 to supply a time slice value, this pragma may be used for this purpose.
5880 It is ignored if it is used in a system that does not allow this control,
5881 or if it appears in other than the main program unit.
5882 @cindex OpenVMS
5883 Note that the effect of this pragma is identical to the effect of the
5884 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5885
5886 @node Pragma Title
5887 @unnumberedsec Pragma Title
5888 @findex Title
5889 @noindent
5890 Syntax:
5891
5892 @smallexample @c ada
5893 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5894
5895 TITLING_OPTION ::=
5896 [Title =>] STRING_LITERAL,
5897 | [Subtitle =>] STRING_LITERAL
5898 @end smallexample
5899
5900 @noindent
5901 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5902 pragma used in DEC Ada 83 implementations to provide a title and/or
5903 subtitle for the program listing. The program listing generated by GNAT
5904 does not have titles or subtitles.
5905
5906 Unlike other pragmas, the full flexibility of named notation is allowed
5907 for this pragma, i.e.@: the parameters may be given in any order if named
5908 notation is used, and named and positional notation can be mixed
5909 following the normal rules for procedure calls in Ada.
5910
5911 @node Pragma Unchecked_Union
5912 @unnumberedsec Pragma Unchecked_Union
5913 @cindex Unions in C
5914 @findex Unchecked_Union
5915 @noindent
5916 Syntax:
5917
5918 @smallexample @c ada
5919 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5920 @end smallexample
5921
5922 @noindent
5923 This pragma is used to specify a representation of a record type that is
5924 equivalent to a C union. It was introduced as a GNAT implementation defined
5925 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5926 pragma, making it language defined, and GNAT fully implements this extended
5927 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5928 details, consult the Ada 2012 Reference Manual, section B.3.3.
5929
5930 @node Pragma Unimplemented_Unit
5931 @unnumberedsec Pragma Unimplemented_Unit
5932 @findex Unimplemented_Unit
5933 @noindent
5934 Syntax:
5935
5936 @smallexample @c ada
5937 pragma Unimplemented_Unit;
5938 @end smallexample
5939
5940 @noindent
5941 If this pragma occurs in a unit that is processed by the compiler, GNAT
5942 aborts with the message @samp{@var{xxx} not implemented}, where
5943 @var{xxx} is the name of the current compilation unit. This pragma is
5944 intended to allow the compiler to handle unimplemented library units in
5945 a clean manner.
5946
5947 The abort only happens if code is being generated. Thus you can use
5948 specs of unimplemented packages in syntax or semantic checking mode.
5949
5950 @node Pragma Universal_Aliasing
5951 @unnumberedsec Pragma Universal_Aliasing
5952 @findex Universal_Aliasing
5953 @noindent
5954 Syntax:
5955
5956 @smallexample @c ada
5957 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5958 @end smallexample
5959
5960 @noindent
5961 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5962 declarative part. The effect is to inhibit strict type-based aliasing
5963 optimization for the given type. In other words, the effect is as though
5964 access types designating this type were subject to pragma No_Strict_Aliasing.
5965 For a detailed description of the strict aliasing optimization, and the
5966 situations in which it must be suppressed, @xref{Optimization and Strict
5967 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5968
5969 @node Pragma Universal_Data
5970 @unnumberedsec Pragma Universal_Data
5971 @findex Universal_Data
5972 @noindent
5973 Syntax:
5974
5975 @smallexample @c ada
5976 pragma Universal_Data [(library_unit_Name)];
5977 @end smallexample
5978
5979 @noindent
5980 This pragma is supported only for the AAMP target and is ignored for
5981 other targets. The pragma specifies that all library-level objects
5982 (Counter 0 data) associated with the library unit are to be accessed
5983 and updated using universal addressing (24-bit addresses for AAMP5)
5984 rather than the default of 16-bit Data Environment (DENV) addressing.
5985 Use of this pragma will generally result in less efficient code for
5986 references to global data associated with the library unit, but
5987 allows such data to be located anywhere in memory. This pragma is
5988 a library unit pragma, but can also be used as a configuration pragma
5989 (including use in the @file{gnat.adc} file). The functionality
5990 of this pragma is also available by applying the -univ switch on the
5991 compilations of units where universal addressing of the data is desired.
5992
5993 @node Pragma Unmodified
5994 @unnumberedsec Pragma Unmodified
5995 @findex Unmodified
5996 @cindex Warnings, unmodified
5997 @noindent
5998 Syntax:
5999
6000 @smallexample @c ada
6001 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6002 @end smallexample
6003
6004 @noindent
6005 This pragma signals that the assignable entities (variables,
6006 @code{out} parameters, @code{in out} parameters) whose names are listed are
6007 deliberately not assigned in the current source unit. This
6008 suppresses warnings about the
6009 entities being referenced but not assigned, and in addition a warning will be
6010 generated if one of these entities is in fact assigned in the
6011 same unit as the pragma (or in the corresponding body, or one
6012 of its subunits).
6013
6014 This is particularly useful for clearly signaling that a particular
6015 parameter is not modified, even though the spec suggests that it might
6016 be.
6017
6018 @node Pragma Unreferenced
6019 @unnumberedsec Pragma Unreferenced
6020 @findex Unreferenced
6021 @cindex Warnings, unreferenced
6022 @noindent
6023 Syntax:
6024
6025 @smallexample @c ada
6026 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6027 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6028 @end smallexample
6029
6030 @noindent
6031 This pragma signals that the entities whose names are listed are
6032 deliberately not referenced in the current source unit. This
6033 suppresses warnings about the
6034 entities being unreferenced, and in addition a warning will be
6035 generated if one of these entities is in fact subsequently referenced in the
6036 same unit as the pragma (or in the corresponding body, or one
6037 of its subunits).
6038
6039 This is particularly useful for clearly signaling that a particular
6040 parameter is not referenced in some particular subprogram implementation
6041 and that this is deliberate. It can also be useful in the case of
6042 objects declared only for their initialization or finalization side
6043 effects.
6044
6045 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6046 current scope, then the entity most recently declared is the one to which
6047 the pragma applies. Note that in the case of accept formals, the pragma
6048 Unreferenced may appear immediately after the keyword @code{do} which
6049 allows the indication of whether or not accept formals are referenced
6050 or not to be given individually for each accept statement.
6051
6052 The left hand side of an assignment does not count as a reference for the
6053 purpose of this pragma. Thus it is fine to assign to an entity for which
6054 pragma Unreferenced is given.
6055
6056 Note that if a warning is desired for all calls to a given subprogram,
6057 regardless of whether they occur in the same unit as the subprogram
6058 declaration, then this pragma should not be used (calls from another
6059 unit would not be flagged); pragma Obsolescent can be used instead
6060 for this purpose, see @xref{Pragma Obsolescent}.
6061
6062 The second form of pragma @code{Unreferenced} is used within a context
6063 clause. In this case the arguments must be unit names of units previously
6064 mentioned in @code{with} clauses (similar to the usage of pragma
6065 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6066 units and unreferenced entities within these units.
6067
6068 @node Pragma Unreferenced_Objects
6069 @unnumberedsec Pragma Unreferenced_Objects
6070 @findex Unreferenced_Objects
6071 @cindex Warnings, unreferenced
6072 @noindent
6073 Syntax:
6074
6075 @smallexample @c ada
6076 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6077 @end smallexample
6078
6079 @noindent
6080 This pragma signals that for the types or subtypes whose names are
6081 listed, objects which are declared with one of these types or subtypes may
6082 not be referenced, and if no references appear, no warnings are given.
6083
6084 This is particularly useful for objects which are declared solely for their
6085 initialization and finalization effect. Such variables are sometimes referred
6086 to as RAII variables (Resource Acquisition Is Initialization). Using this
6087 pragma on the relevant type (most typically a limited controlled type), the
6088 compiler will automatically suppress unwanted warnings about these variables
6089 not being referenced.
6090
6091 @node Pragma Unreserve_All_Interrupts
6092 @unnumberedsec Pragma Unreserve_All_Interrupts
6093 @findex Unreserve_All_Interrupts
6094 @noindent
6095 Syntax:
6096
6097 @smallexample @c ada
6098 pragma Unreserve_All_Interrupts;
6099 @end smallexample
6100
6101 @noindent
6102 Normally certain interrupts are reserved to the implementation. Any attempt
6103 to attach an interrupt causes Program_Error to be raised, as described in
6104 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6105 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6106 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6107 interrupt execution.
6108
6109 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6110 a program, then all such interrupts are unreserved. This allows the
6111 program to handle these interrupts, but disables their standard
6112 functions. For example, if this pragma is used, then pressing
6113 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6114 a program can then handle the @code{SIGINT} interrupt as it chooses.
6115
6116 For a full list of the interrupts handled in a specific implementation,
6117 see the source code for the spec of @code{Ada.Interrupts.Names} in
6118 file @file{a-intnam.ads}. This is a target dependent file that contains the
6119 list of interrupts recognized for a given target. The documentation in
6120 this file also specifies what interrupts are affected by the use of
6121 the @code{Unreserve_All_Interrupts} pragma.
6122
6123 For a more general facility for controlling what interrupts can be
6124 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6125 of the @code{Unreserve_All_Interrupts} pragma.
6126
6127 @node Pragma Unsuppress
6128 @unnumberedsec Pragma Unsuppress
6129 @findex Unsuppress
6130 @noindent
6131 Syntax:
6132
6133 @smallexample @c ada
6134 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6135 @end smallexample
6136
6137 @noindent
6138 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6139 there is no corresponding pragma @code{Suppress} in effect, it has no
6140 effect. The range of the effect is the same as for pragma
6141 @code{Suppress}. The meaning of the arguments is identical to that used
6142 in pragma @code{Suppress}.
6143
6144 One important application is to ensure that checks are on in cases where
6145 code depends on the checks for its correct functioning, so that the code
6146 will compile correctly even if the compiler switches are set to suppress
6147 checks.
6148
6149 This pragma is standard in Ada 2005. It is available in all earlier versions
6150 of Ada as an implementation-defined pragma.
6151
6152 @node Pragma Use_VADS_Size
6153 @unnumberedsec Pragma Use_VADS_Size
6154 @cindex @code{Size}, VADS compatibility
6155 @cindex Rational profile
6156 @findex Use_VADS_Size
6157 @noindent
6158 Syntax:
6159
6160 @smallexample @c ada
6161 pragma Use_VADS_Size;
6162 @end smallexample
6163
6164 @noindent
6165 This is a configuration pragma. In a unit to which it applies, any use
6166 of the 'Size attribute is automatically interpreted as a use of the
6167 'VADS_Size attribute. Note that this may result in incorrect semantic
6168 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6169 the handling of existing code which depends on the interpretation of Size
6170 as implemented in the VADS compiler. See description of the VADS_Size
6171 attribute for further details.
6172
6173 @node Pragma Validity_Checks
6174 @unnumberedsec Pragma Validity_Checks
6175 @findex Validity_Checks
6176 @noindent
6177 Syntax:
6178
6179 @smallexample @c ada
6180 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6181 @end smallexample
6182
6183 @noindent
6184 This pragma is used in conjunction with compiler switches to control the
6185 built-in validity checking provided by GNAT@. The compiler switches, if set
6186 provide an initial setting for the switches, and this pragma may be used
6187 to modify these settings, or the settings may be provided entirely by
6188 the use of the pragma. This pragma can be used anywhere that a pragma
6189 is legal, including use as a configuration pragma (including use in
6190 the @file{gnat.adc} file).
6191
6192 The form with a string literal specifies which validity options are to be
6193 activated. The validity checks are first set to include only the default
6194 reference manual settings, and then a string of letters in the string
6195 specifies the exact set of options required. The form of this string
6196 is exactly as described for the @option{-gnatVx} compiler switch (see the
6197 @value{EDITION} User's Guide for details). For example the following two
6198 methods can be used to enable validity checking for mode @code{in} and
6199 @code{in out} subprogram parameters:
6200
6201 @itemize @bullet
6202 @item
6203 @smallexample @c ada
6204 pragma Validity_Checks ("im");
6205 @end smallexample
6206
6207 @item
6208 @smallexample
6209 gcc -c -gnatVim @dots{}
6210 @end smallexample
6211 @end itemize
6212
6213 @noindent
6214 The form ALL_CHECKS activates all standard checks (its use is equivalent
6215 to the use of the @code{gnatva} switch.
6216
6217 The forms with @code{Off} and @code{On}
6218 can be used to temporarily disable validity checks
6219 as shown in the following example:
6220
6221 @smallexample @c ada
6222 @iftex
6223 @leftskip=0cm
6224 @end iftex
6225 pragma Validity_Checks ("c"); -- validity checks for copies
6226 pragma Validity_Checks (Off); -- turn off validity checks
6227 A := B; -- B will not be validity checked
6228 pragma Validity_Checks (On); -- turn validity checks back on
6229 A := C; -- C will be validity checked
6230 @end smallexample
6231
6232 @node Pragma Volatile
6233 @unnumberedsec Pragma Volatile
6234 @findex Volatile
6235 @noindent
6236 Syntax:
6237
6238 @smallexample @c ada
6239 pragma Volatile (LOCAL_NAME);
6240 @end smallexample
6241
6242 @noindent
6243 This pragma is defined by the Ada Reference Manual, and the GNAT
6244 implementation is fully conformant with this definition. The reason it
6245 is mentioned in this section is that a pragma of the same name was supplied
6246 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6247 implementation of pragma Volatile is upwards compatible with the
6248 implementation in DEC Ada 83.
6249
6250 @node Pragma Warnings
6251 @unnumberedsec Pragma Warnings
6252 @findex Warnings
6253 @noindent
6254 Syntax:
6255
6256 @smallexample @c ada
6257 pragma Warnings (On | Off);
6258 pragma Warnings (On | Off, LOCAL_NAME);
6259 pragma Warnings (static_string_EXPRESSION);
6260 pragma Warnings (On | Off, static_string_EXPRESSION);
6261 @end smallexample
6262
6263 @noindent
6264 Normally warnings are enabled, with the output being controlled by
6265 the command line switch. Warnings (@code{Off}) turns off generation of
6266 warnings until a Warnings (@code{On}) is encountered or the end of the
6267 current unit. If generation of warnings is turned off using this
6268 pragma, then no warning messages are output, regardless of the
6269 setting of the command line switches.
6270
6271 The form with a single argument may be used as a configuration pragma.
6272
6273 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6274 the specified entity. This suppression is effective from the point where
6275 it occurs till the end of the extended scope of the variable (similar to
6276 the scope of @code{Suppress}).
6277
6278 The form with a single static_string_EXPRESSION argument provides more precise
6279 control over which warnings are active. The string is a list of letters
6280 specifying which warnings are to be activated and which deactivated. The
6281 code for these letters is the same as the string used in the command
6282 line switch controlling warnings. For a brief summary, use the gnatmake
6283 command with no arguments, which will generate usage information containing
6284 the list of warnings switches supported. For
6285 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6286 User's Guide}.
6287
6288 @noindent
6289 The warnings controlled by the `-gnatw' switch are generated by the front end
6290 of the compiler. The `GCC' back end can provide additional warnings and they
6291 are controlled by the `-W' switch.
6292 The form with a single static_string_EXPRESSION argument also works for the
6293 latters, but the string must be a single full `-W' switch in this case.
6294 The above reference lists a few examples of these additional warnings.
6295
6296 @noindent
6297 The specified warnings will be in effect until the end of the program
6298 or another pragma Warnings is encountered. The effect of the pragma is
6299 cumulative. Initially the set of warnings is the standard default set
6300 as possibly modified by compiler switches. Then each pragma Warning
6301 modifies this set of warnings as specified. This form of the pragma may
6302 also be used as a configuration pragma.
6303
6304 The fourth form, with an @code{On|Off} parameter and a string, is used to
6305 control individual messages, based on their text. The string argument
6306 is a pattern that is used to match against the text of individual
6307 warning messages (not including the initial "warning: " tag).
6308
6309 The pattern may contain asterisks, which match zero or more characters in
6310 the message. For example, you can use
6311 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6312 message @code{warning: 960 bits of "a" unused}. No other regular
6313 expression notations are permitted. All characters other than asterisk in
6314 these three specific cases are treated as literal characters in the match.
6315
6316 The above use of patterns to match the message applies only to warning
6317 messages generated by the front end. This form of the pragma with a
6318 string argument can also be used to control back end warnings controlled
6319 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6320 of a string of the form "[-Wxxx]" in the message which identifies the
6321 "-W" switch that controls the message. By using the text of the
6322 "-W" switch in the pragma, such back end warnings can be turned on and off.
6323
6324 There are two ways to use the pragma in this form. The OFF form can be used as a
6325 configuration pragma. The effect is to suppress all warnings (if any)
6326 that match the pattern string throughout the compilation (or match the
6327 -W switch in the back end case).
6328
6329 The second usage is to suppress a warning locally, and in this case, two
6330 pragmas must appear in sequence:
6331
6332 @smallexample @c ada
6333 pragma Warnings (Off, Pattern);
6334 @dots{} code where given warning is to be suppressed
6335 pragma Warnings (On, Pattern);
6336 @end smallexample
6337
6338 @noindent
6339 In this usage, the pattern string must match in the Off and On pragmas,
6340 and at least one matching warning must be suppressed.
6341
6342 Note: to write a string that will match any warning, use the string
6343 @code{"***"}. It will not work to use a single asterisk or two asterisks
6344 since this looks like an operator name. This form with three asterisks
6345 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
6346 matching @code{pragma Warnings (On, "***")} will be required. This can be
6347 helpful in avoiding forgetting to turn warnings back on.
6348
6349 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
6350 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6351 be useful in checking whether obsolete pragmas in existing programs are hiding
6352 real problems.
6353
6354 Note: pragma Warnings does not affect the processing of style messages. See
6355 separate entry for pragma Style_Checks for control of style messages.
6356
6357 @node Pragma Weak_External
6358 @unnumberedsec Pragma Weak_External
6359 @findex Weak_External
6360 @noindent
6361 Syntax:
6362
6363 @smallexample @c ada
6364 pragma Weak_External ([Entity =>] LOCAL_NAME);
6365 @end smallexample
6366
6367 @noindent
6368 @var{LOCAL_NAME} must refer to an object that is declared at the library
6369 level. This pragma specifies that the given entity should be marked as a
6370 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
6371 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
6372 of a regular symbol, that is to say a symbol that does not have to be
6373 resolved by the linker if used in conjunction with a pragma Import.
6374
6375 When a weak symbol is not resolved by the linker, its address is set to
6376 zero. This is useful in writing interfaces to external modules that may
6377 or may not be linked in the final executable, for example depending on
6378 configuration settings.
6379
6380 If a program references at run time an entity to which this pragma has been
6381 applied, and the corresponding symbol was not resolved at link time, then
6382 the execution of the program is erroneous. It is not erroneous to take the
6383 Address of such an entity, for example to guard potential references,
6384 as shown in the example below.
6385
6386 Some file formats do not support weak symbols so not all target machines
6387 support this pragma.
6388
6389 @smallexample @c ada
6390 -- Example of the use of pragma Weak_External
6391
6392 package External_Module is
6393 key : Integer;
6394 pragma Import (C, key);
6395 pragma Weak_External (key);
6396 function Present return boolean;
6397 end External_Module;
6398
6399 with System; use System;
6400 package body External_Module is
6401 function Present return boolean is
6402 begin
6403 return key'Address /= System.Null_Address;
6404 end Present;
6405 end External_Module;
6406 @end smallexample
6407
6408 @node Pragma Wide_Character_Encoding
6409 @unnumberedsec Pragma Wide_Character_Encoding
6410 @findex Wide_Character_Encoding
6411 @noindent
6412 Syntax:
6413
6414 @smallexample @c ada
6415 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6416 @end smallexample
6417
6418 @noindent
6419 This pragma specifies the wide character encoding to be used in program
6420 source text appearing subsequently. It is a configuration pragma, but may
6421 also be used at any point that a pragma is allowed, and it is permissible
6422 to have more than one such pragma in a file, allowing multiple encodings
6423 to appear within the same file.
6424
6425 The argument can be an identifier or a character literal. In the identifier
6426 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6427 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6428 case it is correspondingly one of the characters @samp{h}, @samp{u},
6429 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6430
6431 Note that when the pragma is used within a file, it affects only the
6432 encoding within that file, and does not affect withed units, specs,
6433 or subunits.
6434
6435 @node Implementation Defined Attributes
6436 @chapter Implementation Defined Attributes
6437 Ada defines (throughout the Ada reference manual,
6438 summarized in Annex K),
6439 a set of attributes that provide useful additional functionality in all
6440 areas of the language. These language defined attributes are implemented
6441 in GNAT and work as described in the Ada Reference Manual.
6442
6443 In addition, Ada allows implementations to define additional
6444 attributes whose meaning is defined by the implementation. GNAT provides
6445 a number of these implementation-dependent attributes which can be used
6446 to extend and enhance the functionality of the compiler. This section of
6447 the GNAT reference manual describes these additional attributes.
6448
6449 Note that any program using these attributes may not be portable to
6450 other compilers (although GNAT implements this set of attributes on all
6451 platforms). Therefore if portability to other compilers is an important
6452 consideration, you should minimize the use of these attributes.
6453
6454 @menu
6455 * Abort_Signal::
6456 * Address_Size::
6457 * Asm_Input::
6458 * Asm_Output::
6459 * AST_Entry::
6460 * Bit::
6461 * Bit_Position::
6462 * Compiler_Version::
6463 * Code_Address::
6464 * Default_Bit_Order::
6465 * Descriptor_Size::
6466 * Elaborated::
6467 * Elab_Body::
6468 * Elab_Spec::
6469 * Elab_Subp_Body::
6470 * Emax::
6471 * Enabled::
6472 * Enum_Rep::
6473 * Enum_Val::
6474 * Epsilon::
6475 * Fixed_Value::
6476 * Has_Access_Values::
6477 * Has_Discriminants::
6478 * Img::
6479 * Integer_Value::
6480 * Invalid_Value::
6481 * Large::
6482 * Machine_Size::
6483 * Mantissa::
6484 * Max_Interrupt_Priority::
6485 * Max_Priority::
6486 * Maximum_Alignment::
6487 * Mechanism_Code::
6488 * Null_Parameter::
6489 * Object_Size::
6490 * Passed_By_Reference::
6491 * Pool_Address::
6492 * Range_Length::
6493 * Ref::
6494 * Result::
6495 * Safe_Emax::
6496 * Safe_Large::
6497 * Scalar_Storage_Order::
6498 * Simple_Storage_Pool::
6499 * Small::
6500 * Storage_Unit::
6501 * Stub_Type::
6502 * System_Allocator_Alignment::
6503 * Target_Name::
6504 * Tick::
6505 * To_Address::
6506 * Type_Class::
6507 * UET_Address::
6508 * Unconstrained_Array::
6509 * Universal_Literal_String::
6510 * Unrestricted_Access::
6511 * Valid_Scalars::
6512 * VADS_Size::
6513 * Value_Size::
6514 * Wchar_T_Size::
6515 * Word_Size::
6516 @end menu
6517
6518 @node Abort_Signal
6519 @unnumberedsec Abort_Signal
6520 @findex Abort_Signal
6521 @noindent
6522 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6523 prefix) provides the entity for the special exception used to signal
6524 task abort or asynchronous transfer of control. Normally this attribute
6525 should only be used in the tasking runtime (it is highly peculiar, and
6526 completely outside the normal semantics of Ada, for a user program to
6527 intercept the abort exception).
6528
6529 @node Address_Size
6530 @unnumberedsec Address_Size
6531 @cindex Size of @code{Address}
6532 @findex Address_Size
6533 @noindent
6534 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6535 prefix) is a static constant giving the number of bits in an
6536 @code{Address}. It is the same value as System.Address'Size,
6537 but has the advantage of being static, while a direct
6538 reference to System.Address'Size is non-static because Address
6539 is a private type.
6540
6541 @node Asm_Input
6542 @unnumberedsec Asm_Input
6543 @findex Asm_Input
6544 @noindent
6545 The @code{Asm_Input} attribute denotes a function that takes two
6546 parameters. The first is a string, the second is an expression of the
6547 type designated by the prefix. The first (string) argument is required
6548 to be a static expression, and is the constraint for the parameter,
6549 (e.g.@: what kind of register is required). The second argument is the
6550 value to be used as the input argument. The possible values for the
6551 constant are the same as those used in the RTL, and are dependent on
6552 the configuration file used to built the GCC back end.
6553 @ref{Machine Code Insertions}
6554
6555 @node Asm_Output
6556 @unnumberedsec Asm_Output
6557 @findex Asm_Output
6558 @noindent
6559 The @code{Asm_Output} attribute denotes a function that takes two
6560 parameters. The first is a string, the second is the name of a variable
6561 of the type designated by the attribute prefix. The first (string)
6562 argument is required to be a static expression and designates the
6563 constraint for the parameter (e.g.@: what kind of register is
6564 required). The second argument is the variable to be updated with the
6565 result. The possible values for constraint are the same as those used in
6566 the RTL, and are dependent on the configuration file used to build the
6567 GCC back end. If there are no output operands, then this argument may
6568 either be omitted, or explicitly given as @code{No_Output_Operands}.
6569 @ref{Machine Code Insertions}
6570
6571 @node AST_Entry
6572 @unnumberedsec AST_Entry
6573 @cindex OpenVMS
6574 @findex AST_Entry
6575 @noindent
6576 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6577 the name of an entry, it yields a value of the predefined type AST_Handler
6578 (declared in the predefined package System, as extended by the use of
6579 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6580 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6581 Language Reference Manual}, section 9.12a.
6582
6583 @node Bit
6584 @unnumberedsec Bit
6585 @findex Bit
6586 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6587 offset within the storage unit (byte) that contains the first bit of
6588 storage allocated for the object. The value of this attribute is of the
6589 type @code{Universal_Integer}, and is always a non-negative number not
6590 exceeding the value of @code{System.Storage_Unit}.
6591
6592 For an object that is a variable or a constant allocated in a register,
6593 the value is zero. (The use of this attribute does not force the
6594 allocation of a variable to memory).
6595
6596 For an object that is a formal parameter, this attribute applies
6597 to either the matching actual parameter or to a copy of the
6598 matching actual parameter.
6599
6600 For an access object the value is zero. Note that
6601 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6602 designated object. Similarly for a record component
6603 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6604 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6605 are subject to index checks.
6606
6607 This attribute is designed to be compatible with the DEC Ada 83 definition
6608 and implementation of the @code{Bit} attribute.
6609
6610 @node Bit_Position
6611 @unnumberedsec Bit_Position
6612 @findex Bit_Position
6613 @noindent
6614 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6615 of the fields of the record type, yields the bit
6616 offset within the record contains the first bit of
6617 storage allocated for the object. The value of this attribute is of the
6618 type @code{Universal_Integer}. The value depends only on the field
6619 @var{C} and is independent of the alignment of
6620 the containing record @var{R}.
6621
6622 @node Compiler_Version
6623 @unnumberedsec Compiler_Version
6624 @findex Compiler_Version
6625 @noindent
6626 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6627 prefix) yields a static string identifying the version of the compiler
6628 being used to compile the unit containing the attribute reference. A
6629 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6630
6631 @node Code_Address
6632 @unnumberedsec Code_Address
6633 @findex Code_Address
6634 @cindex Subprogram address
6635 @cindex Address of subprogram code
6636 @noindent
6637 The @code{'Address}
6638 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6639 intended effect seems to be to provide
6640 an address value which can be used to call the subprogram by means of
6641 an address clause as in the following example:
6642
6643 @smallexample @c ada
6644 procedure K is @dots{}
6645
6646 procedure L;
6647 for L'Address use K'Address;
6648 pragma Import (Ada, L);
6649 @end smallexample
6650
6651 @noindent
6652 A call to @code{L} is then expected to result in a call to @code{K}@.
6653 In Ada 83, where there were no access-to-subprogram values, this was
6654 a common work-around for getting the effect of an indirect call.
6655 GNAT implements the above use of @code{Address} and the technique
6656 illustrated by the example code works correctly.
6657
6658 However, for some purposes, it is useful to have the address of the start
6659 of the generated code for the subprogram. On some architectures, this is
6660 not necessarily the same as the @code{Address} value described above.
6661 For example, the @code{Address} value may reference a subprogram
6662 descriptor rather than the subprogram itself.
6663
6664 The @code{'Code_Address} attribute, which can only be applied to
6665 subprogram entities, always returns the address of the start of the
6666 generated code of the specified subprogram, which may or may not be
6667 the same value as is returned by the corresponding @code{'Address}
6668 attribute.
6669
6670 @node Default_Bit_Order
6671 @unnumberedsec Default_Bit_Order
6672 @cindex Big endian
6673 @cindex Little endian
6674 @findex Default_Bit_Order
6675 @noindent
6676 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6677 permissible prefix), provides the value @code{System.Default_Bit_Order}
6678 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6679 @code{Low_Order_First}). This is used to construct the definition of
6680 @code{Default_Bit_Order} in package @code{System}.
6681
6682 @node Descriptor_Size
6683 @unnumberedsec Descriptor_Size
6684 @cindex Descriptor
6685 @cindex Dope vector
6686 @findex Descriptor_Size
6687 @noindent
6688 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6689 descriptor allocated for a type. The result is non-zero only for unconstrained
6690 array types and the returned value is of type universal integer. In GNAT, an
6691 array descriptor contains bounds information and is located immediately before
6692 the first element of the array.
6693
6694 @smallexample @c ada
6695 type Unconstr_Array is array (Positive range <>) of Boolean;
6696 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6697 @end smallexample
6698
6699 @noindent
6700 The attribute takes into account any additional padding due to type alignment.
6701 In the example above, the descriptor contains two values of type
6702 @code{Positive} representing the low and high bound. Since @code{Positive} has
6703 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6704 Positive'Size + 2} or 64 bits.
6705
6706 @node Elaborated
6707 @unnumberedsec Elaborated
6708 @findex Elaborated
6709 @noindent
6710 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6711 value is a Boolean which indicates whether or not the given unit has been
6712 elaborated. This attribute is primarily intended for internal use by the
6713 generated code for dynamic elaboration checking, but it can also be used
6714 in user programs. The value will always be True once elaboration of all
6715 units has been completed. An exception is for units which need no
6716 elaboration, the value is always False for such units.
6717
6718 @node Elab_Body
6719 @unnumberedsec Elab_Body
6720 @findex Elab_Body
6721 @noindent
6722 This attribute can only be applied to a program unit name. It returns
6723 the entity for the corresponding elaboration procedure for elaborating
6724 the body of the referenced unit. This is used in the main generated
6725 elaboration procedure by the binder and is not normally used in any
6726 other context. However, there may be specialized situations in which it
6727 is useful to be able to call this elaboration procedure from Ada code,
6728 e.g.@: if it is necessary to do selective re-elaboration to fix some
6729 error.
6730
6731 @node Elab_Spec
6732 @unnumberedsec Elab_Spec
6733 @findex Elab_Spec
6734 @noindent
6735 This attribute can only be applied to a program unit name. It returns
6736 the entity for the corresponding elaboration procedure for elaborating
6737 the spec of the referenced unit. This is used in the main
6738 generated elaboration procedure by the binder and is not normally used
6739 in any other context. However, there may be specialized situations in
6740 which it is useful to be able to call this elaboration procedure from
6741 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6742 some error.
6743
6744 @node Elab_Subp_Body
6745 @unnumberedsec Elab_Subp_Body
6746 @findex Elab_Subp_Body
6747 @noindent
6748 This attribute can only be applied to a library level subprogram
6749 name and is only allowed in CodePeer mode. It returns the entity
6750 for the corresponding elaboration procedure for elaborating the body
6751 of the referenced subprogram unit. This is used in the main generated
6752 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6753 otherwise.
6754
6755 @node Emax
6756 @unnumberedsec Emax
6757 @cindex Ada 83 attributes
6758 @findex Emax
6759 @noindent
6760 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6761 the Ada 83 reference manual for an exact description of the semantics of
6762 this attribute.
6763
6764 @node Enabled
6765 @unnumberedsec Enabled
6766 @findex Enabled
6767 @noindent
6768 The @code{Enabled} attribute allows an application program to check at compile
6769 time to see if the designated check is currently enabled. The prefix is a
6770 simple identifier, referencing any predefined check name (other than
6771 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6772 no argument is given for the attribute, the check is for the general state
6773 of the check, if an argument is given, then it is an entity name, and the
6774 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6775 given naming the entity (if not, then the argument is ignored).
6776
6777 Note that instantiations inherit the check status at the point of the
6778 instantiation, so a useful idiom is to have a library package that
6779 introduces a check name with @code{pragma Check_Name}, and then contains
6780 generic packages or subprograms which use the @code{Enabled} attribute
6781 to see if the check is enabled. A user of this package can then issue
6782 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6783 the package or subprogram, controlling whether the check will be present.
6784
6785 @node Enum_Rep
6786 @unnumberedsec Enum_Rep
6787 @cindex Representation of enums
6788 @findex Enum_Rep
6789 @noindent
6790 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6791 function with the following spec:
6792
6793 @smallexample @c ada
6794 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6795 return @i{Universal_Integer};
6796 @end smallexample
6797
6798 @noindent
6799 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6800 enumeration type or to a non-overloaded enumeration
6801 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6802 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6803 enumeration literal or object.
6804
6805 The function returns the representation value for the given enumeration
6806 value. This will be equal to value of the @code{Pos} attribute in the
6807 absence of an enumeration representation clause. This is a static
6808 attribute (i.e.@: the result is static if the argument is static).
6809
6810 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6811 in which case it simply returns the integer value. The reason for this
6812 is to allow it to be used for @code{(<>)} discrete formal arguments in
6813 a generic unit that can be instantiated with either enumeration types
6814 or integer types. Note that if @code{Enum_Rep} is used on a modular
6815 type whose upper bound exceeds the upper bound of the largest signed
6816 integer type, and the argument is a variable, so that the universal
6817 integer calculation is done at run time, then the call to @code{Enum_Rep}
6818 may raise @code{Constraint_Error}.
6819
6820 @node Enum_Val
6821 @unnumberedsec Enum_Val
6822 @cindex Representation of enums
6823 @findex Enum_Val
6824 @noindent
6825 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6826 function with the following spec:
6827
6828 @smallexample @c ada
6829 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6830 return @var{S}'Base};
6831 @end smallexample
6832
6833 @noindent
6834 The function returns the enumeration value whose representation matches the
6835 argument, or raises Constraint_Error if no enumeration literal of the type
6836 has the matching value.
6837 This will be equal to value of the @code{Val} attribute in the
6838 absence of an enumeration representation clause. This is a static
6839 attribute (i.e.@: the result is static if the argument is static).
6840
6841 @node Epsilon
6842 @unnumberedsec Epsilon
6843 @cindex Ada 83 attributes
6844 @findex Epsilon
6845 @noindent
6846 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6847 the Ada 83 reference manual for an exact description of the semantics of
6848 this attribute.
6849
6850 @node Fixed_Value
6851 @unnumberedsec Fixed_Value
6852 @findex Fixed_Value
6853 @noindent
6854 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6855 function with the following specification:
6856
6857 @smallexample @c ada
6858 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6859 return @var{S};
6860 @end smallexample
6861
6862 @noindent
6863 The value returned is the fixed-point value @var{V} such that
6864
6865 @smallexample @c ada
6866 @var{V} = Arg * @var{S}'Small
6867 @end smallexample
6868
6869 @noindent
6870 The effect is thus similar to first converting the argument to the
6871 integer type used to represent @var{S}, and then doing an unchecked
6872 conversion to the fixed-point type. The difference is
6873 that there are full range checks, to ensure that the result is in range.
6874 This attribute is primarily intended for use in implementation of the
6875 input-output functions for fixed-point values.
6876
6877 @node Has_Access_Values
6878 @unnumberedsec Has_Access_Values
6879 @cindex Access values, testing for
6880 @findex Has_Access_Values
6881 @noindent
6882 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6883 is a Boolean value which is True if the is an access type, or is a composite
6884 type with a component (at any nesting depth) that is an access type, and is
6885 False otherwise.
6886 The intended use of this attribute is in conjunction with generic
6887 definitions. If the attribute is applied to a generic private type, it
6888 indicates whether or not the corresponding actual type has access values.
6889
6890 @node Has_Discriminants
6891 @unnumberedsec Has_Discriminants
6892 @cindex Discriminants, testing for
6893 @findex Has_Discriminants
6894 @noindent
6895 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6896 is a Boolean value which is True if the type has discriminants, and False
6897 otherwise. The intended use of this attribute is in conjunction with generic
6898 definitions. If the attribute is applied to a generic private type, it
6899 indicates whether or not the corresponding actual type has discriminants.
6900
6901 @node Img
6902 @unnumberedsec Img
6903 @findex Img
6904 @noindent
6905 The @code{Img} attribute differs from @code{Image} in that it may be
6906 applied to objects as well as types, in which case it gives the
6907 @code{Image} for the subtype of the object. This is convenient for
6908 debugging:
6909
6910 @smallexample @c ada
6911 Put_Line ("X = " & X'Img);
6912 @end smallexample
6913
6914 @noindent
6915 has the same meaning as the more verbose:
6916
6917 @smallexample @c ada
6918 Put_Line ("X = " & @var{T}'Image (X));
6919 @end smallexample
6920
6921 @noindent
6922 where @var{T} is the (sub)type of the object @code{X}.
6923
6924 @node Integer_Value
6925 @unnumberedsec Integer_Value
6926 @findex Integer_Value
6927 @noindent
6928 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6929 function with the following spec:
6930
6931 @smallexample @c ada
6932 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6933 return @var{S};
6934 @end smallexample
6935
6936 @noindent
6937 The value returned is the integer value @var{V}, such that
6938
6939 @smallexample @c ada
6940 Arg = @var{V} * @var{T}'Small
6941 @end smallexample
6942
6943 @noindent
6944 where @var{T} is the type of @code{Arg}.
6945 The effect is thus similar to first doing an unchecked conversion from
6946 the fixed-point type to its corresponding implementation type, and then
6947 converting the result to the target integer type. The difference is
6948 that there are full range checks, to ensure that the result is in range.
6949 This attribute is primarily intended for use in implementation of the
6950 standard input-output functions for fixed-point values.
6951
6952 @node Invalid_Value
6953 @unnumberedsec Invalid_Value
6954 @findex Invalid_Value
6955 @noindent
6956 For every scalar type S, S'Invalid_Value returns an undefined value of the
6957 type. If possible this value is an invalid representation for the type. The
6958 value returned is identical to the value used to initialize an otherwise
6959 uninitialized value of the type if pragma Initialize_Scalars is used,
6960 including the ability to modify the value with the binder -Sxx flag and
6961 relevant environment variables at run time.
6962
6963 @node Large
6964 @unnumberedsec Large
6965 @cindex Ada 83 attributes
6966 @findex Large
6967 @noindent
6968 The @code{Large} attribute is provided for compatibility with Ada 83. See
6969 the Ada 83 reference manual for an exact description of the semantics of
6970 this attribute.
6971
6972 @node Machine_Size
6973 @unnumberedsec Machine_Size
6974 @findex Machine_Size
6975 @noindent
6976 This attribute is identical to the @code{Object_Size} attribute. It is
6977 provided for compatibility with the DEC Ada 83 attribute of this name.
6978
6979 @node Mantissa
6980 @unnumberedsec Mantissa
6981 @cindex Ada 83 attributes
6982 @findex Mantissa
6983 @noindent
6984 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6985 the Ada 83 reference manual for an exact description of the semantics of
6986 this attribute.
6987
6988 @node Max_Interrupt_Priority
6989 @unnumberedsec Max_Interrupt_Priority
6990 @cindex Interrupt priority, maximum
6991 @findex Max_Interrupt_Priority
6992 @noindent
6993 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6994 permissible prefix), provides the same value as
6995 @code{System.Max_Interrupt_Priority}.
6996
6997 @node Max_Priority
6998 @unnumberedsec Max_Priority
6999 @cindex Priority, maximum
7000 @findex Max_Priority
7001 @noindent
7002 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
7003 prefix) provides the same value as @code{System.Max_Priority}.
7004
7005 @node Maximum_Alignment
7006 @unnumberedsec Maximum_Alignment
7007 @cindex Alignment, maximum
7008 @findex Maximum_Alignment
7009 @noindent
7010 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
7011 permissible prefix) provides the maximum useful alignment value for the
7012 target. This is a static value that can be used to specify the alignment
7013 for an object, guaranteeing that it is properly aligned in all
7014 cases.
7015
7016 @node Mechanism_Code
7017 @unnumberedsec Mechanism_Code
7018 @cindex Return values, passing mechanism
7019 @cindex Parameters, passing mechanism
7020 @findex Mechanism_Code
7021 @noindent
7022 @code{@var{function}'Mechanism_Code} yields an integer code for the
7023 mechanism used for the result of function, and
7024 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
7025 used for formal parameter number @var{n} (a static integer value with 1
7026 meaning the first parameter) of @var{subprogram}. The code returned is:
7027
7028 @table @asis
7029 @item 1
7030 by copy (value)
7031 @item 2
7032 by reference
7033 @item 3
7034 by descriptor (default descriptor class)
7035 @item 4
7036 by descriptor (UBS: unaligned bit string)
7037 @item 5
7038 by descriptor (UBSB: aligned bit string with arbitrary bounds)
7039 @item 6
7040 by descriptor (UBA: unaligned bit array)
7041 @item 7
7042 by descriptor (S: string, also scalar access type parameter)
7043 @item 8
7044 by descriptor (SB: string with arbitrary bounds)
7045 @item 9
7046 by descriptor (A: contiguous array)
7047 @item 10
7048 by descriptor (NCA: non-contiguous array)
7049 @end table
7050
7051 @noindent
7052 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
7053 @cindex OpenVMS
7054
7055 @node Null_Parameter
7056 @unnumberedsec Null_Parameter
7057 @cindex Zero address, passing
7058 @findex Null_Parameter
7059 @noindent
7060 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
7061 type or subtype @var{T} allocated at machine address zero. The attribute
7062 is allowed only as the default expression of a formal parameter, or as
7063 an actual expression of a subprogram call. In either case, the
7064 subprogram must be imported.
7065
7066 The identity of the object is represented by the address zero in the
7067 argument list, independent of the passing mechanism (explicit or
7068 default).
7069
7070 This capability is needed to specify that a zero address should be
7071 passed for a record or other composite object passed by reference.
7072 There is no way of indicating this without the @code{Null_Parameter}
7073 attribute.
7074
7075 @node Object_Size
7076 @unnumberedsec Object_Size
7077 @cindex Size, used for objects
7078 @findex Object_Size
7079 @noindent
7080 The size of an object is not necessarily the same as the size of the type
7081 of an object. This is because by default object sizes are increased to be
7082 a multiple of the alignment of the object. For example,
7083 @code{Natural'Size} is
7084 31, but by default objects of type @code{Natural} will have a size of 32 bits.
7085 Similarly, a record containing an integer and a character:
7086
7087 @smallexample @c ada
7088 type Rec is record
7089 I : Integer;
7090 C : Character;
7091 end record;
7092 @end smallexample
7093
7094 @noindent
7095 will have a size of 40 (that is @code{Rec'Size} will be 40). The
7096 alignment will be 4, because of the
7097 integer field, and so the default size of record objects for this type
7098 will be 64 (8 bytes).
7099
7100 @node Passed_By_Reference
7101 @unnumberedsec Passed_By_Reference
7102 @cindex Parameters, when passed by reference
7103 @findex Passed_By_Reference
7104 @noindent
7105 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
7106 a value of type @code{Boolean} value that is @code{True} if the type is
7107 normally passed by reference and @code{False} if the type is normally
7108 passed by copy in calls. For scalar types, the result is always @code{False}
7109 and is static. For non-scalar types, the result is non-static.
7110
7111 @node Pool_Address
7112 @unnumberedsec Pool_Address
7113 @cindex Parameters, when passed by reference
7114 @findex Pool_Address
7115 @noindent
7116 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
7117 of X within its storage pool. This is the same as
7118 @code{@var{X}'Address}, except that for an unconstrained array whose
7119 bounds are allocated just before the first component,
7120 @code{@var{X}'Pool_Address} returns the address of those bounds,
7121 whereas @code{@var{X}'Address} returns the address of the first
7122 component.
7123
7124 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
7125 the object is allocated'', which could be a user-defined storage pool,
7126 the global heap, on the stack, or in a static memory area. For an
7127 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
7128 what is passed to @code{Allocate} and returned from @code{Deallocate}.
7129
7130 @node Range_Length
7131 @unnumberedsec Range_Length
7132 @findex Range_Length
7133 @noindent
7134 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
7135 the number of values represented by the subtype (zero for a null
7136 range). The result is static for static subtypes. @code{Range_Length}
7137 applied to the index subtype of a one dimensional array always gives the
7138 same result as @code{Range} applied to the array itself.
7139
7140 @node Ref
7141 @unnumberedsec Ref
7142 @findex Ref
7143 @noindent
7144 The @code{System.Address'Ref}
7145 (@code{System.Address} is the only permissible prefix)
7146 denotes a function identical to
7147 @code{System.Storage_Elements.To_Address} except that
7148 it is a static attribute. See @ref{To_Address} for more details.
7149
7150 @node Result
7151 @unnumberedsec Result
7152 @findex Result
7153 @noindent
7154 @code{@var{function}'Result} can only be used with in a Postcondition pragma
7155 for a function. The prefix must be the name of the corresponding function. This
7156 is used to refer to the result of the function in the postcondition expression.
7157 For a further discussion of the use of this attribute and examples of its use,
7158 see the description of pragma Postcondition.
7159
7160 @node Safe_Emax
7161 @unnumberedsec Safe_Emax
7162 @cindex Ada 83 attributes
7163 @findex Safe_Emax
7164 @noindent
7165 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
7166 the Ada 83 reference manual for an exact description of the semantics of
7167 this attribute.
7168
7169 @node Safe_Large
7170 @unnumberedsec Safe_Large
7171 @cindex Ada 83 attributes
7172 @findex Safe_Large
7173 @noindent
7174 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
7175 the Ada 83 reference manual for an exact description of the semantics of
7176 this attribute.
7177
7178 @node Scalar_Storage_Order
7179 @unnumberedsec Scalar_Storage_Order
7180 @cindex Endianness
7181 @cindex Scalar storage order
7182 @findex Scalar_Storage_Order
7183 @noindent
7184 For every array or record type @var{S}, the representation attribute
7185 @code{Scalar_Storage_Order} denotes the order in which storage elements
7186 that make up scalar components are ordered within S:
7187
7188 @smallexample @c ada
7189 -- Component type definitions
7190
7191 subtype Yr_Type is Natural range 0 .. 127;
7192 subtype Mo_Type is Natural range 1 .. 12;
7193 subtype Da_Type is Natural range 1 .. 31;
7194
7195 -- Record declaration
7196
7197 type Date is record
7198 Years_Since_1980 : Yr_Type;
7199 Month : Mo_Type;
7200 Day_Of_Month : Da_Type;
7201 end record;
7202
7203 -- Record representation clause
7204
7205 for Date use record
7206 Years_Since_1980 at 0 range 0 .. 6;
7207 Month at 0 range 7 .. 10;
7208 Day_Of_Month at 0 range 11 .. 15;
7209 end record;
7210
7211 -- Attribute definition clauses
7212
7213 for Date'Bit_Order use System.High_Order_First;
7214 for Date'Scalar_Storage_Order use System.High_Order_First;
7215 -- If Scalar_Storage_Order is specified, it must be consistent with
7216 -- Bit_Order, so it's best to always define the latter explicitly if
7217 -- the former is used.
7218 @end smallexample
7219
7220 Other properties are
7221 as for standard representation attribute @code{Bit_Order}, as defined by
7222 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
7223
7224 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
7225 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
7226 this means that if a @code{Scalar_Storage_Order} attribute definition
7227 clause is not confirming, then the type's @code{Bit_Order} shall be
7228 specified explicitly and set to the same value.
7229
7230 For a record extension, the derived type shall have the same scalar storage
7231 order as the parent type.
7232
7233 If a component of @var{S} has itself a record or array type, then it shall also
7234 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
7235 if the component does not start on a byte boundary, then the scalar storage
7236 order specified for S and for the nested component type shall be identical.
7237
7238 No component of a type that has a @code{Scalar_Storage_Order} attribute
7239 definition may be aliased.
7240
7241 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
7242 with a value equal to @code{System.Default_Bit_Order}) has no effect.
7243
7244 If the opposite storage order is specified, then whenever the value of
7245 a scalar component of an object of type @var{S} is read, the storage
7246 elements of the enclosing machine scalar are first reversed (before
7247 retrieving the component value, possibly applying some shift and mask
7248 operatings on the enclosing machine scalar), and the opposite operation
7249 is done for writes.
7250
7251 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
7252 are relaxed. Instead, the following rules apply:
7253
7254 @itemize @bullet
7255 @item the underlying storage elements are those at positions
7256 @code{(position + first_bit / storage_element_size) ..
7257 (position + (last_bit + storage_element_size - 1) /
7258 storage_element_size)}
7259 @item the sequence of underlying storage elements shall have
7260 a size no greater than the largest machine scalar
7261 @item the enclosing machine scalar is defined as the smallest machine
7262 scalar starting at a position no greater than
7263 @code{position + first_bit / storage_element_size} and covering
7264 storage elements at least up to @code{position + (last_bit +
7265 storage_element_size - 1) / storage_element_size}
7266 @item the position of the component is interpreted relative to that machine
7267 scalar.
7268
7269 @end itemize
7270
7271 @node Simple_Storage_Pool
7272 @unnumberedsec Simple_Storage_Pool
7273 @cindex Storage pool, simple
7274 @cindex Simple storage pool
7275 @findex Simple_Storage_Pool
7276 @noindent
7277 For every nonformal, nonderived access-to-object type @var{Acc}, the
7278 representation attribute @code{Simple_Storage_Pool} may be specified
7279 via an attribute_definition_clause (or by specifying the equivalent aspect):
7280
7281 @smallexample @c ada
7282
7283 My_Pool : My_Simple_Storage_Pool_Type;
7284
7285 type Acc is access My_Data_Type;
7286
7287 for Acc'Simple_Storage_Pool use My_Pool;
7288
7289 @end smallexample
7290
7291 @noindent
7292 The name given in an attribute_definition_clause for the
7293 @code{Simple_Storage_Pool} attribute shall denote a variable of
7294 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
7295
7296 The use of this attribute is only allowed for a prefix denoting a type
7297 for which it has been specified. The type of the attribute is the type
7298 of the variable specified as the simple storage pool of the access type,
7299 and the attribute denotes that variable.
7300
7301 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
7302 for the same access type.
7303
7304 If the @code{Simple_Storage_Pool} attribute has been specified for an access
7305 type, then applying the @code{Storage_Pool} attribute to the type is flagged
7306 with a warning and its evaluation raises the exception @code{Program_Error}.
7307
7308 If the Simple_Storage_Pool attribute has been specified for an access
7309 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
7310 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
7311 which is intended to indicate the number of storage elements reserved for
7312 the simple storage pool. If the Storage_Size function has not been defined
7313 for the simple storage pool type, then this attribute returns zero.
7314
7315 If an access type @var{S} has a specified simple storage pool of type
7316 @var{SSP}, then the evaluation of an allocator for that access type calls
7317 the primitive @code{Allocate} procedure for type @var{SSP}, passing
7318 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
7319 semantics of such allocators is the same as those defined for allocators
7320 in section 13.11 of the Ada Reference Manual, with the term
7321 ``simple storage pool'' substituted for ``storage pool''.
7322
7323 If an access type @var{S} has a specified simple storage pool of type
7324 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
7325 for that access type invokes the primitive @code{Deallocate} procedure
7326 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
7327 parameter. The detailed semantics of such unchecked deallocations is the same
7328 as defined in section 13.11.2 of the Ada Reference Manual, except that the
7329 term ``simple storage pool'' is substituted for ``storage pool''.
7330
7331 @node Small
7332 @unnumberedsec Small
7333 @cindex Ada 83 attributes
7334 @findex Small
7335 @noindent
7336 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
7337 fixed-point types.
7338 GNAT also allows this attribute to be applied to floating-point types
7339 for compatibility with Ada 83. See
7340 the Ada 83 reference manual for an exact description of the semantics of
7341 this attribute when applied to floating-point types.
7342
7343 @node Storage_Unit
7344 @unnumberedsec Storage_Unit
7345 @findex Storage_Unit
7346 @noindent
7347 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
7348 prefix) provides the same value as @code{System.Storage_Unit}.
7349
7350 @node Stub_Type
7351 @unnumberedsec Stub_Type
7352 @findex Stub_Type
7353 @noindent
7354 The GNAT implementation of remote access-to-classwide types is
7355 organized as described in AARM section E.4 (20.t): a value of an RACW type
7356 (designating a remote object) is represented as a normal access
7357 value, pointing to a "stub" object which in turn contains the
7358 necessary information to contact the designated remote object. A
7359 call on any dispatching operation of such a stub object does the
7360 remote call, if necessary, using the information in the stub object
7361 to locate the target partition, etc.
7362
7363 For a prefix @code{T} that denotes a remote access-to-classwide type,
7364 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
7365
7366 By construction, the layout of @code{T'Stub_Type} is identical to that of
7367 type @code{RACW_Stub_Type} declared in the internal implementation-defined
7368 unit @code{System.Partition_Interface}. Use of this attribute will create
7369 an implicit dependency on this unit.
7370
7371 @node System_Allocator_Alignment
7372 @unnumberedsec System_Allocator_Alignment
7373 @cindex Alignment, allocator
7374 @findex System_Allocator_Alignment
7375 @noindent
7376 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
7377 permissible prefix) provides the observable guaranted to be honored by
7378 the system allocator (malloc). This is a static value that can be used
7379 in user storage pools based on malloc either to reject allocation
7380 with alignment too large or to enable a realignment circuitry if the
7381 alignment request is larger than this value.
7382
7383 @node Target_Name
7384 @unnumberedsec Target_Name
7385 @findex Target_Name
7386 @noindent
7387 @code{Standard'Target_Name} (@code{Standard} is the only permissible
7388 prefix) provides a static string value that identifies the target
7389 for the current compilation. For GCC implementations, this is the
7390 standard gcc target name without the terminating slash (for
7391 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
7392
7393 @node Tick
7394 @unnumberedsec Tick
7395 @findex Tick
7396 @noindent
7397 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
7398 provides the same value as @code{System.Tick},
7399
7400 @node To_Address
7401 @unnumberedsec To_Address
7402 @findex To_Address
7403 @noindent
7404 The @code{System'To_Address}
7405 (@code{System} is the only permissible prefix)
7406 denotes a function identical to
7407 @code{System.Storage_Elements.To_Address} except that
7408 it is a static attribute. This means that if its argument is
7409 a static expression, then the result of the attribute is a
7410 static expression. The result is that such an expression can be
7411 used in contexts (e.g.@: preelaborable packages) which require a
7412 static expression and where the function call could not be used
7413 (since the function call is always non-static, even if its
7414 argument is static).
7415
7416 @node Type_Class
7417 @unnumberedsec Type_Class
7418 @findex Type_Class
7419 @noindent
7420 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
7421 the value of the type class for the full type of @var{type}. If
7422 @var{type} is a generic formal type, the value is the value for the
7423 corresponding actual subtype. The value of this attribute is of type
7424 @code{System.Aux_DEC.Type_Class}, which has the following definition:
7425
7426 @smallexample @c ada
7427 type Type_Class is
7428 (Type_Class_Enumeration,
7429 Type_Class_Integer,
7430 Type_Class_Fixed_Point,
7431 Type_Class_Floating_Point,
7432 Type_Class_Array,
7433 Type_Class_Record,
7434 Type_Class_Access,
7435 Type_Class_Task,
7436 Type_Class_Address);
7437 @end smallexample
7438
7439 @noindent
7440 Protected types yield the value @code{Type_Class_Task}, which thus
7441 applies to all concurrent types. This attribute is designed to
7442 be compatible with the DEC Ada 83 attribute of the same name.
7443
7444 @node UET_Address
7445 @unnumberedsec UET_Address
7446 @findex UET_Address
7447 @noindent
7448 The @code{UET_Address} attribute can only be used for a prefix which
7449 denotes a library package. It yields the address of the unit exception
7450 table when zero cost exception handling is used. This attribute is
7451 intended only for use within the GNAT implementation. See the unit
7452 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7453 for details on how this attribute is used in the implementation.
7454
7455 @node Unconstrained_Array
7456 @unnumberedsec Unconstrained_Array
7457 @findex Unconstrained_Array
7458 @noindent
7459 The @code{Unconstrained_Array} attribute can be used with a prefix that
7460 denotes any type or subtype. It is a static attribute that yields
7461 @code{True} if the prefix designates an unconstrained array,
7462 and @code{False} otherwise. In a generic instance, the result is
7463 still static, and yields the result of applying this test to the
7464 generic actual.
7465
7466 @node Universal_Literal_String
7467 @unnumberedsec Universal_Literal_String
7468 @cindex Named numbers, representation of
7469 @findex Universal_Literal_String
7470 @noindent
7471 The prefix of @code{Universal_Literal_String} must be a named
7472 number. The static result is the string consisting of the characters of
7473 the number as defined in the original source. This allows the user
7474 program to access the actual text of named numbers without intermediate
7475 conversions and without the need to enclose the strings in quotes (which
7476 would preclude their use as numbers).
7477
7478 For example, the following program prints the first 50 digits of pi:
7479
7480 @smallexample @c ada
7481 with Text_IO; use Text_IO;
7482 with Ada.Numerics;
7483 procedure Pi is
7484 begin
7485 Put (Ada.Numerics.Pi'Universal_Literal_String);
7486 end;
7487 @end smallexample
7488
7489 @node Unrestricted_Access
7490 @unnumberedsec Unrestricted_Access
7491 @cindex @code{Access}, unrestricted
7492 @findex Unrestricted_Access
7493 @noindent
7494 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7495 except that all accessibility and aliased view checks are omitted. This
7496 is a user-beware attribute. It is similar to
7497 @code{Address}, for which it is a desirable replacement where the value
7498 desired is an access type. In other words, its effect is identical to
7499 first applying the @code{Address} attribute and then doing an unchecked
7500 conversion to a desired access type. In GNAT, but not necessarily in
7501 other implementations, the use of static chains for inner level
7502 subprograms means that @code{Unrestricted_Access} applied to a
7503 subprogram yields a value that can be called as long as the subprogram
7504 is in scope (normal Ada accessibility rules restrict this usage).
7505
7506 It is possible to use @code{Unrestricted_Access} for any type, but care
7507 must be exercised if it is used to create pointers to unconstrained
7508 objects. In this case, the resulting pointer has the same scope as the
7509 context of the attribute, and may not be returned to some enclosing
7510 scope. For instance, a function cannot use @code{Unrestricted_Access}
7511 to create a unconstrained pointer and then return that value to the
7512 caller.
7513
7514 @node Valid_Scalars
7515 @unnumberedsec Valid_Scalars
7516 @findex Valid_Scalars
7517 @noindent
7518 The @code{'Valid_Scalars} attribute is intended to make it easier to
7519 check the validity of scalar subcomponents of composite objects. It
7520 is defined for any prefix @code{X} that denotes an object.
7521 The value of this attribute is of the predefined type Boolean.
7522 @code{X'Valid_Scalars} yields True if and only if evaluation of
7523 @code{P'Valid} yields True for every scalar part P of X or if X has
7524 no scalar parts. It is not specified in what order the scalar parts
7525 are checked, nor whether any more are checked after any one of them
7526 is determined to be invalid. If the prefix @code{X} is of a class-wide
7527 type @code{T'Class} (where @code{T} is the associated specific type),
7528 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7529 only the scalar parts of components of @code{T} are traversed; in other
7530 words, components of extensions of @code{T} are not traversed even if
7531 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7532 be determined at compile time that the prefix of the attribute has no
7533 scalar parts (e.g., if the prefix is of an access type, an interface type,
7534 an undiscriminated task type, or an undiscriminated protected type).
7535
7536 @node VADS_Size
7537 @unnumberedsec VADS_Size
7538 @cindex @code{Size}, VADS compatibility
7539 @findex VADS_Size
7540 @noindent
7541 The @code{'VADS_Size} attribute is intended to make it easier to port
7542 legacy code which relies on the semantics of @code{'Size} as implemented
7543 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7544 same semantic interpretation. In particular, @code{'VADS_Size} applied
7545 to a predefined or other primitive type with no Size clause yields the
7546 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7547 typical machines). In addition @code{'VADS_Size} applied to an object
7548 gives the result that would be obtained by applying the attribute to
7549 the corresponding type.
7550
7551 @node Value_Size
7552 @unnumberedsec Value_Size
7553 @cindex @code{Size}, setting for not-first subtype
7554 @findex Value_Size
7555 @code{@var{type}'Value_Size} is the number of bits required to represent
7556 a value of the given subtype. It is the same as @code{@var{type}'Size},
7557 but, unlike @code{Size}, may be set for non-first subtypes.
7558
7559 @node Wchar_T_Size
7560 @unnumberedsec Wchar_T_Size
7561 @findex Wchar_T_Size
7562 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7563 prefix) provides the size in bits of the C @code{wchar_t} type
7564 primarily for constructing the definition of this type in
7565 package @code{Interfaces.C}.
7566
7567 @node Word_Size
7568 @unnumberedsec Word_Size
7569 @findex Word_Size
7570 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7571 prefix) provides the value @code{System.Word_Size}.
7572
7573 @node Standard and Implementation Defined Restrictions
7574 @chapter Standard and Implementation Defined Restrictions
7575
7576 @noindent
7577 All RM defined Restriction identifiers are implemented:
7578
7579 @itemize @bullet
7580 @item language-defined restrictions (see 13.12.1)
7581 @item tasking restrictions (see D.7)
7582 @item high integrity restrictions (see H.4)
7583 @end itemize
7584
7585 @noindent
7586 GNAT implements additional restriction identifiers. All restrictions, whether
7587 language defined or GNAT-specific, are listed in the following.
7588
7589 @menu
7590 * Partition-Wide Restrictions::
7591 * Program Unit Level Restrictions::
7592 @end menu
7593
7594 @node Partition-Wide Restrictions
7595 @section Partition-Wide Restrictions
7596
7597 There are two separate lists of restriction identifiers. The first
7598 set requires consistency throughout a partition (in other words, if the
7599 restriction identifier is used for any compilation unit in the partition,
7600 then all compilation units in the partition must obey the restriction).
7601
7602 @menu
7603 * Immediate_Reclamation::
7604 * Max_Asynchronous_Select_Nesting::
7605 * Max_Entry_Queue_Length::
7606 * Max_Protected_Entries::
7607 * Max_Select_Alternatives::
7608 * Max_Storage_At_Blocking::
7609 * Max_Task_Entries::
7610 * Max_Tasks::
7611 * No_Abort_Statements::
7612 * No_Access_Parameter_Allocators::
7613 * No_Access_Subprograms::
7614 * No_Allocators::
7615 * No_Anonymous_Allocators::
7616 * No_Calendar::
7617 * No_Coextensions::
7618 * No_Default_Initialization::
7619 * No_Delay::
7620 * No_Dependence::
7621 * No_Direct_Boolean_Operators::
7622 * No_Dispatch::
7623 * No_Dispatching_Calls::
7624 * No_Dynamic_Attachment::
7625 * No_Dynamic_Priorities::
7626 * No_Entry_Calls_In_Elaboration_Code::
7627 * No_Enumeration_Maps::
7628 * No_Exception_Handlers::
7629 * No_Exception_Propagation::
7630 * No_Exception_Registration::
7631 * No_Exceptions::
7632 * No_Finalization::
7633 * No_Fixed_Point::
7634 * No_Floating_Point::
7635 * No_Implicit_Conditionals::
7636 * No_Implicit_Dynamic_Code::
7637 * No_Implicit_Heap_Allocations::
7638 * No_Implicit_Loops::
7639 * No_Initialize_Scalars::
7640 * No_IO::
7641 * No_Local_Allocators::
7642 * No_Local_Protected_Objects::
7643 * No_Local_Timing_Events::
7644 * No_Nested_Finalization::
7645 * No_Protected_Type_Allocators::
7646 * No_Protected_Types::
7647 * No_Recursion::
7648 * No_Reentrancy::
7649 * No_Relative_Delay::
7650 * No_Requeue_Statements::
7651 * No_Secondary_Stack::
7652 * No_Select_Statements::
7653 * No_Specific_Termination_Handlers::
7654 * No_Specification_of_Aspect::
7655 * No_Standard_Allocators_After_Elaboration::
7656 * No_Standard_Storage_Pools::
7657 * No_Stream_Optimizations::
7658 * No_Streams::
7659 * No_Task_Allocators::
7660 * No_Task_Attributes_Package::
7661 * No_Task_Hierarchy::
7662 * No_Task_Termination::
7663 * No_Tasking::
7664 * No_Terminate_Alternatives::
7665 * No_Unchecked_Access::
7666 * Simple_Barriers::
7667 * Static_Priorities::
7668 * Static_Storage_Size::
7669 @end menu
7670
7671 @node Immediate_Reclamation
7672 @unnumberedsubsec Immediate_Reclamation
7673 @findex Immediate_Reclamation
7674 [RM H.4] This restriction ensures that, except for storage occupied by
7675 objects created by allocators and not deallocated via unchecked
7676 deallocation, any storage reserved at run time for an object is
7677 immediately reclaimed when the object no longer exists.
7678
7679 @node Max_Asynchronous_Select_Nesting
7680 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7681 @findex Max_Asynchronous_Select_Nesting
7682 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7683 selects. Violations of this restriction with a value of zero are
7684 detected at compile time. Violations of this restriction with values
7685 other than zero cause Storage_Error to be raised.
7686
7687 @node Max_Entry_Queue_Length
7688 @unnumberedsubsec Max_Entry_Queue_Length
7689 @findex Max_Entry_Queue_Length
7690 [RM D.7] This restriction is a declaration that any protected entry compiled in
7691 the scope of the restriction has at most the specified number of
7692 tasks waiting on the entry at any one time, and so no queue is required.
7693 Note that this restriction is checked at run time. Violation of this
7694 restriction results in the raising of Program_Error exception at the point of
7695 the call.
7696
7697 @node Max_Protected_Entries
7698 @unnumberedsubsec Max_Protected_Entries
7699 @findex Max_Protected_Entries
7700 [RM D.7] Specifies the maximum number of entries per protected type. The
7701 bounds of every entry family of a protected unit shall be static, or shall be
7702 defined by a discriminant of a subtype whose corresponding bound is static.
7703
7704 @node Max_Select_Alternatives
7705 @unnumberedsubsec Max_Select_Alternatives
7706 @findex Max_Select_Alternatives
7707 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7708
7709 @node Max_Storage_At_Blocking
7710 @unnumberedsubsec Max_Storage_At_Blocking
7711 @findex Max_Storage_At_Blocking
7712 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7713 Storage_Size that can be retained by a blocked task. A violation of this
7714 restriction causes Storage_Error to be raised.
7715
7716 @node Max_Task_Entries
7717 @unnumberedsubsec Max_Task_Entries
7718 @findex Max_Task_Entries
7719 [RM D.7] Specifies the maximum number of entries
7720 per task. The bounds of every entry family
7721 of a task unit shall be static, or shall be
7722 defined by a discriminant of a subtype whose
7723 corresponding bound is static.
7724
7725 @node Max_Tasks
7726 @unnumberedsubsec Max_Tasks
7727 @findex Max_Tasks
7728 [RM D.7] Specifies the maximum number of task that may be created, not
7729 counting the creation of the environment task. Violations of this
7730 restriction with a value of zero are detected at compile
7731 time. Violations of this restriction with values other than zero cause
7732 Storage_Error to be raised.
7733
7734 @node No_Abort_Statements
7735 @unnumberedsubsec No_Abort_Statements
7736 @findex No_Abort_Statements
7737 [RM D.7] There are no abort_statements, and there are
7738 no calls to Task_Identification.Abort_Task.
7739
7740 @node No_Access_Parameter_Allocators
7741 @unnumberedsubsec No_Access_Parameter_Allocators
7742 @findex No_Access_Parameter_Allocators
7743 [RM H.4] This restriction ensures at compile time that there are no
7744 occurrences of an allocator as the actual parameter to an access
7745 parameter.
7746
7747 @node No_Access_Subprograms
7748 @unnumberedsubsec No_Access_Subprograms
7749 @findex No_Access_Subprograms
7750 [RM H.4] This restriction ensures at compile time that there are no
7751 declarations of access-to-subprogram types.
7752
7753 @node No_Allocators
7754 @unnumberedsubsec No_Allocators
7755 @findex No_Allocators
7756 [RM H.4] This restriction ensures at compile time that there are no
7757 occurrences of an allocator.
7758
7759 @node No_Anonymous_Allocators
7760 @unnumberedsubsec No_Anonymous_Allocators
7761 @findex No_Anonymous_Allocators
7762 [RM H.4] This restriction ensures at compile time that there are no
7763 occurrences of an allocator of anonymous access type.
7764
7765 @node No_Calendar
7766 @unnumberedsubsec No_Calendar
7767 @findex No_Calendar
7768 [GNAT] This restriction ensures at compile time that there is no implicit or
7769 explicit dependence on the package @code{Ada.Calendar}.
7770
7771 @node No_Coextensions
7772 @unnumberedsubsec No_Coextensions
7773 @findex No_Coextensions
7774 [RM H.4] This restriction ensures at compile time that there are no
7775 coextensions. See 3.10.2.
7776
7777 @node No_Default_Initialization
7778 @unnumberedsubsec No_Default_Initialization
7779 @findex No_Default_Initialization
7780
7781 [GNAT] This restriction prohibits any instance of default initialization
7782 of variables. The binder implements a consistency rule which prevents
7783 any unit compiled without the restriction from with'ing a unit with the
7784 restriction (this allows the generation of initialization procedures to
7785 be skipped, since you can be sure that no call is ever generated to an
7786 initialization procedure in a unit with the restriction active). If used
7787 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7788 is to prohibit all cases of variables declared without a specific
7789 initializer (including the case of OUT scalar parameters).
7790
7791 @node No_Delay
7792 @unnumberedsubsec No_Delay
7793 @findex No_Delay
7794 [RM H.4] This restriction ensures at compile time that there are no
7795 delay statements and no dependences on package Calendar.
7796
7797 @node No_Dependence
7798 @unnumberedsubsec No_Dependence
7799 @findex No_Dependence
7800 [RM 13.12.1] This restriction checks at compile time that there are no
7801 dependence on a library unit.
7802
7803 @node No_Direct_Boolean_Operators
7804 @unnumberedsubsec No_Direct_Boolean_Operators
7805 @findex No_Direct_Boolean_Operators
7806 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7807 operands of type Boolean (or any type derived
7808 from Boolean). This is intended for use in safety critical programs
7809 where the certification protocol requires the use of short-circuit
7810 (and then, or else) forms for all composite boolean operations.
7811
7812 @node No_Dispatch
7813 @unnumberedsubsec No_Dispatch
7814 @findex No_Dispatch
7815 [RM H.4] This restriction ensures at compile time that there are no
7816 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7817
7818 @node No_Dispatching_Calls
7819 @unnumberedsubsec No_Dispatching_Calls
7820 @findex No_Dispatching_Calls
7821 [GNAT] This restriction ensures at compile time that the code generated by the
7822 compiler involves no dispatching calls. The use of this restriction allows the
7823 safe use of record extensions, classwide membership tests and other classwide
7824 features not involving implicit dispatching. This restriction ensures that
7825 the code contains no indirect calls through a dispatching mechanism. Note that
7826 this includes internally-generated calls created by the compiler, for example
7827 in the implementation of class-wide objects assignments. The
7828 membership test is allowed in the presence of this restriction, because its
7829 implementation requires no dispatching.
7830 This restriction is comparable to the official Ada restriction
7831 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7832 all classwide constructs that do not imply dispatching.
7833 The following example indicates constructs that violate this restriction.
7834
7835 @smallexample
7836 package Pkg is
7837 type T is tagged record
7838 Data : Natural;
7839 end record;
7840 procedure P (X : T);
7841
7842 type DT is new T with record
7843 More_Data : Natural;
7844 end record;
7845 procedure Q (X : DT);
7846 end Pkg;
7847
7848 with Pkg; use Pkg;
7849 procedure Example is
7850 procedure Test (O : T'Class) is
7851 N : Natural := O'Size;-- Error: Dispatching call
7852 C : T'Class := O; -- Error: implicit Dispatching Call
7853 begin
7854 if O in DT'Class then -- OK : Membership test
7855 Q (DT (O)); -- OK : Type conversion plus direct call
7856 else
7857 P (O); -- Error: Dispatching call
7858 end if;
7859 end Test;
7860
7861 Obj : DT;
7862 begin
7863 P (Obj); -- OK : Direct call
7864 P (T (Obj)); -- OK : Type conversion plus direct call
7865 P (T'Class (Obj)); -- Error: Dispatching call
7866
7867 Test (Obj); -- OK : Type conversion
7868
7869 if Obj in T'Class then -- OK : Membership test
7870 null;
7871 end if;
7872 end Example;
7873 @end smallexample
7874
7875 @node No_Dynamic_Attachment
7876 @unnumberedsubsec No_Dynamic_Attachment
7877 @findex No_Dynamic_Attachment
7878 [RM D.7] This restriction ensures that there is no call to any of the
7879 operations defined in package Ada.Interrupts
7880 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7881 Detach_Handler, and Reference).
7882
7883 @node No_Dynamic_Priorities
7884 @unnumberedsubsec No_Dynamic_Priorities
7885 @findex No_Dynamic_Priorities
7886 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7887
7888 @node No_Entry_Calls_In_Elaboration_Code
7889 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7890 @findex No_Entry_Calls_In_Elaboration_Code
7891 [GNAT] This restriction ensures at compile time that no task or protected entry
7892 calls are made during elaboration code. As a result of the use of this
7893 restriction, the compiler can assume that no code past an accept statement
7894 in a task can be executed at elaboration time.
7895
7896 @node No_Enumeration_Maps
7897 @unnumberedsubsec No_Enumeration_Maps
7898 @findex No_Enumeration_Maps
7899 [GNAT] This restriction ensures at compile time that no operations requiring
7900 enumeration maps are used (that is Image and Value attributes applied
7901 to enumeration types).
7902
7903 @node No_Exception_Handlers
7904 @unnumberedsubsec No_Exception_Handlers
7905 @findex No_Exception_Handlers
7906 [GNAT] This restriction ensures at compile time that there are no explicit
7907 exception handlers. It also indicates that no exception propagation will
7908 be provided. In this mode, exceptions may be raised but will result in
7909 an immediate call to the last chance handler, a routine that the user
7910 must define with the following profile:
7911
7912 @smallexample @c ada
7913 procedure Last_Chance_Handler
7914 (Source_Location : System.Address; Line : Integer);
7915 pragma Export (C, Last_Chance_Handler,
7916 "__gnat_last_chance_handler");
7917 @end smallexample
7918
7919 The parameter is a C null-terminated string representing a message to be
7920 associated with the exception (typically the source location of the raise
7921 statement generated by the compiler). The Line parameter when nonzero
7922 represents the line number in the source program where the raise occurs.
7923
7924 @node No_Exception_Propagation
7925 @unnumberedsubsec No_Exception_Propagation
7926 @findex No_Exception_Propagation
7927 [GNAT] This restriction guarantees that exceptions are never propagated
7928 to an outer subprogram scope. The only case in which an exception may
7929 be raised is when the handler is statically in the same subprogram, so
7930 that the effect of a raise is essentially like a goto statement. Any
7931 other raise statement (implicit or explicit) will be considered
7932 unhandled. Exception handlers are allowed, but may not contain an
7933 exception occurrence identifier (exception choice). In addition, use of
7934 the package GNAT.Current_Exception is not permitted, and reraise
7935 statements (raise with no operand) are not permitted.
7936
7937 @node No_Exception_Registration
7938 @unnumberedsubsec No_Exception_Registration
7939 @findex No_Exception_Registration
7940 [GNAT] This restriction ensures at compile time that no stream operations for
7941 types Exception_Id or Exception_Occurrence are used. This also makes it
7942 impossible to pass exceptions to or from a partition with this restriction
7943 in a distributed environment. If this exception is active, then the generated
7944 code is simplified by omitting the otherwise-required global registration
7945 of exceptions when they are declared.
7946
7947 @node No_Exceptions
7948 @unnumberedsubsec No_Exceptions
7949 @findex No_Exceptions
7950 [RM H.4] This restriction ensures at compile time that there are no
7951 raise statements and no exception handlers.
7952
7953 @node No_Finalization
7954 @unnumberedsubsec No_Finalization
7955 @findex No_Finalization
7956 [GNAT] This restriction disables the language features described in
7957 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7958 performed by the compiler to support these features. The following types
7959 are no longer considered controlled when this restriction is in effect:
7960 @itemize @bullet
7961 @item
7962 @code{Ada.Finalization.Controlled}
7963 @item
7964 @code{Ada.Finalization.Limited_Controlled}
7965 @item
7966 Derivations from @code{Controlled} or @code{Limited_Controlled}
7967 @item
7968 Class-wide types
7969 @item
7970 Protected types
7971 @item
7972 Task types
7973 @item
7974 Array and record types with controlled components
7975 @end itemize
7976 The compiler no longer generates code to initialize, finalize or adjust an
7977 object or a nested component, either declared on the stack or on the heap. The
7978 deallocation of a controlled object no longer finalizes its contents.
7979
7980 @node No_Fixed_Point
7981 @unnumberedsubsec No_Fixed_Point
7982 @findex No_Fixed_Point
7983 [RM H.4] This restriction ensures at compile time that there are no
7984 occurrences of fixed point types and operations.
7985
7986 @node No_Floating_Point
7987 @unnumberedsubsec No_Floating_Point
7988 @findex No_Floating_Point
7989 [RM H.4] This restriction ensures at compile time that there are no
7990 occurrences of floating point types and operations.
7991
7992 @node No_Implicit_Conditionals
7993 @unnumberedsubsec No_Implicit_Conditionals
7994 @findex No_Implicit_Conditionals
7995 [GNAT] This restriction ensures that the generated code does not contain any
7996 implicit conditionals, either by modifying the generated code where possible,
7997 or by rejecting any construct that would otherwise generate an implicit
7998 conditional. Note that this check does not include run time constraint
7999 checks, which on some targets may generate implicit conditionals as
8000 well. To control the latter, constraint checks can be suppressed in the
8001 normal manner. Constructs generating implicit conditionals include comparisons
8002 of composite objects and the Max/Min attributes.
8003
8004 @node No_Implicit_Dynamic_Code
8005 @unnumberedsubsec No_Implicit_Dynamic_Code
8006 @findex No_Implicit_Dynamic_Code
8007 @cindex trampoline
8008 [GNAT] This restriction prevents the compiler from building ``trampolines''.
8009 This is a structure that is built on the stack and contains dynamic
8010 code to be executed at run time. On some targets, a trampoline is
8011 built for the following features: @code{Access},
8012 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8013 nested task bodies; primitive operations of nested tagged types.
8014 Trampolines do not work on machines that prevent execution of stack
8015 data. For example, on windows systems, enabling DEP (data execution
8016 protection) will cause trampolines to raise an exception.
8017 Trampolines are also quite slow at run time.
8018
8019 On many targets, trampolines have been largely eliminated. Look at the
8020 version of system.ads for your target --- if it has
8021 Always_Compatible_Rep equal to False, then trampolines are largely
8022 eliminated. In particular, a trampoline is built for the following
8023 features: @code{Address} of a nested subprogram;
8024 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8025 but only if pragma Favor_Top_Level applies, or the access type has a
8026 foreign-language convention; primitive operations of nested tagged
8027 types.
8028
8029 @node No_Implicit_Heap_Allocations
8030 @unnumberedsubsec No_Implicit_Heap_Allocations
8031 @findex No_Implicit_Heap_Allocations
8032 [RM D.7] No constructs are allowed to cause implicit heap allocation.
8033
8034 @node No_Implicit_Loops
8035 @unnumberedsubsec No_Implicit_Loops
8036 @findex No_Implicit_Loops
8037 [GNAT] This restriction ensures that the generated code does not contain any
8038 implicit @code{for} loops, either by modifying
8039 the generated code where possible,
8040 or by rejecting any construct that would otherwise generate an implicit
8041 @code{for} loop. If this restriction is active, it is possible to build
8042 large array aggregates with all static components without generating an
8043 intermediate temporary, and without generating a loop to initialize individual
8044 components. Otherwise, a loop is created for arrays larger than about 5000
8045 scalar components.
8046
8047 @node No_Initialize_Scalars
8048 @unnumberedsubsec No_Initialize_Scalars
8049 @findex No_Initialize_Scalars
8050 [GNAT] This restriction ensures that no unit in the partition is compiled with
8051 pragma Initialize_Scalars. This allows the generation of more efficient
8052 code, and in particular eliminates dummy null initialization routines that
8053 are otherwise generated for some record and array types.
8054
8055 @node No_IO
8056 @unnumberedsubsec No_IO
8057 @findex No_IO
8058 [RM H.4] This restriction ensures at compile time that there are no
8059 dependences on any of the library units Sequential_IO, Direct_IO,
8060 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
8061
8062 @node No_Local_Allocators
8063 @unnumberedsubsec No_Local_Allocators
8064 @findex No_Local_Allocators
8065 [RM H.4] This restriction ensures at compile time that there are no
8066 occurrences of an allocator in subprograms, generic subprograms, tasks,
8067 and entry bodies.
8068
8069 @node No_Local_Protected_Objects
8070 @unnumberedsubsec No_Local_Protected_Objects
8071 @findex No_Local_Protected_Objects
8072 [RM D.7] This restriction ensures at compile time that protected objects are
8073 only declared at the library level.
8074
8075 @node No_Local_Timing_Events
8076 @unnumberedsubsec No_Local_Timing_Events
8077 @findex No_Local_Timing_Events
8078 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
8079 declared at the library level.
8080
8081 @node No_Nested_Finalization
8082 @unnumberedsubsec No_Nested_Finalization
8083 @findex No_Nested_Finalization
8084 [RM D.7] All objects requiring finalization are declared at the library level.
8085
8086 @node No_Protected_Type_Allocators
8087 @unnumberedsubsec No_Protected_Type_Allocators
8088 @findex No_Protected_Type_Allocators
8089 [RM D.7] This restriction ensures at compile time that there are no allocator
8090 expressions that attempt to allocate protected objects.
8091
8092 @node No_Protected_Types
8093 @unnumberedsubsec No_Protected_Types
8094 @findex No_Protected_Types
8095 [RM H.4] This restriction ensures at compile time that there are no
8096 declarations of protected types or protected objects.
8097
8098 @node No_Recursion
8099 @unnumberedsubsec No_Recursion
8100 @findex No_Recursion
8101 [RM H.4] A program execution is erroneous if a subprogram is invoked as
8102 part of its execution.
8103
8104 @node No_Reentrancy
8105 @unnumberedsubsec No_Reentrancy
8106 @findex No_Reentrancy
8107 [RM H.4] A program execution is erroneous if a subprogram is executed by
8108 two tasks at the same time.
8109
8110 @node No_Relative_Delay
8111 @unnumberedsubsec No_Relative_Delay
8112 @findex No_Relative_Delay
8113 [RM D.7] This restriction ensures at compile time that there are no delay
8114 relative statements and prevents expressions such as @code{delay 1.23;} from
8115 appearing in source code.
8116
8117 @node No_Requeue_Statements
8118 @unnumberedsubsec No_Requeue_Statements
8119 @findex No_Requeue_Statements
8120 [RM D.7] This restriction ensures at compile time that no requeue statements
8121 are permitted and prevents keyword @code{requeue} from being used in source
8122 code.
8123
8124 @node No_Secondary_Stack
8125 @unnumberedsubsec No_Secondary_Stack
8126 @findex No_Secondary_Stack
8127 [GNAT] This restriction ensures at compile time that the generated code
8128 does not contain any reference to the secondary stack. The secondary
8129 stack is used to implement functions returning unconstrained objects
8130 (arrays or records) on some targets.
8131
8132 @node No_Select_Statements
8133 @unnumberedsubsec No_Select_Statements
8134 @findex No_Select_Statements
8135 [RM D.7] This restriction ensures at compile time no select statements of any
8136 kind are permitted, that is the keyword @code{select} may not appear.
8137
8138 @node No_Specific_Termination_Handlers
8139 @unnumberedsubsec No_Specific_Termination_Handlers
8140 @findex No_Specific_Termination_Handlers
8141 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
8142 or to Ada.Task_Termination.Specific_Handler.
8143
8144 @node No_Specification_of_Aspect
8145 @unnumberedsubsec No_Specification_of_Aspect
8146 @findex No_Specification_of_Aspect
8147 [RM 13.12.1] This restriction checks at compile time that no aspect
8148 specification, attribute definition clause, or pragma is given for a
8149 given aspect.
8150
8151 @node No_Standard_Allocators_After_Elaboration
8152 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
8153 @findex No_Standard_Allocators_After_Elaboration
8154 [RM D.7] Specifies that an allocator using a standard storage pool
8155 should never be evaluated at run time after the elaboration of the
8156 library items of the partition has completed. Otherwise, Storage_Error
8157 is raised.
8158
8159 @node No_Standard_Storage_Pools
8160 @unnumberedsubsec No_Standard_Storage_Pools
8161 @findex No_Standard_Storage_Pools
8162 [GNAT] This restriction ensures at compile time that no access types
8163 use the standard default storage pool. Any access type declared must
8164 have an explicit Storage_Pool attribute defined specifying a
8165 user-defined storage pool.
8166
8167 @node No_Stream_Optimizations
8168 @unnumberedsubsec No_Stream_Optimizations
8169 @findex No_Stream_Optimizations
8170 [GNAT] This restriction affects the performance of stream operations on types
8171 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
8172 compiler uses block reads and writes when manipulating @code{String} objects
8173 due to their supperior performance. When this restriction is in effect, the
8174 compiler performs all IO operations on a per-character basis.
8175
8176 @node No_Streams
8177 @unnumberedsubsec No_Streams
8178 @findex No_Streams
8179 [GNAT] This restriction ensures at compile/bind time that there are no
8180 stream objects created and no use of stream attributes.
8181 This restriction does not forbid dependences on the package
8182 @code{Ada.Streams}. So it is permissible to with
8183 @code{Ada.Streams} (or another package that does so itself)
8184 as long as no actual stream objects are created and no
8185 stream attributes are used.
8186
8187 Note that the use of restriction allows optimization of tagged types,
8188 since they do not need to worry about dispatching stream operations.
8189 To take maximum advantage of this space-saving optimization, any
8190 unit declaring a tagged type should be compiled with the restriction,
8191 though this is not required.
8192
8193 @node No_Task_Allocators
8194 @unnumberedsubsec No_Task_Allocators
8195 @findex No_Task_Allocators
8196 [RM D.7] There are no allocators for task types
8197 or types containing task subcomponents.
8198
8199 @node No_Task_Attributes_Package
8200 @unnumberedsubsec No_Task_Attributes_Package
8201 @findex No_Task_Attributes_Package
8202 [GNAT] This restriction ensures at compile time that there are no implicit or
8203 explicit dependencies on the package @code{Ada.Task_Attributes}.
8204
8205 @node No_Task_Hierarchy
8206 @unnumberedsubsec No_Task_Hierarchy
8207 @findex No_Task_Hierarchy
8208 [RM D.7] All (non-environment) tasks depend
8209 directly on the environment task of the partition.
8210
8211 @node No_Task_Termination
8212 @unnumberedsubsec No_Task_Termination
8213 @findex No_Task_Termination
8214 [RM D.7] Tasks which terminate are erroneous.
8215
8216 @node No_Tasking
8217 @unnumberedsubsec No_Tasking
8218 @findex No_Tasking
8219 [GNAT] This restriction prevents the declaration of tasks or task types
8220 throughout the partition. It is similar in effect to the use of
8221 @code{Max_Tasks => 0} except that violations are caught at compile time
8222 and cause an error message to be output either by the compiler or
8223 binder.
8224
8225 @node No_Terminate_Alternatives
8226 @unnumberedsubsec No_Terminate_Alternatives
8227 @findex No_Terminate_Alternatives
8228 [RM D.7] There are no selective accepts with terminate alternatives.
8229
8230 @node No_Unchecked_Access
8231 @unnumberedsubsec No_Unchecked_Access
8232 @findex No_Unchecked_Access
8233 [RM H.4] This restriction ensures at compile time that there are no
8234 occurrences of the Unchecked_Access attribute.
8235
8236 @node Simple_Barriers
8237 @unnumberedsubsec Simple_Barriers
8238 @findex Simple_Barriers
8239 [RM D.7] This restriction ensures at compile time that barriers in entry
8240 declarations for protected types are restricted to either static boolean
8241 expressions or references to simple boolean variables defined in the private
8242 part of the protected type. No other form of entry barriers is permitted.
8243
8244 @node Static_Priorities
8245 @unnumberedsubsec Static_Priorities
8246 @findex Static_Priorities
8247 [GNAT] This restriction ensures at compile time that all priority expressions
8248 are static, and that there are no dependences on the package
8249 @code{Ada.Dynamic_Priorities}.
8250
8251 @node Static_Storage_Size
8252 @unnumberedsubsec Static_Storage_Size
8253 @findex Static_Storage_Size
8254 [GNAT] This restriction ensures at compile time that any expression appearing
8255 in a Storage_Size pragma or attribute definition clause is static.
8256
8257 @node Program Unit Level Restrictions
8258 @section Program Unit Level Restrictions
8259
8260 @noindent
8261 The second set of restriction identifiers
8262 does not require partition-wide consistency.
8263 The restriction may be enforced for a single
8264 compilation unit without any effect on any of the
8265 other compilation units in the partition.
8266
8267 @menu
8268 * No_Elaboration_Code::
8269 * No_Entry_Queue::
8270 * No_Implementation_Aspect_Specifications::
8271 * No_Implementation_Attributes::
8272 * No_Implementation_Identifiers::
8273 * No_Implementation_Pragmas::
8274 * No_Implementation_Restrictions::
8275 * No_Implementation_Units::
8276 * No_Implicit_Aliasing::
8277 * No_Obsolescent_Features::
8278 * No_Wide_Characters::
8279 * SPARK::
8280 @end menu
8281
8282 @node No_Elaboration_Code
8283 @unnumberedsubsec No_Elaboration_Code
8284 @findex No_Elaboration_Code
8285 [GNAT] This restriction ensures at compile time that no elaboration code is
8286 generated. Note that this is not the same condition as is enforced
8287 by pragma @code{Preelaborate}. There are cases in which pragma
8288 @code{Preelaborate} still permits code to be generated (e.g.@: code
8289 to initialize a large array to all zeroes), and there are cases of units
8290 which do not meet the requirements for pragma @code{Preelaborate},
8291 but for which no elaboration code is generated. Generally, it is
8292 the case that preelaborable units will meet the restrictions, with
8293 the exception of large aggregates initialized with an others_clause,
8294 and exception declarations (which generate calls to a run-time
8295 registry procedure). This restriction is enforced on
8296 a unit by unit basis, it need not be obeyed consistently
8297 throughout a partition.
8298
8299 In the case of aggregates with others, if the aggregate has a dynamic
8300 size, there is no way to eliminate the elaboration code (such dynamic
8301 bounds would be incompatible with @code{Preelaborate} in any case). If
8302 the bounds are static, then use of this restriction actually modifies
8303 the code choice of the compiler to avoid generating a loop, and instead
8304 generate the aggregate statically if possible, no matter how many times
8305 the data for the others clause must be repeatedly generated.
8306
8307 It is not possible to precisely document
8308 the constructs which are compatible with this restriction, since,
8309 unlike most other restrictions, this is not a restriction on the
8310 source code, but a restriction on the generated object code. For
8311 example, if the source contains a declaration:
8312
8313 @smallexample
8314 Val : constant Integer := X;
8315 @end smallexample
8316
8317 @noindent
8318 where X is not a static constant, it may be possible, depending
8319 on complex optimization circuitry, for the compiler to figure
8320 out the value of X at compile time, in which case this initialization
8321 can be done by the loader, and requires no initialization code. It
8322 is not possible to document the precise conditions under which the
8323 optimizer can figure this out.
8324
8325 Note that this the implementation of this restriction requires full
8326 code generation. If it is used in conjunction with "semantics only"
8327 checking, then some cases of violations may be missed.
8328
8329 @node No_Entry_Queue
8330 @unnumberedsubsec No_Entry_Queue
8331 @findex No_Entry_Queue
8332 [GNAT] This restriction is a declaration that any protected entry compiled in
8333 the scope of the restriction has at most one task waiting on the entry
8334 at any one time, and so no queue is required. This restriction is not
8335 checked at compile time. A program execution is erroneous if an attempt
8336 is made to queue a second task on such an entry.
8337
8338 @node No_Implementation_Aspect_Specifications
8339 @unnumberedsubsec No_Implementation_Aspect_Specifications
8340 @findex No_Implementation_Aspect_Specifications
8341 [RM 13.12.1] This restriction checks at compile time that no
8342 GNAT-defined aspects are present. With this restriction, the only
8343 aspects that can be used are those defined in the Ada Reference Manual.
8344
8345 @node No_Implementation_Attributes
8346 @unnumberedsubsec No_Implementation_Attributes
8347 @findex No_Implementation_Attributes
8348 [RM 13.12.1] This restriction checks at compile time that no
8349 GNAT-defined attributes are present. With this restriction, the only
8350 attributes that can be used are those defined in the Ada Reference
8351 Manual.
8352
8353 @node No_Implementation_Identifiers
8354 @unnumberedsubsec No_Implementation_Identifiers
8355 @findex No_Implementation_Identifiers
8356 [RM 13.12.1] This restriction checks at compile time that no
8357 implementation-defined identifiers (marked with pragma Implementation_Defined)
8358 occur within language-defined packages.
8359
8360 @node No_Implementation_Pragmas
8361 @unnumberedsubsec No_Implementation_Pragmas
8362 @findex No_Implementation_Pragmas
8363 [RM 13.12.1] This restriction checks at compile time that no
8364 GNAT-defined pragmas are present. With this restriction, the only
8365 pragmas that can be used are those defined in the Ada Reference Manual.
8366
8367 @node No_Implementation_Restrictions
8368 @unnumberedsubsec No_Implementation_Restrictions
8369 @findex No_Implementation_Restrictions
8370 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
8371 identifiers (other than @code{No_Implementation_Restrictions} itself)
8372 are present. With this restriction, the only other restriction identifiers
8373 that can be used are those defined in the Ada Reference Manual.
8374
8375 @node No_Implementation_Units
8376 @unnumberedsubsec No_Implementation_Units
8377 @findex No_Implementation_Units
8378 [RM 13.12.1] This restriction checks at compile time that there is no
8379 mention in the context clause of any implementation-defined descendants
8380 of packages Ada, Interfaces, or System.
8381
8382 @node No_Implicit_Aliasing
8383 @unnumberedsubsec No_Implicit_Aliasing
8384 @findex No_Implicit_Aliasing
8385 [GNAT] This restriction, which is not required to be partition-wide consistent,
8386 requires an explicit aliased keyword for an object to which 'Access,
8387 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
8388 the 'Unrestricted_Access attribute for objects. Note: the reason that
8389 Unrestricted_Access is forbidden is that it would require the prefix
8390 to be aliased, and in such cases, it can always be replaced by
8391 the standard attribute Unchecked_Access which is preferable.
8392
8393 @node No_Obsolescent_Features
8394 @unnumberedsubsec No_Obsolescent_Features
8395 @findex No_Obsolescent_Features
8396 [RM 13.12.1] This restriction checks at compile time that no obsolescent
8397 features are used, as defined in Annex J of the Ada Reference Manual.
8398
8399 @node No_Wide_Characters
8400 @unnumberedsubsec No_Wide_Characters
8401 @findex No_Wide_Characters
8402 [GNAT] This restriction ensures at compile time that no uses of the types
8403 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8404 wide types
8405 appear, and that no wide or wide wide string or character literals
8406 appear in the program (that is literals representing characters not in
8407 type @code{Character}).
8408
8409 @node SPARK
8410 @unnumberedsubsec SPARK
8411 @findex SPARK
8412 [GNAT] This restriction checks at compile time that some constructs
8413 forbidden in SPARK are not present. The SPARK version used as a
8414 reference is the same as the Ada mode for the unit, so a unit compiled
8415 in Ada 95 mode with SPARK restrictions will be checked for constructs
8416 forbidden in SPARK 95. Error messages related to SPARK restriction have
8417 the form:
8418
8419 @smallexample
8420 violation of restriction "SPARK" at <file>
8421 <error message>
8422 @end smallexample
8423
8424 This is not a replacement for the semantic checks performed by the
8425 SPARK Examiner tool, as the compiler only deals currently with code,
8426 not at all with SPARK annotations and does not guarantee catching all
8427 cases of constructs forbidden by SPARK.
8428
8429 Thus it may well be the case that code which
8430 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
8431 e.g. due to the different visibility rules of the Examiner based on
8432 SPARK @code{inherit} annotations.
8433
8434 This restriction can be useful in providing an initial filter for
8435 code developed using SPARK, or in examining legacy code to see how far
8436 it is from meeting SPARK restrictions.
8437
8438 @c ------------------------
8439 @node Implementation Advice
8440 @chapter Implementation Advice
8441 @noindent
8442 The main text of the Ada Reference Manual describes the required
8443 behavior of all Ada compilers, and the GNAT compiler conforms to
8444 these requirements.
8445
8446 In addition, there are sections throughout the Ada Reference Manual headed
8447 by the phrase ``Implementation advice''. These sections are not normative,
8448 i.e., they do not specify requirements that all compilers must
8449 follow. Rather they provide advice on generally desirable behavior. You
8450 may wonder why they are not requirements. The most typical answer is
8451 that they describe behavior that seems generally desirable, but cannot
8452 be provided on all systems, or which may be undesirable on some systems.
8453
8454 As far as practical, GNAT follows the implementation advice sections in
8455 the Ada Reference Manual. This chapter contains a table giving the
8456 reference manual section number, paragraph number and several keywords
8457 for each advice. Each entry consists of the text of the advice followed
8458 by the GNAT interpretation of this advice. Most often, this simply says
8459 ``followed'', which means that GNAT follows the advice. However, in a
8460 number of cases, GNAT deliberately deviates from this advice, in which
8461 case the text describes what GNAT does and why.
8462
8463 @cindex Error detection
8464 @unnumberedsec 1.1.3(20): Error Detection
8465 @sp 1
8466 @cartouche
8467 If an implementation detects the use of an unsupported Specialized Needs
8468 Annex feature at run time, it should raise @code{Program_Error} if
8469 feasible.
8470 @end cartouche
8471 Not relevant. All specialized needs annex features are either supported,
8472 or diagnosed at compile time.
8473
8474 @cindex Child Units
8475 @unnumberedsec 1.1.3(31): Child Units
8476 @sp 1
8477 @cartouche
8478 If an implementation wishes to provide implementation-defined
8479 extensions to the functionality of a language-defined library unit, it
8480 should normally do so by adding children to the library unit.
8481 @end cartouche
8482 Followed.
8483
8484 @cindex Bounded errors
8485 @unnumberedsec 1.1.5(12): Bounded Errors
8486 @sp 1
8487 @cartouche
8488 If an implementation detects a bounded error or erroneous
8489 execution, it should raise @code{Program_Error}.
8490 @end cartouche
8491 Followed in all cases in which the implementation detects a bounded
8492 error or erroneous execution. Not all such situations are detected at
8493 runtime.
8494
8495 @cindex Pragmas
8496 @unnumberedsec 2.8(16): Pragmas
8497 @sp 1
8498 @cartouche
8499 Normally, implementation-defined pragmas should have no semantic effect
8500 for error-free programs; that is, if the implementation-defined pragmas
8501 are removed from a working program, the program should still be legal,
8502 and should still have the same semantics.
8503 @end cartouche
8504 The following implementation defined pragmas are exceptions to this
8505 rule:
8506
8507 @table @code
8508 @item Abort_Defer
8509 Affects semantics
8510 @item Ada_83
8511 Affects legality
8512 @item Assert
8513 Affects semantics
8514 @item CPP_Class
8515 Affects semantics
8516 @item CPP_Constructor
8517 Affects semantics
8518 @item Debug
8519 Affects semantics
8520 @item Interface_Name
8521 Affects semantics
8522 @item Machine_Attribute
8523 Affects semantics
8524 @item Unimplemented_Unit
8525 Affects legality
8526 @item Unchecked_Union
8527 Affects semantics
8528 @end table
8529
8530 @noindent
8531 In each of the above cases, it is essential to the purpose of the pragma
8532 that this advice not be followed. For details see the separate section
8533 on implementation defined pragmas.
8534
8535 @unnumberedsec 2.8(17-19): Pragmas
8536 @sp 1
8537 @cartouche
8538 Normally, an implementation should not define pragmas that can
8539 make an illegal program legal, except as follows:
8540 @end cartouche
8541 @sp 1
8542 @cartouche
8543 A pragma used to complete a declaration, such as a pragma @code{Import};
8544 @end cartouche
8545 @sp 1
8546 @cartouche
8547 A pragma used to configure the environment by adding, removing, or
8548 replacing @code{library_items}.
8549 @end cartouche
8550 See response to paragraph 16 of this same section.
8551
8552 @cindex Character Sets
8553 @cindex Alternative Character Sets
8554 @unnumberedsec 3.5.2(5): Alternative Character Sets
8555 @sp 1
8556 @cartouche
8557 If an implementation supports a mode with alternative interpretations
8558 for @code{Character} and @code{Wide_Character}, the set of graphic
8559 characters of @code{Character} should nevertheless remain a proper
8560 subset of the set of graphic characters of @code{Wide_Character}. Any
8561 character set ``localizations'' should be reflected in the results of
8562 the subprograms defined in the language-defined package
8563 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8564 an alternative interpretation of @code{Character}, the implementation should
8565 also support a corresponding change in what is a legal
8566 @code{identifier_letter}.
8567 @end cartouche
8568 Not all wide character modes follow this advice, in particular the JIS
8569 and IEC modes reflect standard usage in Japan, and in these encoding,
8570 the upper half of the Latin-1 set is not part of the wide-character
8571 subset, since the most significant bit is used for wide character
8572 encoding. However, this only applies to the external forms. Internally
8573 there is no such restriction.
8574
8575 @cindex Integer types
8576 @unnumberedsec 3.5.4(28): Integer Types
8577
8578 @sp 1
8579 @cartouche
8580 An implementation should support @code{Long_Integer} in addition to
8581 @code{Integer} if the target machine supports 32-bit (or longer)
8582 arithmetic. No other named integer subtypes are recommended for package
8583 @code{Standard}. Instead, appropriate named integer subtypes should be
8584 provided in the library package @code{Interfaces} (see B.2).
8585 @end cartouche
8586 @code{Long_Integer} is supported. Other standard integer types are supported
8587 so this advice is not fully followed. These types
8588 are supported for convenient interface to C, and so that all hardware
8589 types of the machine are easily available.
8590 @unnumberedsec 3.5.4(29): Integer Types
8591
8592 @sp 1
8593 @cartouche
8594 An implementation for a two's complement machine should support
8595 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8596 implementation should support a non-binary modules up to @code{Integer'Last}.
8597 @end cartouche
8598 Followed.
8599
8600 @cindex Enumeration values
8601 @unnumberedsec 3.5.5(8): Enumeration Values
8602 @sp 1
8603 @cartouche
8604 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8605 subtype, if the value of the operand does not correspond to the internal
8606 code for any enumeration literal of its type (perhaps due to an
8607 un-initialized variable), then the implementation should raise
8608 @code{Program_Error}. This is particularly important for enumeration
8609 types with noncontiguous internal codes specified by an
8610 enumeration_representation_clause.
8611 @end cartouche
8612 Followed.
8613
8614 @cindex Float types
8615 @unnumberedsec 3.5.7(17): Float Types
8616 @sp 1
8617 @cartouche
8618 An implementation should support @code{Long_Float} in addition to
8619 @code{Float} if the target machine supports 11 or more digits of
8620 precision. No other named floating point subtypes are recommended for
8621 package @code{Standard}. Instead, appropriate named floating point subtypes
8622 should be provided in the library package @code{Interfaces} (see B.2).
8623 @end cartouche
8624 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8625 former provides improved compatibility with other implementations
8626 supporting this type. The latter corresponds to the highest precision
8627 floating-point type supported by the hardware. On most machines, this
8628 will be the same as @code{Long_Float}, but on some machines, it will
8629 correspond to the IEEE extended form. The notable case is all ia32
8630 (x86) implementations, where @code{Long_Long_Float} corresponds to
8631 the 80-bit extended precision format supported in hardware on this
8632 processor. Note that the 128-bit format on SPARC is not supported,
8633 since this is a software rather than a hardware format.
8634
8635 @cindex Multidimensional arrays
8636 @cindex Arrays, multidimensional
8637 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8638 @sp 1
8639 @cartouche
8640 An implementation should normally represent multidimensional arrays in
8641 row-major order, consistent with the notation used for multidimensional
8642 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8643 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8644 column-major order should be used instead (see B.5, ``Interfacing with
8645 Fortran'').
8646 @end cartouche
8647 Followed.
8648
8649 @findex Duration'Small
8650 @unnumberedsec 9.6(30-31): Duration'Small
8651 @sp 1
8652 @cartouche
8653 Whenever possible in an implementation, the value of @code{Duration'Small}
8654 should be no greater than 100 microseconds.
8655 @end cartouche
8656 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8657
8658 @sp 1
8659 @cartouche
8660 The time base for @code{delay_relative_statements} should be monotonic;
8661 it need not be the same time base as used for @code{Calendar.Clock}.
8662 @end cartouche
8663 Followed.
8664
8665 @unnumberedsec 10.2.1(12): Consistent Representation
8666 @sp 1
8667 @cartouche
8668 In an implementation, a type declared in a pre-elaborated package should
8669 have the same representation in every elaboration of a given version of
8670 the package, whether the elaborations occur in distinct executions of
8671 the same program, or in executions of distinct programs or partitions
8672 that include the given version.
8673 @end cartouche
8674 Followed, except in the case of tagged types. Tagged types involve
8675 implicit pointers to a local copy of a dispatch table, and these pointers
8676 have representations which thus depend on a particular elaboration of the
8677 package. It is not easy to see how it would be possible to follow this
8678 advice without severely impacting efficiency of execution.
8679
8680 @cindex Exception information
8681 @unnumberedsec 11.4.1(19): Exception Information
8682 @sp 1
8683 @cartouche
8684 @code{Exception_Message} by default and @code{Exception_Information}
8685 should produce information useful for
8686 debugging. @code{Exception_Message} should be short, about one
8687 line. @code{Exception_Information} can be long. @code{Exception_Message}
8688 should not include the
8689 @code{Exception_Name}. @code{Exception_Information} should include both
8690 the @code{Exception_Name} and the @code{Exception_Message}.
8691 @end cartouche
8692 Followed. For each exception that doesn't have a specified
8693 @code{Exception_Message}, the compiler generates one containing the location
8694 of the raise statement. This location has the form ``file:line'', where
8695 file is the short file name (without path information) and line is the line
8696 number in the file. Note that in the case of the Zero Cost Exception
8697 mechanism, these messages become redundant with the Exception_Information that
8698 contains a full backtrace of the calling sequence, so they are disabled.
8699 To disable explicitly the generation of the source location message, use the
8700 Pragma @code{Discard_Names}.
8701
8702 @cindex Suppression of checks
8703 @cindex Checks, suppression of
8704 @unnumberedsec 11.5(28): Suppression of Checks
8705 @sp 1
8706 @cartouche
8707 The implementation should minimize the code executed for checks that
8708 have been suppressed.
8709 @end cartouche
8710 Followed.
8711
8712 @cindex Representation clauses
8713 @unnumberedsec 13.1 (21-24): Representation Clauses
8714 @sp 1
8715 @cartouche
8716 The recommended level of support for all representation items is
8717 qualified as follows:
8718 @end cartouche
8719 @sp 1
8720 @cartouche
8721 An implementation need not support representation items containing
8722 non-static expressions, except that an implementation should support a
8723 representation item for a given entity if each non-static expression in
8724 the representation item is a name that statically denotes a constant
8725 declared before the entity.
8726 @end cartouche
8727 Followed. In fact, GNAT goes beyond the recommended level of support
8728 by allowing nonstatic expressions in some representation clauses even
8729 without the need to declare constants initialized with the values of
8730 such expressions.
8731 For example:
8732
8733 @smallexample @c ada
8734 X : Integer;
8735 Y : Float;
8736 for Y'Address use X'Address;>>
8737 @end smallexample
8738
8739 @sp 1
8740 @cartouche
8741 An implementation need not support a specification for the @code{Size}
8742 for a given composite subtype, nor the size or storage place for an
8743 object (including a component) of a given composite subtype, unless the
8744 constraints on the subtype and its composite subcomponents (if any) are
8745 all static constraints.
8746 @end cartouche
8747 Followed. Size Clauses are not permitted on non-static components, as
8748 described above.
8749
8750 @sp 1
8751 @cartouche
8752 An aliased component, or a component whose type is by-reference, should
8753 always be allocated at an addressable location.
8754 @end cartouche
8755 Followed.
8756
8757 @cindex Packed types
8758 @unnumberedsec 13.2(6-8): Packed Types
8759 @sp 1
8760 @cartouche
8761 If a type is packed, then the implementation should try to minimize
8762 storage allocated to objects of the type, possibly at the expense of
8763 speed of accessing components, subject to reasonable complexity in
8764 addressing calculations.
8765 @end cartouche
8766 @sp 1
8767 @cartouche
8768 The recommended level of support pragma @code{Pack} is:
8769
8770 For a packed record type, the components should be packed as tightly as
8771 possible subject to the Sizes of the component subtypes, and subject to
8772 any @code{record_representation_clause} that applies to the type; the
8773 implementation may, but need not, reorder components or cross aligned
8774 word boundaries to improve the packing. A component whose @code{Size} is
8775 greater than the word size may be allocated an integral number of words.
8776 @end cartouche
8777 Followed. Tight packing of arrays is supported for all component sizes
8778 up to 64-bits. If the array component size is 1 (that is to say, if
8779 the component is a boolean type or an enumeration type with two values)
8780 then values of the type are implicitly initialized to zero. This
8781 happens both for objects of the packed type, and for objects that have a
8782 subcomponent of the packed type.
8783
8784 @sp 1
8785 @cartouche
8786 An implementation should support Address clauses for imported
8787 subprograms.
8788 @end cartouche
8789 Followed.
8790 @cindex @code{Address} clauses
8791 @unnumberedsec 13.3(14-19): Address Clauses
8792
8793 @sp 1
8794 @cartouche
8795 For an array @var{X}, @code{@var{X}'Address} should point at the first
8796 component of the array, and not at the array bounds.
8797 @end cartouche
8798 Followed.
8799
8800 @sp 1
8801 @cartouche
8802 The recommended level of support for the @code{Address} attribute is:
8803
8804 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8805 object that is aliased or of a by-reference type, or is an entity whose
8806 @code{Address} has been specified.
8807 @end cartouche
8808 Followed. A valid address will be produced even if none of those
8809 conditions have been met. If necessary, the object is forced into
8810 memory to ensure the address is valid.
8811
8812 @sp 1
8813 @cartouche
8814 An implementation should support @code{Address} clauses for imported
8815 subprograms.
8816 @end cartouche
8817 Followed.
8818
8819 @sp 1
8820 @cartouche
8821 Objects (including subcomponents) that are aliased or of a by-reference
8822 type should be allocated on storage element boundaries.
8823 @end cartouche
8824 Followed.
8825
8826 @sp 1
8827 @cartouche
8828 If the @code{Address} of an object is specified, or it is imported or exported,
8829 then the implementation should not perform optimizations based on
8830 assumptions of no aliases.
8831 @end cartouche
8832 Followed.
8833
8834 @cindex @code{Alignment} clauses
8835 @unnumberedsec 13.3(29-35): Alignment Clauses
8836 @sp 1
8837 @cartouche
8838 The recommended level of support for the @code{Alignment} attribute for
8839 subtypes is:
8840
8841 An implementation should support specified Alignments that are factors
8842 and multiples of the number of storage elements per word, subject to the
8843 following:
8844 @end cartouche
8845 Followed.
8846
8847 @sp 1
8848 @cartouche
8849 An implementation need not support specified @code{Alignment}s for
8850 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8851 loaded and stored by available machine instructions.
8852 @end cartouche
8853 Followed.
8854
8855 @sp 1
8856 @cartouche
8857 An implementation need not support specified @code{Alignment}s that are
8858 greater than the maximum @code{Alignment} the implementation ever returns by
8859 default.
8860 @end cartouche
8861 Followed.
8862
8863 @sp 1
8864 @cartouche
8865 The recommended level of support for the @code{Alignment} attribute for
8866 objects is:
8867
8868 Same as above, for subtypes, but in addition:
8869 @end cartouche
8870 Followed.
8871
8872 @sp 1
8873 @cartouche
8874 For stand-alone library-level objects of statically constrained
8875 subtypes, the implementation should support all @code{Alignment}s
8876 supported by the target linker. For example, page alignment is likely to
8877 be supported for such objects, but not for subtypes.
8878 @end cartouche
8879 Followed.
8880
8881 @cindex @code{Size} clauses
8882 @unnumberedsec 13.3(42-43): Size Clauses
8883 @sp 1
8884 @cartouche
8885 The recommended level of support for the @code{Size} attribute of
8886 objects is:
8887
8888 A @code{Size} clause should be supported for an object if the specified
8889 @code{Size} is at least as large as its subtype's @code{Size}, and
8890 corresponds to a size in storage elements that is a multiple of the
8891 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8892 @end cartouche
8893 Followed.
8894
8895 @unnumberedsec 13.3(50-56): Size Clauses
8896 @sp 1
8897 @cartouche
8898 If the @code{Size} of a subtype is specified, and allows for efficient
8899 independent addressability (see 9.10) on the target architecture, then
8900 the @code{Size} of the following objects of the subtype should equal the
8901 @code{Size} of the subtype:
8902
8903 Aliased objects (including components).
8904 @end cartouche
8905 Followed.
8906
8907 @sp 1
8908 @cartouche
8909 @code{Size} clause on a composite subtype should not affect the
8910 internal layout of components.
8911 @end cartouche
8912 Followed. But note that this can be overridden by use of the implementation
8913 pragma Implicit_Packing in the case of packed arrays.
8914
8915 @sp 1
8916 @cartouche
8917 The recommended level of support for the @code{Size} attribute of subtypes is:
8918 @end cartouche
8919 @sp 1
8920 @cartouche
8921 The @code{Size} (if not specified) of a static discrete or fixed point
8922 subtype should be the number of bits needed to represent each value
8923 belonging to the subtype using an unbiased representation, leaving space
8924 for a sign bit only if the subtype contains negative values. If such a
8925 subtype is a first subtype, then an implementation should support a
8926 specified @code{Size} for it that reflects this representation.
8927 @end cartouche
8928 Followed.
8929
8930 @sp 1
8931 @cartouche
8932 For a subtype implemented with levels of indirection, the @code{Size}
8933 should include the size of the pointers, but not the size of what they
8934 point at.
8935 @end cartouche
8936 Followed.
8937
8938 @cindex @code{Component_Size} clauses
8939 @unnumberedsec 13.3(71-73): Component Size Clauses
8940 @sp 1
8941 @cartouche
8942 The recommended level of support for the @code{Component_Size}
8943 attribute is:
8944 @end cartouche
8945 @sp 1
8946 @cartouche
8947 An implementation need not support specified @code{Component_Sizes} that are
8948 less than the @code{Size} of the component subtype.
8949 @end cartouche
8950 Followed.
8951
8952 @sp 1
8953 @cartouche
8954 An implementation should support specified @code{Component_Size}s that
8955 are factors and multiples of the word size. For such
8956 @code{Component_Size}s, the array should contain no gaps between
8957 components. For other @code{Component_Size}s (if supported), the array
8958 should contain no gaps between components when packing is also
8959 specified; the implementation should forbid this combination in cases
8960 where it cannot support a no-gaps representation.
8961 @end cartouche
8962 Followed.
8963
8964 @cindex Enumeration representation clauses
8965 @cindex Representation clauses, enumeration
8966 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8967 @sp 1
8968 @cartouche
8969 The recommended level of support for enumeration representation clauses
8970 is:
8971
8972 An implementation need not support enumeration representation clauses
8973 for boolean types, but should at minimum support the internal codes in
8974 the range @code{System.Min_Int.System.Max_Int}.
8975 @end cartouche
8976 Followed.
8977
8978 @cindex Record representation clauses
8979 @cindex Representation clauses, records
8980 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8981 @sp 1
8982 @cartouche
8983 The recommended level of support for
8984 @*@code{record_representation_clauses} is:
8985
8986 An implementation should support storage places that can be extracted
8987 with a load, mask, shift sequence of machine code, and set with a load,
8988 shift, mask, store sequence, given the available machine instructions
8989 and run-time model.
8990 @end cartouche
8991 Followed.
8992
8993 @sp 1
8994 @cartouche
8995 A storage place should be supported if its size is equal to the
8996 @code{Size} of the component subtype, and it starts and ends on a
8997 boundary that obeys the @code{Alignment} of the component subtype.
8998 @end cartouche
8999 Followed.
9000
9001 @sp 1
9002 @cartouche
9003 If the default bit ordering applies to the declaration of a given type,
9004 then for a component whose subtype's @code{Size} is less than the word
9005 size, any storage place that does not cross an aligned word boundary
9006 should be supported.
9007 @end cartouche
9008 Followed.
9009
9010 @sp 1
9011 @cartouche
9012 An implementation may reserve a storage place for the tag field of a
9013 tagged type, and disallow other components from overlapping that place.
9014 @end cartouche
9015 Followed. The storage place for the tag field is the beginning of the tagged
9016 record, and its size is Address'Size. GNAT will reject an explicit component
9017 clause for the tag field.
9018
9019 @sp 1
9020 @cartouche
9021 An implementation need not support a @code{component_clause} for a
9022 component of an extension part if the storage place is not after the
9023 storage places of all components of the parent type, whether or not
9024 those storage places had been specified.
9025 @end cartouche
9026 Followed. The above advice on record representation clauses is followed,
9027 and all mentioned features are implemented.
9028
9029 @cindex Storage place attributes
9030 @unnumberedsec 13.5.2(5): Storage Place Attributes
9031 @sp 1
9032 @cartouche
9033 If a component is represented using some form of pointer (such as an
9034 offset) to the actual data of the component, and this data is contiguous
9035 with the rest of the object, then the storage place attributes should
9036 reflect the place of the actual data, not the pointer. If a component is
9037 allocated discontinuously from the rest of the object, then a warning
9038 should be generated upon reference to one of its storage place
9039 attributes.
9040 @end cartouche
9041 Followed. There are no such components in GNAT@.
9042
9043 @cindex Bit ordering
9044 @unnumberedsec 13.5.3(7-8): Bit Ordering
9045 @sp 1
9046 @cartouche
9047 The recommended level of support for the non-default bit ordering is:
9048 @end cartouche
9049 @sp 1
9050 @cartouche
9051 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
9052 should support the non-default bit ordering in addition to the default
9053 bit ordering.
9054 @end cartouche
9055 Followed. Word size does not equal storage size in this implementation.
9056 Thus non-default bit ordering is not supported.
9057
9058 @cindex @code{Address}, as private type
9059 @unnumberedsec 13.7(37): Address as Private
9060 @sp 1
9061 @cartouche
9062 @code{Address} should be of a private type.
9063 @end cartouche
9064 Followed.
9065
9066 @cindex Operations, on @code{Address}
9067 @cindex @code{Address}, operations of
9068 @unnumberedsec 13.7.1(16): Address Operations
9069 @sp 1
9070 @cartouche
9071 Operations in @code{System} and its children should reflect the target
9072 environment semantics as closely as is reasonable. For example, on most
9073 machines, it makes sense for address arithmetic to ``wrap around''.
9074 Operations that do not make sense should raise @code{Program_Error}.
9075 @end cartouche
9076 Followed. Address arithmetic is modular arithmetic that wraps around. No
9077 operation raises @code{Program_Error}, since all operations make sense.
9078
9079 @cindex Unchecked conversion
9080 @unnumberedsec 13.9(14-17): Unchecked Conversion
9081 @sp 1
9082 @cartouche
9083 The @code{Size} of an array object should not include its bounds; hence,
9084 the bounds should not be part of the converted data.
9085 @end cartouche
9086 Followed.
9087
9088 @sp 1
9089 @cartouche
9090 The implementation should not generate unnecessary run-time checks to
9091 ensure that the representation of @var{S} is a representation of the
9092 target type. It should take advantage of the permission to return by
9093 reference when possible. Restrictions on unchecked conversions should be
9094 avoided unless required by the target environment.
9095 @end cartouche
9096 Followed. There are no restrictions on unchecked conversion. A warning is
9097 generated if the source and target types do not have the same size since
9098 the semantics in this case may be target dependent.
9099
9100 @sp 1
9101 @cartouche
9102 The recommended level of support for unchecked conversions is:
9103 @end cartouche
9104 @sp 1
9105 @cartouche
9106 Unchecked conversions should be supported and should be reversible in
9107 the cases where this clause defines the result. To enable meaningful use
9108 of unchecked conversion, a contiguous representation should be used for
9109 elementary subtypes, for statically constrained array subtypes whose
9110 component subtype is one of the subtypes described in this paragraph,
9111 and for record subtypes without discriminants whose component subtypes
9112 are described in this paragraph.
9113 @end cartouche
9114 Followed.
9115
9116 @cindex Heap usage, implicit
9117 @unnumberedsec 13.11(23-25): Implicit Heap Usage
9118 @sp 1
9119 @cartouche
9120 An implementation should document any cases in which it dynamically
9121 allocates heap storage for a purpose other than the evaluation of an
9122 allocator.
9123 @end cartouche
9124 Followed, the only other points at which heap storage is dynamically
9125 allocated are as follows:
9126
9127 @itemize @bullet
9128 @item
9129 At initial elaboration time, to allocate dynamically sized global
9130 objects.
9131
9132 @item
9133 To allocate space for a task when a task is created.
9134
9135 @item
9136 To extend the secondary stack dynamically when needed. The secondary
9137 stack is used for returning variable length results.
9138 @end itemize
9139
9140 @sp 1
9141 @cartouche
9142 A default (implementation-provided) storage pool for an
9143 access-to-constant type should not have overhead to support deallocation of
9144 individual objects.
9145 @end cartouche
9146 Followed.
9147
9148 @sp 1
9149 @cartouche
9150 A storage pool for an anonymous access type should be created at the
9151 point of an allocator for the type, and be reclaimed when the designated
9152 object becomes inaccessible.
9153 @end cartouche
9154 Followed.
9155
9156 @cindex Unchecked deallocation
9157 @unnumberedsec 13.11.2(17): Unchecked De-allocation
9158 @sp 1
9159 @cartouche
9160 For a standard storage pool, @code{Free} should actually reclaim the
9161 storage.
9162 @end cartouche
9163 Followed.
9164
9165 @cindex Stream oriented attributes
9166 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
9167 @sp 1
9168 @cartouche
9169 If a stream element is the same size as a storage element, then the
9170 normal in-memory representation should be used by @code{Read} and
9171 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
9172 should use the smallest number of stream elements needed to represent
9173 all values in the base range of the scalar type.
9174 @end cartouche
9175
9176 Followed. By default, GNAT uses the interpretation suggested by AI-195,
9177 which specifies using the size of the first subtype.
9178 However, such an implementation is based on direct binary
9179 representations and is therefore target- and endianness-dependent.
9180 To address this issue, GNAT also supplies an alternate implementation
9181 of the stream attributes @code{Read} and @code{Write},
9182 which uses the target-independent XDR standard representation
9183 for scalar types.
9184 @cindex XDR representation
9185 @cindex @code{Read} attribute
9186 @cindex @code{Write} attribute
9187 @cindex Stream oriented attributes
9188 The XDR implementation is provided as an alternative body of the
9189 @code{System.Stream_Attributes} package, in the file
9190 @file{s-stratt-xdr.adb} in the GNAT library.
9191 There is no @file{s-stratt-xdr.ads} file.
9192 In order to install the XDR implementation, do the following:
9193 @enumerate
9194 @item Replace the default implementation of the
9195 @code{System.Stream_Attributes} package with the XDR implementation.
9196 For example on a Unix platform issue the commands:
9197 @smallexample
9198 $ mv s-stratt.adb s-stratt-default.adb
9199 $ mv s-stratt-xdr.adb s-stratt.adb
9200 @end smallexample
9201
9202 @item
9203 Rebuild the GNAT run-time library as documented in
9204 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
9205 @end enumerate
9206
9207 @unnumberedsec A.1(52): Names of Predefined Numeric Types
9208 @sp 1
9209 @cartouche
9210 If an implementation provides additional named predefined integer types,
9211 then the names should end with @samp{Integer} as in
9212 @samp{Long_Integer}. If an implementation provides additional named
9213 predefined floating point types, then the names should end with
9214 @samp{Float} as in @samp{Long_Float}.
9215 @end cartouche
9216 Followed.
9217
9218 @findex Ada.Characters.Handling
9219 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
9220 @sp 1
9221 @cartouche
9222 If an implementation provides a localized definition of @code{Character}
9223 or @code{Wide_Character}, then the effects of the subprograms in
9224 @code{Characters.Handling} should reflect the localizations. See also
9225 3.5.2.
9226 @end cartouche
9227 Followed. GNAT provides no such localized definitions.
9228
9229 @cindex Bounded-length strings
9230 @unnumberedsec A.4.4(106): Bounded-Length String Handling
9231 @sp 1
9232 @cartouche
9233 Bounded string objects should not be implemented by implicit pointers
9234 and dynamic allocation.
9235 @end cartouche
9236 Followed. No implicit pointers or dynamic allocation are used.
9237
9238 @cindex Random number generation
9239 @unnumberedsec A.5.2(46-47): Random Number Generation
9240 @sp 1
9241 @cartouche
9242 Any storage associated with an object of type @code{Generator} should be
9243 reclaimed on exit from the scope of the object.
9244 @end cartouche
9245 Followed.
9246
9247 @sp 1
9248 @cartouche
9249 If the generator period is sufficiently long in relation to the number
9250 of distinct initiator values, then each possible value of
9251 @code{Initiator} passed to @code{Reset} should initiate a sequence of
9252 random numbers that does not, in a practical sense, overlap the sequence
9253 initiated by any other value. If this is not possible, then the mapping
9254 between initiator values and generator states should be a rapidly
9255 varying function of the initiator value.
9256 @end cartouche
9257 Followed. The generator period is sufficiently long for the first
9258 condition here to hold true.
9259
9260 @findex Get_Immediate
9261 @unnumberedsec A.10.7(23): @code{Get_Immediate}
9262 @sp 1
9263 @cartouche
9264 The @code{Get_Immediate} procedures should be implemented with
9265 unbuffered input. For a device such as a keyboard, input should be
9266 @dfn{available} if a key has already been typed, whereas for a disk
9267 file, input should always be available except at end of file. For a file
9268 associated with a keyboard-like device, any line-editing features of the
9269 underlying operating system should be disabled during the execution of
9270 @code{Get_Immediate}.
9271 @end cartouche
9272 Followed on all targets except VxWorks. For VxWorks, there is no way to
9273 provide this functionality that does not result in the input buffer being
9274 flushed before the @code{Get_Immediate} call. A special unit
9275 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
9276 this functionality.
9277
9278 @findex Export
9279 @unnumberedsec B.1(39-41): Pragma @code{Export}
9280 @sp 1
9281 @cartouche
9282 If an implementation supports pragma @code{Export} to a given language,
9283 then it should also allow the main subprogram to be written in that
9284 language. It should support some mechanism for invoking the elaboration
9285 of the Ada library units included in the system, and for invoking the
9286 finalization of the environment task. On typical systems, the
9287 recommended mechanism is to provide two subprograms whose link names are
9288 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
9289 elaboration code for library units. @code{adafinal} should contain the
9290 finalization code. These subprograms should have no effect the second
9291 and subsequent time they are called.
9292 @end cartouche
9293 Followed.
9294
9295 @sp 1
9296 @cartouche
9297 Automatic elaboration of pre-elaborated packages should be
9298 provided when pragma @code{Export} is supported.
9299 @end cartouche
9300 Followed when the main program is in Ada. If the main program is in a
9301 foreign language, then
9302 @code{adainit} must be called to elaborate pre-elaborated
9303 packages.
9304
9305 @sp 1
9306 @cartouche
9307 For each supported convention @var{L} other than @code{Intrinsic}, an
9308 implementation should support @code{Import} and @code{Export} pragmas
9309 for objects of @var{L}-compatible types and for subprograms, and pragma
9310 @code{Convention} for @var{L}-eligible types and for subprograms,
9311 presuming the other language has corresponding features. Pragma
9312 @code{Convention} need not be supported for scalar types.
9313 @end cartouche
9314 Followed.
9315
9316 @cindex Package @code{Interfaces}
9317 @findex Interfaces
9318 @unnumberedsec B.2(12-13): Package @code{Interfaces}
9319 @sp 1
9320 @cartouche
9321 For each implementation-defined convention identifier, there should be a
9322 child package of package Interfaces with the corresponding name. This
9323 package should contain any declarations that would be useful for
9324 interfacing to the language (implementation) represented by the
9325 convention. Any declarations useful for interfacing to any language on
9326 the given hardware architecture should be provided directly in
9327 @code{Interfaces}.
9328 @end cartouche
9329 Followed. An additional package not defined
9330 in the Ada Reference Manual is @code{Interfaces.CPP}, used
9331 for interfacing to C++.
9332
9333 @sp 1
9334 @cartouche
9335 An implementation supporting an interface to C, COBOL, or Fortran should
9336 provide the corresponding package or packages described in the following
9337 clauses.
9338 @end cartouche
9339 Followed. GNAT provides all the packages described in this section.
9340
9341 @cindex C, interfacing with
9342 @unnumberedsec B.3(63-71): Interfacing with C
9343 @sp 1
9344 @cartouche
9345 An implementation should support the following interface correspondences
9346 between Ada and C@.
9347 @end cartouche
9348 Followed.
9349
9350 @sp 1
9351 @cartouche
9352 An Ada procedure corresponds to a void-returning C function.
9353 @end cartouche
9354 Followed.
9355
9356 @sp 1
9357 @cartouche
9358 An Ada function corresponds to a non-void C function.
9359 @end cartouche
9360 Followed.
9361
9362 @sp 1
9363 @cartouche
9364 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
9365 function.
9366 @end cartouche
9367 Followed.
9368
9369 @sp 1
9370 @cartouche
9371 An Ada @code{in} parameter of an access-to-object type with designated
9372 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
9373 where @var{t} is the C type corresponding to the Ada type @var{T}.
9374 @end cartouche
9375 Followed.
9376
9377 @sp 1
9378 @cartouche
9379 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
9380 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
9381 argument to a C function, where @var{t} is the C type corresponding to
9382 the Ada type @var{T}. In the case of an elementary @code{out} or
9383 @code{in out} parameter, a pointer to a temporary copy is used to
9384 preserve by-copy semantics.
9385 @end cartouche
9386 Followed.
9387
9388 @sp 1
9389 @cartouche
9390 An Ada parameter of a record type @var{T}, of any mode, is passed as a
9391 @code{@var{t}*} argument to a C function, where @var{t} is the C
9392 structure corresponding to the Ada type @var{T}.
9393 @end cartouche
9394 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
9395 pragma, or Convention, or by explicitly specifying the mechanism for a given
9396 call using an extended import or export pragma.
9397
9398 @sp 1
9399 @cartouche
9400 An Ada parameter of an array type with component type @var{T}, of any
9401 mode, is passed as a @code{@var{t}*} argument to a C function, where
9402 @var{t} is the C type corresponding to the Ada type @var{T}.
9403 @end cartouche
9404 Followed.
9405
9406 @sp 1
9407 @cartouche
9408 An Ada parameter of an access-to-subprogram type is passed as a pointer
9409 to a C function whose prototype corresponds to the designated
9410 subprogram's specification.
9411 @end cartouche
9412 Followed.
9413
9414 @cindex COBOL, interfacing with
9415 @unnumberedsec B.4(95-98): Interfacing with COBOL
9416 @sp 1
9417 @cartouche
9418 An Ada implementation should support the following interface
9419 correspondences between Ada and COBOL@.
9420 @end cartouche
9421 Followed.
9422
9423 @sp 1
9424 @cartouche
9425 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
9426 the COBOL type corresponding to @var{T}.
9427 @end cartouche
9428 Followed.
9429
9430 @sp 1
9431 @cartouche
9432 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
9433 the corresponding COBOL type.
9434 @end cartouche
9435 Followed.
9436
9437 @sp 1
9438 @cartouche
9439 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
9440 COBOL type corresponding to the Ada parameter type; for scalars, a local
9441 copy is used if necessary to ensure by-copy semantics.
9442 @end cartouche
9443 Followed.
9444
9445 @cindex Fortran, interfacing with
9446 @unnumberedsec B.5(22-26): Interfacing with Fortran
9447 @sp 1
9448 @cartouche
9449 An Ada implementation should support the following interface
9450 correspondences between Ada and Fortran:
9451 @end cartouche
9452 Followed.
9453
9454 @sp 1
9455 @cartouche
9456 An Ada procedure corresponds to a Fortran subroutine.
9457 @end cartouche
9458 Followed.
9459
9460 @sp 1
9461 @cartouche
9462 An Ada function corresponds to a Fortran function.
9463 @end cartouche
9464 Followed.
9465
9466 @sp 1
9467 @cartouche
9468 An Ada parameter of an elementary, array, or record type @var{T} is
9469 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9470 the Fortran type corresponding to the Ada type @var{T}, and where the
9471 INTENT attribute of the corresponding dummy argument matches the Ada
9472 formal parameter mode; the Fortran implementation's parameter passing
9473 conventions are used. For elementary types, a local copy is used if
9474 necessary to ensure by-copy semantics.
9475 @end cartouche
9476 Followed.
9477
9478 @sp 1
9479 @cartouche
9480 An Ada parameter of an access-to-subprogram type is passed as a
9481 reference to a Fortran procedure whose interface corresponds to the
9482 designated subprogram's specification.
9483 @end cartouche
9484 Followed.
9485
9486 @cindex Machine operations
9487 @unnumberedsec C.1(3-5): Access to Machine Operations
9488 @sp 1
9489 @cartouche
9490 The machine code or intrinsic support should allow access to all
9491 operations normally available to assembly language programmers for the
9492 target environment, including privileged instructions, if any.
9493 @end cartouche
9494 Followed.
9495
9496 @sp 1
9497 @cartouche
9498 The interfacing pragmas (see Annex B) should support interface to
9499 assembler; the default assembler should be associated with the
9500 convention identifier @code{Assembler}.
9501 @end cartouche
9502 Followed.
9503
9504 @sp 1
9505 @cartouche
9506 If an entity is exported to assembly language, then the implementation
9507 should allocate it at an addressable location, and should ensure that it
9508 is retained by the linking process, even if not otherwise referenced
9509 from the Ada code. The implementation should assume that any call to a
9510 machine code or assembler subprogram is allowed to read or update every
9511 object that is specified as exported.
9512 @end cartouche
9513 Followed.
9514
9515 @unnumberedsec C.1(10-16): Access to Machine Operations
9516 @sp 1
9517 @cartouche
9518 The implementation should ensure that little or no overhead is
9519 associated with calling intrinsic and machine-code subprograms.
9520 @end cartouche
9521 Followed for both intrinsics and machine-code subprograms.
9522
9523 @sp 1
9524 @cartouche
9525 It is recommended that intrinsic subprograms be provided for convenient
9526 access to any machine operations that provide special capabilities or
9527 efficiency and that are not otherwise available through the language
9528 constructs.
9529 @end cartouche
9530 Followed. A full set of machine operation intrinsic subprograms is provided.
9531
9532 @sp 1
9533 @cartouche
9534 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9535 swap, decrement and test, enqueue/dequeue.
9536 @end cartouche
9537 Followed on any target supporting such operations.
9538
9539 @sp 1
9540 @cartouche
9541 Standard numeric functions---e.g.@:, sin, log.
9542 @end cartouche
9543 Followed on any target supporting such operations.
9544
9545 @sp 1
9546 @cartouche
9547 String manipulation operations---e.g.@:, translate and test.
9548 @end cartouche
9549 Followed on any target supporting such operations.
9550
9551 @sp 1
9552 @cartouche
9553 Vector operations---e.g.@:, compare vector against thresholds.
9554 @end cartouche
9555 Followed on any target supporting such operations.
9556
9557 @sp 1
9558 @cartouche
9559 Direct operations on I/O ports.
9560 @end cartouche
9561 Followed on any target supporting such operations.
9562
9563 @cindex Interrupt support
9564 @unnumberedsec C.3(28): Interrupt Support
9565 @sp 1
9566 @cartouche
9567 If the @code{Ceiling_Locking} policy is not in effect, the
9568 implementation should provide means for the application to specify which
9569 interrupts are to be blocked during protected actions, if the underlying
9570 system allows for a finer-grain control of interrupt blocking.
9571 @end cartouche
9572 Followed. The underlying system does not allow for finer-grain control
9573 of interrupt blocking.
9574
9575 @cindex Protected procedure handlers
9576 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9577 @sp 1
9578 @cartouche
9579 Whenever possible, the implementation should allow interrupt handlers to
9580 be called directly by the hardware.
9581 @end cartouche
9582 Followed on any target where the underlying operating system permits
9583 such direct calls.
9584
9585 @sp 1
9586 @cartouche
9587 Whenever practical, violations of any
9588 implementation-defined restrictions should be detected before run time.
9589 @end cartouche
9590 Followed. Compile time warnings are given when possible.
9591
9592 @cindex Package @code{Interrupts}
9593 @findex Interrupts
9594 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9595
9596 @sp 1
9597 @cartouche
9598 If implementation-defined forms of interrupt handler procedures are
9599 supported, such as protected procedures with parameters, then for each
9600 such form of a handler, a type analogous to @code{Parameterless_Handler}
9601 should be specified in a child package of @code{Interrupts}, with the
9602 same operations as in the predefined package Interrupts.
9603 @end cartouche
9604 Followed.
9605
9606 @cindex Pre-elaboration requirements
9607 @unnumberedsec C.4(14): Pre-elaboration Requirements
9608 @sp 1
9609 @cartouche
9610 It is recommended that pre-elaborated packages be implemented in such a
9611 way that there should be little or no code executed at run time for the
9612 elaboration of entities not already covered by the Implementation
9613 Requirements.
9614 @end cartouche
9615 Followed. Executable code is generated in some cases, e.g.@: loops
9616 to initialize large arrays.
9617
9618 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9619 @sp 1
9620 @cartouche
9621 If the pragma applies to an entity, then the implementation should
9622 reduce the amount of storage used for storing names associated with that
9623 entity.
9624 @end cartouche
9625 Followed.
9626
9627 @cindex Package @code{Task_Attributes}
9628 @findex Task_Attributes
9629 @unnumberedsec C.7.2(30): The Package Task_Attributes
9630 @sp 1
9631 @cartouche
9632 Some implementations are targeted to domains in which memory use at run
9633 time must be completely deterministic. For such implementations, it is
9634 recommended that the storage for task attributes will be pre-allocated
9635 statically and not from the heap. This can be accomplished by either
9636 placing restrictions on the number and the size of the task's
9637 attributes, or by using the pre-allocated storage for the first @var{N}
9638 attribute objects, and the heap for the others. In the latter case,
9639 @var{N} should be documented.
9640 @end cartouche
9641 Not followed. This implementation is not targeted to such a domain.
9642
9643 @cindex Locking Policies
9644 @unnumberedsec D.3(17): Locking Policies
9645
9646 @sp 1
9647 @cartouche
9648 The implementation should use names that end with @samp{_Locking} for
9649 locking policies defined by the implementation.
9650 @end cartouche
9651 Followed. Two implementation-defined locking policies are defined,
9652 whose names (@code{Inheritance_Locking} and
9653 @code{Concurrent_Readers_Locking}) follow this suggestion.
9654
9655 @cindex Entry queuing policies
9656 @unnumberedsec D.4(16): Entry Queuing Policies
9657 @sp 1
9658 @cartouche
9659 Names that end with @samp{_Queuing} should be used
9660 for all implementation-defined queuing policies.
9661 @end cartouche
9662 Followed. No such implementation-defined queuing policies exist.
9663
9664 @cindex Preemptive abort
9665 @unnumberedsec D.6(9-10): Preemptive Abort
9666 @sp 1
9667 @cartouche
9668 Even though the @code{abort_statement} is included in the list of
9669 potentially blocking operations (see 9.5.1), it is recommended that this
9670 statement be implemented in a way that never requires the task executing
9671 the @code{abort_statement} to block.
9672 @end cartouche
9673 Followed.
9674
9675 @sp 1
9676 @cartouche
9677 On a multi-processor, the delay associated with aborting a task on
9678 another processor should be bounded; the implementation should use
9679 periodic polling, if necessary, to achieve this.
9680 @end cartouche
9681 Followed.
9682
9683 @cindex Tasking restrictions
9684 @unnumberedsec D.7(21): Tasking Restrictions
9685 @sp 1
9686 @cartouche
9687 When feasible, the implementation should take advantage of the specified
9688 restrictions to produce a more efficient implementation.
9689 @end cartouche
9690 GNAT currently takes advantage of these restrictions by providing an optimized
9691 run time when the Ravenscar profile and the GNAT restricted run time set
9692 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9693 pragma @code{Profile (Restricted)} for more details.
9694
9695 @cindex Time, monotonic
9696 @unnumberedsec D.8(47-49): Monotonic Time
9697 @sp 1
9698 @cartouche
9699 When appropriate, implementations should provide configuration
9700 mechanisms to change the value of @code{Tick}.
9701 @end cartouche
9702 Such configuration mechanisms are not appropriate to this implementation
9703 and are thus not supported.
9704
9705 @sp 1
9706 @cartouche
9707 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9708 be implemented as transformations of the same time base.
9709 @end cartouche
9710 Followed.
9711
9712 @sp 1
9713 @cartouche
9714 It is recommended that the @dfn{best} time base which exists in
9715 the underlying system be available to the application through
9716 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9717 @end cartouche
9718 Followed.
9719
9720 @cindex Partition communication subsystem
9721 @cindex PCS
9722 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9723 @sp 1
9724 @cartouche
9725 Whenever possible, the PCS on the called partition should allow for
9726 multiple tasks to call the RPC-receiver with different messages and
9727 should allow them to block until the corresponding subprogram body
9728 returns.
9729 @end cartouche
9730 Followed by GLADE, a separately supplied PCS that can be used with
9731 GNAT.
9732
9733 @sp 1
9734 @cartouche
9735 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9736 should raise @code{Storage_Error} if it runs out of space trying to
9737 write the @code{Item} into the stream.
9738 @end cartouche
9739 Followed by GLADE, a separately supplied PCS that can be used with
9740 GNAT@.
9741
9742 @cindex COBOL support
9743 @unnumberedsec F(7): COBOL Support
9744 @sp 1
9745 @cartouche
9746 If COBOL (respectively, C) is widely supported in the target
9747 environment, implementations supporting the Information Systems Annex
9748 should provide the child package @code{Interfaces.COBOL} (respectively,
9749 @code{Interfaces.C}) specified in Annex B and should support a
9750 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9751 pragmas (see Annex B), thus allowing Ada programs to interface with
9752 programs written in that language.
9753 @end cartouche
9754 Followed.
9755
9756 @cindex Decimal radix support
9757 @unnumberedsec F.1(2): Decimal Radix Support
9758 @sp 1
9759 @cartouche
9760 Packed decimal should be used as the internal representation for objects
9761 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9762 @end cartouche
9763 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9764 representations.
9765
9766 @cindex Numerics
9767 @unnumberedsec G: Numerics
9768 @sp 2
9769 @cartouche
9770 If Fortran (respectively, C) is widely supported in the target
9771 environment, implementations supporting the Numerics Annex
9772 should provide the child package @code{Interfaces.Fortran} (respectively,
9773 @code{Interfaces.C}) specified in Annex B and should support a
9774 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9775 pragmas (see Annex B), thus allowing Ada programs to interface with
9776 programs written in that language.
9777 @end cartouche
9778 Followed.
9779
9780 @cindex Complex types
9781 @unnumberedsec G.1.1(56-58): Complex Types
9782 @sp 2
9783 @cartouche
9784 Because the usual mathematical meaning of multiplication of a complex
9785 operand and a real operand is that of the scaling of both components of
9786 the former by the latter, an implementation should not perform this
9787 operation by first promoting the real operand to complex type and then
9788 performing a full complex multiplication. In systems that, in the
9789 future, support an Ada binding to IEC 559:1989, the latter technique
9790 will not generate the required result when one of the components of the
9791 complex operand is infinite. (Explicit multiplication of the infinite
9792 component by the zero component obtained during promotion yields a NaN
9793 that propagates into the final result.) Analogous advice applies in the
9794 case of multiplication of a complex operand and a pure-imaginary
9795 operand, and in the case of division of a complex operand by a real or
9796 pure-imaginary operand.
9797 @end cartouche
9798 Not followed.
9799
9800 @sp 1
9801 @cartouche
9802 Similarly, because the usual mathematical meaning of addition of a
9803 complex operand and a real operand is that the imaginary operand remains
9804 unchanged, an implementation should not perform this operation by first
9805 promoting the real operand to complex type and then performing a full
9806 complex addition. In implementations in which the @code{Signed_Zeros}
9807 attribute of the component type is @code{True} (and which therefore
9808 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9809 predefined arithmetic operations), the latter technique will not
9810 generate the required result when the imaginary component of the complex
9811 operand is a negatively signed zero. (Explicit addition of the negative
9812 zero to the zero obtained during promotion yields a positive zero.)
9813 Analogous advice applies in the case of addition of a complex operand
9814 and a pure-imaginary operand, and in the case of subtraction of a
9815 complex operand and a real or pure-imaginary operand.
9816 @end cartouche
9817 Not followed.
9818
9819 @sp 1
9820 @cartouche
9821 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9822 attempt to provide a rational treatment of the signs of zero results and
9823 result components. As one example, the result of the @code{Argument}
9824 function should have the sign of the imaginary component of the
9825 parameter @code{X} when the point represented by that parameter lies on
9826 the positive real axis; as another, the sign of the imaginary component
9827 of the @code{Compose_From_Polar} function should be the same as
9828 (respectively, the opposite of) that of the @code{Argument} parameter when that
9829 parameter has a value of zero and the @code{Modulus} parameter has a
9830 nonnegative (respectively, negative) value.
9831 @end cartouche
9832 Followed.
9833
9834 @cindex Complex elementary functions
9835 @unnumberedsec G.1.2(49): Complex Elementary Functions
9836 @sp 1
9837 @cartouche
9838 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9839 @code{True} should attempt to provide a rational treatment of the signs
9840 of zero results and result components. For example, many of the complex
9841 elementary functions have components that are odd functions of one of
9842 the parameter components; in these cases, the result component should
9843 have the sign of the parameter component at the origin. Other complex
9844 elementary functions have zero components whose sign is opposite that of
9845 a parameter component at the origin, or is always positive or always
9846 negative.
9847 @end cartouche
9848 Followed.
9849
9850 @cindex Accuracy requirements
9851 @unnumberedsec G.2.4(19): Accuracy Requirements
9852 @sp 1
9853 @cartouche
9854 The versions of the forward trigonometric functions without a
9855 @code{Cycle} parameter should not be implemented by calling the
9856 corresponding version with a @code{Cycle} parameter of
9857 @code{2.0*Numerics.Pi}, since this will not provide the required
9858 accuracy in some portions of the domain. For the same reason, the
9859 version of @code{Log} without a @code{Base} parameter should not be
9860 implemented by calling the corresponding version with a @code{Base}
9861 parameter of @code{Numerics.e}.
9862 @end cartouche
9863 Followed.
9864
9865 @cindex Complex arithmetic accuracy
9866 @cindex Accuracy, complex arithmetic
9867 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9868
9869 @sp 1
9870 @cartouche
9871 The version of the @code{Compose_From_Polar} function without a
9872 @code{Cycle} parameter should not be implemented by calling the
9873 corresponding version with a @code{Cycle} parameter of
9874 @code{2.0*Numerics.Pi}, since this will not provide the required
9875 accuracy in some portions of the domain.
9876 @end cartouche
9877 Followed.
9878
9879 @cindex Sequential elaboration policy
9880 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
9881
9882 @sp 1
9883 @cartouche
9884 If the partition elaboration policy is @code{Sequential} and the
9885 Environment task becomes permanently blocked during elaboration then the
9886 partition is deadlocked and it is recommended that the partition be
9887 immediately terminated.
9888 @end cartouche
9889 Not followed.
9890
9891 @c -----------------------------------------
9892 @node Implementation Defined Characteristics
9893 @chapter Implementation Defined Characteristics
9894
9895 @noindent
9896 In addition to the implementation dependent pragmas and attributes, and the
9897 implementation advice, there are a number of other Ada features that are
9898 potentially implementation dependent and are designated as
9899 implementation-defined. These are mentioned throughout the Ada Reference
9900 Manual, and are summarized in Annex M@.
9901
9902 A requirement for conforming Ada compilers is that they provide
9903 documentation describing how the implementation deals with each of these
9904 issues. In this chapter, you will find each point in Annex M listed
9905 followed by a description in italic font of how GNAT
9906 handles the implementation dependence.
9907
9908 You can use this chapter as a guide to minimizing implementation
9909 dependent features in your programs if portability to other compilers
9910 and other operating systems is an important consideration. The numbers
9911 in each section below correspond to the paragraph number in the Ada
9912 Reference Manual.
9913
9914 @sp 1
9915 @cartouche
9916 @noindent
9917 @strong{2}. Whether or not each recommendation given in Implementation
9918 Advice is followed. See 1.1.2(37).
9919 @end cartouche
9920 @noindent
9921 @xref{Implementation Advice}.
9922
9923 @sp 1
9924 @cartouche
9925 @noindent
9926 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9927 @end cartouche
9928 @noindent
9929 The complexity of programs that can be processed is limited only by the
9930 total amount of available virtual memory, and disk space for the
9931 generated object files.
9932
9933 @sp 1
9934 @cartouche
9935 @noindent
9936 @strong{4}. Variations from the standard that are impractical to avoid
9937 given the implementation's execution environment. See 1.1.3(6).
9938 @end cartouche
9939 @noindent
9940 There are no variations from the standard.
9941
9942 @sp 1
9943 @cartouche
9944 @noindent
9945 @strong{5}. Which @code{code_statement}s cause external
9946 interactions. See 1.1.3(10).
9947 @end cartouche
9948 @noindent
9949 Any @code{code_statement} can potentially cause external interactions.
9950
9951 @sp 1
9952 @cartouche
9953 @noindent
9954 @strong{6}. The coded representation for the text of an Ada
9955 program. See 2.1(4).
9956 @end cartouche
9957 @noindent
9958 See separate section on source representation.
9959
9960 @sp 1
9961 @cartouche
9962 @noindent
9963 @strong{7}. The control functions allowed in comments. See 2.1(14).
9964 @end cartouche
9965 @noindent
9966 See separate section on source representation.
9967
9968 @sp 1
9969 @cartouche
9970 @noindent
9971 @strong{8}. The representation for an end of line. See 2.2(2).
9972 @end cartouche
9973 @noindent
9974 See separate section on source representation.
9975
9976 @sp 1
9977 @cartouche
9978 @noindent
9979 @strong{9}. Maximum supported line length and lexical element
9980 length. See 2.2(15).
9981 @end cartouche
9982 @noindent
9983 The maximum line length is 255 characters and the maximum length of
9984 a lexical element is also 255 characters. This is the default setting
9985 if not overridden by the use of compiler switch @option{-gnaty} (which
9986 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
9987 line length to be specified to be any value up to 32767. The maximum
9988 length of a lexical element is the same as the maximum line length.
9989
9990 @sp 1
9991 @cartouche
9992 @noindent
9993 @strong{10}. Implementation defined pragmas. See 2.8(14).
9994 @end cartouche
9995 @noindent
9996
9997 @xref{Implementation Defined Pragmas}.
9998
9999 @sp 1
10000 @cartouche
10001 @noindent
10002 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
10003 @end cartouche
10004 @noindent
10005 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
10006 parameter, checks that the optimization flag is set, and aborts if it is
10007 not.
10008
10009 @sp 1
10010 @cartouche
10011 @noindent
10012 @strong{12}. The sequence of characters of the value returned by
10013 @code{@var{S}'Image} when some of the graphic characters of
10014 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
10015 3.5(37).
10016 @end cartouche
10017 @noindent
10018 The sequence of characters is as defined by the wide character encoding
10019 method used for the source. See section on source representation for
10020 further details.
10021
10022 @sp 1
10023 @cartouche
10024 @noindent
10025 @strong{13}. The predefined integer types declared in
10026 @code{Standard}. See 3.5.4(25).
10027 @end cartouche
10028 @noindent
10029 @table @code
10030 @item Short_Short_Integer
10031 8 bit signed
10032 @item Short_Integer
10033 (Short) 16 bit signed
10034 @item Integer
10035 32 bit signed
10036 @item Long_Integer
10037 64 bit signed (on most 64 bit targets, depending on the C definition of long).
10038 32 bit signed (all other targets)
10039 @item Long_Long_Integer
10040 64 bit signed
10041 @end table
10042
10043 @sp 1
10044 @cartouche
10045 @noindent
10046 @strong{14}. Any nonstandard integer types and the operators defined
10047 for them. See 3.5.4(26).
10048 @end cartouche
10049 @noindent
10050 There are no nonstandard integer types.
10051
10052 @sp 1
10053 @cartouche
10054 @noindent
10055 @strong{15}. Any nonstandard real types and the operators defined for
10056 them. See 3.5.6(8).
10057 @end cartouche
10058 @noindent
10059 There are no nonstandard real types.
10060
10061 @sp 1
10062 @cartouche
10063 @noindent
10064 @strong{16}. What combinations of requested decimal precision and range
10065 are supported for floating point types. See 3.5.7(7).
10066 @end cartouche
10067 @noindent
10068 The precision and range is as defined by the IEEE standard.
10069
10070 @sp 1
10071 @cartouche
10072 @noindent
10073 @strong{17}. The predefined floating point types declared in
10074 @code{Standard}. See 3.5.7(16).
10075 @end cartouche
10076 @noindent
10077 @table @code
10078 @item Short_Float
10079 32 bit IEEE short
10080 @item Float
10081 (Short) 32 bit IEEE short
10082 @item Long_Float
10083 64 bit IEEE long
10084 @item Long_Long_Float
10085 64 bit IEEE long (80 bit IEEE long on x86 processors)
10086 @end table
10087
10088 @sp 1
10089 @cartouche
10090 @noindent
10091 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
10092 @end cartouche
10093 @noindent
10094 @code{Fine_Delta} is 2**(@minus{}63)
10095
10096 @sp 1
10097 @cartouche
10098 @noindent
10099 @strong{19}. What combinations of small, range, and digits are
10100 supported for fixed point types. See 3.5.9(10).
10101 @end cartouche
10102 @noindent
10103 Any combinations are permitted that do not result in a small less than
10104 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
10105 If the mantissa is larger than 53 bits on machines where Long_Long_Float
10106 is 64 bits (true of all architectures except ia32), then the output from
10107 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
10108 is because floating-point conversions are used to convert fixed point.
10109
10110 @sp 1
10111 @cartouche
10112 @noindent
10113 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
10114 within an unnamed @code{block_statement}. See 3.9(10).
10115 @end cartouche
10116 @noindent
10117 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
10118 decimal integer are allocated.
10119
10120 @sp 1
10121 @cartouche
10122 @noindent
10123 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
10124 @end cartouche
10125 @noindent
10126 @xref{Implementation Defined Attributes}.
10127
10128 @sp 1
10129 @cartouche
10130 @noindent
10131 @strong{22}. Any implementation-defined time types. See 9.6(6).
10132 @end cartouche
10133 @noindent
10134 There are no implementation-defined time types.
10135
10136 @sp 1
10137 @cartouche
10138 @noindent
10139 @strong{23}. The time base associated with relative delays.
10140 @end cartouche
10141 @noindent
10142 See 9.6(20). The time base used is that provided by the C library
10143 function @code{gettimeofday}.
10144
10145 @sp 1
10146 @cartouche
10147 @noindent
10148 @strong{24}. The time base of the type @code{Calendar.Time}. See
10149 9.6(23).
10150 @end cartouche
10151 @noindent
10152 The time base used is that provided by the C library function
10153 @code{gettimeofday}.
10154
10155 @sp 1
10156 @cartouche
10157 @noindent
10158 @strong{25}. The time zone used for package @code{Calendar}
10159 operations. See 9.6(24).
10160 @end cartouche
10161 @noindent
10162 The time zone used by package @code{Calendar} is the current system time zone
10163 setting for local time, as accessed by the C library function
10164 @code{localtime}.
10165
10166 @sp 1
10167 @cartouche
10168 @noindent
10169 @strong{26}. Any limit on @code{delay_until_statements} of
10170 @code{select_statements}. See 9.6(29).
10171 @end cartouche
10172 @noindent
10173 There are no such limits.
10174
10175 @sp 1
10176 @cartouche
10177 @noindent
10178 @strong{27}. Whether or not two non-overlapping parts of a composite
10179 object are independently addressable, in the case where packing, record
10180 layout, or @code{Component_Size} is specified for the object. See
10181 9.10(1).
10182 @end cartouche
10183 @noindent
10184 Separate components are independently addressable if they do not share
10185 overlapping storage units.
10186
10187 @sp 1
10188 @cartouche
10189 @noindent
10190 @strong{28}. The representation for a compilation. See 10.1(2).
10191 @end cartouche
10192 @noindent
10193 A compilation is represented by a sequence of files presented to the
10194 compiler in a single invocation of the @command{gcc} command.
10195
10196 @sp 1
10197 @cartouche
10198 @noindent
10199 @strong{29}. Any restrictions on compilations that contain multiple
10200 compilation_units. See 10.1(4).
10201 @end cartouche
10202 @noindent
10203 No single file can contain more than one compilation unit, but any
10204 sequence of files can be presented to the compiler as a single
10205 compilation.
10206
10207 @sp 1
10208 @cartouche
10209 @noindent
10210 @strong{30}. The mechanisms for creating an environment and for adding
10211 and replacing compilation units. See 10.1.4(3).
10212 @end cartouche
10213 @noindent
10214 See separate section on compilation model.
10215
10216 @sp 1
10217 @cartouche
10218 @noindent
10219 @strong{31}. The manner of explicitly assigning library units to a
10220 partition. See 10.2(2).
10221 @end cartouche
10222 @noindent
10223 If a unit contains an Ada main program, then the Ada units for the partition
10224 are determined by recursive application of the rules in the Ada Reference
10225 Manual section 10.2(2-6). In other words, the Ada units will be those that
10226 are needed by the main program, and then this definition of need is applied
10227 recursively to those units, and the partition contains the transitive
10228 closure determined by this relationship. In short, all the necessary units
10229 are included, with no need to explicitly specify the list. If additional
10230 units are required, e.g.@: by foreign language units, then all units must be
10231 mentioned in the context clause of one of the needed Ada units.
10232
10233 If the partition contains no main program, or if the main program is in
10234 a language other than Ada, then GNAT
10235 provides the binder options @option{-z} and @option{-n} respectively, and in
10236 this case a list of units can be explicitly supplied to the binder for
10237 inclusion in the partition (all units needed by these units will also
10238 be included automatically). For full details on the use of these
10239 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
10240 @value{EDITION} User's Guide}.
10241
10242 @sp 1
10243 @cartouche
10244 @noindent
10245 @strong{32}. The implementation-defined means, if any, of specifying
10246 which compilation units are needed by a given compilation unit. See
10247 10.2(2).
10248 @end cartouche
10249 @noindent
10250 The units needed by a given compilation unit are as defined in
10251 the Ada Reference Manual section 10.2(2-6). There are no
10252 implementation-defined pragmas or other implementation-defined
10253 means for specifying needed units.
10254
10255 @sp 1
10256 @cartouche
10257 @noindent
10258 @strong{33}. The manner of designating the main subprogram of a
10259 partition. See 10.2(7).
10260 @end cartouche
10261 @noindent
10262 The main program is designated by providing the name of the
10263 corresponding @file{ALI} file as the input parameter to the binder.
10264
10265 @sp 1
10266 @cartouche
10267 @noindent
10268 @strong{34}. The order of elaboration of @code{library_items}. See
10269 10.2(18).
10270 @end cartouche
10271 @noindent
10272 The first constraint on ordering is that it meets the requirements of
10273 Chapter 10 of the Ada Reference Manual. This still leaves some
10274 implementation dependent choices, which are resolved by first
10275 elaborating bodies as early as possible (i.e., in preference to specs
10276 where there is a choice), and second by evaluating the immediate with
10277 clauses of a unit to determine the probably best choice, and
10278 third by elaborating in alphabetical order of unit names
10279 where a choice still remains.
10280
10281 @sp 1
10282 @cartouche
10283 @noindent
10284 @strong{35}. Parameter passing and function return for the main
10285 subprogram. See 10.2(21).
10286 @end cartouche
10287 @noindent
10288 The main program has no parameters. It may be a procedure, or a function
10289 returning an integer type. In the latter case, the returned integer
10290 value is the return code of the program (overriding any value that
10291 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
10292
10293 @sp 1
10294 @cartouche
10295 @noindent
10296 @strong{36}. The mechanisms for building and running partitions. See
10297 10.2(24).
10298 @end cartouche
10299 @noindent
10300 GNAT itself supports programs with only a single partition. The GNATDIST
10301 tool provided with the GLADE package (which also includes an implementation
10302 of the PCS) provides a completely flexible method for building and running
10303 programs consisting of multiple partitions. See the separate GLADE manual
10304 for details.
10305
10306 @sp 1
10307 @cartouche
10308 @noindent
10309 @strong{37}. The details of program execution, including program
10310 termination. See 10.2(25).
10311 @end cartouche
10312 @noindent
10313 See separate section on compilation model.
10314
10315 @sp 1
10316 @cartouche
10317 @noindent
10318 @strong{38}. The semantics of any non-active partitions supported by the
10319 implementation. See 10.2(28).
10320 @end cartouche
10321 @noindent
10322 Passive partitions are supported on targets where shared memory is
10323 provided by the operating system. See the GLADE reference manual for
10324 further details.
10325
10326 @sp 1
10327 @cartouche
10328 @noindent
10329 @strong{39}. The information returned by @code{Exception_Message}. See
10330 11.4.1(10).
10331 @end cartouche
10332 @noindent
10333 Exception message returns the null string unless a specific message has
10334 been passed by the program.
10335
10336 @sp 1
10337 @cartouche
10338 @noindent
10339 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
10340 declared within an unnamed @code{block_statement}. See 11.4.1(12).
10341 @end cartouche
10342 @noindent
10343 Blocks have implementation defined names of the form @code{B@var{nnn}}
10344 where @var{nnn} is an integer.
10345
10346 @sp 1
10347 @cartouche
10348 @noindent
10349 @strong{41}. The information returned by
10350 @code{Exception_Information}. See 11.4.1(13).
10351 @end cartouche
10352 @noindent
10353 @code{Exception_Information} returns a string in the following format:
10354
10355 @smallexample
10356 @emph{Exception_Name:} nnnnn
10357 @emph{Message:} mmmmm
10358 @emph{PID:} ppp
10359 @emph{Call stack traceback locations:}
10360 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
10361 @end smallexample
10362
10363 @noindent
10364 where
10365
10366 @itemize @bullet
10367 @item
10368 @code{nnnn} is the fully qualified name of the exception in all upper
10369 case letters. This line is always present.
10370
10371 @item
10372 @code{mmmm} is the message (this line present only if message is non-null)
10373
10374 @item
10375 @code{ppp} is the Process Id value as a decimal integer (this line is
10376 present only if the Process Id is nonzero). Currently we are
10377 not making use of this field.
10378
10379 @item
10380 The Call stack traceback locations line and the following values
10381 are present only if at least one traceback location was recorded.
10382 The values are given in C style format, with lower case letters
10383 for a-f, and only as many digits present as are necessary.
10384 @end itemize
10385
10386 @noindent
10387 The line terminator sequence at the end of each line, including
10388 the last line is a single @code{LF} character (@code{16#0A#}).
10389
10390 @sp 1
10391 @cartouche
10392 @noindent
10393 @strong{42}. Implementation-defined check names. See 11.5(27).
10394 @end cartouche
10395 @noindent
10396 The implementation defined check name Alignment_Check controls checking of
10397 address clause values for proper alignment (that is, the address supplied
10398 must be consistent with the alignment of the type).
10399
10400 In addition, a user program can add implementation-defined check names
10401 by means of the pragma Check_Name.
10402
10403 @sp 1
10404 @cartouche
10405 @noindent
10406 @strong{43}. The interpretation of each aspect of representation. See
10407 13.1(20).
10408 @end cartouche
10409 @noindent
10410 See separate section on data representations.
10411
10412 @sp 1
10413 @cartouche
10414 @noindent
10415 @strong{44}. Any restrictions placed upon representation items. See
10416 13.1(20).
10417 @end cartouche
10418 @noindent
10419 See separate section on data representations.
10420
10421 @sp 1
10422 @cartouche
10423 @noindent
10424 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
10425 13.3(48).
10426 @end cartouche
10427 @noindent
10428 Size for an indefinite subtype is the maximum possible size, except that
10429 for the case of a subprogram parameter, the size of the parameter object
10430 is the actual size.
10431
10432 @sp 1
10433 @cartouche
10434 @noindent
10435 @strong{46}. The default external representation for a type tag. See
10436 13.3(75).
10437 @end cartouche
10438 @noindent
10439 The default external representation for a type tag is the fully expanded
10440 name of the type in upper case letters.
10441
10442 @sp 1
10443 @cartouche
10444 @noindent
10445 @strong{47}. What determines whether a compilation unit is the same in
10446 two different partitions. See 13.3(76).
10447 @end cartouche
10448 @noindent
10449 A compilation unit is the same in two different partitions if and only
10450 if it derives from the same source file.
10451
10452 @sp 1
10453 @cartouche
10454 @noindent
10455 @strong{48}. Implementation-defined components. See 13.5.1(15).
10456 @end cartouche
10457 @noindent
10458 The only implementation defined component is the tag for a tagged type,
10459 which contains a pointer to the dispatching table.
10460
10461 @sp 1
10462 @cartouche
10463 @noindent
10464 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
10465 ordering. See 13.5.3(5).
10466 @end cartouche
10467 @noindent
10468 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10469 implementation, so no non-default bit ordering is supported. The default
10470 bit ordering corresponds to the natural endianness of the target architecture.
10471
10472 @sp 1
10473 @cartouche
10474 @noindent
10475 @strong{50}. The contents of the visible part of package @code{System}
10476 and its language-defined children. See 13.7(2).
10477 @end cartouche
10478 @noindent
10479 See the definition of these packages in files @file{system.ads} and
10480 @file{s-stoele.ads}.
10481
10482 @sp 1
10483 @cartouche
10484 @noindent
10485 @strong{51}. The contents of the visible part of package
10486 @code{System.Machine_Code}, and the meaning of
10487 @code{code_statements}. See 13.8(7).
10488 @end cartouche
10489 @noindent
10490 See the definition and documentation in file @file{s-maccod.ads}.
10491
10492 @sp 1
10493 @cartouche
10494 @noindent
10495 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10496 @end cartouche
10497 @noindent
10498 Unchecked conversion between types of the same size
10499 results in an uninterpreted transmission of the bits from one type
10500 to the other. If the types are of unequal sizes, then in the case of
10501 discrete types, a shorter source is first zero or sign extended as
10502 necessary, and a shorter target is simply truncated on the left.
10503 For all non-discrete types, the source is first copied if necessary
10504 to ensure that the alignment requirements of the target are met, then
10505 a pointer is constructed to the source value, and the result is obtained
10506 by dereferencing this pointer after converting it to be a pointer to the
10507 target type. Unchecked conversions where the target subtype is an
10508 unconstrained array are not permitted. If the target alignment is
10509 greater than the source alignment, then a copy of the result is
10510 made with appropriate alignment
10511
10512 @sp 1
10513 @cartouche
10514 @noindent
10515 @strong{53}. The semantics of operations on invalid representations.
10516 See 13.9.2(10-11).
10517 @end cartouche
10518 @noindent
10519 For assignments and other operations where the use of invalid values cannot
10520 result in erroneous behavior, the compiler ignores the possibility of invalid
10521 values. An exception is raised at the point where an invalid value would
10522 result in erroneous behavior. For example executing:
10523
10524 @smallexample @c ada
10525 procedure invalidvals is
10526 X : Integer := -1;
10527 Y : Natural range 1 .. 10;
10528 for Y'Address use X'Address;
10529 Z : Natural range 1 .. 10;
10530 A : array (Natural range 1 .. 10) of Integer;
10531 begin
10532 Z := Y; -- no exception
10533 A (Z) := 3; -- exception raised;
10534 end;
10535 @end smallexample
10536
10537 @noindent
10538 As indicated, an exception is raised on the array assignment, but not
10539 on the simple assignment of the invalid negative value from Y to Z.
10540
10541 @sp 1
10542 @cartouche
10543 @noindent
10544 @strong{53}. The manner of choosing a storage pool for an access type
10545 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10546 @end cartouche
10547 @noindent
10548 There are 3 different standard pools used by the compiler when
10549 @code{Storage_Pool} is not specified depending whether the type is local
10550 to a subprogram or defined at the library level and whether
10551 @code{Storage_Size}is specified or not. See documentation in the runtime
10552 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10553 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10554 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10555 default pools used.
10556
10557 @sp 1
10558 @cartouche
10559 @noindent
10560 @strong{54}. Whether or not the implementation provides user-accessible
10561 names for the standard pool type(s). See 13.11(17).
10562 @end cartouche
10563 @noindent
10564
10565 See documentation in the sources of the run time mentioned in paragraph
10566 @strong{53} . All these pools are accessible by means of @code{with}'ing
10567 these units.
10568
10569 @sp 1
10570 @cartouche
10571 @noindent
10572 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10573 @end cartouche
10574 @noindent
10575 @code{Storage_Size} is measured in storage units, and refers to the
10576 total space available for an access type collection, or to the primary
10577 stack space for a task.
10578
10579 @sp 1
10580 @cartouche
10581 @noindent
10582 @strong{56}. Implementation-defined aspects of storage pools. See
10583 13.11(22).
10584 @end cartouche
10585 @noindent
10586 See documentation in the sources of the run time mentioned in paragraph
10587 @strong{53} for details on GNAT-defined aspects of storage pools.
10588
10589 @sp 1
10590 @cartouche
10591 @noindent
10592 @strong{57}. The set of restrictions allowed in a pragma
10593 @code{Restrictions}. See 13.12(7).
10594 @end cartouche
10595 @noindent
10596 @xref{Standard and Implementation Defined Restrictions}.
10597
10598 @sp 1
10599 @cartouche
10600 @noindent
10601 @strong{58}. The consequences of violating limitations on
10602 @code{Restrictions} pragmas. See 13.12(9).
10603 @end cartouche
10604 @noindent
10605 Restrictions that can be checked at compile time result in illegalities
10606 if violated. Currently there are no other consequences of violating
10607 restrictions.
10608
10609 @sp 1
10610 @cartouche
10611 @noindent
10612 @strong{59}. The representation used by the @code{Read} and
10613 @code{Write} attributes of elementary types in terms of stream
10614 elements. See 13.13.2(9).
10615 @end cartouche
10616 @noindent
10617 The representation is the in-memory representation of the base type of
10618 the type, using the number of bits corresponding to the
10619 @code{@var{type}'Size} value, and the natural ordering of the machine.
10620
10621 @sp 1
10622 @cartouche
10623 @noindent
10624 @strong{60}. The names and characteristics of the numeric subtypes
10625 declared in the visible part of package @code{Standard}. See A.1(3).
10626 @end cartouche
10627 @noindent
10628 See items describing the integer and floating-point types supported.
10629
10630 @sp 1
10631 @cartouche
10632 @noindent
10633 @strong{61}. The accuracy actually achieved by the elementary
10634 functions. See A.5.1(1).
10635 @end cartouche
10636 @noindent
10637 The elementary functions correspond to the functions available in the C
10638 library. Only fast math mode is implemented.
10639
10640 @sp 1
10641 @cartouche
10642 @noindent
10643 @strong{62}. The sign of a zero result from some of the operators or
10644 functions in @code{Numerics.Generic_Elementary_Functions}, when
10645 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10646 @end cartouche
10647 @noindent
10648 The sign of zeroes follows the requirements of the IEEE 754 standard on
10649 floating-point.
10650
10651 @sp 1
10652 @cartouche
10653 @noindent
10654 @strong{63}. The value of
10655 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10656 @end cartouche
10657 @noindent
10658 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10659
10660 @sp 1
10661 @cartouche
10662 @noindent
10663 @strong{64}. The value of
10664 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10665 @end cartouche
10666 @noindent
10667 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10668
10669 @sp 1
10670 @cartouche
10671 @noindent
10672 @strong{65}. The algorithms for random number generation. See
10673 A.5.2(32).
10674 @end cartouche
10675 @noindent
10676 The algorithm is the Mersenne Twister, as documented in the source file
10677 @file{s-rannum.adb}. This version of the algorithm has a period of
10678 2**19937-1.
10679
10680 @sp 1
10681 @cartouche
10682 @noindent
10683 @strong{66}. The string representation of a random number generator's
10684 state. See A.5.2(38).
10685 @end cartouche
10686 @noindent
10687 The value returned by the Image function is the concatenation of
10688 the fixed-width decimal representations of the 624 32-bit integers
10689 of the state vector.
10690
10691 @sp 1
10692 @cartouche
10693 @noindent
10694 @strong{67}. The minimum time interval between calls to the
10695 time-dependent Reset procedure that are guaranteed to initiate different
10696 random number sequences. See A.5.2(45).
10697 @end cartouche
10698 @noindent
10699 The minimum period between reset calls to guarantee distinct series of
10700 random numbers is one microsecond.
10701
10702 @sp 1
10703 @cartouche
10704 @noindent
10705 @strong{68}. The values of the @code{Model_Mantissa},
10706 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10707 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10708 Annex is not supported. See A.5.3(72).
10709 @end cartouche
10710 @noindent
10711 Run the compiler with @option{-gnatS} to produce a listing of package
10712 @code{Standard}, has the values of all numeric attributes.
10713
10714 @sp 1
10715 @cartouche
10716 @noindent
10717 @strong{69}. Any implementation-defined characteristics of the
10718 input-output packages. See A.7(14).
10719 @end cartouche
10720 @noindent
10721 There are no special implementation defined characteristics for these
10722 packages.
10723
10724 @sp 1
10725 @cartouche
10726 @noindent
10727 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10728 A.9(10).
10729 @end cartouche
10730 @noindent
10731 All type representations are contiguous, and the @code{Buffer_Size} is
10732 the value of @code{@var{type}'Size} rounded up to the next storage unit
10733 boundary.
10734
10735 @sp 1
10736 @cartouche
10737 @noindent
10738 @strong{71}. External files for standard input, standard output, and
10739 standard error See A.10(5).
10740 @end cartouche
10741 @noindent
10742 These files are mapped onto the files provided by the C streams
10743 libraries. See source file @file{i-cstrea.ads} for further details.
10744
10745 @sp 1
10746 @cartouche
10747 @noindent
10748 @strong{72}. The accuracy of the value produced by @code{Put}. See
10749 A.10.9(36).
10750 @end cartouche
10751 @noindent
10752 If more digits are requested in the output than are represented by the
10753 precision of the value, zeroes are output in the corresponding least
10754 significant digit positions.
10755
10756 @sp 1
10757 @cartouche
10758 @noindent
10759 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10760 @code{Command_Name}. See A.15(1).
10761 @end cartouche
10762 @noindent
10763 These are mapped onto the @code{argv} and @code{argc} parameters of the
10764 main program in the natural manner.
10765
10766 @sp 1
10767 @cartouche
10768 @noindent
10769 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10770 @code{Create_Directory}. See A.16(56).
10771 @end cartouche
10772 @noindent
10773 The @code{Form} parameter is not used.
10774
10775 @sp 1
10776 @cartouche
10777 @noindent
10778 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10779 @code{Create_Path}. See A.16(60).
10780 @end cartouche
10781 @noindent
10782 The @code{Form} parameter is not used.
10783
10784 @sp 1
10785 @cartouche
10786 @noindent
10787 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10788 @code{Copy_File}. See A.16(68).
10789 @end cartouche
10790 @noindent
10791 The @code{Form} parameter is case-insensitive.
10792
10793 Two fields are recognized in the @code{Form} parameter:
10794
10795 @table @code
10796
10797 @item preserve=<value>
10798
10799 @item mode=<value>
10800
10801 @end table
10802
10803 @noindent
10804 <value> starts immediately after the character '=' and ends with the
10805 character immediately preceding the next comma (',') or with the last
10806 character of the parameter.
10807
10808 The only possible values for preserve= are:
10809
10810 @table @code
10811
10812 @item no_attributes
10813 Do not try to preserve any file attributes. This is the default if no
10814 preserve= is found in Form.
10815
10816 @item all_attributes
10817 Try to preserve all file attributes (timestamps, access rights).
10818
10819 @item timestamps
10820 Preserve the timestamp of the copied file, but not the other file attributes.
10821
10822 @end table
10823
10824 @noindent
10825 The only possible values for mode= are:
10826
10827 @table @code
10828
10829 @item copy
10830 Only do the copy if the destination file does not already exist. If it already
10831 exists, Copy_File fails.
10832
10833 @item overwrite
10834 Copy the file in all cases. Overwrite an already existing destination file.
10835
10836 @item append
10837 Append the original file to the destination file. If the destination file does
10838 not exist, the destination file is a copy of the source file. When mode=append,
10839 the field preserve=, if it exists, is not taken into account.
10840
10841 @end table
10842
10843 @noindent
10844 If the Form parameter includes one or both of the fields and the value or
10845 values are incorrect, Copy_file fails with Use_Error.
10846
10847 Examples of correct Forms:
10848
10849 @smallexample
10850 Form => "preserve=no_attributes,mode=overwrite" (the default)
10851 Form => "mode=append"
10852 Form => "mode=copy, preserve=all_attributes"
10853 @end smallexample
10854
10855 @noindent
10856 Examples of incorrect Forms
10857
10858 @smallexample
10859 Form => "preserve=junk"
10860 Form => "mode=internal, preserve=timestamps"
10861 @end smallexample
10862
10863 @sp 1
10864 @cartouche
10865 @noindent
10866 @strong{77}. Implementation-defined convention names. See B.1(11).
10867 @end cartouche
10868 @noindent
10869 The following convention names are supported
10870
10871 @table @code
10872 @item Ada
10873 Ada
10874 @item Ada_Pass_By_Copy
10875 Allowed for any types except by-reference types such as limited
10876 records. Compatible with convention Ada, but causes any parameters
10877 with this convention to be passed by copy.
10878 @item Ada_Pass_By_Reference
10879 Allowed for any types except by-copy types such as scalars.
10880 Compatible with convention Ada, but causes any parameters
10881 with this convention to be passed by reference.
10882 @item Assembler
10883 Assembly language
10884 @item Asm
10885 Synonym for Assembler
10886 @item Assembly
10887 Synonym for Assembler
10888 @item C
10889 C
10890 @item C_Pass_By_Copy
10891 Allowed only for record types, like C, but also notes that record
10892 is to be passed by copy rather than reference.
10893 @item COBOL
10894 COBOL
10895 @item C_Plus_Plus (or CPP)
10896 C++
10897 @item Default
10898 Treated the same as C
10899 @item External
10900 Treated the same as C
10901 @item Fortran
10902 Fortran
10903 @item Intrinsic
10904 For support of pragma @code{Import} with convention Intrinsic, see
10905 separate section on Intrinsic Subprograms.
10906 @item Stdcall
10907 Stdcall (used for Windows implementations only). This convention correspond
10908 to the WINAPI (previously called Pascal convention) C/C++ convention under
10909 Windows. A routine with this convention cleans the stack before
10910 exit. This pragma cannot be applied to a dispatching call.
10911 @item DLL
10912 Synonym for Stdcall
10913 @item Win32
10914 Synonym for Stdcall
10915 @item Stubbed
10916 Stubbed is a special convention used to indicate that the body of the
10917 subprogram will be entirely ignored. Any call to the subprogram
10918 is converted into a raise of the @code{Program_Error} exception. If a
10919 pragma @code{Import} specifies convention @code{stubbed} then no body need
10920 be present at all. This convention is useful during development for the
10921 inclusion of subprograms whose body has not yet been written.
10922
10923 @end table
10924 @noindent
10925 In addition, all otherwise unrecognized convention names are also
10926 treated as being synonymous with convention C@. In all implementations
10927 except for VMS, use of such other names results in a warning. In VMS
10928 implementations, these names are accepted silently.
10929
10930 @sp 1
10931 @cartouche
10932 @noindent
10933 @strong{78}. The meaning of link names. See B.1(36).
10934 @end cartouche
10935 @noindent
10936 Link names are the actual names used by the linker.
10937
10938 @sp 1
10939 @cartouche
10940 @noindent
10941 @strong{79}. The manner of choosing link names when neither the link
10942 name nor the address of an imported or exported entity is specified. See
10943 B.1(36).
10944 @end cartouche
10945 @noindent
10946 The default linker name is that which would be assigned by the relevant
10947 external language, interpreting the Ada name as being in all lower case
10948 letters.
10949
10950 @sp 1
10951 @cartouche
10952 @noindent
10953 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10954 @end cartouche
10955 @noindent
10956 The string passed to @code{Linker_Options} is presented uninterpreted as
10957 an argument to the link command, unless it contains ASCII.NUL characters.
10958 NUL characters if they appear act as argument separators, so for example
10959
10960 @smallexample @c ada
10961 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10962 @end smallexample
10963
10964 @noindent
10965 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10966 linker. The order of linker options is preserved for a given unit. The final
10967 list of options passed to the linker is in reverse order of the elaboration
10968 order. For example, linker options for a body always appear before the options
10969 from the corresponding package spec.
10970
10971 @sp 1
10972 @cartouche
10973 @noindent
10974 @strong{81}. The contents of the visible part of package
10975 @code{Interfaces} and its language-defined descendants. See B.2(1).
10976 @end cartouche
10977 @noindent
10978 See files with prefix @file{i-} in the distributed library.
10979
10980 @sp 1
10981 @cartouche
10982 @noindent
10983 @strong{82}. Implementation-defined children of package
10984 @code{Interfaces}. The contents of the visible part of package
10985 @code{Interfaces}. See B.2(11).
10986 @end cartouche
10987 @noindent
10988 See files with prefix @file{i-} in the distributed library.
10989
10990 @sp 1
10991 @cartouche
10992 @noindent
10993 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10994 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10995 @code{COBOL_Character}; and the initialization of the variables
10996 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10997 @code{Interfaces.COBOL}. See B.4(50).
10998 @end cartouche
10999 @noindent
11000 @table @code
11001 @item Floating
11002 Float
11003 @item Long_Floating
11004 (Floating) Long_Float
11005 @item Binary
11006 Integer
11007 @item Long_Binary
11008 Long_Long_Integer
11009 @item Decimal_Element
11010 Character
11011 @item COBOL_Character
11012 Character
11013 @end table
11014
11015 @noindent
11016 For initialization, see the file @file{i-cobol.ads} in the distributed library.
11017
11018 @sp 1
11019 @cartouche
11020 @noindent
11021 @strong{84}. Support for access to machine instructions. See C.1(1).
11022 @end cartouche
11023 @noindent
11024 See documentation in file @file{s-maccod.ads} in the distributed library.
11025
11026 @sp 1
11027 @cartouche
11028 @noindent
11029 @strong{85}. Implementation-defined aspects of access to machine
11030 operations. See C.1(9).
11031 @end cartouche
11032 @noindent
11033 See documentation in file @file{s-maccod.ads} in the distributed library.
11034
11035 @sp 1
11036 @cartouche
11037 @noindent
11038 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
11039 @end cartouche
11040 @noindent
11041 Interrupts are mapped to signals or conditions as appropriate. See
11042 definition of unit
11043 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
11044 on the interrupts supported on a particular target.
11045
11046 @sp 1
11047 @cartouche
11048 @noindent
11049 @strong{87}. Implementation-defined aspects of pre-elaboration. See
11050 C.4(13).
11051 @end cartouche
11052 @noindent
11053 GNAT does not permit a partition to be restarted without reloading,
11054 except under control of the debugger.
11055
11056 @sp 1
11057 @cartouche
11058 @noindent
11059 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
11060 @end cartouche
11061 @noindent
11062 Pragma @code{Discard_Names} causes names of enumeration literals to
11063 be suppressed. In the presence of this pragma, the Image attribute
11064 provides the image of the Pos of the literal, and Value accepts
11065 Pos values.
11066
11067 @sp 1
11068 @cartouche
11069 @noindent
11070 @strong{89}. The result of the @code{Task_Identification.Image}
11071 attribute. See C.7.1(7).
11072 @end cartouche
11073 @noindent
11074 The result of this attribute is a string that identifies
11075 the object or component that denotes a given task. If a variable @code{Var}
11076 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
11077 where the suffix
11078 is the hexadecimal representation of the virtual address of the corresponding
11079 task control block. If the variable is an array of tasks, the image of each
11080 task will have the form of an indexed component indicating the position of a
11081 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
11082 component of a record, the image of the task will have the form of a selected
11083 component. These rules are fully recursive, so that the image of a task that
11084 is a subcomponent of a composite object corresponds to the expression that
11085 designates this task.
11086 @noindent
11087 If a task is created by an allocator, its image depends on the context. If the
11088 allocator is part of an object declaration, the rules described above are used
11089 to construct its image, and this image is not affected by subsequent
11090 assignments. If the allocator appears within an expression, the image
11091 includes only the name of the task type.
11092 @noindent
11093 If the configuration pragma Discard_Names is present, or if the restriction
11094 No_Implicit_Heap_Allocation is in effect, the image reduces to
11095 the numeric suffix, that is to say the hexadecimal representation of the
11096 virtual address of the control block of the task.
11097 @sp 1
11098 @cartouche
11099 @noindent
11100 @strong{90}. The value of @code{Current_Task} when in a protected entry
11101 or interrupt handler. See C.7.1(17).
11102 @end cartouche
11103 @noindent
11104 Protected entries or interrupt handlers can be executed by any
11105 convenient thread, so the value of @code{Current_Task} is undefined.
11106
11107 @sp 1
11108 @cartouche
11109 @noindent
11110 @strong{91}. The effect of calling @code{Current_Task} from an entry
11111 body or interrupt handler. See C.7.1(19).
11112 @end cartouche
11113 @noindent
11114 The effect of calling @code{Current_Task} from an entry body or
11115 interrupt handler is to return the identification of the task currently
11116 executing the code.
11117
11118 @sp 1
11119 @cartouche
11120 @noindent
11121 @strong{92}. Implementation-defined aspects of
11122 @code{Task_Attributes}. See C.7.2(19).
11123 @end cartouche
11124 @noindent
11125 There are no implementation-defined aspects of @code{Task_Attributes}.
11126
11127 @sp 1
11128 @cartouche
11129 @noindent
11130 @strong{93}. Values of all @code{Metrics}. See D(2).
11131 @end cartouche
11132 @noindent
11133 The metrics information for GNAT depends on the performance of the
11134 underlying operating system. The sources of the run-time for tasking
11135 implementation, together with the output from @option{-gnatG} can be
11136 used to determine the exact sequence of operating systems calls made
11137 to implement various tasking constructs. Together with appropriate
11138 information on the performance of the underlying operating system,
11139 on the exact target in use, this information can be used to determine
11140 the required metrics.
11141
11142 @sp 1
11143 @cartouche
11144 @noindent
11145 @strong{94}. The declarations of @code{Any_Priority} and
11146 @code{Priority}. See D.1(11).
11147 @end cartouche
11148 @noindent
11149 See declarations in file @file{system.ads}.
11150
11151 @sp 1
11152 @cartouche
11153 @noindent
11154 @strong{95}. Implementation-defined execution resources. See D.1(15).
11155 @end cartouche
11156 @noindent
11157 There are no implementation-defined execution resources.
11158
11159 @sp 1
11160 @cartouche
11161 @noindent
11162 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
11163 access to a protected object keeps its processor busy. See D.2.1(3).
11164 @end cartouche
11165 @noindent
11166 On a multi-processor, a task that is waiting for access to a protected
11167 object does not keep its processor busy.
11168
11169 @sp 1
11170 @cartouche
11171 @noindent
11172 @strong{97}. The affect of implementation defined execution resources
11173 on task dispatching. See D.2.1(9).
11174 @end cartouche
11175 @noindent
11176 Tasks map to threads in the threads package used by GNAT@. Where possible
11177 and appropriate, these threads correspond to native threads of the
11178 underlying operating system.
11179
11180 @sp 1
11181 @cartouche
11182 @noindent
11183 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
11184 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
11185 @end cartouche
11186 @noindent
11187 There are no implementation-defined policy-identifiers allowed in this
11188 pragma.
11189
11190 @sp 1
11191 @cartouche
11192 @noindent
11193 @strong{99}. Implementation-defined aspects of priority inversion. See
11194 D.2.2(16).
11195 @end cartouche
11196 @noindent
11197 Execution of a task cannot be preempted by the implementation processing
11198 of delay expirations for lower priority tasks.
11199
11200 @sp 1
11201 @cartouche
11202 @noindent
11203 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
11204 @end cartouche
11205 @noindent
11206 The policy is the same as that of the underlying threads implementation.
11207
11208 @sp 1
11209 @cartouche
11210 @noindent
11211 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
11212 in a pragma @code{Locking_Policy}. See D.3(4).
11213 @end cartouche
11214 @noindent
11215 The two implementation defined policies permitted in GNAT are
11216 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
11217 targets that support the @code{Inheritance_Locking} policy, locking is
11218 implemented by inheritance, i.e.@: the task owning the lock operates
11219 at a priority equal to the highest priority of any task currently
11220 requesting the lock. On targets that support the
11221 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
11222 read/write lock allowing multiple propected object functions to enter
11223 concurrently.
11224
11225 @sp 1
11226 @cartouche
11227 @noindent
11228 @strong{102}. Default ceiling priorities. See D.3(10).
11229 @end cartouche
11230 @noindent
11231 The ceiling priority of protected objects of the type
11232 @code{System.Interrupt_Priority'Last} as described in the Ada
11233 Reference Manual D.3(10),
11234
11235 @sp 1
11236 @cartouche
11237 @noindent
11238 @strong{103}. The ceiling of any protected object used internally by
11239 the implementation. See D.3(16).
11240 @end cartouche
11241 @noindent
11242 The ceiling priority of internal protected objects is
11243 @code{System.Priority'Last}.
11244
11245 @sp 1
11246 @cartouche
11247 @noindent
11248 @strong{104}. Implementation-defined queuing policies. See D.4(1).
11249 @end cartouche
11250 @noindent
11251 There are no implementation-defined queuing policies.
11252
11253 @sp 1
11254 @cartouche
11255 @noindent
11256 @strong{105}. On a multiprocessor, any conditions that cause the
11257 completion of an aborted construct to be delayed later than what is
11258 specified for a single processor. See D.6(3).
11259 @end cartouche
11260 @noindent
11261 The semantics for abort on a multi-processor is the same as on a single
11262 processor, there are no further delays.
11263
11264 @sp 1
11265 @cartouche
11266 @noindent
11267 @strong{106}. Any operations that implicitly require heap storage
11268 allocation. See D.7(8).
11269 @end cartouche
11270 @noindent
11271 The only operation that implicitly requires heap storage allocation is
11272 task creation.
11273
11274 @sp 1
11275 @cartouche
11276 @noindent
11277 @strong{107}. Implementation-defined aspects of pragma
11278 @code{Restrictions}. See D.7(20).
11279 @end cartouche
11280 @noindent
11281 There are no such implementation-defined aspects.
11282
11283 @sp 1
11284 @cartouche
11285 @noindent
11286 @strong{108}. Implementation-defined aspects of package
11287 @code{Real_Time}. See D.8(17).
11288 @end cartouche
11289 @noindent
11290 There are no implementation defined aspects of package @code{Real_Time}.
11291
11292 @sp 1
11293 @cartouche
11294 @noindent
11295 @strong{109}. Implementation-defined aspects of
11296 @code{delay_statements}. See D.9(8).
11297 @end cartouche
11298 @noindent
11299 Any difference greater than one microsecond will cause the task to be
11300 delayed (see D.9(7)).
11301
11302 @sp 1
11303 @cartouche
11304 @noindent
11305 @strong{110}. The upper bound on the duration of interrupt blocking
11306 caused by the implementation. See D.12(5).
11307 @end cartouche
11308 @noindent
11309 The upper bound is determined by the underlying operating system. In
11310 no cases is it more than 10 milliseconds.
11311
11312 @sp 1
11313 @cartouche
11314 @noindent
11315 @strong{111}. The means for creating and executing distributed
11316 programs. See E(5).
11317 @end cartouche
11318 @noindent
11319 The GLADE package provides a utility GNATDIST for creating and executing
11320 distributed programs. See the GLADE reference manual for further details.
11321
11322 @sp 1
11323 @cartouche
11324 @noindent
11325 @strong{112}. Any events that can result in a partition becoming
11326 inaccessible. See E.1(7).
11327 @end cartouche
11328 @noindent
11329 See the GLADE reference manual for full details on such events.
11330
11331 @sp 1
11332 @cartouche
11333 @noindent
11334 @strong{113}. The scheduling policies, treatment of priorities, and
11335 management of shared resources between partitions in certain cases. See
11336 E.1(11).
11337 @end cartouche
11338 @noindent
11339 See the GLADE reference manual for full details on these aspects of
11340 multi-partition execution.
11341
11342 @sp 1
11343 @cartouche
11344 @noindent
11345 @strong{114}. Events that cause the version of a compilation unit to
11346 change. See E.3(5).
11347 @end cartouche
11348 @noindent
11349 Editing the source file of a compilation unit, or the source files of
11350 any units on which it is dependent in a significant way cause the version
11351 to change. No other actions cause the version number to change. All changes
11352 are significant except those which affect only layout, capitalization or
11353 comments.
11354
11355 @sp 1
11356 @cartouche
11357 @noindent
11358 @strong{115}. Whether the execution of the remote subprogram is
11359 immediately aborted as a result of cancellation. See E.4(13).
11360 @end cartouche
11361 @noindent
11362 See the GLADE reference manual for details on the effect of abort in
11363 a distributed application.
11364
11365 @sp 1
11366 @cartouche
11367 @noindent
11368 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
11369 @end cartouche
11370 @noindent
11371 See the GLADE reference manual for a full description of all implementation
11372 defined aspects of the PCS@.
11373
11374 @sp 1
11375 @cartouche
11376 @noindent
11377 @strong{117}. Implementation-defined interfaces in the PCS@. See
11378 E.5(26).
11379 @end cartouche
11380 @noindent
11381 See the GLADE reference manual for a full description of all
11382 implementation defined interfaces.
11383
11384 @sp 1
11385 @cartouche
11386 @noindent
11387 @strong{118}. The values of named numbers in the package
11388 @code{Decimal}. See F.2(7).
11389 @end cartouche
11390 @noindent
11391 @table @code
11392 @item Max_Scale
11393 +18
11394 @item Min_Scale
11395 -18
11396 @item Min_Delta
11397 1.0E-18
11398 @item Max_Delta
11399 1.0E+18
11400 @item Max_Decimal_Digits
11401 18
11402 @end table
11403
11404 @sp 1
11405 @cartouche
11406 @noindent
11407 @strong{119}. The value of @code{Max_Picture_Length} in the package
11408 @code{Text_IO.Editing}. See F.3.3(16).
11409 @end cartouche
11410 @noindent
11411 64
11412
11413 @sp 1
11414 @cartouche
11415 @noindent
11416 @strong{120}. The value of @code{Max_Picture_Length} in the package
11417 @code{Wide_Text_IO.Editing}. See F.3.4(5).
11418 @end cartouche
11419 @noindent
11420 64
11421
11422 @sp 1
11423 @cartouche
11424 @noindent
11425 @strong{121}. The accuracy actually achieved by the complex elementary
11426 functions and by other complex arithmetic operations. See G.1(1).
11427 @end cartouche
11428 @noindent
11429 Standard library functions are used for the complex arithmetic
11430 operations. Only fast math mode is currently supported.
11431
11432 @sp 1
11433 @cartouche
11434 @noindent
11435 @strong{122}. The sign of a zero result (or a component thereof) from
11436 any operator or function in @code{Numerics.Generic_Complex_Types}, when
11437 @code{Real'Signed_Zeros} is True. See G.1.1(53).
11438 @end cartouche
11439 @noindent
11440 The signs of zero values are as recommended by the relevant
11441 implementation advice.
11442
11443 @sp 1
11444 @cartouche
11445 @noindent
11446 @strong{123}. The sign of a zero result (or a component thereof) from
11447 any operator or function in
11448 @code{Numerics.Generic_Complex_Elementary_Functions}, when
11449 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
11450 @end cartouche
11451 @noindent
11452 The signs of zero values are as recommended by the relevant
11453 implementation advice.
11454
11455 @sp 1
11456 @cartouche
11457 @noindent
11458 @strong{124}. Whether the strict mode or the relaxed mode is the
11459 default. See G.2(2).
11460 @end cartouche
11461 @noindent
11462 The strict mode is the default. There is no separate relaxed mode. GNAT
11463 provides a highly efficient implementation of strict mode.
11464
11465 @sp 1
11466 @cartouche
11467 @noindent
11468 @strong{125}. The result interval in certain cases of fixed-to-float
11469 conversion. See G.2.1(10).
11470 @end cartouche
11471 @noindent
11472 For cases where the result interval is implementation dependent, the
11473 accuracy is that provided by performing all operations in 64-bit IEEE
11474 floating-point format.
11475
11476 @sp 1
11477 @cartouche
11478 @noindent
11479 @strong{126}. The result of a floating point arithmetic operation in
11480 overflow situations, when the @code{Machine_Overflows} attribute of the
11481 result type is @code{False}. See G.2.1(13).
11482 @end cartouche
11483 @noindent
11484 Infinite and NaN values are produced as dictated by the IEEE
11485 floating-point standard.
11486
11487 Note that on machines that are not fully compliant with the IEEE
11488 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11489 must be used for achieving IEEE conforming behavior (although at the cost
11490 of a significant performance penalty), so infinite and NaN values are
11491 properly generated.
11492
11493 @sp 1
11494 @cartouche
11495 @noindent
11496 @strong{127}. The result interval for division (or exponentiation by a
11497 negative exponent), when the floating point hardware implements division
11498 as multiplication by a reciprocal. See G.2.1(16).
11499 @end cartouche
11500 @noindent
11501 Not relevant, division is IEEE exact.
11502
11503 @sp 1
11504 @cartouche
11505 @noindent
11506 @strong{128}. The definition of close result set, which determines the
11507 accuracy of certain fixed point multiplications and divisions. See
11508 G.2.3(5).
11509 @end cartouche
11510 @noindent
11511 Operations in the close result set are performed using IEEE long format
11512 floating-point arithmetic. The input operands are converted to
11513 floating-point, the operation is done in floating-point, and the result
11514 is converted to the target type.
11515
11516 @sp 1
11517 @cartouche
11518 @noindent
11519 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11520 point multiplication or division for which the result shall be in the
11521 perfect result set. See G.2.3(22).
11522 @end cartouche
11523 @noindent
11524 The result is only defined to be in the perfect result set if the result
11525 can be computed by a single scaling operation involving a scale factor
11526 representable in 64-bits.
11527
11528 @sp 1
11529 @cartouche
11530 @noindent
11531 @strong{130}. The result of a fixed point arithmetic operation in
11532 overflow situations, when the @code{Machine_Overflows} attribute of the
11533 result type is @code{False}. See G.2.3(27).
11534 @end cartouche
11535 @noindent
11536 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11537 types.
11538
11539 @sp 1
11540 @cartouche
11541 @noindent
11542 @strong{131}. The result of an elementary function reference in
11543 overflow situations, when the @code{Machine_Overflows} attribute of the
11544 result type is @code{False}. See G.2.4(4).
11545 @end cartouche
11546 @noindent
11547 IEEE infinite and Nan values are produced as appropriate.
11548
11549 @sp 1
11550 @cartouche
11551 @noindent
11552 @strong{132}. The value of the angle threshold, within which certain
11553 elementary functions, complex arithmetic operations, and complex
11554 elementary functions yield results conforming to a maximum relative
11555 error bound. See G.2.4(10).
11556 @end cartouche
11557 @noindent
11558 Information on this subject is not yet available.
11559
11560 @sp 1
11561 @cartouche
11562 @noindent
11563 @strong{133}. The accuracy of certain elementary functions for
11564 parameters beyond the angle threshold. See G.2.4(10).
11565 @end cartouche
11566 @noindent
11567 Information on this subject is not yet available.
11568
11569 @sp 1
11570 @cartouche
11571 @noindent
11572 @strong{134}. The result of a complex arithmetic operation or complex
11573 elementary function reference in overflow situations, when the
11574 @code{Machine_Overflows} attribute of the corresponding real type is
11575 @code{False}. See G.2.6(5).
11576 @end cartouche
11577 @noindent
11578 IEEE infinite and Nan values are produced as appropriate.
11579
11580 @sp 1
11581 @cartouche
11582 @noindent
11583 @strong{135}. The accuracy of certain complex arithmetic operations and
11584 certain complex elementary functions for parameters (or components
11585 thereof) beyond the angle threshold. See G.2.6(8).
11586 @end cartouche
11587 @noindent
11588 Information on those subjects is not yet available.
11589
11590 @sp 1
11591 @cartouche
11592 @noindent
11593 @strong{136}. Information regarding bounded errors and erroneous
11594 execution. See H.2(1).
11595 @end cartouche
11596 @noindent
11597 Information on this subject is not yet available.
11598
11599 @sp 1
11600 @cartouche
11601 @noindent
11602 @strong{137}. Implementation-defined aspects of pragma
11603 @code{Inspection_Point}. See H.3.2(8).
11604 @end cartouche
11605 @noindent
11606 Pragma @code{Inspection_Point} ensures that the variable is live and can
11607 be examined by the debugger at the inspection point.
11608
11609 @sp 1
11610 @cartouche
11611 @noindent
11612 @strong{138}. Implementation-defined aspects of pragma
11613 @code{Restrictions}. See H.4(25).
11614 @end cartouche
11615 @noindent
11616 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11617 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11618 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11619
11620 @sp 1
11621 @cartouche
11622 @noindent
11623 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11624 H.4(27).
11625 @end cartouche
11626 @noindent
11627 There are no restrictions on pragma @code{Restrictions}.
11628
11629 @node Intrinsic Subprograms
11630 @chapter Intrinsic Subprograms
11631 @cindex Intrinsic Subprograms
11632
11633 @menu
11634 * Intrinsic Operators::
11635 * Enclosing_Entity::
11636 * Exception_Information::
11637 * Exception_Message::
11638 * Exception_Name::
11639 * File::
11640 * Line::
11641 * Shifts and Rotates::
11642 * Source_Location::
11643 @end menu
11644
11645 @noindent
11646 GNAT allows a user application program to write the declaration:
11647
11648 @smallexample @c ada
11649 pragma Import (Intrinsic, name);
11650 @end smallexample
11651
11652 @noindent
11653 providing that the name corresponds to one of the implemented intrinsic
11654 subprograms in GNAT, and that the parameter profile of the referenced
11655 subprogram meets the requirements. This chapter describes the set of
11656 implemented intrinsic subprograms, and the requirements on parameter profiles.
11657 Note that no body is supplied; as with other uses of pragma Import, the
11658 body is supplied elsewhere (in this case by the compiler itself). Note
11659 that any use of this feature is potentially non-portable, since the
11660 Ada standard does not require Ada compilers to implement this feature.
11661
11662 @node Intrinsic Operators
11663 @section Intrinsic Operators
11664 @cindex Intrinsic operator
11665
11666 @noindent
11667 All the predefined numeric operators in package Standard
11668 in @code{pragma Import (Intrinsic,..)}
11669 declarations. In the binary operator case, the operands must have the same
11670 size. The operand or operands must also be appropriate for
11671 the operator. For example, for addition, the operands must
11672 both be floating-point or both be fixed-point, and the
11673 right operand for @code{"**"} must have a root type of
11674 @code{Standard.Integer'Base}.
11675 You can use an intrinsic operator declaration as in the following example:
11676
11677 @smallexample @c ada
11678 type Int1 is new Integer;
11679 type Int2 is new Integer;
11680
11681 function "+" (X1 : Int1; X2 : Int2) return Int1;
11682 function "+" (X1 : Int1; X2 : Int2) return Int2;
11683 pragma Import (Intrinsic, "+");
11684 @end smallexample
11685
11686 @noindent
11687 This declaration would permit ``mixed mode'' arithmetic on items
11688 of the differing types @code{Int1} and @code{Int2}.
11689 It is also possible to specify such operators for private types, if the
11690 full views are appropriate arithmetic types.
11691
11692 @node Enclosing_Entity
11693 @section Enclosing_Entity
11694 @cindex Enclosing_Entity
11695 @noindent
11696 This intrinsic subprogram is used in the implementation of the
11697 library routine @code{GNAT.Source_Info}. The only useful use of the
11698 intrinsic import in this case is the one in this unit, so an
11699 application program should simply call the function
11700 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11701 the current subprogram, package, task, entry, or protected subprogram.
11702
11703 @node Exception_Information
11704 @section Exception_Information
11705 @cindex Exception_Information'
11706 @noindent
11707 This intrinsic subprogram is used in the implementation of the
11708 library routine @code{GNAT.Current_Exception}. The only useful
11709 use of the intrinsic import in this case is the one in this unit,
11710 so an application program should simply call the function
11711 @code{GNAT.Current_Exception.Exception_Information} to obtain
11712 the exception information associated with the current exception.
11713
11714 @node Exception_Message
11715 @section Exception_Message
11716 @cindex Exception_Message
11717 @noindent
11718 This intrinsic subprogram is used in the implementation of the
11719 library routine @code{GNAT.Current_Exception}. The only useful
11720 use of the intrinsic import in this case is the one in this unit,
11721 so an application program should simply call the function
11722 @code{GNAT.Current_Exception.Exception_Message} to obtain
11723 the message associated with the current exception.
11724
11725 @node Exception_Name
11726 @section Exception_Name
11727 @cindex Exception_Name
11728 @noindent
11729 This intrinsic subprogram is used in the implementation of the
11730 library routine @code{GNAT.Current_Exception}. The only useful
11731 use of the intrinsic import in this case is the one in this unit,
11732 so an application program should simply call the function
11733 @code{GNAT.Current_Exception.Exception_Name} to obtain
11734 the name of the current exception.
11735
11736 @node File
11737 @section File
11738 @cindex File
11739 @noindent
11740 This intrinsic subprogram is used in the implementation of the
11741 library routine @code{GNAT.Source_Info}. The only useful use of the
11742 intrinsic import in this case is the one in this unit, so an
11743 application program should simply call the function
11744 @code{GNAT.Source_Info.File} to obtain the name of the current
11745 file.
11746
11747 @node Line
11748 @section Line
11749 @cindex Line
11750 @noindent
11751 This intrinsic subprogram is used in the implementation of the
11752 library routine @code{GNAT.Source_Info}. The only useful use of the
11753 intrinsic import in this case is the one in this unit, so an
11754 application program should simply call the function
11755 @code{GNAT.Source_Info.Line} to obtain the number of the current
11756 source line.
11757
11758 @node Shifts and Rotates
11759 @section Shifts and Rotates
11760 @cindex Shift_Left
11761 @cindex Shift_Right
11762 @cindex Shift_Right_Arithmetic
11763 @cindex Rotate_Left
11764 @cindex Rotate_Right
11765 @noindent
11766 In standard Ada, the shift and rotate functions are available only
11767 for the predefined modular types in package @code{Interfaces}. However, in
11768 GNAT it is possible to define these functions for any integer
11769 type (signed or modular), as in this example:
11770
11771 @smallexample @c ada
11772 function Shift_Left
11773 (Value : T;
11774 Amount : Natural)
11775 return T;
11776 @end smallexample
11777
11778 @noindent
11779 The function name must be one of
11780 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11781 Rotate_Right. T must be an integer type. T'Size must be
11782 8, 16, 32 or 64 bits; if T is modular, the modulus
11783 must be 2**8, 2**16, 2**32 or 2**64.
11784 The result type must be the same as the type of @code{Value}.
11785 The shift amount must be Natural.
11786 The formal parameter names can be anything.
11787
11788 @node Source_Location
11789 @section Source_Location
11790 @cindex Source_Location
11791 @noindent
11792 This intrinsic subprogram is used in the implementation of the
11793 library routine @code{GNAT.Source_Info}. The only useful use of the
11794 intrinsic import in this case is the one in this unit, so an
11795 application program should simply call the function
11796 @code{GNAT.Source_Info.Source_Location} to obtain the current
11797 source file location.
11798
11799 @node Representation Clauses and Pragmas
11800 @chapter Representation Clauses and Pragmas
11801 @cindex Representation Clauses
11802
11803 @menu
11804 * Alignment Clauses::
11805 * Size Clauses::
11806 * Storage_Size Clauses::
11807 * Size of Variant Record Objects::
11808 * Biased Representation ::
11809 * Value_Size and Object_Size Clauses::
11810 * Component_Size Clauses::
11811 * Bit_Order Clauses::
11812 * Effect of Bit_Order on Byte Ordering::
11813 * Pragma Pack for Arrays::
11814 * Pragma Pack for Records::
11815 * Record Representation Clauses::
11816 * Enumeration Clauses::
11817 * Address Clauses::
11818 * Effect of Convention on Representation::
11819 * Determining the Representations chosen by GNAT::
11820 @end menu
11821
11822 @noindent
11823 @cindex Representation Clause
11824 @cindex Representation Pragma
11825 @cindex Pragma, representation
11826 This section describes the representation clauses accepted by GNAT, and
11827 their effect on the representation of corresponding data objects.
11828
11829 GNAT fully implements Annex C (Systems Programming). This means that all
11830 the implementation advice sections in chapter 13 are fully implemented.
11831 However, these sections only require a minimal level of support for
11832 representation clauses. GNAT provides much more extensive capabilities,
11833 and this section describes the additional capabilities provided.
11834
11835 @node Alignment Clauses
11836 @section Alignment Clauses
11837 @cindex Alignment Clause
11838
11839 @noindent
11840 GNAT requires that all alignment clauses specify a power of 2, and all
11841 default alignments are always a power of 2. The default alignment
11842 values are as follows:
11843
11844 @itemize @bullet
11845 @item @emph{Primitive Types}.
11846 For primitive types, the alignment is the minimum of the actual size of
11847 objects of the type divided by @code{Storage_Unit},
11848 and the maximum alignment supported by the target.
11849 (This maximum alignment is given by the GNAT-specific attribute
11850 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11851 @cindex @code{Maximum_Alignment} attribute
11852 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11853 default alignment will be 8 on any target that supports alignments
11854 this large, but on some targets, the maximum alignment may be smaller
11855 than 8, in which case objects of type @code{Long_Float} will be maximally
11856 aligned.
11857
11858 @item @emph{Arrays}.
11859 For arrays, the alignment is equal to the alignment of the component type
11860 for the normal case where no packing or component size is given. If the
11861 array is packed, and the packing is effective (see separate section on
11862 packed arrays), then the alignment will be one for long packed arrays,
11863 or arrays whose length is not known at compile time. For short packed
11864 arrays, which are handled internally as modular types, the alignment
11865 will be as described for primitive types, e.g.@: a packed array of length
11866 31 bits will have an object size of four bytes, and an alignment of 4.
11867
11868 @item @emph{Records}.
11869 For the normal non-packed case, the alignment of a record is equal to
11870 the maximum alignment of any of its components. For tagged records, this
11871 includes the implicit access type used for the tag. If a pragma @code{Pack}
11872 is used and all components are packable (see separate section on pragma
11873 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11874 record makes it profitable to increase it.
11875
11876 A special case is when:
11877 @itemize @bullet
11878 @item
11879 the size of the record is given explicitly, or a
11880 full record representation clause is given, and
11881 @item
11882 the size of the record is 2, 4, or 8 bytes.
11883 @end itemize
11884 @noindent
11885 In this case, an alignment is chosen to match the
11886 size of the record. For example, if we have:
11887
11888 @smallexample @c ada
11889 type Small is record
11890 A, B : Character;
11891 end record;
11892 for Small'Size use 16;
11893 @end smallexample
11894
11895 @noindent
11896 then the default alignment of the record type @code{Small} is 2, not 1. This
11897 leads to more efficient code when the record is treated as a unit, and also
11898 allows the type to specified as @code{Atomic} on architectures requiring
11899 strict alignment.
11900
11901 @end itemize
11902
11903 @noindent
11904 An alignment clause may specify a larger alignment than the default value
11905 up to some maximum value dependent on the target (obtainable by using the
11906 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11907 a smaller alignment than the default value for enumeration, integer and
11908 fixed point types, as well as for record types, for example
11909
11910 @smallexample @c ada
11911 type V is record
11912 A : Integer;
11913 end record;
11914
11915 for V'alignment use 1;
11916 @end smallexample
11917
11918 @noindent
11919 @cindex Alignment, default
11920 The default alignment for the type @code{V} is 4, as a result of the
11921 Integer field in the record, but it is permissible, as shown, to
11922 override the default alignment of the record with a smaller value.
11923
11924 @cindex Alignment, subtypes
11925 Note that according to the Ada standard, an alignment clause applies only
11926 to the first named subtype. If additional subtypes are declared, then the
11927 compiler is allowed to choose any alignment it likes, and there is no way
11928 to control this choice. Consider:
11929
11930 @smallexample @c ada
11931 type R is range 1 .. 10_000;
11932 for R'Alignment use 1;
11933 subtype RS is R range 1 .. 1000;
11934 @end smallexample
11935
11936 @noindent
11937 The alignment clause specifies an alignment of 1 for the first named subtype
11938 @code{R} but this does not necessarily apply to @code{RS}. When writing
11939 portable Ada code, you should avoid writing code that explicitly or
11940 implicitly relies on the alignment of such subtypes.
11941
11942 For the GNAT compiler, if an explicit alignment clause is given, this
11943 value is also used for any subsequent subtypes. So for GNAT, in the
11944 above example, you can count on the alignment of @code{RS} being 1. But this
11945 assumption is non-portable, and other compilers may choose different
11946 alignments for the subtype @code{RS}.
11947
11948 @node Size Clauses
11949 @section Size Clauses
11950 @cindex Size Clause
11951
11952 @noindent
11953 The default size for a type @code{T} is obtainable through the
11954 language-defined attribute @code{T'Size} and also through the
11955 equivalent GNAT-defined attribute @code{T'Value_Size}.
11956 For objects of type @code{T}, GNAT will generally increase the type size
11957 so that the object size (obtainable through the GNAT-defined attribute
11958 @code{T'Object_Size})
11959 is a multiple of @code{T'Alignment * Storage_Unit}.
11960 For example
11961
11962 @smallexample @c ada
11963 type Smallint is range 1 .. 6;
11964
11965 type Rec is record
11966 Y1 : integer;
11967 Y2 : boolean;
11968 end record;
11969 @end smallexample
11970
11971 @noindent
11972 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11973 as specified by the RM rules,
11974 but objects of this type will have a size of 8
11975 (@code{Smallint'Object_Size} = 8),
11976 since objects by default occupy an integral number
11977 of storage units. On some targets, notably older
11978 versions of the Digital Alpha, the size of stand
11979 alone objects of this type may be 32, reflecting
11980 the inability of the hardware to do byte load/stores.
11981
11982 Similarly, the size of type @code{Rec} is 40 bits
11983 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11984 the alignment is 4, so objects of this type will have
11985 their size increased to 64 bits so that it is a multiple
11986 of the alignment (in bits). This decision is
11987 in accordance with the specific Implementation Advice in RM 13.3(43):
11988
11989 @quotation
11990 A @code{Size} clause should be supported for an object if the specified
11991 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11992 to a size in storage elements that is a multiple of the object's
11993 @code{Alignment} (if the @code{Alignment} is nonzero).
11994 @end quotation
11995
11996 @noindent
11997 An explicit size clause may be used to override the default size by
11998 increasing it. For example, if we have:
11999
12000 @smallexample @c ada
12001 type My_Boolean is new Boolean;
12002 for My_Boolean'Size use 32;
12003 @end smallexample
12004
12005 @noindent
12006 then values of this type will always be 32 bits long. In the case of
12007 discrete types, the size can be increased up to 64 bits, with the effect
12008 that the entire specified field is used to hold the value, sign- or
12009 zero-extended as appropriate. If more than 64 bits is specified, then
12010 padding space is allocated after the value, and a warning is issued that
12011 there are unused bits.
12012
12013 Similarly the size of records and arrays may be increased, and the effect
12014 is to add padding bits after the value. This also causes a warning message
12015 to be generated.
12016
12017 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
12018 Size in bits, this corresponds to an object of size 256 megabytes (minus
12019 one). This limitation is true on all targets. The reason for this
12020 limitation is that it improves the quality of the code in many cases
12021 if it is known that a Size value can be accommodated in an object of
12022 type Integer.
12023
12024 @node Storage_Size Clauses
12025 @section Storage_Size Clauses
12026 @cindex Storage_Size Clause
12027
12028 @noindent
12029 For tasks, the @code{Storage_Size} clause specifies the amount of space
12030 to be allocated for the task stack. This cannot be extended, and if the
12031 stack is exhausted, then @code{Storage_Error} will be raised (if stack
12032 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
12033 or a @code{Storage_Size} pragma in the task definition to set the
12034 appropriate required size. A useful technique is to include in every
12035 task definition a pragma of the form:
12036
12037 @smallexample @c ada
12038 pragma Storage_Size (Default_Stack_Size);
12039 @end smallexample
12040
12041 @noindent
12042 Then @code{Default_Stack_Size} can be defined in a global package, and
12043 modified as required. Any tasks requiring stack sizes different from the
12044 default can have an appropriate alternative reference in the pragma.
12045
12046 You can also use the @option{-d} binder switch to modify the default stack
12047 size.
12048
12049 For access types, the @code{Storage_Size} clause specifies the maximum
12050 space available for allocation of objects of the type. If this space is
12051 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
12052 In the case where the access type is declared local to a subprogram, the
12053 use of a @code{Storage_Size} clause triggers automatic use of a special
12054 predefined storage pool (@code{System.Pool_Size}) that ensures that all
12055 space for the pool is automatically reclaimed on exit from the scope in
12056 which the type is declared.
12057
12058 A special case recognized by the compiler is the specification of a
12059 @code{Storage_Size} of zero for an access type. This means that no
12060 items can be allocated from the pool, and this is recognized at compile
12061 time, and all the overhead normally associated with maintaining a fixed
12062 size storage pool is eliminated. Consider the following example:
12063
12064 @smallexample @c ada
12065 procedure p is
12066 type R is array (Natural) of Character;
12067 type P is access all R;
12068 for P'Storage_Size use 0;
12069 -- Above access type intended only for interfacing purposes
12070
12071 y : P;
12072
12073 procedure g (m : P);
12074 pragma Import (C, g);
12075
12076 -- @dots{}
12077
12078 begin
12079 -- @dots{}
12080 y := new R;
12081 end;
12082 @end smallexample
12083
12084 @noindent
12085 As indicated in this example, these dummy storage pools are often useful in
12086 connection with interfacing where no object will ever be allocated. If you
12087 compile the above example, you get the warning:
12088
12089 @smallexample
12090 p.adb:16:09: warning: allocation from empty storage pool
12091 p.adb:16:09: warning: Storage_Error will be raised at run time
12092 @end smallexample
12093
12094 @noindent
12095 Of course in practice, there will not be any explicit allocators in the
12096 case of such an access declaration.
12097
12098 @node Size of Variant Record Objects
12099 @section Size of Variant Record Objects
12100 @cindex Size, variant record objects
12101 @cindex Variant record objects, size
12102
12103 @noindent
12104 In the case of variant record objects, there is a question whether Size gives
12105 information about a particular variant, or the maximum size required
12106 for any variant. Consider the following program
12107
12108 @smallexample @c ada
12109 with Text_IO; use Text_IO;
12110 procedure q is
12111 type R1 (A : Boolean := False) is record
12112 case A is
12113 when True => X : Character;
12114 when False => null;
12115 end case;
12116 end record;
12117
12118 V1 : R1 (False);
12119 V2 : R1;
12120
12121 begin
12122 Put_Line (Integer'Image (V1'Size));
12123 Put_Line (Integer'Image (V2'Size));
12124 end q;
12125 @end smallexample
12126
12127 @noindent
12128 Here we are dealing with a variant record, where the True variant
12129 requires 16 bits, and the False variant requires 8 bits.
12130 In the above example, both V1 and V2 contain the False variant,
12131 which is only 8 bits long. However, the result of running the
12132 program is:
12133
12134 @smallexample
12135 8
12136 16
12137 @end smallexample
12138
12139 @noindent
12140 The reason for the difference here is that the discriminant value of
12141 V1 is fixed, and will always be False. It is not possible to assign
12142 a True variant value to V1, therefore 8 bits is sufficient. On the
12143 other hand, in the case of V2, the initial discriminant value is
12144 False (from the default), but it is possible to assign a True
12145 variant value to V2, therefore 16 bits must be allocated for V2
12146 in the general case, even fewer bits may be needed at any particular
12147 point during the program execution.
12148
12149 As can be seen from the output of this program, the @code{'Size}
12150 attribute applied to such an object in GNAT gives the actual allocated
12151 size of the variable, which is the largest size of any of the variants.
12152 The Ada Reference Manual is not completely clear on what choice should
12153 be made here, but the GNAT behavior seems most consistent with the
12154 language in the RM@.
12155
12156 In some cases, it may be desirable to obtain the size of the current
12157 variant, rather than the size of the largest variant. This can be
12158 achieved in GNAT by making use of the fact that in the case of a
12159 subprogram parameter, GNAT does indeed return the size of the current
12160 variant (because a subprogram has no way of knowing how much space
12161 is actually allocated for the actual).
12162
12163 Consider the following modified version of the above program:
12164
12165 @smallexample @c ada
12166 with Text_IO; use Text_IO;
12167 procedure q is
12168 type R1 (A : Boolean := False) is record
12169 case A is
12170 when True => X : Character;
12171 when False => null;
12172 end case;
12173 end record;
12174
12175 V2 : R1;
12176
12177 function Size (V : R1) return Integer is
12178 begin
12179 return V'Size;
12180 end Size;
12181
12182 begin
12183 Put_Line (Integer'Image (V2'Size));
12184 Put_Line (Integer'IMage (Size (V2)));
12185 V2 := (True, 'x');
12186 Put_Line (Integer'Image (V2'Size));
12187 Put_Line (Integer'IMage (Size (V2)));
12188 end q;
12189 @end smallexample
12190
12191 @noindent
12192 The output from this program is
12193
12194 @smallexample
12195 16
12196 8
12197 16
12198 16
12199 @end smallexample
12200
12201 @noindent
12202 Here we see that while the @code{'Size} attribute always returns
12203 the maximum size, regardless of the current variant value, the
12204 @code{Size} function does indeed return the size of the current
12205 variant value.
12206
12207 @node Biased Representation
12208 @section Biased Representation
12209 @cindex Size for biased representation
12210 @cindex Biased representation
12211
12212 @noindent
12213 In the case of scalars with a range starting at other than zero, it is
12214 possible in some cases to specify a size smaller than the default minimum
12215 value, and in such cases, GNAT uses an unsigned biased representation,
12216 in which zero is used to represent the lower bound, and successive values
12217 represent successive values of the type.
12218
12219 For example, suppose we have the declaration:
12220
12221 @smallexample @c ada
12222 type Small is range -7 .. -4;
12223 for Small'Size use 2;
12224 @end smallexample
12225
12226 @noindent
12227 Although the default size of type @code{Small} is 4, the @code{Size}
12228 clause is accepted by GNAT and results in the following representation
12229 scheme:
12230
12231 @smallexample
12232 -7 is represented as 2#00#
12233 -6 is represented as 2#01#
12234 -5 is represented as 2#10#
12235 -4 is represented as 2#11#
12236 @end smallexample
12237
12238 @noindent
12239 Biased representation is only used if the specified @code{Size} clause
12240 cannot be accepted in any other manner. These reduced sizes that force
12241 biased representation can be used for all discrete types except for
12242 enumeration types for which a representation clause is given.
12243
12244 @node Value_Size and Object_Size Clauses
12245 @section Value_Size and Object_Size Clauses
12246 @findex Value_Size
12247 @findex Object_Size
12248 @cindex Size, of objects
12249
12250 @noindent
12251 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
12252 number of bits required to hold values of type @code{T}.
12253 Although this interpretation was allowed in Ada 83, it was not required,
12254 and this requirement in practice can cause some significant difficulties.
12255 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
12256 However, in Ada 95 and Ada 2005,
12257 @code{Natural'Size} is
12258 typically 31. This means that code may change in behavior when moving
12259 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
12260
12261 @smallexample @c ada
12262 type Rec is record;
12263 A : Natural;
12264 B : Natural;
12265 end record;
12266
12267 for Rec use record
12268 at 0 range 0 .. Natural'Size - 1;
12269 at 0 range Natural'Size .. 2 * Natural'Size - 1;
12270 end record;
12271 @end smallexample
12272
12273 @noindent
12274 In the above code, since the typical size of @code{Natural} objects
12275 is 32 bits and @code{Natural'Size} is 31, the above code can cause
12276 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
12277 there are cases where the fact that the object size can exceed the
12278 size of the type causes surprises.
12279
12280 To help get around this problem GNAT provides two implementation
12281 defined attributes, @code{Value_Size} and @code{Object_Size}. When
12282 applied to a type, these attributes yield the size of the type
12283 (corresponding to the RM defined size attribute), and the size of
12284 objects of the type respectively.
12285
12286 The @code{Object_Size} is used for determining the default size of
12287 objects and components. This size value can be referred to using the
12288 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
12289 the basis of the determination of the size. The backend is free to
12290 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
12291 character might be stored in 32 bits on a machine with no efficient
12292 byte access instructions such as the Alpha.
12293
12294 The default rules for the value of @code{Object_Size} for
12295 discrete types are as follows:
12296
12297 @itemize @bullet
12298 @item
12299 The @code{Object_Size} for base subtypes reflect the natural hardware
12300 size in bits (run the compiler with @option{-gnatS} to find those values
12301 for numeric types). Enumeration types and fixed-point base subtypes have
12302 8, 16, 32 or 64 bits for this size, depending on the range of values
12303 to be stored.
12304
12305 @item
12306 The @code{Object_Size} of a subtype is the same as the
12307 @code{Object_Size} of
12308 the type from which it is obtained.
12309
12310 @item
12311 The @code{Object_Size} of a derived base type is copied from the parent
12312 base type, and the @code{Object_Size} of a derived first subtype is copied
12313 from the parent first subtype.
12314 @end itemize
12315
12316 @noindent
12317 The @code{Value_Size} attribute
12318 is the (minimum) number of bits required to store a value
12319 of the type.
12320 This value is used to determine how tightly to pack
12321 records or arrays with components of this type, and also affects
12322 the semantics of unchecked conversion (unchecked conversions where
12323 the @code{Value_Size} values differ generate a warning, and are potentially
12324 target dependent).
12325
12326 The default rules for the value of @code{Value_Size} are as follows:
12327
12328 @itemize @bullet
12329 @item
12330 The @code{Value_Size} for a base subtype is the minimum number of bits
12331 required to store all values of the type (including the sign bit
12332 only if negative values are possible).
12333
12334 @item
12335 If a subtype statically matches the first subtype of a given type, then it has
12336 by default the same @code{Value_Size} as the first subtype. This is a
12337 consequence of RM 13.1(14) (``if two subtypes statically match,
12338 then their subtype-specific aspects are the same''.)
12339
12340 @item
12341 All other subtypes have a @code{Value_Size} corresponding to the minimum
12342 number of bits required to store all values of the subtype. For
12343 dynamic bounds, it is assumed that the value can range down or up
12344 to the corresponding bound of the ancestor
12345 @end itemize
12346
12347 @noindent
12348 The RM defined attribute @code{Size} corresponds to the
12349 @code{Value_Size} attribute.
12350
12351 The @code{Size} attribute may be defined for a first-named subtype. This sets
12352 the @code{Value_Size} of
12353 the first-named subtype to the given value, and the
12354 @code{Object_Size} of this first-named subtype to the given value padded up
12355 to an appropriate boundary. It is a consequence of the default rules
12356 above that this @code{Object_Size} will apply to all further subtypes. On the
12357 other hand, @code{Value_Size} is affected only for the first subtype, any
12358 dynamic subtypes obtained from it directly, and any statically matching
12359 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
12360
12361 @code{Value_Size} and
12362 @code{Object_Size} may be explicitly set for any subtype using
12363 an attribute definition clause. Note that the use of these attributes
12364 can cause the RM 13.1(14) rule to be violated. If two access types
12365 reference aliased objects whose subtypes have differing @code{Object_Size}
12366 values as a result of explicit attribute definition clauses, then it
12367 is erroneous to convert from one access subtype to the other.
12368
12369 At the implementation level, Esize stores the Object_Size and the
12370 RM_Size field stores the @code{Value_Size} (and hence the value of the
12371 @code{Size} attribute,
12372 which, as noted above, is equivalent to @code{Value_Size}).
12373
12374 To get a feel for the difference, consider the following examples (note
12375 that in each case the base is @code{Short_Short_Integer} with a size of 8):
12376
12377 @smallexample
12378 Object_Size Value_Size
12379
12380 type x1 is range 0 .. 5; 8 3
12381
12382 type x2 is range 0 .. 5;
12383 for x2'size use 12; 16 12
12384
12385 subtype x3 is x2 range 0 .. 3; 16 2
12386
12387 subtype x4 is x2'base range 0 .. 10; 8 4
12388
12389 subtype x5 is x2 range 0 .. dynamic; 16 3*
12390
12391 subtype x6 is x2'base range 0 .. dynamic; 8 3*
12392
12393 @end smallexample
12394
12395 @noindent
12396 Note: the entries marked ``3*'' are not actually specified by the Ada
12397 Reference Manual, but it seems in the spirit of the RM rules to allocate
12398 the minimum number of bits (here 3, given the range for @code{x2})
12399 known to be large enough to hold the given range of values.
12400
12401 So far, so good, but GNAT has to obey the RM rules, so the question is
12402 under what conditions must the RM @code{Size} be used.
12403 The following is a list
12404 of the occasions on which the RM @code{Size} must be used:
12405
12406 @itemize @bullet
12407 @item
12408 Component size for packed arrays or records
12409
12410 @item
12411 Value of the attribute @code{Size} for a type
12412
12413 @item
12414 Warning about sizes not matching for unchecked conversion
12415 @end itemize
12416
12417 @noindent
12418 For record types, the @code{Object_Size} is always a multiple of the
12419 alignment of the type (this is true for all types). In some cases the
12420 @code{Value_Size} can be smaller. Consider:
12421
12422 @smallexample
12423 type R is record
12424 X : Integer;
12425 Y : Character;
12426 end record;
12427 @end smallexample
12428
12429 @noindent
12430 On a typical 32-bit architecture, the X component will be four bytes, and
12431 require four-byte alignment, and the Y component will be one byte. In this
12432 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
12433 required to store a value of this type, and for example, it is permissible
12434 to have a component of type R in an outer array whose component size is
12435 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
12436 since it must be rounded up so that this value is a multiple of the
12437 alignment (4 bytes = 32 bits).
12438
12439 @noindent
12440 For all other types, the @code{Object_Size}
12441 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
12442 Only @code{Size} may be specified for such types.
12443
12444 @node Component_Size Clauses
12445 @section Component_Size Clauses
12446 @cindex Component_Size Clause
12447
12448 @noindent
12449 Normally, the value specified in a component size clause must be consistent
12450 with the subtype of the array component with regard to size and alignment.
12451 In other words, the value specified must be at least equal to the size
12452 of this subtype, and must be a multiple of the alignment value.
12453
12454 In addition, component size clauses are allowed which cause the array
12455 to be packed, by specifying a smaller value. A first case is for
12456 component size values in the range 1 through 63. The value specified
12457 must not be smaller than the Size of the subtype. GNAT will accurately
12458 honor all packing requests in this range. For example, if we have:
12459
12460 @smallexample @c ada
12461 type r is array (1 .. 8) of Natural;
12462 for r'Component_Size use 31;
12463 @end smallexample
12464
12465 @noindent
12466 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
12467 Of course access to the components of such an array is considerably
12468 less efficient than if the natural component size of 32 is used.
12469 A second case is when the subtype of the component is a record type
12470 padded because of its default alignment. For example, if we have:
12471
12472 @smallexample @c ada
12473 type r is record
12474 i : Integer;
12475 j : Integer;
12476 b : Boolean;
12477 end record;
12478
12479 type a is array (1 .. 8) of r;
12480 for a'Component_Size use 72;
12481 @end smallexample
12482
12483 @noindent
12484 then the resulting array has a length of 72 bytes, instead of 96 bytes
12485 if the alignment of the record (4) was obeyed.
12486
12487 Note that there is no point in giving both a component size clause
12488 and a pragma Pack for the same array type. if such duplicate
12489 clauses are given, the pragma Pack will be ignored.
12490
12491 @node Bit_Order Clauses
12492 @section Bit_Order Clauses
12493 @cindex Bit_Order Clause
12494 @cindex bit ordering
12495 @cindex ordering, of bits
12496
12497 @noindent
12498 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12499 attribute. The specification may either correspond to the default bit
12500 order for the target, in which case the specification has no effect and
12501 places no additional restrictions, or it may be for the non-standard
12502 setting (that is the opposite of the default).
12503
12504 In the case where the non-standard value is specified, the effect is
12505 to renumber bits within each byte, but the ordering of bytes is not
12506 affected. There are certain
12507 restrictions placed on component clauses as follows:
12508
12509 @itemize @bullet
12510
12511 @item Components fitting within a single storage unit.
12512 @noindent
12513 These are unrestricted, and the effect is merely to renumber bits. For
12514 example if we are on a little-endian machine with @code{Low_Order_First}
12515 being the default, then the following two declarations have exactly
12516 the same effect:
12517
12518 @smallexample @c ada
12519 type R1 is record
12520 A : Boolean;
12521 B : Integer range 1 .. 120;
12522 end record;
12523
12524 for R1 use record
12525 A at 0 range 0 .. 0;
12526 B at 0 range 1 .. 7;
12527 end record;
12528
12529 type R2 is record
12530 A : Boolean;
12531 B : Integer range 1 .. 120;
12532 end record;
12533
12534 for R2'Bit_Order use High_Order_First;
12535
12536 for R2 use record
12537 A at 0 range 7 .. 7;
12538 B at 0 range 0 .. 6;
12539 end record;
12540 @end smallexample
12541
12542 @noindent
12543 The useful application here is to write the second declaration with the
12544 @code{Bit_Order} attribute definition clause, and know that it will be treated
12545 the same, regardless of whether the target is little-endian or big-endian.
12546
12547 @item Components occupying an integral number of bytes.
12548 @noindent
12549 These are components that exactly fit in two or more bytes. Such component
12550 declarations are allowed, but have no effect, since it is important to realize
12551 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12552 In particular, the following attempt at getting an endian-independent integer
12553 does not work:
12554
12555 @smallexample @c ada
12556 type R2 is record
12557 A : Integer;
12558 end record;
12559
12560 for R2'Bit_Order use High_Order_First;
12561
12562 for R2 use record
12563 A at 0 range 0 .. 31;
12564 end record;
12565 @end smallexample
12566
12567 @noindent
12568 This declaration will result in a little-endian integer on a
12569 little-endian machine, and a big-endian integer on a big-endian machine.
12570 If byte flipping is required for interoperability between big- and
12571 little-endian machines, this must be explicitly programmed. This capability
12572 is not provided by @code{Bit_Order}.
12573
12574 @item Components that are positioned across byte boundaries
12575 @noindent
12576 but do not occupy an integral number of bytes. Given that bytes are not
12577 reordered, such fields would occupy a non-contiguous sequence of bits
12578 in memory, requiring non-trivial code to reassemble. They are for this
12579 reason not permitted, and any component clause specifying such a layout
12580 will be flagged as illegal by GNAT@.
12581
12582 @end itemize
12583
12584 @noindent
12585 Since the misconception that Bit_Order automatically deals with all
12586 endian-related incompatibilities is a common one, the specification of
12587 a component field that is an integral number of bytes will always
12588 generate a warning. This warning may be suppressed using @code{pragma
12589 Warnings (Off)} if desired. The following section contains additional
12590 details regarding the issue of byte ordering.
12591
12592 @node Effect of Bit_Order on Byte Ordering
12593 @section Effect of Bit_Order on Byte Ordering
12594 @cindex byte ordering
12595 @cindex ordering, of bytes
12596
12597 @noindent
12598 In this section we will review the effect of the @code{Bit_Order} attribute
12599 definition clause on byte ordering. Briefly, it has no effect at all, but
12600 a detailed example will be helpful. Before giving this
12601 example, let us review the precise
12602 definition of the effect of defining @code{Bit_Order}. The effect of a
12603 non-standard bit order is described in section 15.5.3 of the Ada
12604 Reference Manual:
12605
12606 @quotation
12607 2 A bit ordering is a method of interpreting the meaning of
12608 the storage place attributes.
12609 @end quotation
12610
12611 @noindent
12612 To understand the precise definition of storage place attributes in
12613 this context, we visit section 13.5.1 of the manual:
12614
12615 @quotation
12616 13 A record_representation_clause (without the mod_clause)
12617 specifies the layout. The storage place attributes (see 13.5.2)
12618 are taken from the values of the position, first_bit, and last_bit
12619 expressions after normalizing those values so that first_bit is
12620 less than Storage_Unit.
12621 @end quotation
12622
12623 @noindent
12624 The critical point here is that storage places are taken from
12625 the values after normalization, not before. So the @code{Bit_Order}
12626 interpretation applies to normalized values. The interpretation
12627 is described in the later part of the 15.5.3 paragraph:
12628
12629 @quotation
12630 2 A bit ordering is a method of interpreting the meaning of
12631 the storage place attributes. High_Order_First (known in the
12632 vernacular as ``big endian'') means that the first bit of a
12633 storage element (bit 0) is the most significant bit (interpreting
12634 the sequence of bits that represent a component as an unsigned
12635 integer value). Low_Order_First (known in the vernacular as
12636 ``little endian'') means the opposite: the first bit is the
12637 least significant.
12638 @end quotation
12639
12640 @noindent
12641 Note that the numbering is with respect to the bits of a storage
12642 unit. In other words, the specification affects only the numbering
12643 of bits within a single storage unit.
12644
12645 We can make the effect clearer by giving an example.
12646
12647 Suppose that we have an external device which presents two bytes, the first
12648 byte presented, which is the first (low addressed byte) of the two byte
12649 record is called Master, and the second byte is called Slave.
12650
12651 The left most (most significant bit is called Control for each byte, and
12652 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12653 (least significant) bit.
12654
12655 On a big-endian machine, we can write the following representation clause
12656
12657 @smallexample @c ada
12658 type Data is record
12659 Master_Control : Bit;
12660 Master_V1 : Bit;
12661 Master_V2 : Bit;
12662 Master_V3 : Bit;
12663 Master_V4 : Bit;
12664 Master_V5 : Bit;
12665 Master_V6 : Bit;
12666 Master_V7 : Bit;
12667 Slave_Control : Bit;
12668 Slave_V1 : Bit;
12669 Slave_V2 : Bit;
12670 Slave_V3 : Bit;
12671 Slave_V4 : Bit;
12672 Slave_V5 : Bit;
12673 Slave_V6 : Bit;
12674 Slave_V7 : Bit;
12675 end record;
12676
12677 for Data use record
12678 Master_Control at 0 range 0 .. 0;
12679 Master_V1 at 0 range 1 .. 1;
12680 Master_V2 at 0 range 2 .. 2;
12681 Master_V3 at 0 range 3 .. 3;
12682 Master_V4 at 0 range 4 .. 4;
12683 Master_V5 at 0 range 5 .. 5;
12684 Master_V6 at 0 range 6 .. 6;
12685 Master_V7 at 0 range 7 .. 7;
12686 Slave_Control at 1 range 0 .. 0;
12687 Slave_V1 at 1 range 1 .. 1;
12688 Slave_V2 at 1 range 2 .. 2;
12689 Slave_V3 at 1 range 3 .. 3;
12690 Slave_V4 at 1 range 4 .. 4;
12691 Slave_V5 at 1 range 5 .. 5;
12692 Slave_V6 at 1 range 6 .. 6;
12693 Slave_V7 at 1 range 7 .. 7;
12694 end record;
12695 @end smallexample
12696
12697 @noindent
12698 Now if we move this to a little endian machine, then the bit ordering within
12699 the byte is backwards, so we have to rewrite the record rep clause as:
12700
12701 @smallexample @c ada
12702 for Data use record
12703 Master_Control at 0 range 7 .. 7;
12704 Master_V1 at 0 range 6 .. 6;
12705 Master_V2 at 0 range 5 .. 5;
12706 Master_V3 at 0 range 4 .. 4;
12707 Master_V4 at 0 range 3 .. 3;
12708 Master_V5 at 0 range 2 .. 2;
12709 Master_V6 at 0 range 1 .. 1;
12710 Master_V7 at 0 range 0 .. 0;
12711 Slave_Control at 1 range 7 .. 7;
12712 Slave_V1 at 1 range 6 .. 6;
12713 Slave_V2 at 1 range 5 .. 5;
12714 Slave_V3 at 1 range 4 .. 4;
12715 Slave_V4 at 1 range 3 .. 3;
12716 Slave_V5 at 1 range 2 .. 2;
12717 Slave_V6 at 1 range 1 .. 1;
12718 Slave_V7 at 1 range 0 .. 0;
12719 end record;
12720 @end smallexample
12721
12722 @noindent
12723 It is a nuisance to have to rewrite the clause, especially if
12724 the code has to be maintained on both machines. However,
12725 this is a case that we can handle with the
12726 @code{Bit_Order} attribute if it is implemented.
12727 Note that the implementation is not required on byte addressed
12728 machines, but it is indeed implemented in GNAT.
12729 This means that we can simply use the
12730 first record clause, together with the declaration
12731
12732 @smallexample @c ada
12733 for Data'Bit_Order use High_Order_First;
12734 @end smallexample
12735
12736 @noindent
12737 and the effect is what is desired, namely the layout is exactly the same,
12738 independent of whether the code is compiled on a big-endian or little-endian
12739 machine.
12740
12741 The important point to understand is that byte ordering is not affected.
12742 A @code{Bit_Order} attribute definition never affects which byte a field
12743 ends up in, only where it ends up in that byte.
12744 To make this clear, let us rewrite the record rep clause of the previous
12745 example as:
12746
12747 @smallexample @c ada
12748 for Data'Bit_Order use High_Order_First;
12749 for Data use record
12750 Master_Control at 0 range 0 .. 0;
12751 Master_V1 at 0 range 1 .. 1;
12752 Master_V2 at 0 range 2 .. 2;
12753 Master_V3 at 0 range 3 .. 3;
12754 Master_V4 at 0 range 4 .. 4;
12755 Master_V5 at 0 range 5 .. 5;
12756 Master_V6 at 0 range 6 .. 6;
12757 Master_V7 at 0 range 7 .. 7;
12758 Slave_Control at 0 range 8 .. 8;
12759 Slave_V1 at 0 range 9 .. 9;
12760 Slave_V2 at 0 range 10 .. 10;
12761 Slave_V3 at 0 range 11 .. 11;
12762 Slave_V4 at 0 range 12 .. 12;
12763 Slave_V5 at 0 range 13 .. 13;
12764 Slave_V6 at 0 range 14 .. 14;
12765 Slave_V7 at 0 range 15 .. 15;
12766 end record;
12767 @end smallexample
12768
12769 @noindent
12770 This is exactly equivalent to saying (a repeat of the first example):
12771
12772 @smallexample @c ada
12773 for Data'Bit_Order use High_Order_First;
12774 for Data use record
12775 Master_Control at 0 range 0 .. 0;
12776 Master_V1 at 0 range 1 .. 1;
12777 Master_V2 at 0 range 2 .. 2;
12778 Master_V3 at 0 range 3 .. 3;
12779 Master_V4 at 0 range 4 .. 4;
12780 Master_V5 at 0 range 5 .. 5;
12781 Master_V6 at 0 range 6 .. 6;
12782 Master_V7 at 0 range 7 .. 7;
12783 Slave_Control at 1 range 0 .. 0;
12784 Slave_V1 at 1 range 1 .. 1;
12785 Slave_V2 at 1 range 2 .. 2;
12786 Slave_V3 at 1 range 3 .. 3;
12787 Slave_V4 at 1 range 4 .. 4;
12788 Slave_V5 at 1 range 5 .. 5;
12789 Slave_V6 at 1 range 6 .. 6;
12790 Slave_V7 at 1 range 7 .. 7;
12791 end record;
12792 @end smallexample
12793
12794 @noindent
12795 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12796 field. The storage place attributes are obtained by normalizing the
12797 values given so that the @code{First_Bit} value is less than 8. After
12798 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12799 we specified in the other case.
12800
12801 Now one might expect that the @code{Bit_Order} attribute might affect
12802 bit numbering within the entire record component (two bytes in this
12803 case, thus affecting which byte fields end up in), but that is not
12804 the way this feature is defined, it only affects numbering of bits,
12805 not which byte they end up in.
12806
12807 Consequently it never makes sense to specify a starting bit number
12808 greater than 7 (for a byte addressable field) if an attribute
12809 definition for @code{Bit_Order} has been given, and indeed it
12810 may be actively confusing to specify such a value, so the compiler
12811 generates a warning for such usage.
12812
12813 If you do need to control byte ordering then appropriate conditional
12814 values must be used. If in our example, the slave byte came first on
12815 some machines we might write:
12816
12817 @smallexample @c ada
12818 Master_Byte_First constant Boolean := @dots{};
12819
12820 Master_Byte : constant Natural :=
12821 1 - Boolean'Pos (Master_Byte_First);
12822 Slave_Byte : constant Natural :=
12823 Boolean'Pos (Master_Byte_First);
12824
12825 for Data'Bit_Order use High_Order_First;
12826 for Data use record
12827 Master_Control at Master_Byte range 0 .. 0;
12828 Master_V1 at Master_Byte range 1 .. 1;
12829 Master_V2 at Master_Byte range 2 .. 2;
12830 Master_V3 at Master_Byte range 3 .. 3;
12831 Master_V4 at Master_Byte range 4 .. 4;
12832 Master_V5 at Master_Byte range 5 .. 5;
12833 Master_V6 at Master_Byte range 6 .. 6;
12834 Master_V7 at Master_Byte range 7 .. 7;
12835 Slave_Control at Slave_Byte range 0 .. 0;
12836 Slave_V1 at Slave_Byte range 1 .. 1;
12837 Slave_V2 at Slave_Byte range 2 .. 2;
12838 Slave_V3 at Slave_Byte range 3 .. 3;
12839 Slave_V4 at Slave_Byte range 4 .. 4;
12840 Slave_V5 at Slave_Byte range 5 .. 5;
12841 Slave_V6 at Slave_Byte range 6 .. 6;
12842 Slave_V7 at Slave_Byte range 7 .. 7;
12843 end record;
12844 @end smallexample
12845
12846 @noindent
12847 Now to switch between machines, all that is necessary is
12848 to set the boolean constant @code{Master_Byte_First} in
12849 an appropriate manner.
12850
12851 @node Pragma Pack for Arrays
12852 @section Pragma Pack for Arrays
12853 @cindex Pragma Pack (for arrays)
12854
12855 @noindent
12856 Pragma @code{Pack} applied to an array has no effect unless the component type
12857 is packable. For a component type to be packable, it must be one of the
12858 following cases:
12859
12860 @itemize @bullet
12861 @item
12862 Any scalar type
12863 @item
12864 Any type whose size is specified with a size clause
12865 @item
12866 Any packed array type with a static size
12867 @item
12868 Any record type padded because of its default alignment
12869 @end itemize
12870
12871 @noindent
12872 For all these cases, if the component subtype size is in the range
12873 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12874 component size were specified giving the component subtype size.
12875 For example if we have:
12876
12877 @smallexample @c ada
12878 type r is range 0 .. 17;
12879
12880 type ar is array (1 .. 8) of r;
12881 pragma Pack (ar);
12882 @end smallexample
12883
12884 @noindent
12885 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12886 and the size of the array @code{ar} will be exactly 40 bits.
12887
12888 Note that in some cases this rather fierce approach to packing can produce
12889 unexpected effects. For example, in Ada 95 and Ada 2005,
12890 subtype @code{Natural} typically has a size of 31, meaning that if you
12891 pack an array of @code{Natural}, you get 31-bit
12892 close packing, which saves a few bits, but results in far less efficient
12893 access. Since many other Ada compilers will ignore such a packing request,
12894 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12895 might not be what is intended. You can easily remove this warning by
12896 using an explicit @code{Component_Size} setting instead, which never generates
12897 a warning, since the intention of the programmer is clear in this case.
12898
12899 GNAT treats packed arrays in one of two ways. If the size of the array is
12900 known at compile time and is less than 64 bits, then internally the array
12901 is represented as a single modular type, of exactly the appropriate number
12902 of bits. If the length is greater than 63 bits, or is not known at compile
12903 time, then the packed array is represented as an array of bytes, and the
12904 length is always a multiple of 8 bits.
12905
12906 Note that to represent a packed array as a modular type, the alignment must
12907 be suitable for the modular type involved. For example, on typical machines
12908 a 32-bit packed array will be represented by a 32-bit modular integer with
12909 an alignment of four bytes. If you explicitly override the default alignment
12910 with an alignment clause that is too small, the modular representation
12911 cannot be used. For example, consider the following set of declarations:
12912
12913 @smallexample @c ada
12914 type R is range 1 .. 3;
12915 type S is array (1 .. 31) of R;
12916 for S'Component_Size use 2;
12917 for S'Size use 62;
12918 for S'Alignment use 1;
12919 @end smallexample
12920
12921 @noindent
12922 If the alignment clause were not present, then a 62-bit modular
12923 representation would be chosen (typically with an alignment of 4 or 8
12924 bytes depending on the target). But the default alignment is overridden
12925 with the explicit alignment clause. This means that the modular
12926 representation cannot be used, and instead the array of bytes
12927 representation must be used, meaning that the length must be a multiple
12928 of 8. Thus the above set of declarations will result in a diagnostic
12929 rejecting the size clause and noting that the minimum size allowed is 64.
12930
12931 @cindex Pragma Pack (for type Natural)
12932 @cindex Pragma Pack warning
12933
12934 One special case that is worth noting occurs when the base type of the
12935 component size is 8/16/32 and the subtype is one bit less. Notably this
12936 occurs with subtype @code{Natural}. Consider:
12937
12938 @smallexample @c ada
12939 type Arr is array (1 .. 32) of Natural;
12940 pragma Pack (Arr);
12941 @end smallexample
12942
12943 @noindent
12944 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12945 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12946 Ada 83 compilers did not attempt 31 bit packing.
12947
12948 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12949 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12950 substantial unintended performance penalty when porting legacy Ada 83 code.
12951 To help prevent this, GNAT generates a warning in such cases. If you really
12952 want 31 bit packing in a case like this, you can set the component size
12953 explicitly:
12954
12955 @smallexample @c ada
12956 type Arr is array (1 .. 32) of Natural;
12957 for Arr'Component_Size use 31;
12958 @end smallexample
12959
12960 @noindent
12961 Here 31-bit packing is achieved as required, and no warning is generated,
12962 since in this case the programmer intention is clear.
12963
12964 @node Pragma Pack for Records
12965 @section Pragma Pack for Records
12966 @cindex Pragma Pack (for records)
12967
12968 @noindent
12969 Pragma @code{Pack} applied to a record will pack the components to reduce
12970 wasted space from alignment gaps and by reducing the amount of space
12971 taken by components. We distinguish between @emph{packable} components and
12972 @emph{non-packable} components.
12973 Components of the following types are considered packable:
12974 @itemize @bullet
12975 @item
12976 All primitive types are packable.
12977
12978 @item
12979 Small packed arrays, whose size does not exceed 64 bits, and where the
12980 size is statically known at compile time, are represented internally
12981 as modular integers, and so they are also packable.
12982
12983 @end itemize
12984
12985 @noindent
12986 All packable components occupy the exact number of bits corresponding to
12987 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12988 can start on an arbitrary bit boundary.
12989
12990 All other types are non-packable, they occupy an integral number of
12991 storage units, and
12992 are placed at a boundary corresponding to their alignment requirements.
12993
12994 For example, consider the record
12995
12996 @smallexample @c ada
12997 type Rb1 is array (1 .. 13) of Boolean;
12998 pragma Pack (rb1);
12999
13000 type Rb2 is array (1 .. 65) of Boolean;
13001 pragma Pack (rb2);
13002
13003 type x2 is record
13004 l1 : Boolean;
13005 l2 : Duration;
13006 l3 : Float;
13007 l4 : Boolean;
13008 l5 : Rb1;
13009 l6 : Rb2;
13010 end record;
13011 pragma Pack (x2);
13012 @end smallexample
13013
13014 @noindent
13015 The representation for the record x2 is as follows:
13016
13017 @smallexample @c ada
13018 for x2'Size use 224;
13019 for x2 use record
13020 l1 at 0 range 0 .. 0;
13021 l2 at 0 range 1 .. 64;
13022 l3 at 12 range 0 .. 31;
13023 l4 at 16 range 0 .. 0;
13024 l5 at 16 range 1 .. 13;
13025 l6 at 18 range 0 .. 71;
13026 end record;
13027 @end smallexample
13028
13029 @noindent
13030 Studying this example, we see that the packable fields @code{l1}
13031 and @code{l2} are
13032 of length equal to their sizes, and placed at specific bit boundaries (and
13033 not byte boundaries) to
13034 eliminate padding. But @code{l3} is of a non-packable float type, so
13035 it is on the next appropriate alignment boundary.
13036
13037 The next two fields are fully packable, so @code{l4} and @code{l5} are
13038 minimally packed with no gaps. However, type @code{Rb2} is a packed
13039 array that is longer than 64 bits, so it is itself non-packable. Thus
13040 the @code{l6} field is aligned to the next byte boundary, and takes an
13041 integral number of bytes, i.e.@: 72 bits.
13042
13043 @node Record Representation Clauses
13044 @section Record Representation Clauses
13045 @cindex Record Representation Clause
13046
13047 @noindent
13048 Record representation clauses may be given for all record types, including
13049 types obtained by record extension. Component clauses are allowed for any
13050 static component. The restrictions on component clauses depend on the type
13051 of the component.
13052
13053 @cindex Component Clause
13054 For all components of an elementary type, the only restriction on component
13055 clauses is that the size must be at least the 'Size value of the type
13056 (actually the Value_Size). There are no restrictions due to alignment,
13057 and such components may freely cross storage boundaries.
13058
13059 Packed arrays with a size up to and including 64 bits are represented
13060 internally using a modular type with the appropriate number of bits, and
13061 thus the same lack of restriction applies. For example, if you declare:
13062
13063 @smallexample @c ada
13064 type R is array (1 .. 49) of Boolean;
13065 pragma Pack (R);
13066 for R'Size use 49;
13067 @end smallexample
13068
13069 @noindent
13070 then a component clause for a component of type R may start on any
13071 specified bit boundary, and may specify a value of 49 bits or greater.
13072
13073 For packed bit arrays that are longer than 64 bits, there are two
13074 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
13075 including the important case of single bits or boolean values, then
13076 there are no limitations on placement of such components, and they
13077 may start and end at arbitrary bit boundaries.
13078
13079 If the component size is not a power of 2 (e.g.@: 3 or 5), then
13080 an array of this type longer than 64 bits must always be placed on
13081 on a storage unit (byte) boundary and occupy an integral number
13082 of storage units (bytes). Any component clause that does not
13083 meet this requirement will be rejected.
13084
13085 Any aliased component, or component of an aliased type, must
13086 have its normal alignment and size. A component clause that
13087 does not meet this requirement will be rejected.
13088
13089 The tag field of a tagged type always occupies an address sized field at
13090 the start of the record. No component clause may attempt to overlay this
13091 tag. When a tagged type appears as a component, the tag field must have
13092 proper alignment
13093
13094 In the case of a record extension T1, of a type T, no component clause applied
13095 to the type T1 can specify a storage location that would overlap the first
13096 T'Size bytes of the record.
13097
13098 For all other component types, including non-bit-packed arrays,
13099 the component can be placed at an arbitrary bit boundary,
13100 so for example, the following is permitted:
13101
13102 @smallexample @c ada
13103 type R is array (1 .. 10) of Boolean;
13104 for R'Size use 80;
13105
13106 type Q is record
13107 G, H : Boolean;
13108 L, M : R;
13109 end record;
13110
13111 for Q use record
13112 G at 0 range 0 .. 0;
13113 H at 0 range 1 .. 1;
13114 L at 0 range 2 .. 81;
13115 R at 0 range 82 .. 161;
13116 end record;
13117 @end smallexample
13118
13119 @noindent
13120 Note: the above rules apply to recent releases of GNAT 5.
13121 In GNAT 3, there are more severe restrictions on larger components.
13122 For non-primitive types, including packed arrays with a size greater than
13123 64 bits, component clauses must respect the alignment requirement of the
13124 type, in particular, always starting on a byte boundary, and the length
13125 must be a multiple of the storage unit.
13126
13127 @node Enumeration Clauses
13128 @section Enumeration Clauses
13129
13130 The only restriction on enumeration clauses is that the range of values
13131 must be representable. For the signed case, if one or more of the
13132 representation values are negative, all values must be in the range:
13133
13134 @smallexample @c ada
13135 System.Min_Int .. System.Max_Int
13136 @end smallexample
13137
13138 @noindent
13139 For the unsigned case, where all values are nonnegative, the values must
13140 be in the range:
13141
13142 @smallexample @c ada
13143 0 .. System.Max_Binary_Modulus;
13144 @end smallexample
13145
13146 @noindent
13147 A @emph{confirming} representation clause is one in which the values range
13148 from 0 in sequence, i.e.@: a clause that confirms the default representation
13149 for an enumeration type.
13150 Such a confirming representation
13151 is permitted by these rules, and is specially recognized by the compiler so
13152 that no extra overhead results from the use of such a clause.
13153
13154 If an array has an index type which is an enumeration type to which an
13155 enumeration clause has been applied, then the array is stored in a compact
13156 manner. Consider the declarations:
13157
13158 @smallexample @c ada
13159 type r is (A, B, C);
13160 for r use (A => 1, B => 5, C => 10);
13161 type t is array (r) of Character;
13162 @end smallexample
13163
13164 @noindent
13165 The array type t corresponds to a vector with exactly three elements and
13166 has a default size equal to @code{3*Character'Size}. This ensures efficient
13167 use of space, but means that accesses to elements of the array will incur
13168 the overhead of converting representation values to the corresponding
13169 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
13170
13171 @node Address Clauses
13172 @section Address Clauses
13173 @cindex Address Clause
13174
13175 The reference manual allows a general restriction on representation clauses,
13176 as found in RM 13.1(22):
13177
13178 @quotation
13179 An implementation need not support representation
13180 items containing nonstatic expressions, except that
13181 an implementation should support a representation item
13182 for a given entity if each nonstatic expression in the
13183 representation item is a name that statically denotes
13184 a constant declared before the entity.
13185 @end quotation
13186
13187 @noindent
13188 In practice this is applicable only to address clauses, since this is the
13189 only case in which a non-static expression is permitted by the syntax. As
13190 the AARM notes in sections 13.1 (22.a-22.h):
13191
13192 @display
13193 22.a Reason: This is to avoid the following sort of thing:
13194
13195 22.b X : Integer := F(@dots{});
13196 Y : Address := G(@dots{});
13197 for X'Address use Y;
13198
13199 22.c In the above, we have to evaluate the
13200 initialization expression for X before we
13201 know where to put the result. This seems
13202 like an unreasonable implementation burden.
13203
13204 22.d The above code should instead be written
13205 like this:
13206
13207 22.e Y : constant Address := G(@dots{});
13208 X : Integer := F(@dots{});
13209 for X'Address use Y;
13210
13211 22.f This allows the expression ``Y'' to be safely
13212 evaluated before X is created.
13213
13214 22.g The constant could be a formal parameter of mode in.
13215
13216 22.h An implementation can support other nonstatic
13217 expressions if it wants to. Expressions of type
13218 Address are hardly ever static, but their value
13219 might be known at compile time anyway in many
13220 cases.
13221 @end display
13222
13223 @noindent
13224 GNAT does indeed permit many additional cases of non-static expressions. In
13225 particular, if the type involved is elementary there are no restrictions
13226 (since in this case, holding a temporary copy of the initialization value,
13227 if one is present, is inexpensive). In addition, if there is no implicit or
13228 explicit initialization, then there are no restrictions. GNAT will reject
13229 only the case where all three of these conditions hold:
13230
13231 @itemize @bullet
13232
13233 @item
13234 The type of the item is non-elementary (e.g.@: a record or array).
13235
13236 @item
13237 There is explicit or implicit initialization required for the object.
13238 Note that access values are always implicitly initialized.
13239
13240 @item
13241 The address value is non-static. Here GNAT is more permissive than the
13242 RM, and allows the address value to be the address of a previously declared
13243 stand-alone variable, as long as it does not itself have an address clause.
13244
13245 @smallexample @c ada
13246 Anchor : Some_Initialized_Type;
13247 Overlay : Some_Initialized_Type;
13248 for Overlay'Address use Anchor'Address;
13249 @end smallexample
13250
13251 @noindent
13252 However, the prefix of the address clause cannot be an array component, or
13253 a component of a discriminated record.
13254
13255 @end itemize
13256
13257 @noindent
13258 As noted above in section 22.h, address values are typically non-static. In
13259 particular the To_Address function, even if applied to a literal value, is
13260 a non-static function call. To avoid this minor annoyance, GNAT provides
13261 the implementation defined attribute 'To_Address. The following two
13262 expressions have identical values:
13263
13264 @findex Attribute
13265 @findex To_Address
13266 @smallexample @c ada
13267 To_Address (16#1234_0000#)
13268 System'To_Address (16#1234_0000#);
13269 @end smallexample
13270
13271 @noindent
13272 except that the second form is considered to be a static expression, and
13273 thus when used as an address clause value is always permitted.
13274
13275 @noindent
13276 Additionally, GNAT treats as static an address clause that is an
13277 unchecked_conversion of a static integer value. This simplifies the porting
13278 of legacy code, and provides a portable equivalent to the GNAT attribute
13279 @code{To_Address}.
13280
13281 Another issue with address clauses is the interaction with alignment
13282 requirements. When an address clause is given for an object, the address
13283 value must be consistent with the alignment of the object (which is usually
13284 the same as the alignment of the type of the object). If an address clause
13285 is given that specifies an inappropriately aligned address value, then the
13286 program execution is erroneous.
13287
13288 Since this source of erroneous behavior can have unfortunate effects, GNAT
13289 checks (at compile time if possible, generating a warning, or at execution
13290 time with a run-time check) that the alignment is appropriate. If the
13291 run-time check fails, then @code{Program_Error} is raised. This run-time
13292 check is suppressed if range checks are suppressed, or if the special GNAT
13293 check Alignment_Check is suppressed, or if
13294 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
13295
13296 Finally, GNAT does not permit overlaying of objects of controlled types or
13297 composite types containing a controlled component. In most cases, the compiler
13298 can detect an attempt at such overlays and will generate a warning at compile
13299 time and a Program_Error exception at run time.
13300
13301 @findex Export
13302 An address clause cannot be given for an exported object. More
13303 understandably the real restriction is that objects with an address
13304 clause cannot be exported. This is because such variables are not
13305 defined by the Ada program, so there is no external object to export.
13306
13307 @findex Import
13308 It is permissible to give an address clause and a pragma Import for the
13309 same object. In this case, the variable is not really defined by the
13310 Ada program, so there is no external symbol to be linked. The link name
13311 and the external name are ignored in this case. The reason that we allow this
13312 combination is that it provides a useful idiom to avoid unwanted
13313 initializations on objects with address clauses.
13314
13315 When an address clause is given for an object that has implicit or
13316 explicit initialization, then by default initialization takes place. This
13317 means that the effect of the object declaration is to overwrite the
13318 memory at the specified address. This is almost always not what the
13319 programmer wants, so GNAT will output a warning:
13320
13321 @smallexample
13322 with System;
13323 package G is
13324 type R is record
13325 M : Integer := 0;
13326 end record;
13327
13328 Ext : R;
13329 for Ext'Address use System'To_Address (16#1234_1234#);
13330 |
13331 >>> warning: implicit initialization of "Ext" may
13332 modify overlaid storage
13333 >>> warning: use pragma Import for "Ext" to suppress
13334 initialization (RM B(24))
13335
13336 end G;
13337 @end smallexample
13338
13339 @noindent
13340 As indicated by the warning message, the solution is to use a (dummy) pragma
13341 Import to suppress this initialization. The pragma tell the compiler that the
13342 object is declared and initialized elsewhere. The following package compiles
13343 without warnings (and the initialization is suppressed):
13344
13345 @smallexample @c ada
13346 with System;
13347 package G is
13348 type R is record
13349 M : Integer := 0;
13350 end record;
13351
13352 Ext : R;
13353 for Ext'Address use System'To_Address (16#1234_1234#);
13354 pragma Import (Ada, Ext);
13355 end G;
13356 @end smallexample
13357
13358 @noindent
13359 A final issue with address clauses involves their use for overlaying
13360 variables, as in the following example:
13361 @cindex Overlaying of objects
13362
13363 @smallexample @c ada
13364 A : Integer;
13365 B : Integer;
13366 for B'Address use A'Address;
13367 @end smallexample
13368
13369 @noindent
13370 or alternatively, using the form recommended by the RM:
13371
13372 @smallexample @c ada
13373 A : Integer;
13374 Addr : constant Address := A'Address;
13375 B : Integer;
13376 for B'Address use Addr;
13377 @end smallexample
13378
13379 @noindent
13380 In both of these cases, @code{A}
13381 and @code{B} become aliased to one another via the
13382 address clause. This use of address clauses to overlay
13383 variables, achieving an effect similar to unchecked
13384 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
13385 the effect is implementation defined. Furthermore, the
13386 Ada RM specifically recommends that in a situation
13387 like this, @code{B} should be subject to the following
13388 implementation advice (RM 13.3(19)):
13389
13390 @quotation
13391 19 If the Address of an object is specified, or it is imported
13392 or exported, then the implementation should not perform
13393 optimizations based on assumptions of no aliases.
13394 @end quotation
13395
13396 @noindent
13397 GNAT follows this recommendation, and goes further by also applying
13398 this recommendation to the overlaid variable (@code{A}
13399 in the above example) in this case. This means that the overlay
13400 works "as expected", in that a modification to one of the variables
13401 will affect the value of the other.
13402
13403 @node Effect of Convention on Representation
13404 @section Effect of Convention on Representation
13405 @cindex Convention, effect on representation
13406
13407 @noindent
13408 Normally the specification of a foreign language convention for a type or
13409 an object has no effect on the chosen representation. In particular, the
13410 representation chosen for data in GNAT generally meets the standard system
13411 conventions, and for example records are laid out in a manner that is
13412 consistent with C@. This means that specifying convention C (for example)
13413 has no effect.
13414
13415 There are four exceptions to this general rule:
13416
13417 @itemize @bullet
13418
13419 @item Convention Fortran and array subtypes
13420 If pragma Convention Fortran is specified for an array subtype, then in
13421 accordance with the implementation advice in section 3.6.2(11) of the
13422 Ada Reference Manual, the array will be stored in a Fortran-compatible
13423 column-major manner, instead of the normal default row-major order.
13424
13425 @item Convention C and enumeration types
13426 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
13427 to accommodate all values of the type. For example, for the enumeration
13428 type declared by:
13429
13430 @smallexample @c ada
13431 type Color is (Red, Green, Blue);
13432 @end smallexample
13433
13434 @noindent
13435 8 bits is sufficient to store all values of the type, so by default, objects
13436 of type @code{Color} will be represented using 8 bits. However, normal C
13437 convention is to use 32 bits for all enum values in C, since enum values
13438 are essentially of type int. If pragma @code{Convention C} is specified for an
13439 Ada enumeration type, then the size is modified as necessary (usually to
13440 32 bits) to be consistent with the C convention for enum values.
13441
13442 Note that this treatment applies only to types. If Convention C is given for
13443 an enumeration object, where the enumeration type is not Convention C, then
13444 Object_Size bits are allocated. For example, for a normal enumeration type,
13445 with less than 256 elements, only 8 bits will be allocated for the object.
13446 Since this may be a surprise in terms of what C expects, GNAT will issue a
13447 warning in this situation. The warning can be suppressed by giving an explicit
13448 size clause specifying the desired size.
13449
13450 @item Convention C/Fortran and Boolean types
13451 In C, the usual convention for boolean values, that is values used for
13452 conditions, is that zero represents false, and nonzero values represent
13453 true. In Ada, the normal convention is that two specific values, typically
13454 0/1, are used to represent false/true respectively.
13455
13456 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
13457 value represents true).
13458
13459 To accommodate the Fortran and C conventions, if a pragma Convention specifies
13460 C or Fortran convention for a derived Boolean, as in the following example:
13461
13462 @smallexample @c ada
13463 type C_Switch is new Boolean;
13464 pragma Convention (C, C_Switch);
13465 @end smallexample
13466
13467 @noindent
13468 then the GNAT generated code will treat any nonzero value as true. For truth
13469 values generated by GNAT, the conventional value 1 will be used for True, but
13470 when one of these values is read, any nonzero value is treated as True.
13471
13472 @item Access types on OpenVMS
13473 For 64-bit OpenVMS systems, access types (other than those for unconstrained
13474 arrays) are 64-bits long. An exception to this rule is for the case of
13475 C-convention access types where there is no explicit size clause present (or
13476 inherited for derived types). In this case, GNAT chooses to make these
13477 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
13478 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
13479
13480 @end itemize
13481
13482 @node Determining the Representations chosen by GNAT
13483 @section Determining the Representations chosen by GNAT
13484 @cindex Representation, determination of
13485 @cindex @option{-gnatR} switch
13486
13487 @noindent
13488 Although the descriptions in this section are intended to be complete, it is
13489 often easier to simply experiment to see what GNAT accepts and what the
13490 effect is on the layout of types and objects.
13491
13492 As required by the Ada RM, if a representation clause is not accepted, then
13493 it must be rejected as illegal by the compiler. However, when a
13494 representation clause or pragma is accepted, there can still be questions
13495 of what the compiler actually does. For example, if a partial record
13496 representation clause specifies the location of some components and not
13497 others, then where are the non-specified components placed? Or if pragma
13498 @code{Pack} is used on a record, then exactly where are the resulting
13499 fields placed? The section on pragma @code{Pack} in this chapter can be
13500 used to answer the second question, but it is often easier to just see
13501 what the compiler does.
13502
13503 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13504 with this option, then the compiler will output information on the actual
13505 representations chosen, in a format similar to source representation
13506 clauses. For example, if we compile the package:
13507
13508 @smallexample @c ada
13509 package q is
13510 type r (x : boolean) is tagged record
13511 case x is
13512 when True => S : String (1 .. 100);
13513 when False => null;
13514 end case;
13515 end record;
13516
13517 type r2 is new r (false) with record
13518 y2 : integer;
13519 end record;
13520
13521 for r2 use record
13522 y2 at 16 range 0 .. 31;
13523 end record;
13524
13525 type x is record
13526 y : character;
13527 end record;
13528
13529 type x1 is array (1 .. 10) of x;
13530 for x1'component_size use 11;
13531
13532 type ia is access integer;
13533
13534 type Rb1 is array (1 .. 13) of Boolean;
13535 pragma Pack (rb1);
13536
13537 type Rb2 is array (1 .. 65) of Boolean;
13538 pragma Pack (rb2);
13539
13540 type x2 is record
13541 l1 : Boolean;
13542 l2 : Duration;
13543 l3 : Float;
13544 l4 : Boolean;
13545 l5 : Rb1;
13546 l6 : Rb2;
13547 end record;
13548 pragma Pack (x2);
13549 end q;
13550 @end smallexample
13551
13552 @noindent
13553 using the switch @option{-gnatR} we obtain the following output:
13554
13555 @smallexample
13556 Representation information for unit q
13557 -------------------------------------
13558
13559 for r'Size use ??;
13560 for r'Alignment use 4;
13561 for r use record
13562 x at 4 range 0 .. 7;
13563 _tag at 0 range 0 .. 31;
13564 s at 5 range 0 .. 799;
13565 end record;
13566
13567 for r2'Size use 160;
13568 for r2'Alignment use 4;
13569 for r2 use record
13570 x at 4 range 0 .. 7;
13571 _tag at 0 range 0 .. 31;
13572 _parent at 0 range 0 .. 63;
13573 y2 at 16 range 0 .. 31;
13574 end record;
13575
13576 for x'Size use 8;
13577 for x'Alignment use 1;
13578 for x use record
13579 y at 0 range 0 .. 7;
13580 end record;
13581
13582 for x1'Size use 112;
13583 for x1'Alignment use 1;
13584 for x1'Component_Size use 11;
13585
13586 for rb1'Size use 13;
13587 for rb1'Alignment use 2;
13588 for rb1'Component_Size use 1;
13589
13590 for rb2'Size use 72;
13591 for rb2'Alignment use 1;
13592 for rb2'Component_Size use 1;
13593
13594 for x2'Size use 224;
13595 for x2'Alignment use 4;
13596 for x2 use record
13597 l1 at 0 range 0 .. 0;
13598 l2 at 0 range 1 .. 64;
13599 l3 at 12 range 0 .. 31;
13600 l4 at 16 range 0 .. 0;
13601 l5 at 16 range 1 .. 13;
13602 l6 at 18 range 0 .. 71;
13603 end record;
13604 @end smallexample
13605
13606 @noindent
13607 The Size values are actually the Object_Size, i.e.@: the default size that
13608 will be allocated for objects of the type.
13609 The ?? size for type r indicates that we have a variant record, and the
13610 actual size of objects will depend on the discriminant value.
13611
13612 The Alignment values show the actual alignment chosen by the compiler
13613 for each record or array type.
13614
13615 The record representation clause for type r shows where all fields
13616 are placed, including the compiler generated tag field (whose location
13617 cannot be controlled by the programmer).
13618
13619 The record representation clause for the type extension r2 shows all the
13620 fields present, including the parent field, which is a copy of the fields
13621 of the parent type of r2, i.e.@: r1.
13622
13623 The component size and size clauses for types rb1 and rb2 show
13624 the exact effect of pragma @code{Pack} on these arrays, and the record
13625 representation clause for type x2 shows how pragma @code{Pack} affects
13626 this record type.
13627
13628 In some cases, it may be useful to cut and paste the representation clauses
13629 generated by the compiler into the original source to fix and guarantee
13630 the actual representation to be used.
13631
13632 @node Standard Library Routines
13633 @chapter Standard Library Routines
13634
13635 @noindent
13636 The Ada Reference Manual contains in Annex A a full description of an
13637 extensive set of standard library routines that can be used in any Ada
13638 program, and which must be provided by all Ada compilers. They are
13639 analogous to the standard C library used by C programs.
13640
13641 GNAT implements all of the facilities described in annex A, and for most
13642 purposes the description in the Ada Reference Manual, or appropriate Ada
13643 text book, will be sufficient for making use of these facilities.
13644
13645 In the case of the input-output facilities,
13646 @xref{The Implementation of Standard I/O},
13647 gives details on exactly how GNAT interfaces to the
13648 file system. For the remaining packages, the Ada Reference Manual
13649 should be sufficient. The following is a list of the packages included,
13650 together with a brief description of the functionality that is provided.
13651
13652 For completeness, references are included to other predefined library
13653 routines defined in other sections of the Ada Reference Manual (these are
13654 cross-indexed from Annex A).
13655
13656 @table @code
13657 @item Ada (A.2)
13658 This is a parent package for all the standard library packages. It is
13659 usually included implicitly in your program, and itself contains no
13660 useful data or routines.
13661
13662 @item Ada.Calendar (9.6)
13663 @code{Calendar} provides time of day access, and routines for
13664 manipulating times and durations.
13665
13666 @item Ada.Characters (A.3.1)
13667 This is a dummy parent package that contains no useful entities
13668
13669 @item Ada.Characters.Handling (A.3.2)
13670 This package provides some basic character handling capabilities,
13671 including classification functions for classes of characters (e.g.@: test
13672 for letters, or digits).
13673
13674 @item Ada.Characters.Latin_1 (A.3.3)
13675 This package includes a complete set of definitions of the characters
13676 that appear in type CHARACTER@. It is useful for writing programs that
13677 will run in international environments. For example, if you want an
13678 upper case E with an acute accent in a string, it is often better to use
13679 the definition of @code{UC_E_Acute} in this package. Then your program
13680 will print in an understandable manner even if your environment does not
13681 support these extended characters.
13682
13683 @item Ada.Command_Line (A.15)
13684 This package provides access to the command line parameters and the name
13685 of the current program (analogous to the use of @code{argc} and @code{argv}
13686 in C), and also allows the exit status for the program to be set in a
13687 system-independent manner.
13688
13689 @item Ada.Decimal (F.2)
13690 This package provides constants describing the range of decimal numbers
13691 implemented, and also a decimal divide routine (analogous to the COBOL
13692 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13693
13694 @item Ada.Direct_IO (A.8.4)
13695 This package provides input-output using a model of a set of records of
13696 fixed-length, containing an arbitrary definite Ada type, indexed by an
13697 integer record number.
13698
13699 @item Ada.Dynamic_Priorities (D.5)
13700 This package allows the priorities of a task to be adjusted dynamically
13701 as the task is running.
13702
13703 @item Ada.Exceptions (11.4.1)
13704 This package provides additional information on exceptions, and also
13705 contains facilities for treating exceptions as data objects, and raising
13706 exceptions with associated messages.
13707
13708 @item Ada.Finalization (7.6)
13709 This package contains the declarations and subprograms to support the
13710 use of controlled types, providing for automatic initialization and
13711 finalization (analogous to the constructors and destructors of C++)
13712
13713 @item Ada.Interrupts (C.3.2)
13714 This package provides facilities for interfacing to interrupts, which
13715 includes the set of signals or conditions that can be raised and
13716 recognized as interrupts.
13717
13718 @item Ada.Interrupts.Names (C.3.2)
13719 This package provides the set of interrupt names (actually signal
13720 or condition names) that can be handled by GNAT@.
13721
13722 @item Ada.IO_Exceptions (A.13)
13723 This package defines the set of exceptions that can be raised by use of
13724 the standard IO packages.
13725
13726 @item Ada.Numerics
13727 This package contains some standard constants and exceptions used
13728 throughout the numerics packages. Note that the constants pi and e are
13729 defined here, and it is better to use these definitions than rolling
13730 your own.
13731
13732 @item Ada.Numerics.Complex_Elementary_Functions
13733 Provides the implementation of standard elementary functions (such as
13734 log and trigonometric functions) operating on complex numbers using the
13735 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13736 created by the package @code{Numerics.Complex_Types}.
13737
13738 @item Ada.Numerics.Complex_Types
13739 This is a predefined instantiation of
13740 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13741 build the type @code{Complex} and @code{Imaginary}.
13742
13743 @item Ada.Numerics.Discrete_Random
13744 This generic package provides a random number generator suitable for generating
13745 uniformly distributed values of a specified discrete subtype.
13746
13747 @item Ada.Numerics.Float_Random
13748 This package provides a random number generator suitable for generating
13749 uniformly distributed floating point values in the unit interval.
13750
13751 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13752 This is a generic version of the package that provides the
13753 implementation of standard elementary functions (such as log and
13754 trigonometric functions) for an arbitrary complex type.
13755
13756 The following predefined instantiations of this package are provided:
13757
13758 @table @code
13759 @item Short_Float
13760 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13761 @item Float
13762 @code{Ada.Numerics.Complex_Elementary_Functions}
13763 @item Long_Float
13764 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13765 @end table
13766
13767 @item Ada.Numerics.Generic_Complex_Types
13768 This is a generic package that allows the creation of complex types,
13769 with associated complex arithmetic operations.
13770
13771 The following predefined instantiations of this package exist
13772 @table @code
13773 @item Short_Float
13774 @code{Ada.Numerics.Short_Complex_Complex_Types}
13775 @item Float
13776 @code{Ada.Numerics.Complex_Complex_Types}
13777 @item Long_Float
13778 @code{Ada.Numerics.Long_Complex_Complex_Types}
13779 @end table
13780
13781 @item Ada.Numerics.Generic_Elementary_Functions
13782 This is a generic package that provides the implementation of standard
13783 elementary functions (such as log an trigonometric functions) for an
13784 arbitrary float type.
13785
13786 The following predefined instantiations of this package exist
13787
13788 @table @code
13789 @item Short_Float
13790 @code{Ada.Numerics.Short_Elementary_Functions}
13791 @item Float
13792 @code{Ada.Numerics.Elementary_Functions}
13793 @item Long_Float
13794 @code{Ada.Numerics.Long_Elementary_Functions}
13795 @end table
13796
13797 @item Ada.Real_Time (D.8)
13798 This package provides facilities similar to those of @code{Calendar}, but
13799 operating with a finer clock suitable for real time control. Note that
13800 annex D requires that there be no backward clock jumps, and GNAT generally
13801 guarantees this behavior, but of course if the external clock on which
13802 the GNAT runtime depends is deliberately reset by some external event,
13803 then such a backward jump may occur.
13804
13805 @item Ada.Sequential_IO (A.8.1)
13806 This package provides input-output facilities for sequential files,
13807 which can contain a sequence of values of a single type, which can be
13808 any Ada type, including indefinite (unconstrained) types.
13809
13810 @item Ada.Storage_IO (A.9)
13811 This package provides a facility for mapping arbitrary Ada types to and
13812 from a storage buffer. It is primarily intended for the creation of new
13813 IO packages.
13814
13815 @item Ada.Streams (13.13.1)
13816 This is a generic package that provides the basic support for the
13817 concept of streams as used by the stream attributes (@code{Input},
13818 @code{Output}, @code{Read} and @code{Write}).
13819
13820 @item Ada.Streams.Stream_IO (A.12.1)
13821 This package is a specialization of the type @code{Streams} defined in
13822 package @code{Streams} together with a set of operations providing
13823 Stream_IO capability. The Stream_IO model permits both random and
13824 sequential access to a file which can contain an arbitrary set of values
13825 of one or more Ada types.
13826
13827 @item Ada.Strings (A.4.1)
13828 This package provides some basic constants used by the string handling
13829 packages.
13830
13831 @item Ada.Strings.Bounded (A.4.4)
13832 This package provides facilities for handling variable length
13833 strings. The bounded model requires a maximum length. It is thus
13834 somewhat more limited than the unbounded model, but avoids the use of
13835 dynamic allocation or finalization.
13836
13837 @item Ada.Strings.Fixed (A.4.3)
13838 This package provides facilities for handling fixed length strings.
13839
13840 @item Ada.Strings.Maps (A.4.2)
13841 This package provides facilities for handling character mappings and
13842 arbitrarily defined subsets of characters. For instance it is useful in
13843 defining specialized translation tables.
13844
13845 @item Ada.Strings.Maps.Constants (A.4.6)
13846 This package provides a standard set of predefined mappings and
13847 predefined character sets. For example, the standard upper to lower case
13848 conversion table is found in this package. Note that upper to lower case
13849 conversion is non-trivial if you want to take the entire set of
13850 characters, including extended characters like E with an acute accent,
13851 into account. You should use the mappings in this package (rather than
13852 adding 32 yourself) to do case mappings.
13853
13854 @item Ada.Strings.Unbounded (A.4.5)
13855 This package provides facilities for handling variable length
13856 strings. The unbounded model allows arbitrary length strings, but
13857 requires the use of dynamic allocation and finalization.
13858
13859 @item Ada.Strings.Wide_Bounded (A.4.7)
13860 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13861 @itemx Ada.Strings.Wide_Maps (A.4.7)
13862 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13863 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13864 These packages provide analogous capabilities to the corresponding
13865 packages without @samp{Wide_} in the name, but operate with the types
13866 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13867 and @code{Character}.
13868
13869 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13870 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13871 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13872 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13873 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13874 These packages provide analogous capabilities to the corresponding
13875 packages without @samp{Wide_} in the name, but operate with the types
13876 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13877 of @code{String} and @code{Character}.
13878
13879 @item Ada.Synchronous_Task_Control (D.10)
13880 This package provides some standard facilities for controlling task
13881 communication in a synchronous manner.
13882
13883 @item Ada.Tags
13884 This package contains definitions for manipulation of the tags of tagged
13885 values.
13886
13887 @item Ada.Task_Attributes
13888 This package provides the capability of associating arbitrary
13889 task-specific data with separate tasks.
13890
13891 @item Ada.Text_IO
13892 This package provides basic text input-output capabilities for
13893 character, string and numeric data. The subpackages of this
13894 package are listed next.
13895
13896 @item Ada.Text_IO.Decimal_IO
13897 Provides input-output facilities for decimal fixed-point types
13898
13899 @item Ada.Text_IO.Enumeration_IO
13900 Provides input-output facilities for enumeration types.
13901
13902 @item Ada.Text_IO.Fixed_IO
13903 Provides input-output facilities for ordinary fixed-point types.
13904
13905 @item Ada.Text_IO.Float_IO
13906 Provides input-output facilities for float types. The following
13907 predefined instantiations of this generic package are available:
13908
13909 @table @code
13910 @item Short_Float
13911 @code{Short_Float_Text_IO}
13912 @item Float
13913 @code{Float_Text_IO}
13914 @item Long_Float
13915 @code{Long_Float_Text_IO}
13916 @end table
13917
13918 @item Ada.Text_IO.Integer_IO
13919 Provides input-output facilities for integer types. The following
13920 predefined instantiations of this generic package are available:
13921
13922 @table @code
13923 @item Short_Short_Integer
13924 @code{Ada.Short_Short_Integer_Text_IO}
13925 @item Short_Integer
13926 @code{Ada.Short_Integer_Text_IO}
13927 @item Integer
13928 @code{Ada.Integer_Text_IO}
13929 @item Long_Integer
13930 @code{Ada.Long_Integer_Text_IO}
13931 @item Long_Long_Integer
13932 @code{Ada.Long_Long_Integer_Text_IO}
13933 @end table
13934
13935 @item Ada.Text_IO.Modular_IO
13936 Provides input-output facilities for modular (unsigned) types
13937
13938 @item Ada.Text_IO.Complex_IO (G.1.3)
13939 This package provides basic text input-output capabilities for complex
13940 data.
13941
13942 @item Ada.Text_IO.Editing (F.3.3)
13943 This package contains routines for edited output, analogous to the use
13944 of pictures in COBOL@. The picture formats used by this package are a
13945 close copy of the facility in COBOL@.
13946
13947 @item Ada.Text_IO.Text_Streams (A.12.2)
13948 This package provides a facility that allows Text_IO files to be treated
13949 as streams, so that the stream attributes can be used for writing
13950 arbitrary data, including binary data, to Text_IO files.
13951
13952 @item Ada.Unchecked_Conversion (13.9)
13953 This generic package allows arbitrary conversion from one type to
13954 another of the same size, providing for breaking the type safety in
13955 special circumstances.
13956
13957 If the types have the same Size (more accurately the same Value_Size),
13958 then the effect is simply to transfer the bits from the source to the
13959 target type without any modification. This usage is well defined, and
13960 for simple types whose representation is typically the same across
13961 all implementations, gives a portable method of performing such
13962 conversions.
13963
13964 If the types do not have the same size, then the result is implementation
13965 defined, and thus may be non-portable. The following describes how GNAT
13966 handles such unchecked conversion cases.
13967
13968 If the types are of different sizes, and are both discrete types, then
13969 the effect is of a normal type conversion without any constraint checking.
13970 In particular if the result type has a larger size, the result will be
13971 zero or sign extended. If the result type has a smaller size, the result
13972 will be truncated by ignoring high order bits.
13973
13974 If the types are of different sizes, and are not both discrete types,
13975 then the conversion works as though pointers were created to the source
13976 and target, and the pointer value is converted. The effect is that bits
13977 are copied from successive low order storage units and bits of the source
13978 up to the length of the target type.
13979
13980 A warning is issued if the lengths differ, since the effect in this
13981 case is implementation dependent, and the above behavior may not match
13982 that of some other compiler.
13983
13984 A pointer to one type may be converted to a pointer to another type using
13985 unchecked conversion. The only case in which the effect is undefined is
13986 when one or both pointers are pointers to unconstrained array types. In
13987 this case, the bounds information may get incorrectly transferred, and in
13988 particular, GNAT uses double size pointers for such types, and it is
13989 meaningless to convert between such pointer types. GNAT will issue a
13990 warning if the alignment of the target designated type is more strict
13991 than the alignment of the source designated type (since the result may
13992 be unaligned in this case).
13993
13994 A pointer other than a pointer to an unconstrained array type may be
13995 converted to and from System.Address. Such usage is common in Ada 83
13996 programs, but note that Ada.Address_To_Access_Conversions is the
13997 preferred method of performing such conversions in Ada 95 and Ada 2005.
13998 Neither
13999 unchecked conversion nor Ada.Address_To_Access_Conversions should be
14000 used in conjunction with pointers to unconstrained objects, since
14001 the bounds information cannot be handled correctly in this case.
14002
14003 @item Ada.Unchecked_Deallocation (13.11.2)
14004 This generic package allows explicit freeing of storage previously
14005 allocated by use of an allocator.
14006
14007 @item Ada.Wide_Text_IO (A.11)
14008 This package is similar to @code{Ada.Text_IO}, except that the external
14009 file supports wide character representations, and the internal types are
14010 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14011 and @code{String}. It contains generic subpackages listed next.
14012
14013 @item Ada.Wide_Text_IO.Decimal_IO
14014 Provides input-output facilities for decimal fixed-point types
14015
14016 @item Ada.Wide_Text_IO.Enumeration_IO
14017 Provides input-output facilities for enumeration types.
14018
14019 @item Ada.Wide_Text_IO.Fixed_IO
14020 Provides input-output facilities for ordinary fixed-point types.
14021
14022 @item Ada.Wide_Text_IO.Float_IO
14023 Provides input-output facilities for float types. The following
14024 predefined instantiations of this generic package are available:
14025
14026 @table @code
14027 @item Short_Float
14028 @code{Short_Float_Wide_Text_IO}
14029 @item Float
14030 @code{Float_Wide_Text_IO}
14031 @item Long_Float
14032 @code{Long_Float_Wide_Text_IO}
14033 @end table
14034
14035 @item Ada.Wide_Text_IO.Integer_IO
14036 Provides input-output facilities for integer types. The following
14037 predefined instantiations of this generic package are available:
14038
14039 @table @code
14040 @item Short_Short_Integer
14041 @code{Ada.Short_Short_Integer_Wide_Text_IO}
14042 @item Short_Integer
14043 @code{Ada.Short_Integer_Wide_Text_IO}
14044 @item Integer
14045 @code{Ada.Integer_Wide_Text_IO}
14046 @item Long_Integer
14047 @code{Ada.Long_Integer_Wide_Text_IO}
14048 @item Long_Long_Integer
14049 @code{Ada.Long_Long_Integer_Wide_Text_IO}
14050 @end table
14051
14052 @item Ada.Wide_Text_IO.Modular_IO
14053 Provides input-output facilities for modular (unsigned) types
14054
14055 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
14056 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14057 external file supports wide character representations.
14058
14059 @item Ada.Wide_Text_IO.Editing (F.3.4)
14060 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14061 types are @code{Wide_Character} and @code{Wide_String} instead of
14062 @code{Character} and @code{String}.
14063
14064 @item Ada.Wide_Text_IO.Streams (A.12.3)
14065 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14066 types are @code{Wide_Character} and @code{Wide_String} instead of
14067 @code{Character} and @code{String}.
14068
14069 @item Ada.Wide_Wide_Text_IO (A.11)
14070 This package is similar to @code{Ada.Text_IO}, except that the external
14071 file supports wide character representations, and the internal types are
14072 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14073 and @code{String}. It contains generic subpackages listed next.
14074
14075 @item Ada.Wide_Wide_Text_IO.Decimal_IO
14076 Provides input-output facilities for decimal fixed-point types
14077
14078 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
14079 Provides input-output facilities for enumeration types.
14080
14081 @item Ada.Wide_Wide_Text_IO.Fixed_IO
14082 Provides input-output facilities for ordinary fixed-point types.
14083
14084 @item Ada.Wide_Wide_Text_IO.Float_IO
14085 Provides input-output facilities for float types. The following
14086 predefined instantiations of this generic package are available:
14087
14088 @table @code
14089 @item Short_Float
14090 @code{Short_Float_Wide_Wide_Text_IO}
14091 @item Float
14092 @code{Float_Wide_Wide_Text_IO}
14093 @item Long_Float
14094 @code{Long_Float_Wide_Wide_Text_IO}
14095 @end table
14096
14097 @item Ada.Wide_Wide_Text_IO.Integer_IO
14098 Provides input-output facilities for integer types. The following
14099 predefined instantiations of this generic package are available:
14100
14101 @table @code
14102 @item Short_Short_Integer
14103 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
14104 @item Short_Integer
14105 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
14106 @item Integer
14107 @code{Ada.Integer_Wide_Wide_Text_IO}
14108 @item Long_Integer
14109 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
14110 @item Long_Long_Integer
14111 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
14112 @end table
14113
14114 @item Ada.Wide_Wide_Text_IO.Modular_IO
14115 Provides input-output facilities for modular (unsigned) types
14116
14117 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
14118 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14119 external file supports wide character representations.
14120
14121 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
14122 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14123 types are @code{Wide_Character} and @code{Wide_String} instead of
14124 @code{Character} and @code{String}.
14125
14126 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
14127 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14128 types are @code{Wide_Character} and @code{Wide_String} instead of
14129 @code{Character} and @code{String}.
14130 @end table
14131
14132 @node The Implementation of Standard I/O
14133 @chapter The Implementation of Standard I/O
14134
14135 @noindent
14136 GNAT implements all the required input-output facilities described in
14137 A.6 through A.14. These sections of the Ada Reference Manual describe the
14138 required behavior of these packages from the Ada point of view, and if
14139 you are writing a portable Ada program that does not need to know the
14140 exact manner in which Ada maps to the outside world when it comes to
14141 reading or writing external files, then you do not need to read this
14142 chapter. As long as your files are all regular files (not pipes or
14143 devices), and as long as you write and read the files only from Ada, the
14144 description in the Ada Reference Manual is sufficient.
14145
14146 However, if you want to do input-output to pipes or other devices, such
14147 as the keyboard or screen, or if the files you are dealing with are
14148 either generated by some other language, or to be read by some other
14149 language, then you need to know more about the details of how the GNAT
14150 implementation of these input-output facilities behaves.
14151
14152 In this chapter we give a detailed description of exactly how GNAT
14153 interfaces to the file system. As always, the sources of the system are
14154 available to you for answering questions at an even more detailed level,
14155 but for most purposes the information in this chapter will suffice.
14156
14157 Another reason that you may need to know more about how input-output is
14158 implemented arises when you have a program written in mixed languages
14159 where, for example, files are shared between the C and Ada sections of
14160 the same program. GNAT provides some additional facilities, in the form
14161 of additional child library packages, that facilitate this sharing, and
14162 these additional facilities are also described in this chapter.
14163
14164 @menu
14165 * Standard I/O Packages::
14166 * FORM Strings::
14167 * Direct_IO::
14168 * Sequential_IO::
14169 * Text_IO::
14170 * Wide_Text_IO::
14171 * Wide_Wide_Text_IO::
14172 * Stream_IO::
14173 * Text Translation::
14174 * Shared Files::
14175 * Filenames encoding::
14176 * Open Modes::
14177 * Operations on C Streams::
14178 * Interfacing to C Streams::
14179 @end menu
14180
14181 @node Standard I/O Packages
14182 @section Standard I/O Packages
14183
14184 @noindent
14185 The Standard I/O packages described in Annex A for
14186
14187 @itemize @bullet
14188 @item
14189 Ada.Text_IO
14190 @item
14191 Ada.Text_IO.Complex_IO
14192 @item
14193 Ada.Text_IO.Text_Streams
14194 @item
14195 Ada.Wide_Text_IO
14196 @item
14197 Ada.Wide_Text_IO.Complex_IO
14198 @item
14199 Ada.Wide_Text_IO.Text_Streams
14200 @item
14201 Ada.Wide_Wide_Text_IO
14202 @item
14203 Ada.Wide_Wide_Text_IO.Complex_IO
14204 @item
14205 Ada.Wide_Wide_Text_IO.Text_Streams
14206 @item
14207 Ada.Stream_IO
14208 @item
14209 Ada.Sequential_IO
14210 @item
14211 Ada.Direct_IO
14212 @end itemize
14213
14214 @noindent
14215 are implemented using the C
14216 library streams facility; where
14217
14218 @itemize @bullet
14219 @item
14220 All files are opened using @code{fopen}.
14221 @item
14222 All input/output operations use @code{fread}/@code{fwrite}.
14223 @end itemize
14224
14225 @noindent
14226 There is no internal buffering of any kind at the Ada library level. The only
14227 buffering is that provided at the system level in the implementation of the
14228 library routines that support streams. This facilitates shared use of these
14229 streams by mixed language programs. Note though that system level buffering is
14230 explicitly enabled at elaboration of the standard I/O packages and that can
14231 have an impact on mixed language programs, in particular those using I/O before
14232 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
14233 the Ada elaboration routine before performing any I/O or when impractical,
14234 flush the common I/O streams and in particular Standard_Output before
14235 elaborating the Ada code.
14236
14237 @node FORM Strings
14238 @section FORM Strings
14239
14240 @noindent
14241 The format of a FORM string in GNAT is:
14242
14243 @smallexample
14244 "keyword=value,keyword=value,@dots{},keyword=value"
14245 @end smallexample
14246
14247 @noindent
14248 where letters may be in upper or lower case, and there are no spaces
14249 between values. The order of the entries is not important. Currently
14250 the following keywords defined.
14251
14252 @smallexample
14253 TEXT_TRANSLATION=[YES|NO]
14254 SHARED=[YES|NO]
14255 WCEM=[n|h|u|s|e|8|b]
14256 ENCODING=[UTF8|8BITS]
14257 @end smallexample
14258
14259 @noindent
14260 The use of these parameters is described later in this section. If an
14261 unrecognized keyword appears in a form string, it is silently ignored
14262 and not considered invalid.
14263
14264 @noindent
14265 For OpenVMS additional FORM string keywords are available for use with
14266 RMS services. The syntax is:
14267
14268 @smallexample
14269 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
14270 @end smallexample
14271
14272 @noindent
14273 The following RMS keywords and values are currently defined:
14274
14275 @smallexample
14276 Context=Force_Stream_Mode|Force_Record_Mode
14277 @end smallexample
14278
14279 @noindent
14280 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
14281 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
14282
14283 @node Direct_IO
14284 @section Direct_IO
14285
14286 @noindent
14287 Direct_IO can only be instantiated for definite types. This is a
14288 restriction of the Ada language, which means that the records are fixed
14289 length (the length being determined by @code{@var{type}'Size}, rounded
14290 up to the next storage unit boundary if necessary).
14291
14292 The records of a Direct_IO file are simply written to the file in index
14293 sequence, with the first record starting at offset zero, and subsequent
14294 records following. There is no control information of any kind. For
14295 example, if 32-bit integers are being written, each record takes
14296 4-bytes, so the record at index @var{K} starts at offset
14297 (@var{K}@minus{}1)*4.
14298
14299 There is no limit on the size of Direct_IO files, they are expanded as
14300 necessary to accommodate whatever records are written to the file.
14301
14302 @node Sequential_IO
14303 @section Sequential_IO
14304
14305 @noindent
14306 Sequential_IO may be instantiated with either a definite (constrained)
14307 or indefinite (unconstrained) type.
14308
14309 For the definite type case, the elements written to the file are simply
14310 the memory images of the data values with no control information of any
14311 kind. The resulting file should be read using the same type, no validity
14312 checking is performed on input.
14313
14314 For the indefinite type case, the elements written consist of two
14315 parts. First is the size of the data item, written as the memory image
14316 of a @code{Interfaces.C.size_t} value, followed by the memory image of
14317 the data value. The resulting file can only be read using the same
14318 (unconstrained) type. Normal assignment checks are performed on these
14319 read operations, and if these checks fail, @code{Data_Error} is
14320 raised. In particular, in the array case, the lengths must match, and in
14321 the variant record case, if the variable for a particular read operation
14322 is constrained, the discriminants must match.
14323
14324 Note that it is not possible to use Sequential_IO to write variable
14325 length array items, and then read the data back into different length
14326 arrays. For example, the following will raise @code{Data_Error}:
14327
14328 @smallexample @c ada
14329 package IO is new Sequential_IO (String);
14330 F : IO.File_Type;
14331 S : String (1..4);
14332 @dots{}
14333 IO.Create (F)
14334 IO.Write (F, "hello!")
14335 IO.Reset (F, Mode=>In_File);
14336 IO.Read (F, S);
14337 Put_Line (S);
14338
14339 @end smallexample
14340
14341 @noindent
14342 On some Ada implementations, this will print @code{hell}, but the program is
14343 clearly incorrect, since there is only one element in the file, and that
14344 element is the string @code{hello!}.
14345
14346 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
14347 using Stream_IO, and this is the preferred mechanism. In particular, the
14348 above program fragment rewritten to use Stream_IO will work correctly.
14349
14350 @node Text_IO
14351 @section Text_IO
14352
14353 @noindent
14354 Text_IO files consist of a stream of characters containing the following
14355 special control characters:
14356
14357 @smallexample
14358 LF (line feed, 16#0A#) Line Mark
14359 FF (form feed, 16#0C#) Page Mark
14360 @end smallexample
14361
14362 @noindent
14363 A canonical Text_IO file is defined as one in which the following
14364 conditions are met:
14365
14366 @itemize @bullet
14367 @item
14368 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
14369 of the line.
14370
14371 @item
14372 The character @code{FF} is used only as a page mark, i.e.@: to mark the
14373 end of a page and consequently can appear only immediately following a
14374 @code{LF} (line mark) character.
14375
14376 @item
14377 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
14378 (line mark, page mark). In the former case, the page mark is implicitly
14379 assumed to be present.
14380 @end itemize
14381
14382 @noindent
14383 A file written using Text_IO will be in canonical form provided that no
14384 explicit @code{LF} or @code{FF} characters are written using @code{Put}
14385 or @code{Put_Line}. There will be no @code{FF} character at the end of
14386 the file unless an explicit @code{New_Page} operation was performed
14387 before closing the file.
14388
14389 A canonical Text_IO file that is a regular file (i.e., not a device or a
14390 pipe) can be read using any of the routines in Text_IO@. The
14391 semantics in this case will be exactly as defined in the Ada Reference
14392 Manual, and all the routines in Text_IO are fully implemented.
14393
14394 A text file that does not meet the requirements for a canonical Text_IO
14395 file has one of the following:
14396
14397 @itemize @bullet
14398 @item
14399 The file contains @code{FF} characters not immediately following a
14400 @code{LF} character.
14401
14402 @item
14403 The file contains @code{LF} or @code{FF} characters written by
14404 @code{Put} or @code{Put_Line}, which are not logically considered to be
14405 line marks or page marks.
14406
14407 @item
14408 The file ends in a character other than @code{LF} or @code{FF},
14409 i.e.@: there is no explicit line mark or page mark at the end of the file.
14410 @end itemize
14411
14412 @noindent
14413 Text_IO can be used to read such non-standard text files but subprograms
14414 to do with line or page numbers do not have defined meanings. In
14415 particular, a @code{FF} character that does not follow a @code{LF}
14416 character may or may not be treated as a page mark from the point of
14417 view of page and line numbering. Every @code{LF} character is considered
14418 to end a line, and there is an implied @code{LF} character at the end of
14419 the file.
14420
14421 @menu
14422 * Text_IO Stream Pointer Positioning::
14423 * Text_IO Reading and Writing Non-Regular Files::
14424 * Get_Immediate::
14425 * Treating Text_IO Files as Streams::
14426 * Text_IO Extensions::
14427 * Text_IO Facilities for Unbounded Strings::
14428 @end menu
14429
14430 @node Text_IO Stream Pointer Positioning
14431 @subsection Stream Pointer Positioning
14432
14433 @noindent
14434 @code{Ada.Text_IO} has a definition of current position for a file that
14435 is being read. No internal buffering occurs in Text_IO, and usually the
14436 physical position in the stream used to implement the file corresponds
14437 to this logical position defined by Text_IO@. There are two exceptions:
14438
14439 @itemize @bullet
14440 @item
14441 After a call to @code{End_Of_Page} that returns @code{True}, the stream
14442 is positioned past the @code{LF} (line mark) that precedes the page
14443 mark. Text_IO maintains an internal flag so that subsequent read
14444 operations properly handle the logical position which is unchanged by
14445 the @code{End_Of_Page} call.
14446
14447 @item
14448 After a call to @code{End_Of_File} that returns @code{True}, if the
14449 Text_IO file was positioned before the line mark at the end of file
14450 before the call, then the logical position is unchanged, but the stream
14451 is physically positioned right at the end of file (past the line mark,
14452 and past a possible page mark following the line mark. Again Text_IO
14453 maintains internal flags so that subsequent read operations properly
14454 handle the logical position.
14455 @end itemize
14456
14457 @noindent
14458 These discrepancies have no effect on the observable behavior of
14459 Text_IO, but if a single Ada stream is shared between a C program and
14460 Ada program, or shared (using @samp{shared=yes} in the form string)
14461 between two Ada files, then the difference may be observable in some
14462 situations.
14463
14464 @node Text_IO Reading and Writing Non-Regular Files
14465 @subsection Reading and Writing Non-Regular Files
14466
14467 @noindent
14468 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
14469 can be used for reading and writing. Writing is not affected and the
14470 sequence of characters output is identical to the normal file case, but
14471 for reading, the behavior of Text_IO is modified to avoid undesirable
14472 look-ahead as follows:
14473
14474 An input file that is not a regular file is considered to have no page
14475 marks. Any @code{Ascii.FF} characters (the character normally used for a
14476 page mark) appearing in the file are considered to be data
14477 characters. In particular:
14478
14479 @itemize @bullet
14480 @item
14481 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
14482 following a line mark. If a page mark appears, it will be treated as a
14483 data character.
14484
14485 @item
14486 This avoids the need to wait for an extra character to be typed or
14487 entered from the pipe to complete one of these operations.
14488
14489 @item
14490 @code{End_Of_Page} always returns @code{False}
14491
14492 @item
14493 @code{End_Of_File} will return @code{False} if there is a page mark at
14494 the end of the file.
14495 @end itemize
14496
14497 @noindent
14498 Output to non-regular files is the same as for regular files. Page marks
14499 may be written to non-regular files using @code{New_Page}, but as noted
14500 above they will not be treated as page marks on input if the output is
14501 piped to another Ada program.
14502
14503 Another important discrepancy when reading non-regular files is that the end
14504 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
14505 pressing the @key{EOT} key,
14506 then end of file
14507 is signaled once (i.e.@: the test @code{End_Of_File}
14508 will yield @code{True}, or a read will
14509 raise @code{End_Error}), but then reading can resume
14510 to read data past that end of
14511 file indication, until another end of file indication is entered.
14512
14513 @node Get_Immediate
14514 @subsection Get_Immediate
14515 @cindex Get_Immediate
14516
14517 @noindent
14518 Get_Immediate returns the next character (including control characters)
14519 from the input file. In particular, Get_Immediate will return LF or FF
14520 characters used as line marks or page marks. Such operations leave the
14521 file positioned past the control character, and it is thus not treated
14522 as having its normal function. This means that page, line and column
14523 counts after this kind of Get_Immediate call are set as though the mark
14524 did not occur. In the case where a Get_Immediate leaves the file
14525 positioned between the line mark and page mark (which is not normally
14526 possible), it is undefined whether the FF character will be treated as a
14527 page mark.
14528
14529 @node Treating Text_IO Files as Streams
14530 @subsection Treating Text_IO Files as Streams
14531 @cindex Stream files
14532
14533 @noindent
14534 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14535 as a stream. Data written to a Text_IO file in this stream mode is
14536 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14537 16#0C# (@code{FF}), the resulting file may have non-standard
14538 format. Similarly if read operations are used to read from a Text_IO
14539 file treated as a stream, then @code{LF} and @code{FF} characters may be
14540 skipped and the effect is similar to that described above for
14541 @code{Get_Immediate}.
14542
14543 @node Text_IO Extensions
14544 @subsection Text_IO Extensions
14545 @cindex Text_IO extensions
14546
14547 @noindent
14548 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14549 to the standard @code{Text_IO} package:
14550
14551 @itemize @bullet
14552 @item function File_Exists (Name : String) return Boolean;
14553 Determines if a file of the given name exists.
14554
14555 @item function Get_Line return String;
14556 Reads a string from the standard input file. The value returned is exactly
14557 the length of the line that was read.
14558
14559 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14560 Similar, except that the parameter File specifies the file from which
14561 the string is to be read.
14562
14563 @end itemize
14564
14565 @node Text_IO Facilities for Unbounded Strings
14566 @subsection Text_IO Facilities for Unbounded Strings
14567 @cindex Text_IO for unbounded strings
14568 @cindex Unbounded_String, Text_IO operations
14569
14570 @noindent
14571 The package @code{Ada.Strings.Unbounded.Text_IO}
14572 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14573 subprograms useful for Text_IO operations on unbounded strings:
14574
14575 @itemize @bullet
14576
14577 @item function Get_Line (File : File_Type) return Unbounded_String;
14578 Reads a line from the specified file
14579 and returns the result as an unbounded string.
14580
14581 @item procedure Put (File : File_Type; U : Unbounded_String);
14582 Writes the value of the given unbounded string to the specified file
14583 Similar to the effect of
14584 @code{Put (To_String (U))} except that an extra copy is avoided.
14585
14586 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14587 Writes the value of the given unbounded string to the specified file,
14588 followed by a @code{New_Line}.
14589 Similar to the effect of @code{Put_Line (To_String (U))} except
14590 that an extra copy is avoided.
14591 @end itemize
14592
14593 @noindent
14594 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14595 and is optional. If the parameter is omitted, then the standard input or
14596 output file is referenced as appropriate.
14597
14598 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14599 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14600 @code{Wide_Text_IO} functionality for unbounded wide strings.
14601
14602 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14603 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14604 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14605
14606 @node Wide_Text_IO
14607 @section Wide_Text_IO
14608
14609 @noindent
14610 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14611 both input and output files may contain special sequences that represent
14612 wide character values. The encoding scheme for a given file may be
14613 specified using a FORM parameter:
14614
14615 @smallexample
14616 WCEM=@var{x}
14617 @end smallexample
14618
14619 @noindent
14620 as part of the FORM string (WCEM = wide character encoding method),
14621 where @var{x} is one of the following characters
14622
14623 @table @samp
14624 @item h
14625 Hex ESC encoding
14626 @item u
14627 Upper half encoding
14628 @item s
14629 Shift-JIS encoding
14630 @item e
14631 EUC Encoding
14632 @item 8
14633 UTF-8 encoding
14634 @item b
14635 Brackets encoding
14636 @end table
14637
14638 @noindent
14639 The encoding methods match those that
14640 can be used in a source
14641 program, but there is no requirement that the encoding method used for
14642 the source program be the same as the encoding method used for files,
14643 and different files may use different encoding methods.
14644
14645 The default encoding method for the standard files, and for opened files
14646 for which no WCEM parameter is given in the FORM string matches the
14647 wide character encoding specified for the main program (the default
14648 being brackets encoding if no coding method was specified with -gnatW).
14649
14650 @table @asis
14651 @item Hex Coding
14652 In this encoding, a wide character is represented by a five character
14653 sequence:
14654
14655 @smallexample
14656 ESC a b c d
14657 @end smallexample
14658
14659 @noindent
14660 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14661 characters (using upper case letters) of the wide character code. For
14662 example, ESC A345 is used to represent the wide character with code
14663 16#A345#. This scheme is compatible with use of the full
14664 @code{Wide_Character} set.
14665
14666 @item Upper Half Coding
14667 The wide character with encoding 16#abcd#, where the upper bit is on
14668 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14669 16#cd#. The second byte may never be a format control character, but is
14670 not required to be in the upper half. This method can be also used for
14671 shift-JIS or EUC where the internal coding matches the external coding.
14672
14673 @item Shift JIS Coding
14674 A wide character is represented by a two character sequence 16#ab# and
14675 16#cd#, with the restrictions described for upper half encoding as
14676 described above. The internal character code is the corresponding JIS
14677 character according to the standard algorithm for Shift-JIS
14678 conversion. Only characters defined in the JIS code set table can be
14679 used with this encoding method.
14680
14681 @item EUC Coding
14682 A wide character is represented by a two character sequence 16#ab# and
14683 16#cd#, with both characters being in the upper half. The internal
14684 character code is the corresponding JIS character according to the EUC
14685 encoding algorithm. Only characters defined in the JIS code set table
14686 can be used with this encoding method.
14687
14688 @item UTF-8 Coding
14689 A wide character is represented using
14690 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14691 10646-1/Am.2. Depending on the character value, the representation
14692 is a one, two, or three byte sequence:
14693
14694 @smallexample
14695 16#0000#-16#007f#: 2#0xxxxxxx#
14696 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14697 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14698 @end smallexample
14699
14700 @noindent
14701 where the @var{xxx} bits correspond to the left-padded bits of the
14702 16-bit character value. Note that all lower half ASCII characters
14703 are represented as ASCII bytes and all upper half characters and
14704 other wide characters are represented as sequences of upper-half
14705 (The full UTF-8 scheme allows for encoding 31-bit characters as
14706 6-byte sequences, but in this implementation, all UTF-8 sequences
14707 of four or more bytes length will raise a Constraint_Error, as
14708 will all invalid UTF-8 sequences.)
14709
14710 @item Brackets Coding
14711 In this encoding, a wide character is represented by the following eight
14712 character sequence:
14713
14714 @smallexample
14715 [ " a b c d " ]
14716 @end smallexample
14717
14718 @noindent
14719 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14720 characters (using uppercase letters) of the wide character code. For
14721 example, @code{["A345"]} is used to represent the wide character with code
14722 @code{16#A345#}.
14723 This scheme is compatible with use of the full Wide_Character set.
14724 On input, brackets coding can also be used for upper half characters,
14725 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14726 is only used for wide characters with a code greater than @code{16#FF#}.
14727
14728 Note that brackets coding is not normally used in the context of
14729 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14730 a portable way of encoding source files. In the context of Wide_Text_IO
14731 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14732 any instance of the left bracket character other than to encode wide
14733 character values using the brackets encoding method. In practice it is
14734 expected that some standard wide character encoding method such
14735 as UTF-8 will be used for text input output.
14736
14737 If brackets notation is used, then any occurrence of a left bracket
14738 in the input file which is not the start of a valid wide character
14739 sequence will cause Constraint_Error to be raised. It is possible to
14740 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14741 input will interpret this as a left bracket.
14742
14743 However, when a left bracket is output, it will be output as a left bracket
14744 and not as ["5B"]. We make this decision because for normal use of
14745 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14746 brackets. For example, if we write:
14747
14748 @smallexample
14749 Put_Line ("Start of output [first run]");
14750 @end smallexample
14751
14752 @noindent
14753 we really do not want to have the left bracket in this message clobbered so
14754 that the output reads:
14755
14756 @smallexample
14757 Start of output ["5B"]first run]
14758 @end smallexample
14759
14760 @noindent
14761 In practice brackets encoding is reasonably useful for normal Put_Line use
14762 since we won't get confused between left brackets and wide character
14763 sequences in the output. But for input, or when files are written out
14764 and read back in, it really makes better sense to use one of the standard
14765 encoding methods such as UTF-8.
14766
14767 @end table
14768
14769 @noindent
14770 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14771 not all wide character
14772 values can be represented. An attempt to output a character that cannot
14773 be represented using the encoding scheme for the file causes
14774 Constraint_Error to be raised. An invalid wide character sequence on
14775 input also causes Constraint_Error to be raised.
14776
14777 @menu
14778 * Wide_Text_IO Stream Pointer Positioning::
14779 * Wide_Text_IO Reading and Writing Non-Regular Files::
14780 @end menu
14781
14782 @node Wide_Text_IO Stream Pointer Positioning
14783 @subsection Stream Pointer Positioning
14784
14785 @noindent
14786 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14787 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14788 case:
14789
14790 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14791 normal lower ASCII set (i.e.@: a character in the range:
14792
14793 @smallexample @c ada
14794 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14795 @end smallexample
14796
14797 @noindent
14798 then although the logical position of the file pointer is unchanged by
14799 the @code{Look_Ahead} call, the stream is physically positioned past the
14800 wide character sequence. Again this is to avoid the need for buffering
14801 or backup, and all @code{Wide_Text_IO} routines check the internal
14802 indication that this situation has occurred so that this is not visible
14803 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14804 can be observed if the wide text file shares a stream with another file.
14805
14806 @node Wide_Text_IO Reading and Writing Non-Regular Files
14807 @subsection Reading and Writing Non-Regular Files
14808
14809 @noindent
14810 As in the case of Text_IO, when a non-regular file is read, it is
14811 assumed that the file contains no page marks (any form characters are
14812 treated as data characters), and @code{End_Of_Page} always returns
14813 @code{False}. Similarly, the end of file indication is not sticky, so
14814 it is possible to read beyond an end of file.
14815
14816 @node Wide_Wide_Text_IO
14817 @section Wide_Wide_Text_IO
14818
14819 @noindent
14820 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14821 both input and output files may contain special sequences that represent
14822 wide wide character values. The encoding scheme for a given file may be
14823 specified using a FORM parameter:
14824
14825 @smallexample
14826 WCEM=@var{x}
14827 @end smallexample
14828
14829 @noindent
14830 as part of the FORM string (WCEM = wide character encoding method),
14831 where @var{x} is one of the following characters
14832
14833 @table @samp
14834 @item h
14835 Hex ESC encoding
14836 @item u
14837 Upper half encoding
14838 @item s
14839 Shift-JIS encoding
14840 @item e
14841 EUC Encoding
14842 @item 8
14843 UTF-8 encoding
14844 @item b
14845 Brackets encoding
14846 @end table
14847
14848 @noindent
14849 The encoding methods match those that
14850 can be used in a source
14851 program, but there is no requirement that the encoding method used for
14852 the source program be the same as the encoding method used for files,
14853 and different files may use different encoding methods.
14854
14855 The default encoding method for the standard files, and for opened files
14856 for which no WCEM parameter is given in the FORM string matches the
14857 wide character encoding specified for the main program (the default
14858 being brackets encoding if no coding method was specified with -gnatW).
14859
14860 @table @asis
14861
14862 @item UTF-8 Coding
14863 A wide character is represented using
14864 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14865 10646-1/Am.2. Depending on the character value, the representation
14866 is a one, two, three, or four byte sequence:
14867
14868 @smallexample
14869 16#000000#-16#00007f#: 2#0xxxxxxx#
14870 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14871 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14872 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14873 @end smallexample
14874
14875 @noindent
14876 where the @var{xxx} bits correspond to the left-padded bits of the
14877 21-bit character value. Note that all lower half ASCII characters
14878 are represented as ASCII bytes and all upper half characters and
14879 other wide characters are represented as sequences of upper-half
14880 characters.
14881
14882 @item Brackets Coding
14883 In this encoding, a wide wide character is represented by the following eight
14884 character sequence if is in wide character range
14885
14886 @smallexample
14887 [ " a b c d " ]
14888 @end smallexample
14889
14890 and by the following ten character sequence if not
14891
14892 @smallexample
14893 [ " a b c d e f " ]
14894 @end smallexample
14895
14896 @noindent
14897 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14898 are the four or six hexadecimal
14899 characters (using uppercase letters) of the wide wide character code. For
14900 example, @code{["01A345"]} is used to represent the wide wide character
14901 with code @code{16#01A345#}.
14902
14903 This scheme is compatible with use of the full Wide_Wide_Character set.
14904 On input, brackets coding can also be used for upper half characters,
14905 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14906 is only used for wide characters with a code greater than @code{16#FF#}.
14907
14908 @end table
14909
14910 @noindent
14911 If is also possible to use the other Wide_Character encoding methods,
14912 such as Shift-JIS, but the other schemes cannot support the full range
14913 of wide wide characters.
14914 An attempt to output a character that cannot
14915 be represented using the encoding scheme for the file causes
14916 Constraint_Error to be raised. An invalid wide character sequence on
14917 input also causes Constraint_Error to be raised.
14918
14919 @menu
14920 * Wide_Wide_Text_IO Stream Pointer Positioning::
14921 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14922 @end menu
14923
14924 @node Wide_Wide_Text_IO Stream Pointer Positioning
14925 @subsection Stream Pointer Positioning
14926
14927 @noindent
14928 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14929 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14930 case:
14931
14932 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14933 normal lower ASCII set (i.e.@: a character in the range:
14934
14935 @smallexample @c ada
14936 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14937 @end smallexample
14938
14939 @noindent
14940 then although the logical position of the file pointer is unchanged by
14941 the @code{Look_Ahead} call, the stream is physically positioned past the
14942 wide character sequence. Again this is to avoid the need for buffering
14943 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14944 indication that this situation has occurred so that this is not visible
14945 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14946 can be observed if the wide text file shares a stream with another file.
14947
14948 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14949 @subsection Reading and Writing Non-Regular Files
14950
14951 @noindent
14952 As in the case of Text_IO, when a non-regular file is read, it is
14953 assumed that the file contains no page marks (any form characters are
14954 treated as data characters), and @code{End_Of_Page} always returns
14955 @code{False}. Similarly, the end of file indication is not sticky, so
14956 it is possible to read beyond an end of file.
14957
14958 @node Stream_IO
14959 @section Stream_IO
14960
14961 @noindent
14962 A stream file is a sequence of bytes, where individual elements are
14963 written to the file as described in the Ada Reference Manual. The type
14964 @code{Stream_Element} is simply a byte. There are two ways to read or
14965 write a stream file.
14966
14967 @itemize @bullet
14968 @item
14969 The operations @code{Read} and @code{Write} directly read or write a
14970 sequence of stream elements with no control information.
14971
14972 @item
14973 The stream attributes applied to a stream file transfer data in the
14974 manner described for stream attributes.
14975 @end itemize
14976
14977 @node Text Translation
14978 @section Text Translation
14979
14980 @noindent
14981 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14982 passed to Text_IO.Create and Text_IO.Open:
14983 @samp{Text_Translation=@var{Yes}} is the default, which means to
14984 translate LF to/from CR/LF on Windows systems.
14985 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14986 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14987 may be used to create Unix-style files on
14988 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14989 systems.
14990
14991 @node Shared Files
14992 @section Shared Files
14993
14994 @noindent
14995 Section A.14 of the Ada Reference Manual allows implementations to
14996 provide a wide variety of behavior if an attempt is made to access the
14997 same external file with two or more internal files.
14998
14999 To provide a full range of functionality, while at the same time
15000 minimizing the problems of portability caused by this implementation
15001 dependence, GNAT handles file sharing as follows:
15002
15003 @itemize @bullet
15004 @item
15005 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
15006 to open two or more files with the same full name is considered an error
15007 and is not supported. The exception @code{Use_Error} will be
15008 raised. Note that a file that is not explicitly closed by the program
15009 remains open until the program terminates.
15010
15011 @item
15012 If the form parameter @samp{shared=no} appears in the form string, the
15013 file can be opened or created with its own separate stream identifier,
15014 regardless of whether other files sharing the same external file are
15015 opened. The exact effect depends on how the C stream routines handle
15016 multiple accesses to the same external files using separate streams.
15017
15018 @item
15019 If the form parameter @samp{shared=yes} appears in the form string for
15020 each of two or more files opened using the same full name, the same
15021 stream is shared between these files, and the semantics are as described
15022 in Ada Reference Manual, Section A.14.
15023 @end itemize
15024
15025 @noindent
15026 When a program that opens multiple files with the same name is ported
15027 from another Ada compiler to GNAT, the effect will be that
15028 @code{Use_Error} is raised.
15029
15030 The documentation of the original compiler and the documentation of the
15031 program should then be examined to determine if file sharing was
15032 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
15033 and @code{Create} calls as required.
15034
15035 When a program is ported from GNAT to some other Ada compiler, no
15036 special attention is required unless the @samp{shared=@var{xxx}} form
15037 parameter is used in the program. In this case, you must examine the
15038 documentation of the new compiler to see if it supports the required
15039 file sharing semantics, and form strings modified appropriately. Of
15040 course it may be the case that the program cannot be ported if the
15041 target compiler does not support the required functionality. The best
15042 approach in writing portable code is to avoid file sharing (and hence
15043 the use of the @samp{shared=@var{xxx}} parameter in the form string)
15044 completely.
15045
15046 One common use of file sharing in Ada 83 is the use of instantiations of
15047 Sequential_IO on the same file with different types, to achieve
15048 heterogeneous input-output. Although this approach will work in GNAT if
15049 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
15050 for this purpose (using the stream attributes)
15051
15052 @node Filenames encoding
15053 @section Filenames encoding
15054
15055 @noindent
15056 An encoding form parameter can be used to specify the filename
15057 encoding @samp{encoding=@var{xxx}}.
15058
15059 @itemize @bullet
15060 @item
15061 If the form parameter @samp{encoding=utf8} appears in the form string, the
15062 filename must be encoded in UTF-8.
15063
15064 @item
15065 If the form parameter @samp{encoding=8bits} appears in the form
15066 string, the filename must be a standard 8bits string.
15067 @end itemize
15068
15069 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
15070 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
15071 variable. And if not set @samp{utf8} is assumed.
15072
15073 @table @samp
15074 @item CP_ACP
15075 The current system Windows ANSI code page.
15076 @item CP_UTF8
15077 UTF-8 encoding
15078 @end table
15079
15080 This encoding form parameter is only supported on the Windows
15081 platform. On the other Operating Systems the run-time is supporting
15082 UTF-8 natively.
15083
15084 @node Open Modes
15085 @section Open Modes
15086
15087 @noindent
15088 @code{Open} and @code{Create} calls result in a call to @code{fopen}
15089 using the mode shown in the following table:
15090
15091 @sp 2
15092 @center @code{Open} and @code{Create} Call Modes
15093 @smallexample
15094 @b{OPEN } @b{CREATE}
15095 Append_File "r+" "w+"
15096 In_File "r" "w+"
15097 Out_File (Direct_IO) "r+" "w"
15098 Out_File (all other cases) "w" "w"
15099 Inout_File "r+" "w+"
15100 @end smallexample
15101
15102 @noindent
15103 If text file translation is required, then either @samp{b} or @samp{t}
15104 is added to the mode, depending on the setting of Text. Text file
15105 translation refers to the mapping of CR/LF sequences in an external file
15106 to LF characters internally. This mapping only occurs in DOS and
15107 DOS-like systems, and is not relevant to other systems.
15108
15109 A special case occurs with Stream_IO@. As shown in the above table, the
15110 file is initially opened in @samp{r} or @samp{w} mode for the
15111 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
15112 subsequently requires switching from reading to writing or vice-versa,
15113 then the file is reopened in @samp{r+} mode to permit the required operation.
15114
15115 @node Operations on C Streams
15116 @section Operations on C Streams
15117 The package @code{Interfaces.C_Streams} provides an Ada program with direct
15118 access to the C library functions for operations on C streams:
15119
15120 @smallexample @c adanocomment
15121 package Interfaces.C_Streams is
15122 -- Note: the reason we do not use the types that are in
15123 -- Interfaces.C is that we want to avoid dragging in the
15124 -- code in this unit if possible.
15125 subtype chars is System.Address;
15126 -- Pointer to null-terminated array of characters
15127 subtype FILEs is System.Address;
15128 -- Corresponds to the C type FILE*
15129 subtype voids is System.Address;
15130 -- Corresponds to the C type void*
15131 subtype int is Integer;
15132 subtype long is Long_Integer;
15133 -- Note: the above types are subtypes deliberately, and it
15134 -- is part of this spec that the above correspondences are
15135 -- guaranteed. This means that it is legitimate to, for
15136 -- example, use Integer instead of int. We provide these
15137 -- synonyms for clarity, but in some cases it may be
15138 -- convenient to use the underlying types (for example to
15139 -- avoid an unnecessary dependency of a spec on the spec
15140 -- of this unit).
15141 type size_t is mod 2 ** Standard'Address_Size;
15142 NULL_Stream : constant FILEs;
15143 -- Value returned (NULL in C) to indicate an
15144 -- fdopen/fopen/tmpfile error
15145 ----------------------------------
15146 -- Constants Defined in stdio.h --
15147 ----------------------------------
15148 EOF : constant int;
15149 -- Used by a number of routines to indicate error or
15150 -- end of file
15151 IOFBF : constant int;
15152 IOLBF : constant int;
15153 IONBF : constant int;
15154 -- Used to indicate buffering mode for setvbuf call
15155 SEEK_CUR : constant int;
15156 SEEK_END : constant int;
15157 SEEK_SET : constant int;
15158 -- Used to indicate origin for fseek call
15159 function stdin return FILEs;
15160 function stdout return FILEs;
15161 function stderr return FILEs;
15162 -- Streams associated with standard files
15163 --------------------------
15164 -- Standard C functions --
15165 --------------------------
15166 -- The functions selected below are ones that are
15167 -- available in UNIX (but not necessarily in ANSI C).
15168 -- These are very thin interfaces
15169 -- which copy exactly the C headers. For more
15170 -- documentation on these functions, see the Microsoft C
15171 -- "Run-Time Library Reference" (Microsoft Press, 1990,
15172 -- ISBN 1-55615-225-6), which includes useful information
15173 -- on system compatibility.
15174 procedure clearerr (stream : FILEs);
15175 function fclose (stream : FILEs) return int;
15176 function fdopen (handle : int; mode : chars) return FILEs;
15177 function feof (stream : FILEs) return int;
15178 function ferror (stream : FILEs) return int;
15179 function fflush (stream : FILEs) return int;
15180 function fgetc (stream : FILEs) return int;
15181 function fgets (strng : chars; n : int; stream : FILEs)
15182 return chars;
15183 function fileno (stream : FILEs) return int;
15184 function fopen (filename : chars; Mode : chars)
15185 return FILEs;
15186 -- Note: to maintain target independence, use
15187 -- text_translation_required, a boolean variable defined in
15188 -- a-sysdep.c to deal with the target dependent text
15189 -- translation requirement. If this variable is set,
15190 -- then b/t should be appended to the standard mode
15191 -- argument to set the text translation mode off or on
15192 -- as required.
15193 function fputc (C : int; stream : FILEs) return int;
15194 function fputs (Strng : chars; Stream : FILEs) return int;
15195 function fread
15196 (buffer : voids;
15197 size : size_t;
15198 count : size_t;
15199 stream : FILEs)
15200 return size_t;
15201 function freopen
15202 (filename : chars;
15203 mode : chars;
15204 stream : FILEs)
15205 return FILEs;
15206 function fseek
15207 (stream : FILEs;
15208 offset : long;
15209 origin : int)
15210 return int;
15211 function ftell (stream : FILEs) return long;
15212 function fwrite
15213 (buffer : voids;
15214 size : size_t;
15215 count : size_t;
15216 stream : FILEs)
15217 return size_t;
15218 function isatty (handle : int) return int;
15219 procedure mktemp (template : chars);
15220 -- The return value (which is just a pointer to template)
15221 -- is discarded
15222 procedure rewind (stream : FILEs);
15223 function rmtmp return int;
15224 function setvbuf
15225 (stream : FILEs;
15226 buffer : chars;
15227 mode : int;
15228 size : size_t)
15229 return int;
15230
15231 function tmpfile return FILEs;
15232 function ungetc (c : int; stream : FILEs) return int;
15233 function unlink (filename : chars) return int;
15234 ---------------------
15235 -- Extra functions --
15236 ---------------------
15237 -- These functions supply slightly thicker bindings than
15238 -- those above. They are derived from functions in the
15239 -- C Run-Time Library, but may do a bit more work than
15240 -- just directly calling one of the Library functions.
15241 function is_regular_file (handle : int) return int;
15242 -- Tests if given handle is for a regular file (result 1)
15243 -- or for a non-regular file (pipe or device, result 0).
15244 ---------------------------------
15245 -- Control of Text/Binary Mode --
15246 ---------------------------------
15247 -- If text_translation_required is true, then the following
15248 -- functions may be used to dynamically switch a file from
15249 -- binary to text mode or vice versa. These functions have
15250 -- no effect if text_translation_required is false (i.e.@: in
15251 -- normal UNIX mode). Use fileno to get a stream handle.
15252 procedure set_binary_mode (handle : int);
15253 procedure set_text_mode (handle : int);
15254 ----------------------------
15255 -- Full Path Name support --
15256 ----------------------------
15257 procedure full_name (nam : chars; buffer : chars);
15258 -- Given a NUL terminated string representing a file
15259 -- name, returns in buffer a NUL terminated string
15260 -- representing the full path name for the file name.
15261 -- On systems where it is relevant the drive is also
15262 -- part of the full path name. It is the responsibility
15263 -- of the caller to pass an actual parameter for buffer
15264 -- that is big enough for any full path name. Use
15265 -- max_path_len given below as the size of buffer.
15266 max_path_len : integer;
15267 -- Maximum length of an allowable full path name on the
15268 -- system, including a terminating NUL character.
15269 end Interfaces.C_Streams;
15270 @end smallexample
15271
15272 @node Interfacing to C Streams
15273 @section Interfacing to C Streams
15274
15275 @noindent
15276 The packages in this section permit interfacing Ada files to C Stream
15277 operations.
15278
15279 @smallexample @c ada
15280 with Interfaces.C_Streams;
15281 package Ada.Sequential_IO.C_Streams is
15282 function C_Stream (F : File_Type)
15283 return Interfaces.C_Streams.FILEs;
15284 procedure Open
15285 (File : in out File_Type;
15286 Mode : in File_Mode;
15287 C_Stream : in Interfaces.C_Streams.FILEs;
15288 Form : in String := "");
15289 end Ada.Sequential_IO.C_Streams;
15290
15291 with Interfaces.C_Streams;
15292 package Ada.Direct_IO.C_Streams is
15293 function C_Stream (F : File_Type)
15294 return Interfaces.C_Streams.FILEs;
15295 procedure Open
15296 (File : in out File_Type;
15297 Mode : in File_Mode;
15298 C_Stream : in Interfaces.C_Streams.FILEs;
15299 Form : in String := "");
15300 end Ada.Direct_IO.C_Streams;
15301
15302 with Interfaces.C_Streams;
15303 package Ada.Text_IO.C_Streams is
15304 function C_Stream (F : File_Type)
15305 return Interfaces.C_Streams.FILEs;
15306 procedure Open
15307 (File : in out File_Type;
15308 Mode : in File_Mode;
15309 C_Stream : in Interfaces.C_Streams.FILEs;
15310 Form : in String := "");
15311 end Ada.Text_IO.C_Streams;
15312
15313 with Interfaces.C_Streams;
15314 package Ada.Wide_Text_IO.C_Streams is
15315 function C_Stream (F : File_Type)
15316 return Interfaces.C_Streams.FILEs;
15317 procedure Open
15318 (File : in out File_Type;
15319 Mode : in File_Mode;
15320 C_Stream : in Interfaces.C_Streams.FILEs;
15321 Form : in String := "");
15322 end Ada.Wide_Text_IO.C_Streams;
15323
15324 with Interfaces.C_Streams;
15325 package Ada.Wide_Wide_Text_IO.C_Streams is
15326 function C_Stream (F : File_Type)
15327 return Interfaces.C_Streams.FILEs;
15328 procedure Open
15329 (File : in out File_Type;
15330 Mode : in File_Mode;
15331 C_Stream : in Interfaces.C_Streams.FILEs;
15332 Form : in String := "");
15333 end Ada.Wide_Wide_Text_IO.C_Streams;
15334
15335 with Interfaces.C_Streams;
15336 package Ada.Stream_IO.C_Streams is
15337 function C_Stream (F : File_Type)
15338 return Interfaces.C_Streams.FILEs;
15339 procedure Open
15340 (File : in out File_Type;
15341 Mode : in File_Mode;
15342 C_Stream : in Interfaces.C_Streams.FILEs;
15343 Form : in String := "");
15344 end Ada.Stream_IO.C_Streams;
15345 @end smallexample
15346
15347 @noindent
15348 In each of these six packages, the @code{C_Stream} function obtains the
15349 @code{FILE} pointer from a currently opened Ada file. It is then
15350 possible to use the @code{Interfaces.C_Streams} package to operate on
15351 this stream, or the stream can be passed to a C program which can
15352 operate on it directly. Of course the program is responsible for
15353 ensuring that only appropriate sequences of operations are executed.
15354
15355 One particular use of relevance to an Ada program is that the
15356 @code{setvbuf} function can be used to control the buffering of the
15357 stream used by an Ada file. In the absence of such a call the standard
15358 default buffering is used.
15359
15360 The @code{Open} procedures in these packages open a file giving an
15361 existing C Stream instead of a file name. Typically this stream is
15362 imported from a C program, allowing an Ada file to operate on an
15363 existing C file.
15364
15365 @node The GNAT Library
15366 @chapter The GNAT Library
15367
15368 @noindent
15369 The GNAT library contains a number of general and special purpose packages.
15370 It represents functionality that the GNAT developers have found useful, and
15371 which is made available to GNAT users. The packages described here are fully
15372 supported, and upwards compatibility will be maintained in future releases,
15373 so you can use these facilities with the confidence that the same functionality
15374 will be available in future releases.
15375
15376 The chapter here simply gives a brief summary of the facilities available.
15377 The full documentation is found in the spec file for the package. The full
15378 sources of these library packages, including both spec and body, are provided
15379 with all GNAT releases. For example, to find out the full specifications of
15380 the SPITBOL pattern matching capability, including a full tutorial and
15381 extensive examples, look in the @file{g-spipat.ads} file in the library.
15382
15383 For each entry here, the package name (as it would appear in a @code{with}
15384 clause) is given, followed by the name of the corresponding spec file in
15385 parentheses. The packages are children in four hierarchies, @code{Ada},
15386 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
15387 GNAT-specific hierarchy.
15388
15389 Note that an application program should only use packages in one of these
15390 four hierarchies if the package is defined in the Ada Reference Manual,
15391 or is listed in this section of the GNAT Programmers Reference Manual.
15392 All other units should be considered internal implementation units and
15393 should not be directly @code{with}'ed by application code. The use of
15394 a @code{with} statement that references one of these internal implementation
15395 units makes an application potentially dependent on changes in versions
15396 of GNAT, and will generate a warning message.
15397
15398 @menu
15399 * Ada.Characters.Latin_9 (a-chlat9.ads)::
15400 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
15401 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
15402 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
15403 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
15404 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
15405 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
15406 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
15407 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
15408 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
15409 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
15410 * Ada.Command_Line.Environment (a-colien.ads)::
15411 * Ada.Command_Line.Remove (a-colire.ads)::
15412 * Ada.Command_Line.Response_File (a-clrefi.ads)::
15413 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
15414 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
15415 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
15416 * Ada.Exceptions.Traceback (a-exctra.ads)::
15417 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
15418 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
15419 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
15420 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
15421 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
15422 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
15423 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
15424 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
15425 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
15426 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
15427 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
15428 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
15429 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
15430 * GNAT.Altivec (g-altive.ads)::
15431 * GNAT.Altivec.Conversions (g-altcon.ads)::
15432 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
15433 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
15434 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
15435 * GNAT.Array_Split (g-arrspl.ads)::
15436 * GNAT.AWK (g-awk.ads)::
15437 * GNAT.Bounded_Buffers (g-boubuf.ads)::
15438 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
15439 * GNAT.Bubble_Sort (g-bubsor.ads)::
15440 * GNAT.Bubble_Sort_A (g-busora.ads)::
15441 * GNAT.Bubble_Sort_G (g-busorg.ads)::
15442 * GNAT.Byte_Order_Mark (g-byorma.ads)::
15443 * GNAT.Byte_Swapping (g-bytswa.ads)::
15444 * GNAT.Calendar (g-calend.ads)::
15445 * GNAT.Calendar.Time_IO (g-catiio.ads)::
15446 * GNAT.Case_Util (g-casuti.ads)::
15447 * GNAT.CGI (g-cgi.ads)::
15448 * GNAT.CGI.Cookie (g-cgicoo.ads)::
15449 * GNAT.CGI.Debug (g-cgideb.ads)::
15450 * GNAT.Command_Line (g-comlin.ads)::
15451 * GNAT.Compiler_Version (g-comver.ads)::
15452 * GNAT.Ctrl_C (g-ctrl_c.ads)::
15453 * GNAT.CRC32 (g-crc32.ads)::
15454 * GNAT.Current_Exception (g-curexc.ads)::
15455 * GNAT.Debug_Pools (g-debpoo.ads)::
15456 * GNAT.Debug_Utilities (g-debuti.ads)::
15457 * GNAT.Decode_String (g-decstr.ads)::
15458 * GNAT.Decode_UTF8_String (g-deutst.ads)::
15459 * GNAT.Directory_Operations (g-dirope.ads)::
15460 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
15461 * GNAT.Dynamic_HTables (g-dynhta.ads)::
15462 * GNAT.Dynamic_Tables (g-dyntab.ads)::
15463 * GNAT.Encode_String (g-encstr.ads)::
15464 * GNAT.Encode_UTF8_String (g-enutst.ads)::
15465 * GNAT.Exception_Actions (g-excact.ads)::
15466 * GNAT.Exception_Traces (g-exctra.ads)::
15467 * GNAT.Exceptions (g-except.ads)::
15468 * GNAT.Expect (g-expect.ads)::
15469 * GNAT.Expect.TTY (g-exptty.ads)::
15470 * GNAT.Float_Control (g-flocon.ads)::
15471 * GNAT.Heap_Sort (g-heasor.ads)::
15472 * GNAT.Heap_Sort_A (g-hesora.ads)::
15473 * GNAT.Heap_Sort_G (g-hesorg.ads)::
15474 * GNAT.HTable (g-htable.ads)::
15475 * GNAT.IO (g-io.ads)::
15476 * GNAT.IO_Aux (g-io_aux.ads)::
15477 * GNAT.Lock_Files (g-locfil.ads)::
15478 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
15479 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
15480 * GNAT.MD5 (g-md5.ads)::
15481 * GNAT.Memory_Dump (g-memdum.ads)::
15482 * GNAT.Most_Recent_Exception (g-moreex.ads)::
15483 * GNAT.OS_Lib (g-os_lib.ads)::
15484 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
15485 * GNAT.Random_Numbers (g-rannum.ads)::
15486 * GNAT.Regexp (g-regexp.ads)::
15487 * GNAT.Registry (g-regist.ads)::
15488 * GNAT.Regpat (g-regpat.ads)::
15489 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
15490 * GNAT.Semaphores (g-semaph.ads)::
15491 * GNAT.Serial_Communications (g-sercom.ads)::
15492 * GNAT.SHA1 (g-sha1.ads)::
15493 * GNAT.SHA224 (g-sha224.ads)::
15494 * GNAT.SHA256 (g-sha256.ads)::
15495 * GNAT.SHA384 (g-sha384.ads)::
15496 * GNAT.SHA512 (g-sha512.ads)::
15497 * GNAT.Signals (g-signal.ads)::
15498 * GNAT.Sockets (g-socket.ads)::
15499 * GNAT.Source_Info (g-souinf.ads)::
15500 * GNAT.Spelling_Checker (g-speche.ads)::
15501 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
15502 * GNAT.Spitbol.Patterns (g-spipat.ads)::
15503 * GNAT.Spitbol (g-spitbo.ads)::
15504 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
15505 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
15506 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
15507 * GNAT.SSE (g-sse.ads)::
15508 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
15509 * GNAT.Strings (g-string.ads)::
15510 * GNAT.String_Split (g-strspl.ads)::
15511 * GNAT.Table (g-table.ads)::
15512 * GNAT.Task_Lock (g-tasloc.ads)::
15513 * GNAT.Threads (g-thread.ads)::
15514 * GNAT.Time_Stamp (g-timsta.ads)::
15515 * GNAT.Traceback (g-traceb.ads)::
15516 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15517 * GNAT.UTF_32 (g-utf_32.ads)::
15518 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15519 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15520 * GNAT.Wide_String_Split (g-wistsp.ads)::
15521 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15522 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15523 * Interfaces.C.Extensions (i-cexten.ads)::
15524 * Interfaces.C.Streams (i-cstrea.ads)::
15525 * Interfaces.CPP (i-cpp.ads)::
15526 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15527 * Interfaces.VxWorks (i-vxwork.ads)::
15528 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15529 * System.Address_Image (s-addima.ads)::
15530 * System.Assertions (s-assert.ads)::
15531 * System.Memory (s-memory.ads)::
15532 * System.Multiprocessors (s-multip.ads)::
15533 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
15534 * System.Partition_Interface (s-parint.ads)::
15535 * System.Pool_Global (s-pooglo.ads)::
15536 * System.Pool_Local (s-pooloc.ads)::
15537 * System.Restrictions (s-restri.ads)::
15538 * System.Rident (s-rident.ads)::
15539 * System.Strings.Stream_Ops (s-ststop.ads)::
15540 * System.Task_Info (s-tasinf.ads)::
15541 * System.Wch_Cnv (s-wchcnv.ads)::
15542 * System.Wch_Con (s-wchcon.ads)::
15543 @end menu
15544
15545 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15546 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15547 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15548 @cindex Latin_9 constants for Character
15549
15550 @noindent
15551 This child of @code{Ada.Characters}
15552 provides a set of definitions corresponding to those in the
15553 RM-defined package @code{Ada.Characters.Latin_1} but with the
15554 few modifications required for @code{Latin-9}
15555 The provision of such a package
15556 is specifically authorized by the Ada Reference Manual
15557 (RM A.3.3(27)).
15558
15559 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15560 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15561 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15562 @cindex Latin_1 constants for Wide_Character
15563
15564 @noindent
15565 This child of @code{Ada.Characters}
15566 provides a set of definitions corresponding to those in the
15567 RM-defined package @code{Ada.Characters.Latin_1} but with the
15568 types of the constants being @code{Wide_Character}
15569 instead of @code{Character}. The provision of such a package
15570 is specifically authorized by the Ada Reference Manual
15571 (RM A.3.3(27)).
15572
15573 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15574 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15575 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15576 @cindex Latin_9 constants for Wide_Character
15577
15578 @noindent
15579 This child of @code{Ada.Characters}
15580 provides a set of definitions corresponding to those in the
15581 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15582 types of the constants being @code{Wide_Character}
15583 instead of @code{Character}. The provision of such a package
15584 is specifically authorized by the Ada Reference Manual
15585 (RM A.3.3(27)).
15586
15587 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15588 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15589 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15590 @cindex Latin_1 constants for Wide_Wide_Character
15591
15592 @noindent
15593 This child of @code{Ada.Characters}
15594 provides a set of definitions corresponding to those in the
15595 RM-defined package @code{Ada.Characters.Latin_1} but with the
15596 types of the constants being @code{Wide_Wide_Character}
15597 instead of @code{Character}. The provision of such a package
15598 is specifically authorized by the Ada Reference Manual
15599 (RM A.3.3(27)).
15600
15601 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15602 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15603 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15604 @cindex Latin_9 constants for Wide_Wide_Character
15605
15606 @noindent
15607 This child of @code{Ada.Characters}
15608 provides a set of definitions corresponding to those in the
15609 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15610 types of the constants being @code{Wide_Wide_Character}
15611 instead of @code{Character}. The provision of such a package
15612 is specifically authorized by the Ada Reference Manual
15613 (RM A.3.3(27)).
15614
15615 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15616 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15617 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15618 @cindex Formal container for doubly linked lists
15619
15620 @noindent
15621 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15622 container for doubly linked lists, meant to facilitate formal verification of
15623 code using such containers.
15624
15625 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15626 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15627 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15628 @cindex Formal container for hashed maps
15629
15630 @noindent
15631 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15632 container for hashed maps, meant to facilitate formal verification of
15633 code using such containers.
15634
15635 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15636 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15637 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15638 @cindex Formal container for hashed sets
15639
15640 @noindent
15641 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15642 container for hashed sets, meant to facilitate formal verification of
15643 code using such containers.
15644
15645 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15646 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15647 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15648 @cindex Formal container for ordered maps
15649
15650 @noindent
15651 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15652 container for ordered maps, meant to facilitate formal verification of
15653 code using such containers.
15654
15655 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15656 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15657 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15658 @cindex Formal container for ordered sets
15659
15660 @noindent
15661 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15662 container for ordered sets, meant to facilitate formal verification of
15663 code using such containers.
15664
15665 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15666 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15667 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15668 @cindex Formal container for vectors
15669
15670 @noindent
15671 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15672 container for vectors, meant to facilitate formal verification of
15673 code using such containers.
15674
15675 @node Ada.Command_Line.Environment (a-colien.ads)
15676 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15677 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15678 @cindex Environment entries
15679
15680 @noindent
15681 This child of @code{Ada.Command_Line}
15682 provides a mechanism for obtaining environment values on systems
15683 where this concept makes sense.
15684
15685 @node Ada.Command_Line.Remove (a-colire.ads)
15686 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15687 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15688 @cindex Removing command line arguments
15689 @cindex Command line, argument removal
15690
15691 @noindent
15692 This child of @code{Ada.Command_Line}
15693 provides a mechanism for logically removing
15694 arguments from the argument list. Once removed, an argument is not visible
15695 to further calls on the subprograms in @code{Ada.Command_Line} will not
15696 see the removed argument.
15697
15698 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15699 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15700 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15701 @cindex Response file for command line
15702 @cindex Command line, response file
15703 @cindex Command line, handling long command lines
15704
15705 @noindent
15706 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15707 getting command line arguments from a text file, called a "response file".
15708 Using a response file allow passing a set of arguments to an executable longer
15709 than the maximum allowed by the system on the command line.
15710
15711 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15712 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15713 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15714 @cindex C Streams, Interfacing with Direct_IO
15715
15716 @noindent
15717 This package provides subprograms that allow interfacing between
15718 C streams and @code{Direct_IO}. The stream identifier can be
15719 extracted from a file opened on the Ada side, and an Ada file
15720 can be constructed from a stream opened on the C side.
15721
15722 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15723 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15724 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15725 @cindex Null_Occurrence, testing for
15726
15727 @noindent
15728 This child subprogram provides a way of testing for the null
15729 exception occurrence (@code{Null_Occurrence}) without raising
15730 an exception.
15731
15732 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15733 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15734 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15735 @cindex Null_Occurrence, testing for
15736
15737 @noindent
15738 This child subprogram is used for handling otherwise unhandled
15739 exceptions (hence the name last chance), and perform clean ups before
15740 terminating the program. Note that this subprogram never returns.
15741
15742 @node Ada.Exceptions.Traceback (a-exctra.ads)
15743 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15744 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15745 @cindex Traceback for Exception Occurrence
15746
15747 @noindent
15748 This child package provides the subprogram (@code{Tracebacks}) to
15749 give a traceback array of addresses based on an exception
15750 occurrence.
15751
15752 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15753 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15754 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15755 @cindex C Streams, Interfacing with Sequential_IO
15756
15757 @noindent
15758 This package provides subprograms that allow interfacing between
15759 C streams and @code{Sequential_IO}. The stream identifier can be
15760 extracted from a file opened on the Ada side, and an Ada file
15761 can be constructed from a stream opened on the C side.
15762
15763 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15764 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15765 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15766 @cindex C Streams, Interfacing with Stream_IO
15767
15768 @noindent
15769 This package provides subprograms that allow interfacing between
15770 C streams and @code{Stream_IO}. The stream identifier can be
15771 extracted from a file opened on the Ada side, and an Ada file
15772 can be constructed from a stream opened on the C side.
15773
15774 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15775 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15776 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15777 @cindex @code{Unbounded_String}, IO support
15778 @cindex @code{Text_IO}, extensions for unbounded strings
15779
15780 @noindent
15781 This package provides subprograms for Text_IO for unbounded
15782 strings, avoiding the necessity for an intermediate operation
15783 with ordinary strings.
15784
15785 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15786 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15787 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15788 @cindex @code{Unbounded_Wide_String}, IO support
15789 @cindex @code{Text_IO}, extensions for unbounded wide strings
15790
15791 @noindent
15792 This package provides subprograms for Text_IO for unbounded
15793 wide strings, avoiding the necessity for an intermediate operation
15794 with ordinary wide strings.
15795
15796 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15797 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15798 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15799 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15800 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15801
15802 @noindent
15803 This package provides subprograms for Text_IO for unbounded
15804 wide wide strings, avoiding the necessity for an intermediate operation
15805 with ordinary wide wide strings.
15806
15807 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15808 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15809 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15810 @cindex C Streams, Interfacing with @code{Text_IO}
15811
15812 @noindent
15813 This package provides subprograms that allow interfacing between
15814 C streams and @code{Text_IO}. The stream identifier can be
15815 extracted from a file opened on the Ada side, and an Ada file
15816 can be constructed from a stream opened on the C side.
15817
15818 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15819 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15820 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15821 @cindex @code{Text_IO} resetting standard files
15822
15823 @noindent
15824 This procedure is used to reset the status of the standard files used
15825 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15826 embedded application) where the status of the files may change during
15827 execution (for example a standard input file may be redefined to be
15828 interactive).
15829
15830 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15831 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15832 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15833 @cindex Unicode categorization, Wide_Character
15834
15835 @noindent
15836 This package provides subprograms that allow categorization of
15837 Wide_Character values according to Unicode categories.
15838
15839 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15840 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15841 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15842 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15843
15844 @noindent
15845 This package provides subprograms that allow interfacing between
15846 C streams and @code{Wide_Text_IO}. The stream identifier can be
15847 extracted from a file opened on the Ada side, and an Ada file
15848 can be constructed from a stream opened on the C side.
15849
15850 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15851 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15852 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15853 @cindex @code{Wide_Text_IO} resetting standard files
15854
15855 @noindent
15856 This procedure is used to reset the status of the standard files used
15857 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15858 embedded application) where the status of the files may change during
15859 execution (for example a standard input file may be redefined to be
15860 interactive).
15861
15862 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15863 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15864 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15865 @cindex Unicode categorization, Wide_Wide_Character
15866
15867 @noindent
15868 This package provides subprograms that allow categorization of
15869 Wide_Wide_Character values according to Unicode categories.
15870
15871 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15872 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15873 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15874 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15875
15876 @noindent
15877 This package provides subprograms that allow interfacing between
15878 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15879 extracted from a file opened on the Ada side, and an Ada file
15880 can be constructed from a stream opened on the C side.
15881
15882 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15883 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15884 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15885 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15886
15887 @noindent
15888 This procedure is used to reset the status of the standard files used
15889 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15890 restart in an embedded application) where the status of the files may
15891 change during execution (for example a standard input file may be
15892 redefined to be interactive).
15893
15894 @node GNAT.Altivec (g-altive.ads)
15895 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15896 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15897 @cindex AltiVec
15898
15899 @noindent
15900 This is the root package of the GNAT AltiVec binding. It provides
15901 definitions of constants and types common to all the versions of the
15902 binding.
15903
15904 @node GNAT.Altivec.Conversions (g-altcon.ads)
15905 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15906 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15907 @cindex AltiVec
15908
15909 @noindent
15910 This package provides the Vector/View conversion routines.
15911
15912 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15913 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15914 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15915 @cindex AltiVec
15916
15917 @noindent
15918 This package exposes the Ada interface to the AltiVec operations on
15919 vector objects. A soft emulation is included by default in the GNAT
15920 library. The hard binding is provided as a separate package. This unit
15921 is common to both bindings.
15922
15923 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15924 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15925 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15926 @cindex AltiVec
15927
15928 @noindent
15929 This package exposes the various vector types part of the Ada binding
15930 to AltiVec facilities.
15931
15932 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15933 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15934 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15935 @cindex AltiVec
15936
15937 @noindent
15938 This package provides public 'View' data types from/to which private
15939 vector representations can be converted via
15940 GNAT.Altivec.Conversions. This allows convenient access to individual
15941 vector elements and provides a simple way to initialize vector
15942 objects.
15943
15944 @node GNAT.Array_Split (g-arrspl.ads)
15945 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15946 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15947 @cindex Array splitter
15948
15949 @noindent
15950 Useful array-manipulation routines: given a set of separators, split
15951 an array wherever the separators appear, and provide direct access
15952 to the resulting slices.
15953
15954 @node GNAT.AWK (g-awk.ads)
15955 @section @code{GNAT.AWK} (@file{g-awk.ads})
15956 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15957 @cindex Parsing
15958 @cindex AWK
15959
15960 @noindent
15961 Provides AWK-like parsing functions, with an easy interface for parsing one
15962 or more files containing formatted data. The file is viewed as a database
15963 where each record is a line and a field is a data element in this line.
15964
15965 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15966 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15967 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15968 @cindex Parsing
15969 @cindex Bounded Buffers
15970
15971 @noindent
15972 Provides a concurrent generic bounded buffer abstraction. Instances are
15973 useful directly or as parts of the implementations of other abstractions,
15974 such as mailboxes.
15975
15976 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15977 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15978 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15979 @cindex Parsing
15980 @cindex Mailboxes
15981
15982 @noindent
15983 Provides a thread-safe asynchronous intertask mailbox communication facility.
15984
15985 @node GNAT.Bubble_Sort (g-bubsor.ads)
15986 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15987 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15988 @cindex Sorting
15989 @cindex Bubble sort
15990
15991 @noindent
15992 Provides a general implementation of bubble sort usable for sorting arbitrary
15993 data items. Exchange and comparison procedures are provided by passing
15994 access-to-procedure values.
15995
15996 @node GNAT.Bubble_Sort_A (g-busora.ads)
15997 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15998 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15999 @cindex Sorting
16000 @cindex Bubble sort
16001
16002 @noindent
16003 Provides a general implementation of bubble sort usable for sorting arbitrary
16004 data items. Move and comparison procedures are provided by passing
16005 access-to-procedure values. This is an older version, retained for
16006 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
16007
16008 @node GNAT.Bubble_Sort_G (g-busorg.ads)
16009 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16010 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16011 @cindex Sorting
16012 @cindex Bubble sort
16013
16014 @noindent
16015 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
16016 are provided as generic parameters, this improves efficiency, especially
16017 if the procedures can be inlined, at the expense of duplicating code for
16018 multiple instantiations.
16019
16020 @node GNAT.Byte_Order_Mark (g-byorma.ads)
16021 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16022 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16023 @cindex UTF-8 representation
16024 @cindex Wide characte representations
16025
16026 @noindent
16027 Provides a routine which given a string, reads the start of the string to
16028 see whether it is one of the standard byte order marks (BOM's) which signal
16029 the encoding of the string. The routine includes detection of special XML
16030 sequences for various UCS input formats.
16031
16032 @node GNAT.Byte_Swapping (g-bytswa.ads)
16033 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16034 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16035 @cindex Byte swapping
16036 @cindex Endianness
16037
16038 @noindent
16039 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
16040 Machine-specific implementations are available in some cases.
16041
16042 @node GNAT.Calendar (g-calend.ads)
16043 @section @code{GNAT.Calendar} (@file{g-calend.ads})
16044 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
16045 @cindex @code{Calendar}
16046
16047 @noindent
16048 Extends the facilities provided by @code{Ada.Calendar} to include handling
16049 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
16050 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
16051 C @code{timeval} format.
16052
16053 @node GNAT.Calendar.Time_IO (g-catiio.ads)
16054 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16055 @cindex @code{Calendar}
16056 @cindex Time
16057 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16058
16059 @node GNAT.CRC32 (g-crc32.ads)
16060 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
16061 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
16062 @cindex CRC32
16063 @cindex Cyclic Redundancy Check
16064
16065 @noindent
16066 This package implements the CRC-32 algorithm. For a full description
16067 of this algorithm see
16068 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
16069 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
16070 Aug.@: 1988. Sarwate, D.V@.
16071
16072 @node GNAT.Case_Util (g-casuti.ads)
16073 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
16074 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
16075 @cindex Casing utilities
16076 @cindex Character handling (@code{GNAT.Case_Util})
16077
16078 @noindent
16079 A set of simple routines for handling upper and lower casing of strings
16080 without the overhead of the full casing tables
16081 in @code{Ada.Characters.Handling}.
16082
16083 @node GNAT.CGI (g-cgi.ads)
16084 @section @code{GNAT.CGI} (@file{g-cgi.ads})
16085 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
16086 @cindex CGI (Common Gateway Interface)
16087
16088 @noindent
16089 This is a package for interfacing a GNAT program with a Web server via the
16090 Common Gateway Interface (CGI)@. Basically this package parses the CGI
16091 parameters, which are a set of key/value pairs sent by the Web server. It
16092 builds a table whose index is the key and provides some services to deal
16093 with this table.
16094
16095 @node GNAT.CGI.Cookie (g-cgicoo.ads)
16096 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16097 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16098 @cindex CGI (Common Gateway Interface) cookie support
16099 @cindex Cookie support in CGI
16100
16101 @noindent
16102 This is a package to interface a GNAT program with a Web server via the
16103 Common Gateway Interface (CGI). It exports services to deal with Web
16104 cookies (piece of information kept in the Web client software).
16105
16106 @node GNAT.CGI.Debug (g-cgideb.ads)
16107 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16108 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16109 @cindex CGI (Common Gateway Interface) debugging
16110
16111 @noindent
16112 This is a package to help debugging CGI (Common Gateway Interface)
16113 programs written in Ada.
16114
16115 @node GNAT.Command_Line (g-comlin.ads)
16116 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
16117 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
16118 @cindex Command line
16119
16120 @noindent
16121 Provides a high level interface to @code{Ada.Command_Line} facilities,
16122 including the ability to scan for named switches with optional parameters
16123 and expand file names using wild card notations.
16124
16125 @node GNAT.Compiler_Version (g-comver.ads)
16126 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16127 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16128 @cindex Compiler Version
16129 @cindex Version, of compiler
16130
16131 @noindent
16132 Provides a routine for obtaining the version of the compiler used to
16133 compile the program. More accurately this is the version of the binder
16134 used to bind the program (this will normally be the same as the version
16135 of the compiler if a consistent tool set is used to compile all units
16136 of a partition).
16137
16138 @node GNAT.Ctrl_C (g-ctrl_c.ads)
16139 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16140 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16141 @cindex Interrupt
16142
16143 @noindent
16144 Provides a simple interface to handle Ctrl-C keyboard events.
16145
16146 @node GNAT.Current_Exception (g-curexc.ads)
16147 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16148 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16149 @cindex Current exception
16150 @cindex Exception retrieval
16151
16152 @noindent
16153 Provides access to information on the current exception that has been raised
16154 without the need for using the Ada 95 / Ada 2005 exception choice parameter
16155 specification syntax.
16156 This is particularly useful in simulating typical facilities for
16157 obtaining information about exceptions provided by Ada 83 compilers.
16158
16159 @node GNAT.Debug_Pools (g-debpoo.ads)
16160 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16161 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16162 @cindex Debugging
16163 @cindex Debug pools
16164 @cindex Memory corruption debugging
16165
16166 @noindent
16167 Provide a debugging storage pools that helps tracking memory corruption
16168 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
16169 @value{EDITION} User's Guide}.
16170
16171 @node GNAT.Debug_Utilities (g-debuti.ads)
16172 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16173 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16174 @cindex Debugging
16175
16176 @noindent
16177 Provides a few useful utilities for debugging purposes, including conversion
16178 to and from string images of address values. Supports both C and Ada formats
16179 for hexadecimal literals.
16180
16181 @node GNAT.Decode_String (g-decstr.ads)
16182 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
16183 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
16184 @cindex Decoding strings
16185 @cindex String decoding
16186 @cindex Wide character encoding
16187 @cindex UTF-8
16188 @cindex Unicode
16189
16190 @noindent
16191 A generic package providing routines for decoding wide character and wide wide
16192 character strings encoded as sequences of 8-bit characters using a specified
16193 encoding method. Includes validation routines, and also routines for stepping
16194 to next or previous encoded character in an encoded string.
16195 Useful in conjunction with Unicode character coding. Note there is a
16196 preinstantiation for UTF-8. See next entry.
16197
16198 @node GNAT.Decode_UTF8_String (g-deutst.ads)
16199 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16200 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16201 @cindex Decoding strings
16202 @cindex Decoding UTF-8 strings
16203 @cindex UTF-8 string decoding
16204 @cindex Wide character decoding
16205 @cindex UTF-8
16206 @cindex Unicode
16207
16208 @noindent
16209 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
16210
16211 @node GNAT.Directory_Operations (g-dirope.ads)
16212 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16213 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16214 @cindex Directory operations
16215
16216 @noindent
16217 Provides a set of routines for manipulating directories, including changing
16218 the current directory, making new directories, and scanning the files in a
16219 directory.
16220
16221 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
16222 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16223 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16224 @cindex Directory operations iteration
16225
16226 @noindent
16227 A child unit of GNAT.Directory_Operations providing additional operations
16228 for iterating through directories.
16229
16230 @node GNAT.Dynamic_HTables (g-dynhta.ads)
16231 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16232 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16233 @cindex Hash tables
16234
16235 @noindent
16236 A generic implementation of hash tables that can be used to hash arbitrary
16237 data. Provided in two forms, a simple form with built in hash functions,
16238 and a more complex form in which the hash function is supplied.
16239
16240 @noindent
16241 This package provides a facility similar to that of @code{GNAT.HTable},
16242 except that this package declares a type that can be used to define
16243 dynamic instances of the hash table, while an instantiation of
16244 @code{GNAT.HTable} creates a single instance of the hash table.
16245
16246 @node GNAT.Dynamic_Tables (g-dyntab.ads)
16247 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16248 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16249 @cindex Table implementation
16250 @cindex Arrays, extendable
16251
16252 @noindent
16253 A generic package providing a single dimension array abstraction where the
16254 length of the array can be dynamically modified.
16255
16256 @noindent
16257 This package provides a facility similar to that of @code{GNAT.Table},
16258 except that this package declares a type that can be used to define
16259 dynamic instances of the table, while an instantiation of
16260 @code{GNAT.Table} creates a single instance of the table type.
16261
16262 @node GNAT.Encode_String (g-encstr.ads)
16263 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
16264 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
16265 @cindex Encoding strings
16266 @cindex String encoding
16267 @cindex Wide character encoding
16268 @cindex UTF-8
16269 @cindex Unicode
16270
16271 @noindent
16272 A generic package providing routines for encoding wide character and wide
16273 wide character strings as sequences of 8-bit characters using a specified
16274 encoding method. Useful in conjunction with Unicode character coding.
16275 Note there is a preinstantiation for UTF-8. See next entry.
16276
16277 @node GNAT.Encode_UTF8_String (g-enutst.ads)
16278 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16279 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16280 @cindex Encoding strings
16281 @cindex Encoding UTF-8 strings
16282 @cindex UTF-8 string encoding
16283 @cindex Wide character encoding
16284 @cindex UTF-8
16285 @cindex Unicode
16286
16287 @noindent
16288 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
16289
16290 @node GNAT.Exception_Actions (g-excact.ads)
16291 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16292 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16293 @cindex Exception actions
16294
16295 @noindent
16296 Provides callbacks when an exception is raised. Callbacks can be registered
16297 for specific exceptions, or when any exception is raised. This
16298 can be used for instance to force a core dump to ease debugging.
16299
16300 @node GNAT.Exception_Traces (g-exctra.ads)
16301 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16302 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16303 @cindex Exception traces
16304 @cindex Debugging
16305
16306 @noindent
16307 Provides an interface allowing to control automatic output upon exception
16308 occurrences.
16309
16310 @node GNAT.Exceptions (g-except.ads)
16311 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
16312 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
16313 @cindex Exceptions, Pure
16314 @cindex Pure packages, exceptions
16315
16316 @noindent
16317 Normally it is not possible to raise an exception with
16318 a message from a subprogram in a pure package, since the
16319 necessary types and subprograms are in @code{Ada.Exceptions}
16320 which is not a pure unit. @code{GNAT.Exceptions} provides a
16321 facility for getting around this limitation for a few
16322 predefined exceptions, and for example allow raising
16323 @code{Constraint_Error} with a message from a pure subprogram.
16324
16325 @node GNAT.Expect (g-expect.ads)
16326 @section @code{GNAT.Expect} (@file{g-expect.ads})
16327 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
16328
16329 @noindent
16330 Provides a set of subprograms similar to what is available
16331 with the standard Tcl Expect tool.
16332 It allows you to easily spawn and communicate with an external process.
16333 You can send commands or inputs to the process, and compare the output
16334 with some expected regular expression. Currently @code{GNAT.Expect}
16335 is implemented on all native GNAT ports except for OpenVMS@.
16336 It is not implemented for cross ports, and in particular is not
16337 implemented for VxWorks or LynxOS@.
16338
16339 @node GNAT.Expect.TTY (g-exptty.ads)
16340 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16341 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16342
16343 @noindent
16344 As GNAT.Expect but using pseudo-terminal.
16345 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
16346 ports except for OpenVMS@. It is not implemented for cross ports, and
16347 in particular is not implemented for VxWorks or LynxOS@.
16348
16349 @node GNAT.Float_Control (g-flocon.ads)
16350 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
16351 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
16352 @cindex Floating-Point Processor
16353
16354 @noindent
16355 Provides an interface for resetting the floating-point processor into the
16356 mode required for correct semantic operation in Ada. Some third party
16357 library calls may cause this mode to be modified, and the Reset procedure
16358 in this package can be used to reestablish the required mode.
16359
16360 @node GNAT.Heap_Sort (g-heasor.ads)
16361 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16362 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16363 @cindex Sorting
16364
16365 @noindent
16366 Provides a general implementation of heap sort usable for sorting arbitrary
16367 data items. Exchange and comparison procedures are provided by passing
16368 access-to-procedure values. The algorithm used is a modified heap sort
16369 that performs approximately N*log(N) comparisons in the worst case.
16370
16371 @node GNAT.Heap_Sort_A (g-hesora.ads)
16372 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16373 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16374 @cindex Sorting
16375
16376 @noindent
16377 Provides a general implementation of heap sort usable for sorting arbitrary
16378 data items. Move and comparison procedures are provided by passing
16379 access-to-procedure values. The algorithm used is a modified heap sort
16380 that performs approximately N*log(N) comparisons in the worst case.
16381 This differs from @code{GNAT.Heap_Sort} in having a less convenient
16382 interface, but may be slightly more efficient.
16383
16384 @node GNAT.Heap_Sort_G (g-hesorg.ads)
16385 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16386 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16387 @cindex Sorting
16388
16389 @noindent
16390 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
16391 are provided as generic parameters, this improves efficiency, especially
16392 if the procedures can be inlined, at the expense of duplicating code for
16393 multiple instantiations.
16394
16395 @node GNAT.HTable (g-htable.ads)
16396 @section @code{GNAT.HTable} (@file{g-htable.ads})
16397 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
16398 @cindex Hash tables
16399
16400 @noindent
16401 A generic implementation of hash tables that can be used to hash arbitrary
16402 data. Provides two approaches, one a simple static approach, and the other
16403 allowing arbitrary dynamic hash tables.
16404
16405 @node GNAT.IO (g-io.ads)
16406 @section @code{GNAT.IO} (@file{g-io.ads})
16407 @cindex @code{GNAT.IO} (@file{g-io.ads})
16408 @cindex Simple I/O
16409 @cindex Input/Output facilities
16410
16411 @noindent
16412 A simple preelaborable input-output package that provides a subset of
16413 simple Text_IO functions for reading characters and strings from
16414 Standard_Input, and writing characters, strings and integers to either
16415 Standard_Output or Standard_Error.
16416
16417 @node GNAT.IO_Aux (g-io_aux.ads)
16418 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16419 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16420 @cindex Text_IO
16421 @cindex Input/Output facilities
16422
16423 Provides some auxiliary functions for use with Text_IO, including a test
16424 for whether a file exists, and functions for reading a line of text.
16425
16426 @node GNAT.Lock_Files (g-locfil.ads)
16427 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16428 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16429 @cindex File locking
16430 @cindex Locking using files
16431
16432 @noindent
16433 Provides a general interface for using files as locks. Can be used for
16434 providing program level synchronization.
16435
16436 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
16437 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16438 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16439 @cindex Random number generation
16440
16441 @noindent
16442 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
16443 a modified version of the Blum-Blum-Shub generator.
16444
16445 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
16446 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16447 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16448 @cindex Random number generation
16449
16450 @noindent
16451 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
16452 a modified version of the Blum-Blum-Shub generator.
16453
16454 @node GNAT.MD5 (g-md5.ads)
16455 @section @code{GNAT.MD5} (@file{g-md5.ads})
16456 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
16457 @cindex Message Digest MD5
16458
16459 @noindent
16460 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
16461
16462 @node GNAT.Memory_Dump (g-memdum.ads)
16463 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16464 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16465 @cindex Dump Memory
16466
16467 @noindent
16468 Provides a convenient routine for dumping raw memory to either the
16469 standard output or standard error files. Uses GNAT.IO for actual
16470 output.
16471
16472 @node GNAT.Most_Recent_Exception (g-moreex.ads)
16473 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16474 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16475 @cindex Exception, obtaining most recent
16476
16477 @noindent
16478 Provides access to the most recently raised exception. Can be used for
16479 various logging purposes, including duplicating functionality of some
16480 Ada 83 implementation dependent extensions.
16481
16482 @node GNAT.OS_Lib (g-os_lib.ads)
16483 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16484 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16485 @cindex Operating System interface
16486 @cindex Spawn capability
16487
16488 @noindent
16489 Provides a range of target independent operating system interface functions,
16490 including time/date management, file operations, subprocess management,
16491 including a portable spawn procedure, and access to environment variables
16492 and error return codes.
16493
16494 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
16495 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16496 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16497 @cindex Hash functions
16498
16499 @noindent
16500 Provides a generator of static minimal perfect hash functions. No
16501 collisions occur and each item can be retrieved from the table in one
16502 probe (perfect property). The hash table size corresponds to the exact
16503 size of the key set and no larger (minimal property). The key set has to
16504 be know in advance (static property). The hash functions are also order
16505 preserving. If w2 is inserted after w1 in the generator, their
16506 hashcode are in the same order. These hashing functions are very
16507 convenient for use with realtime applications.
16508
16509 @node GNAT.Random_Numbers (g-rannum.ads)
16510 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16511 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16512 @cindex Random number generation
16513
16514 @noindent
16515 Provides random number capabilities which extend those available in the
16516 standard Ada library and are more convenient to use.
16517
16518 @node GNAT.Regexp (g-regexp.ads)
16519 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16520 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16521 @cindex Regular expressions
16522 @cindex Pattern matching
16523
16524 @noindent
16525 A simple implementation of regular expressions, using a subset of regular
16526 expression syntax copied from familiar Unix style utilities. This is the
16527 simples of the three pattern matching packages provided, and is particularly
16528 suitable for ``file globbing'' applications.
16529
16530 @node GNAT.Registry (g-regist.ads)
16531 @section @code{GNAT.Registry} (@file{g-regist.ads})
16532 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16533 @cindex Windows Registry
16534
16535 @noindent
16536 This is a high level binding to the Windows registry. It is possible to
16537 do simple things like reading a key value, creating a new key. For full
16538 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16539 package provided with the Win32Ada binding
16540
16541 @node GNAT.Regpat (g-regpat.ads)
16542 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16543 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16544 @cindex Regular expressions
16545 @cindex Pattern matching
16546
16547 @noindent
16548 A complete implementation of Unix-style regular expression matching, copied
16549 from the original V7 style regular expression library written in C by
16550 Henry Spencer (and binary compatible with this C library).
16551
16552 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16553 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16554 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16555 @cindex Secondary Stack Info
16556
16557 @noindent
16558 Provide the capability to query the high water mark of the current task's
16559 secondary stack.
16560
16561 @node GNAT.Semaphores (g-semaph.ads)
16562 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16563 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16564 @cindex Semaphores
16565
16566 @noindent
16567 Provides classic counting and binary semaphores using protected types.
16568
16569 @node GNAT.Serial_Communications (g-sercom.ads)
16570 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16571 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16572 @cindex Serial_Communications
16573
16574 @noindent
16575 Provides a simple interface to send and receive data over a serial
16576 port. This is only supported on GNU/Linux and Windows.
16577
16578 @node GNAT.SHA1 (g-sha1.ads)
16579 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16580 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16581 @cindex Secure Hash Algorithm SHA-1
16582
16583 @noindent
16584 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16585 and RFC 3174.
16586
16587 @node GNAT.SHA224 (g-sha224.ads)
16588 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16589 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16590 @cindex Secure Hash Algorithm SHA-224
16591
16592 @noindent
16593 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16594
16595 @node GNAT.SHA256 (g-sha256.ads)
16596 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16597 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16598 @cindex Secure Hash Algorithm SHA-256
16599
16600 @noindent
16601 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16602
16603 @node GNAT.SHA384 (g-sha384.ads)
16604 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16605 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16606 @cindex Secure Hash Algorithm SHA-384
16607
16608 @noindent
16609 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16610
16611 @node GNAT.SHA512 (g-sha512.ads)
16612 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16613 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16614 @cindex Secure Hash Algorithm SHA-512
16615
16616 @noindent
16617 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16618
16619 @node GNAT.Signals (g-signal.ads)
16620 @section @code{GNAT.Signals} (@file{g-signal.ads})
16621 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16622 @cindex Signals
16623
16624 @noindent
16625 Provides the ability to manipulate the blocked status of signals on supported
16626 targets.
16627
16628 @node GNAT.Sockets (g-socket.ads)
16629 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16630 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16631 @cindex Sockets
16632
16633 @noindent
16634 A high level and portable interface to develop sockets based applications.
16635 This package is based on the sockets thin binding found in
16636 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16637 on all native GNAT ports except for OpenVMS@. It is not implemented
16638 for the LynxOS@ cross port.
16639
16640 @node GNAT.Source_Info (g-souinf.ads)
16641 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16642 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16643 @cindex Source Information
16644
16645 @noindent
16646 Provides subprograms that give access to source code information known at
16647 compile time, such as the current file name and line number.
16648
16649 @node GNAT.Spelling_Checker (g-speche.ads)
16650 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16651 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16652 @cindex Spell checking
16653
16654 @noindent
16655 Provides a function for determining whether one string is a plausible
16656 near misspelling of another string.
16657
16658 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16659 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16660 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16661 @cindex Spell checking
16662
16663 @noindent
16664 Provides a generic function that can be instantiated with a string type for
16665 determining whether one string is a plausible near misspelling of another
16666 string.
16667
16668 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16669 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16670 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16671 @cindex SPITBOL pattern matching
16672 @cindex Pattern matching
16673
16674 @noindent
16675 A complete implementation of SNOBOL4 style pattern matching. This is the
16676 most elaborate of the pattern matching packages provided. It fully duplicates
16677 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16678 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16679
16680 @node GNAT.Spitbol (g-spitbo.ads)
16681 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16682 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16683 @cindex SPITBOL interface
16684
16685 @noindent
16686 The top level package of the collection of SPITBOL-style functionality, this
16687 package provides basic SNOBOL4 string manipulation functions, such as
16688 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16689 useful for constructing arbitrary mappings from strings in the style of
16690 the SNOBOL4 TABLE function.
16691
16692 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16693 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16694 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16695 @cindex Sets of strings
16696 @cindex SPITBOL Tables
16697
16698 @noindent
16699 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16700 for type @code{Standard.Boolean}, giving an implementation of sets of
16701 string values.
16702
16703 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16704 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16705 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16706 @cindex Integer maps
16707 @cindex Maps
16708 @cindex SPITBOL Tables
16709
16710 @noindent
16711 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16712 for type @code{Standard.Integer}, giving an implementation of maps
16713 from string to integer values.
16714
16715 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16716 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16717 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16718 @cindex String maps
16719 @cindex Maps
16720 @cindex SPITBOL Tables
16721
16722 @noindent
16723 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16724 a variable length string type, giving an implementation of general
16725 maps from strings to strings.
16726
16727 @node GNAT.SSE (g-sse.ads)
16728 @section @code{GNAT.SSE} (@file{g-sse.ads})
16729 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16730
16731 @noindent
16732 Root of a set of units aimed at offering Ada bindings to a subset of
16733 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16734 targets. It exposes vector component types together with a general
16735 introduction to the binding contents and use.
16736
16737 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16738 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16739 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16740
16741 @noindent
16742 SSE vector types for use with SSE related intrinsics.
16743
16744 @node GNAT.Strings (g-string.ads)
16745 @section @code{GNAT.Strings} (@file{g-string.ads})
16746 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16747
16748 @noindent
16749 Common String access types and related subprograms. Basically it
16750 defines a string access and an array of string access types.
16751
16752 @node GNAT.String_Split (g-strspl.ads)
16753 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16754 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16755 @cindex String splitter
16756
16757 @noindent
16758 Useful string manipulation routines: given a set of separators, split
16759 a string wherever the separators appear, and provide direct access
16760 to the resulting slices. This package is instantiated from
16761 @code{GNAT.Array_Split}.
16762
16763 @node GNAT.Table (g-table.ads)
16764 @section @code{GNAT.Table} (@file{g-table.ads})
16765 @cindex @code{GNAT.Table} (@file{g-table.ads})
16766 @cindex Table implementation
16767 @cindex Arrays, extendable
16768
16769 @noindent
16770 A generic package providing a single dimension array abstraction where the
16771 length of the array can be dynamically modified.
16772
16773 @noindent
16774 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16775 except that this package declares a single instance of the table type,
16776 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16777 used to define dynamic instances of the table.
16778
16779 @node GNAT.Task_Lock (g-tasloc.ads)
16780 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16781 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16782 @cindex Task synchronization
16783 @cindex Task locking
16784 @cindex Locking
16785
16786 @noindent
16787 A very simple facility for locking and unlocking sections of code using a
16788 single global task lock. Appropriate for use in situations where contention
16789 between tasks is very rarely expected.
16790
16791 @node GNAT.Time_Stamp (g-timsta.ads)
16792 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16793 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16794 @cindex Time stamp
16795 @cindex Current time
16796
16797 @noindent
16798 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16799 represents the current date and time in ISO 8601 format. This is a very simple
16800 routine with minimal code and there are no dependencies on any other unit.
16801
16802 @node GNAT.Threads (g-thread.ads)
16803 @section @code{GNAT.Threads} (@file{g-thread.ads})
16804 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16805 @cindex Foreign threads
16806 @cindex Threads, foreign
16807
16808 @noindent
16809 Provides facilities for dealing with foreign threads which need to be known
16810 by the GNAT run-time system. Consult the documentation of this package for
16811 further details if your program has threads that are created by a non-Ada
16812 environment which then accesses Ada code.
16813
16814 @node GNAT.Traceback (g-traceb.ads)
16815 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16816 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16817 @cindex Trace back facilities
16818
16819 @noindent
16820 Provides a facility for obtaining non-symbolic traceback information, useful
16821 in various debugging situations.
16822
16823 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16824 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16825 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16826 @cindex Trace back facilities
16827
16828 @node GNAT.UTF_32 (g-utf_32.ads)
16829 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16830 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16831 @cindex Wide character codes
16832
16833 @noindent
16834 This is a package intended to be used in conjunction with the
16835 @code{Wide_Character} type in Ada 95 and the
16836 @code{Wide_Wide_Character} type in Ada 2005 (available
16837 in @code{GNAT} in Ada 2005 mode). This package contains
16838 Unicode categorization routines, as well as lexical
16839 categorization routines corresponding to the Ada 2005
16840 lexical rules for identifiers and strings, and also a
16841 lower case to upper case fold routine corresponding to
16842 the Ada 2005 rules for identifier equivalence.
16843
16844 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16845 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16846 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16847 @cindex Spell checking
16848
16849 @noindent
16850 Provides a function for determining whether one wide wide string is a plausible
16851 near misspelling of another wide wide string, where the strings are represented
16852 using the UTF_32_String type defined in System.Wch_Cnv.
16853
16854 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16855 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16856 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16857 @cindex Spell checking
16858
16859 @noindent
16860 Provides a function for determining whether one wide string is a plausible
16861 near misspelling of another wide string.
16862
16863 @node GNAT.Wide_String_Split (g-wistsp.ads)
16864 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16865 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16866 @cindex Wide_String splitter
16867
16868 @noindent
16869 Useful wide string manipulation routines: given a set of separators, split
16870 a wide string wherever the separators appear, and provide direct access
16871 to the resulting slices. This package is instantiated from
16872 @code{GNAT.Array_Split}.
16873
16874 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16875 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16876 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16877 @cindex Spell checking
16878
16879 @noindent
16880 Provides a function for determining whether one wide wide string is a plausible
16881 near misspelling of another wide wide string.
16882
16883 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16884 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16885 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16886 @cindex Wide_Wide_String splitter
16887
16888 @noindent
16889 Useful wide wide string manipulation routines: given a set of separators, split
16890 a wide wide string wherever the separators appear, and provide direct access
16891 to the resulting slices. This package is instantiated from
16892 @code{GNAT.Array_Split}.
16893
16894 @node Interfaces.C.Extensions (i-cexten.ads)
16895 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16896 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16897
16898 @noindent
16899 This package contains additional C-related definitions, intended
16900 for use with either manually or automatically generated bindings
16901 to C libraries.
16902
16903 @node Interfaces.C.Streams (i-cstrea.ads)
16904 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16905 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16906 @cindex C streams, interfacing
16907
16908 @noindent
16909 This package is a binding for the most commonly used operations
16910 on C streams.
16911
16912 @node Interfaces.CPP (i-cpp.ads)
16913 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16914 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16915 @cindex C++ interfacing
16916 @cindex Interfacing, to C++
16917
16918 @noindent
16919 This package provides facilities for use in interfacing to C++. It
16920 is primarily intended to be used in connection with automated tools
16921 for the generation of C++ interfaces.
16922
16923 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16924 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16925 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16926 @cindex IBM Packed Format
16927 @cindex Packed Decimal
16928
16929 @noindent
16930 This package provides a set of routines for conversions to and
16931 from a packed decimal format compatible with that used on IBM
16932 mainframes.
16933
16934 @node Interfaces.VxWorks (i-vxwork.ads)
16935 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16936 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16937 @cindex Interfacing to VxWorks
16938 @cindex VxWorks, interfacing
16939
16940 @noindent
16941 This package provides a limited binding to the VxWorks API.
16942 In particular, it interfaces with the
16943 VxWorks hardware interrupt facilities.
16944
16945 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16946 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16947 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16948 @cindex Interfacing to VxWorks' I/O
16949 @cindex VxWorks, I/O interfacing
16950 @cindex VxWorks, Get_Immediate
16951 @cindex Get_Immediate, VxWorks
16952
16953 @noindent
16954 This package provides a binding to the ioctl (IO/Control)
16955 function of VxWorks, defining a set of option values and
16956 function codes. A particular use of this package is
16957 to enable the use of Get_Immediate under VxWorks.
16958
16959 @node System.Address_Image (s-addima.ads)
16960 @section @code{System.Address_Image} (@file{s-addima.ads})
16961 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16962 @cindex Address image
16963 @cindex Image, of an address
16964
16965 @noindent
16966 This function provides a useful debugging
16967 function that gives an (implementation dependent)
16968 string which identifies an address.
16969
16970 @node System.Assertions (s-assert.ads)
16971 @section @code{System.Assertions} (@file{s-assert.ads})
16972 @cindex @code{System.Assertions} (@file{s-assert.ads})
16973 @cindex Assertions
16974 @cindex Assert_Failure, exception
16975
16976 @noindent
16977 This package provides the declaration of the exception raised
16978 by an run-time assertion failure, as well as the routine that
16979 is used internally to raise this assertion.
16980
16981 @node System.Memory (s-memory.ads)
16982 @section @code{System.Memory} (@file{s-memory.ads})
16983 @cindex @code{System.Memory} (@file{s-memory.ads})
16984 @cindex Memory allocation
16985
16986 @noindent
16987 This package provides the interface to the low level routines used
16988 by the generated code for allocation and freeing storage for the
16989 default storage pool (analogous to the C routines malloc and free.
16990 It also provides a reallocation interface analogous to the C routine
16991 realloc. The body of this unit may be modified to provide alternative
16992 allocation mechanisms for the default pool, and in addition, direct
16993 calls to this unit may be made for low level allocation uses (for
16994 example see the body of @code{GNAT.Tables}).
16995
16996 @node System.Multiprocessors (s-multip.ads)
16997 @section @code{System.Multiprocessors} (@file{s-multip.ads})
16998 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
16999 @cindex Multiprocessor interface
17000 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17001 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17002 technically an implementation-defined addition).
17003
17004 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
17005 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17006 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17007 @cindex Multiprocessor interface
17008 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17009 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17010 technically an implementation-defined addition).
17011
17012 @node System.Partition_Interface (s-parint.ads)
17013 @section @code{System.Partition_Interface} (@file{s-parint.ads})
17014 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
17015 @cindex Partition interfacing functions
17016
17017 @noindent
17018 This package provides facilities for partition interfacing. It
17019 is used primarily in a distribution context when using Annex E
17020 with @code{GLADE}.
17021
17022 @node System.Pool_Global (s-pooglo.ads)
17023 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
17024 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
17025 @cindex Storage pool, global
17026 @cindex Global storage pool
17027
17028 @noindent
17029 This package provides a storage pool that is equivalent to the default
17030 storage pool used for access types for which no pool is specifically
17031 declared. It uses malloc/free to allocate/free and does not attempt to
17032 do any automatic reclamation.
17033
17034 @node System.Pool_Local (s-pooloc.ads)
17035 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
17036 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
17037 @cindex Storage pool, local
17038 @cindex Local storage pool
17039
17040 @noindent
17041 This package provides a storage pool that is intended for use with locally
17042 defined access types. It uses malloc/free for allocate/free, and maintains
17043 a list of allocated blocks, so that all storage allocated for the pool can
17044 be freed automatically when the pool is finalized.
17045
17046 @node System.Restrictions (s-restri.ads)
17047 @section @code{System.Restrictions} (@file{s-restri.ads})
17048 @cindex @code{System.Restrictions} (@file{s-restri.ads})
17049 @cindex Run-time restrictions access
17050
17051 @noindent
17052 This package provides facilities for accessing at run time
17053 the status of restrictions specified at compile time for
17054 the partition. Information is available both with regard
17055 to actual restrictions specified, and with regard to
17056 compiler determined information on which restrictions
17057 are violated by one or more packages in the partition.
17058
17059 @node System.Rident (s-rident.ads)
17060 @section @code{System.Rident} (@file{s-rident.ads})
17061 @cindex @code{System.Rident} (@file{s-rident.ads})
17062 @cindex Restrictions definitions
17063
17064 @noindent
17065 This package provides definitions of the restrictions
17066 identifiers supported by GNAT, and also the format of
17067 the restrictions provided in package System.Restrictions.
17068 It is not normally necessary to @code{with} this generic package
17069 since the necessary instantiation is included in
17070 package System.Restrictions.
17071
17072 @node System.Strings.Stream_Ops (s-ststop.ads)
17073 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17074 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17075 @cindex Stream operations
17076 @cindex String stream operations
17077
17078 @noindent
17079 This package provides a set of stream subprograms for standard string types.
17080 It is intended primarily to support implicit use of such subprograms when
17081 stream attributes are applied to string types, but the subprograms in this
17082 package can be used directly by application programs.
17083
17084 @node System.Task_Info (s-tasinf.ads)
17085 @section @code{System.Task_Info} (@file{s-tasinf.ads})
17086 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
17087 @cindex Task_Info pragma
17088
17089 @noindent
17090 This package provides target dependent functionality that is used
17091 to support the @code{Task_Info} pragma
17092
17093 @node System.Wch_Cnv (s-wchcnv.ads)
17094 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17095 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17096 @cindex Wide Character, Representation
17097 @cindex Wide String, Conversion
17098 @cindex Representation of wide characters
17099
17100 @noindent
17101 This package provides routines for converting between
17102 wide and wide wide characters and a representation as a value of type
17103 @code{Standard.String}, using a specified wide character
17104 encoding method. It uses definitions in
17105 package @code{System.Wch_Con}.
17106
17107 @node System.Wch_Con (s-wchcon.ads)
17108 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
17109 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
17110
17111 @noindent
17112 This package provides definitions and descriptions of
17113 the various methods used for encoding wide characters
17114 in ordinary strings. These definitions are used by
17115 the package @code{System.Wch_Cnv}.
17116
17117 @node Interfacing to Other Languages
17118 @chapter Interfacing to Other Languages
17119 @noindent
17120 The facilities in annex B of the Ada Reference Manual are fully
17121 implemented in GNAT, and in addition, a full interface to C++ is
17122 provided.
17123
17124 @menu
17125 * Interfacing to C::
17126 * Interfacing to C++::
17127 * Interfacing to COBOL::
17128 * Interfacing to Fortran::
17129 * Interfacing to non-GNAT Ada code::
17130 @end menu
17131
17132 @node Interfacing to C
17133 @section Interfacing to C
17134
17135 @noindent
17136 Interfacing to C with GNAT can use one of two approaches:
17137
17138 @itemize @bullet
17139 @item
17140 The types in the package @code{Interfaces.C} may be used.
17141 @item
17142 Standard Ada types may be used directly. This may be less portable to
17143 other compilers, but will work on all GNAT compilers, which guarantee
17144 correspondence between the C and Ada types.
17145 @end itemize
17146
17147 @noindent
17148 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
17149 effect, since this is the default. The following table shows the
17150 correspondence between Ada scalar types and the corresponding C types.
17151
17152 @table @code
17153 @item Integer
17154 @code{int}
17155 @item Short_Integer
17156 @code{short}
17157 @item Short_Short_Integer
17158 @code{signed char}
17159 @item Long_Integer
17160 @code{long}
17161 @item Long_Long_Integer
17162 @code{long long}
17163 @item Short_Float
17164 @code{float}
17165 @item Float
17166 @code{float}
17167 @item Long_Float
17168 @code{double}
17169 @item Long_Long_Float
17170 This is the longest floating-point type supported by the hardware.
17171 @end table
17172
17173 @noindent
17174 Additionally, there are the following general correspondences between Ada
17175 and C types:
17176 @itemize @bullet
17177 @item
17178 Ada enumeration types map to C enumeration types directly if pragma
17179 @code{Convention C} is specified, which causes them to have int
17180 length. Without pragma @code{Convention C}, Ada enumeration types map to
17181 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
17182 @code{int}, respectively) depending on the number of values passed.
17183 This is the only case in which pragma @code{Convention C} affects the
17184 representation of an Ada type.
17185
17186 @item
17187 Ada access types map to C pointers, except for the case of pointers to
17188 unconstrained types in Ada, which have no direct C equivalent.
17189
17190 @item
17191 Ada arrays map directly to C arrays.
17192
17193 @item
17194 Ada records map directly to C structures.
17195
17196 @item
17197 Packed Ada records map to C structures where all members are bit fields
17198 of the length corresponding to the @code{@var{type}'Size} value in Ada.
17199 @end itemize
17200
17201 @node Interfacing to C++
17202 @section Interfacing to C++
17203
17204 @noindent
17205 The interface to C++ makes use of the following pragmas, which are
17206 primarily intended to be constructed automatically using a binding generator
17207 tool, although it is possible to construct them by hand.
17208
17209 Using these pragmas it is possible to achieve complete
17210 inter-operability between Ada tagged types and C++ class definitions.
17211 See @ref{Implementation Defined Pragmas}, for more details.
17212
17213 @table @code
17214 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
17215 The argument denotes an entity in the current declarative region that is
17216 declared as a tagged or untagged record type. It indicates that the type
17217 corresponds to an externally declared C++ class type, and is to be laid
17218 out the same way that C++ would lay out the type.
17219
17220 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
17221 for backward compatibility but its functionality is available
17222 using pragma @code{Import} with @code{Convention} = @code{CPP}.
17223
17224 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
17225 This pragma identifies an imported function (imported in the usual way
17226 with pragma @code{Import}) as corresponding to a C++ constructor.
17227 @end table
17228
17229 A few restrictions are placed on the use of the @code{Access} attribute
17230 in conjunction with subprograms subject to convention @code{CPP}: the
17231 attribute may be used neither on primitive operations of a tagged
17232 record type with convention @code{CPP}, imported or not, nor on
17233 subprograms imported with pragma @code{CPP_Constructor}.
17234
17235 In addition, C++ exceptions are propagated and can be handled in an
17236 @code{others} choice of an exception handler. The corresponding Ada
17237 occurrence has no message, and the simple name of the exception identity
17238 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
17239 tasks works properly when such foreign exceptions are propagated.
17240
17241 @node Interfacing to COBOL
17242 @section Interfacing to COBOL
17243
17244 @noindent
17245 Interfacing to COBOL is achieved as described in section B.4 of
17246 the Ada Reference Manual.
17247
17248 @node Interfacing to Fortran
17249 @section Interfacing to Fortran
17250
17251 @noindent
17252 Interfacing to Fortran is achieved as described in section B.5 of the
17253 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
17254 multi-dimensional array causes the array to be stored in column-major
17255 order as required for convenient interface to Fortran.
17256
17257 @node Interfacing to non-GNAT Ada code
17258 @section Interfacing to non-GNAT Ada code
17259
17260 It is possible to specify the convention @code{Ada} in a pragma
17261 @code{Import} or pragma @code{Export}. However this refers to
17262 the calling conventions used by GNAT, which may or may not be
17263 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
17264 compiler to allow interoperation.
17265
17266 If arguments types are kept simple, and if the foreign compiler generally
17267 follows system calling conventions, then it may be possible to integrate
17268 files compiled by other Ada compilers, provided that the elaboration
17269 issues are adequately addressed (for example by eliminating the
17270 need for any load time elaboration).
17271
17272 In particular, GNAT running on VMS is designed to
17273 be highly compatible with the DEC Ada 83 compiler, so this is one
17274 case in which it is possible to import foreign units of this type,
17275 provided that the data items passed are restricted to simple scalar
17276 values or simple record types without variants, or simple array
17277 types with fixed bounds.
17278
17279 @node Specialized Needs Annexes
17280 @chapter Specialized Needs Annexes
17281
17282 @noindent
17283 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
17284 required in all implementations. However, as described in this chapter,
17285 GNAT implements all of these annexes:
17286
17287 @table @asis
17288 @item Systems Programming (Annex C)
17289 The Systems Programming Annex is fully implemented.
17290
17291 @item Real-Time Systems (Annex D)
17292 The Real-Time Systems Annex is fully implemented.
17293
17294 @item Distributed Systems (Annex E)
17295 Stub generation is fully implemented in the GNAT compiler. In addition,
17296 a complete compatible PCS is available as part of the GLADE system,
17297 a separate product. When the two
17298 products are used in conjunction, this annex is fully implemented.
17299
17300 @item Information Systems (Annex F)
17301 The Information Systems annex is fully implemented.
17302
17303 @item Numerics (Annex G)
17304 The Numerics Annex is fully implemented.
17305
17306 @item Safety and Security / High-Integrity Systems (Annex H)
17307 The Safety and Security Annex (termed the High-Integrity Systems Annex
17308 in Ada 2005) is fully implemented.
17309 @end table
17310
17311 @node Implementation of Specific Ada Features
17312 @chapter Implementation of Specific Ada Features
17313
17314 @noindent
17315 This chapter describes the GNAT implementation of several Ada language
17316 facilities.
17317
17318 @menu
17319 * Machine Code Insertions::
17320 * GNAT Implementation of Tasking::
17321 * GNAT Implementation of Shared Passive Packages::
17322 * Code Generation for Array Aggregates::
17323 * The Size of Discriminated Records with Default Discriminants::
17324 * Strict Conformance to the Ada Reference Manual::
17325 @end menu
17326
17327 @node Machine Code Insertions
17328 @section Machine Code Insertions
17329 @cindex Machine Code insertions
17330
17331 @noindent
17332 Package @code{Machine_Code} provides machine code support as described
17333 in the Ada Reference Manual in two separate forms:
17334 @itemize @bullet
17335 @item
17336 Machine code statements, consisting of qualified expressions that
17337 fit the requirements of RM section 13.8.
17338 @item
17339 An intrinsic callable procedure, providing an alternative mechanism of
17340 including machine instructions in a subprogram.
17341 @end itemize
17342
17343 @noindent
17344 The two features are similar, and both are closely related to the mechanism
17345 provided by the asm instruction in the GNU C compiler. Full understanding
17346 and use of the facilities in this package requires understanding the asm
17347 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
17348 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
17349
17350 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
17351 semantic restrictions and effects as described below. Both are provided so
17352 that the procedure call can be used as a statement, and the function call
17353 can be used to form a code_statement.
17354
17355 The first example given in the GCC documentation is the C @code{asm}
17356 instruction:
17357 @smallexample
17358 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
17359 @end smallexample
17360
17361 @noindent
17362 The equivalent can be written for GNAT as:
17363
17364 @smallexample @c ada
17365 Asm ("fsinx %1 %0",
17366 My_Float'Asm_Output ("=f", result),
17367 My_Float'Asm_Input ("f", angle));
17368 @end smallexample
17369
17370 @noindent
17371 The first argument to @code{Asm} is the assembler template, and is
17372 identical to what is used in GNU C@. This string must be a static
17373 expression. The second argument is the output operand list. It is
17374 either a single @code{Asm_Output} attribute reference, or a list of such
17375 references enclosed in parentheses (technically an array aggregate of
17376 such references).
17377
17378 The @code{Asm_Output} attribute denotes a function that takes two
17379 parameters. The first is a string, the second is the name of a variable
17380 of the type designated by the attribute prefix. The first (string)
17381 argument is required to be a static expression and designates the
17382 constraint for the parameter (e.g.@: what kind of register is
17383 required). The second argument is the variable to be updated with the
17384 result. The possible values for constraint are the same as those used in
17385 the RTL, and are dependent on the configuration file used to build the
17386 GCC back end. If there are no output operands, then this argument may
17387 either be omitted, or explicitly given as @code{No_Output_Operands}.
17388
17389 The second argument of @code{@var{my_float}'Asm_Output} functions as
17390 though it were an @code{out} parameter, which is a little curious, but
17391 all names have the form of expressions, so there is no syntactic
17392 irregularity, even though normally functions would not be permitted
17393 @code{out} parameters. The third argument is the list of input
17394 operands. It is either a single @code{Asm_Input} attribute reference, or
17395 a list of such references enclosed in parentheses (technically an array
17396 aggregate of such references).
17397
17398 The @code{Asm_Input} attribute denotes a function that takes two
17399 parameters. The first is a string, the second is an expression of the
17400 type designated by the prefix. The first (string) argument is required
17401 to be a static expression, and is the constraint for the parameter,
17402 (e.g.@: what kind of register is required). The second argument is the
17403 value to be used as the input argument. The possible values for the
17404 constant are the same as those used in the RTL, and are dependent on
17405 the configuration file used to built the GCC back end.
17406
17407 If there are no input operands, this argument may either be omitted, or
17408 explicitly given as @code{No_Input_Operands}. The fourth argument, not
17409 present in the above example, is a list of register names, called the
17410 @dfn{clobber} argument. This argument, if given, must be a static string
17411 expression, and is a space or comma separated list of names of registers
17412 that must be considered destroyed as a result of the @code{Asm} call. If
17413 this argument is the null string (the default value), then the code
17414 generator assumes that no additional registers are destroyed.
17415
17416 The fifth argument, not present in the above example, called the
17417 @dfn{volatile} argument, is by default @code{False}. It can be set to
17418 the literal value @code{True} to indicate to the code generator that all
17419 optimizations with respect to the instruction specified should be
17420 suppressed, and that in particular, for an instruction that has outputs,
17421 the instruction will still be generated, even if none of the outputs are
17422 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
17423 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
17424 Generally it is strongly advisable to use Volatile for any ASM statement
17425 that is missing either input or output operands, or when two or more ASM
17426 statements appear in sequence, to avoid unwanted optimizations. A warning
17427 is generated if this advice is not followed.
17428
17429 The @code{Asm} subprograms may be used in two ways. First the procedure
17430 forms can be used anywhere a procedure call would be valid, and
17431 correspond to what the RM calls ``intrinsic'' routines. Such calls can
17432 be used to intersperse machine instructions with other Ada statements.
17433 Second, the function forms, which return a dummy value of the limited
17434 private type @code{Asm_Insn}, can be used in code statements, and indeed
17435 this is the only context where such calls are allowed. Code statements
17436 appear as aggregates of the form:
17437
17438 @smallexample @c ada
17439 Asm_Insn'(Asm (@dots{}));
17440 Asm_Insn'(Asm_Volatile (@dots{}));
17441 @end smallexample
17442
17443 @noindent
17444 In accordance with RM rules, such code statements are allowed only
17445 within subprograms whose entire body consists of such statements. It is
17446 not permissible to intermix such statements with other Ada statements.
17447
17448 Typically the form using intrinsic procedure calls is more convenient
17449 and more flexible. The code statement form is provided to meet the RM
17450 suggestion that such a facility should be made available. The following
17451 is the exact syntax of the call to @code{Asm}. As usual, if named notation
17452 is used, the arguments may be given in arbitrary order, following the
17453 normal rules for use of positional and named arguments)
17454
17455 @smallexample
17456 ASM_CALL ::= Asm (
17457 [Template =>] static_string_EXPRESSION
17458 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
17459 [,[Inputs =>] INPUT_OPERAND_LIST ]
17460 [,[Clobber =>] static_string_EXPRESSION ]
17461 [,[Volatile =>] static_boolean_EXPRESSION] )
17462
17463 OUTPUT_OPERAND_LIST ::=
17464 [PREFIX.]No_Output_Operands
17465 | OUTPUT_OPERAND_ATTRIBUTE
17466 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
17467
17468 OUTPUT_OPERAND_ATTRIBUTE ::=
17469 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
17470
17471 INPUT_OPERAND_LIST ::=
17472 [PREFIX.]No_Input_Operands
17473 | INPUT_OPERAND_ATTRIBUTE
17474 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
17475
17476 INPUT_OPERAND_ATTRIBUTE ::=
17477 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
17478 @end smallexample
17479
17480 @noindent
17481 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
17482 are declared in the package @code{Machine_Code} and must be referenced
17483 according to normal visibility rules. In particular if there is no
17484 @code{use} clause for this package, then appropriate package name
17485 qualification is required.
17486
17487 @node GNAT Implementation of Tasking
17488 @section GNAT Implementation of Tasking
17489
17490 @noindent
17491 This chapter outlines the basic GNAT approach to tasking (in particular,
17492 a multi-layered library for portability) and discusses issues related
17493 to compliance with the Real-Time Systems Annex.
17494
17495 @menu
17496 * Mapping Ada Tasks onto the Underlying Kernel Threads::
17497 * Ensuring Compliance with the Real-Time Annex::
17498 @end menu
17499
17500 @node Mapping Ada Tasks onto the Underlying Kernel Threads
17501 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
17502
17503 @noindent
17504 GNAT's run-time support comprises two layers:
17505
17506 @itemize @bullet
17507 @item GNARL (GNAT Run-time Layer)
17508 @item GNULL (GNAT Low-level Library)
17509 @end itemize
17510
17511 @noindent
17512 In GNAT, Ada's tasking services rely on a platform and OS independent
17513 layer known as GNARL@. This code is responsible for implementing the
17514 correct semantics of Ada's task creation, rendezvous, protected
17515 operations etc.
17516
17517 GNARL decomposes Ada's tasking semantics into simpler lower level
17518 operations such as create a thread, set the priority of a thread,
17519 yield, create a lock, lock/unlock, etc. The spec for these low-level
17520 operations constitutes GNULLI, the GNULL Interface. This interface is
17521 directly inspired from the POSIX real-time API@.
17522
17523 If the underlying executive or OS implements the POSIX standard
17524 faithfully, the GNULL Interface maps as is to the services offered by
17525 the underlying kernel. Otherwise, some target dependent glue code maps
17526 the services offered by the underlying kernel to the semantics expected
17527 by GNARL@.
17528
17529 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
17530 key point is that each Ada task is mapped on a thread in the underlying
17531 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
17532
17533 In addition Ada task priorities map onto the underlying thread priorities.
17534 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17535
17536 @itemize @bullet
17537 @item
17538 The underlying scheduler is used to schedule the Ada tasks. This
17539 makes Ada tasks as efficient as kernel threads from a scheduling
17540 standpoint.
17541
17542 @item
17543 Interaction with code written in C containing threads is eased
17544 since at the lowest level Ada tasks and C threads map onto the same
17545 underlying kernel concept.
17546
17547 @item
17548 When an Ada task is blocked during I/O the remaining Ada tasks are
17549 able to proceed.
17550
17551 @item
17552 On multiprocessor systems Ada tasks can execute in parallel.
17553 @end itemize
17554
17555 @noindent
17556 Some threads libraries offer a mechanism to fork a new process, with the
17557 child process duplicating the threads from the parent.
17558 GNAT does not
17559 support this functionality when the parent contains more than one task.
17560 @cindex Forking a new process
17561
17562 @node Ensuring Compliance with the Real-Time Annex
17563 @subsection Ensuring Compliance with the Real-Time Annex
17564 @cindex Real-Time Systems Annex compliance
17565
17566 @noindent
17567 Although mapping Ada tasks onto
17568 the underlying threads has significant advantages, it does create some
17569 complications when it comes to respecting the scheduling semantics
17570 specified in the real-time annex (Annex D).
17571
17572 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17573 scheduling policy states:
17574
17575 @quotation
17576 @emph{When the active priority of a ready task that is not running
17577 changes, or the setting of its base priority takes effect, the
17578 task is removed from the ready queue for its old active priority
17579 and is added at the tail of the ready queue for its new active
17580 priority, except in the case where the active priority is lowered
17581 due to the loss of inherited priority, in which case the task is
17582 added at the head of the ready queue for its new active priority.}
17583 @end quotation
17584
17585 @noindent
17586 While most kernels do put tasks at the end of the priority queue when
17587 a task changes its priority, (which respects the main
17588 FIFO_Within_Priorities requirement), almost none keep a thread at the
17589 beginning of its priority queue when its priority drops from the loss
17590 of inherited priority.
17591
17592 As a result most vendors have provided incomplete Annex D implementations.
17593
17594 The GNAT run-time, has a nice cooperative solution to this problem
17595 which ensures that accurate FIFO_Within_Priorities semantics are
17596 respected.
17597
17598 The principle is as follows. When an Ada task T is about to start
17599 running, it checks whether some other Ada task R with the same
17600 priority as T has been suspended due to the loss of priority
17601 inheritance. If this is the case, T yields and is placed at the end of
17602 its priority queue. When R arrives at the front of the queue it
17603 executes.
17604
17605 Note that this simple scheme preserves the relative order of the tasks
17606 that were ready to execute in the priority queue where R has been
17607 placed at the end.
17608
17609 @node GNAT Implementation of Shared Passive Packages
17610 @section GNAT Implementation of Shared Passive Packages
17611 @cindex Shared passive packages
17612
17613 @noindent
17614 GNAT fully implements the pragma @code{Shared_Passive} for
17615 @cindex pragma @code{Shared_Passive}
17616 the purpose of designating shared passive packages.
17617 This allows the use of passive partitions in the
17618 context described in the Ada Reference Manual; i.e., for communication
17619 between separate partitions of a distributed application using the
17620 features in Annex E.
17621 @cindex Annex E
17622 @cindex Distribution Systems Annex
17623
17624 However, the implementation approach used by GNAT provides for more
17625 extensive usage as follows:
17626
17627 @table @emph
17628 @item Communication between separate programs
17629
17630 This allows separate programs to access the data in passive
17631 partitions, using protected objects for synchronization where
17632 needed. The only requirement is that the two programs have a
17633 common shared file system. It is even possible for programs
17634 running on different machines with different architectures
17635 (e.g.@: different endianness) to communicate via the data in
17636 a passive partition.
17637
17638 @item Persistence between program runs
17639
17640 The data in a passive package can persist from one run of a
17641 program to another, so that a later program sees the final
17642 values stored by a previous run of the same program.
17643
17644 @end table
17645
17646 @noindent
17647 The implementation approach used is to store the data in files. A
17648 separate stream file is created for each object in the package, and
17649 an access to an object causes the corresponding file to be read or
17650 written.
17651
17652 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17653 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17654 set to the directory to be used for these files.
17655 The files in this directory
17656 have names that correspond to their fully qualified names. For
17657 example, if we have the package
17658
17659 @smallexample @c ada
17660 package X is
17661 pragma Shared_Passive (X);
17662 Y : Integer;
17663 Z : Float;
17664 end X;
17665 @end smallexample
17666
17667 @noindent
17668 and the environment variable is set to @code{/stemp/}, then the files created
17669 will have the names:
17670
17671 @smallexample
17672 /stemp/x.y
17673 /stemp/x.z
17674 @end smallexample
17675
17676 @noindent
17677 These files are created when a value is initially written to the object, and
17678 the files are retained until manually deleted. This provides the persistence
17679 semantics. If no file exists, it means that no partition has assigned a value
17680 to the variable; in this case the initial value declared in the package
17681 will be used. This model ensures that there are no issues in synchronizing
17682 the elaboration process, since elaboration of passive packages elaborates the
17683 initial values, but does not create the files.
17684
17685 The files are written using normal @code{Stream_IO} access.
17686 If you want to be able
17687 to communicate between programs or partitions running on different
17688 architectures, then you should use the XDR versions of the stream attribute
17689 routines, since these are architecture independent.
17690
17691 If active synchronization is required for access to the variables in the
17692 shared passive package, then as described in the Ada Reference Manual, the
17693 package may contain protected objects used for this purpose. In this case
17694 a lock file (whose name is @file{___lock} (three underscores)
17695 is created in the shared memory directory.
17696 @cindex @file{___lock} file (for shared passive packages)
17697 This is used to provide the required locking
17698 semantics for proper protected object synchronization.
17699
17700 As of January 2003, GNAT supports shared passive packages on all platforms
17701 except for OpenVMS.
17702
17703 @node Code Generation for Array Aggregates
17704 @section Code Generation for Array Aggregates
17705
17706 @menu
17707 * Static constant aggregates with static bounds::
17708 * Constant aggregates with unconstrained nominal types::
17709 * Aggregates with static bounds::
17710 * Aggregates with non-static bounds::
17711 * Aggregates in assignment statements::
17712 @end menu
17713
17714 @noindent
17715 Aggregates have a rich syntax and allow the user to specify the values of
17716 complex data structures by means of a single construct. As a result, the
17717 code generated for aggregates can be quite complex and involve loops, case
17718 statements and multiple assignments. In the simplest cases, however, the
17719 compiler will recognize aggregates whose components and constraints are
17720 fully static, and in those cases the compiler will generate little or no
17721 executable code. The following is an outline of the code that GNAT generates
17722 for various aggregate constructs. For further details, you will find it
17723 useful to examine the output produced by the -gnatG flag to see the expanded
17724 source that is input to the code generator. You may also want to examine
17725 the assembly code generated at various levels of optimization.
17726
17727 The code generated for aggregates depends on the context, the component values,
17728 and the type. In the context of an object declaration the code generated is
17729 generally simpler than in the case of an assignment. As a general rule, static
17730 component values and static subtypes also lead to simpler code.
17731
17732 @node Static constant aggregates with static bounds
17733 @subsection Static constant aggregates with static bounds
17734
17735 @noindent
17736 For the declarations:
17737 @smallexample @c ada
17738 type One_Dim is array (1..10) of integer;
17739 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17740 @end smallexample
17741
17742 @noindent
17743 GNAT generates no executable code: the constant ar0 is placed in static memory.
17744 The same is true for constant aggregates with named associations:
17745
17746 @smallexample @c ada
17747 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17748 Cr3 : constant One_Dim := (others => 7777);
17749 @end smallexample
17750
17751 @noindent
17752 The same is true for multidimensional constant arrays such as:
17753
17754 @smallexample @c ada
17755 type two_dim is array (1..3, 1..3) of integer;
17756 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17757 @end smallexample
17758
17759 @noindent
17760 The same is true for arrays of one-dimensional arrays: the following are
17761 static:
17762
17763 @smallexample @c ada
17764 type ar1b is array (1..3) of boolean;
17765 type ar_ar is array (1..3) of ar1b;
17766 None : constant ar1b := (others => false); -- fully static
17767 None2 : constant ar_ar := (1..3 => None); -- fully static
17768 @end smallexample
17769
17770 @noindent
17771 However, for multidimensional aggregates with named associations, GNAT will
17772 generate assignments and loops, even if all associations are static. The
17773 following two declarations generate a loop for the first dimension, and
17774 individual component assignments for the second dimension:
17775
17776 @smallexample @c ada
17777 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17778 Zero2: constant two_dim := (others => (others => 0));
17779 @end smallexample
17780
17781 @node Constant aggregates with unconstrained nominal types
17782 @subsection Constant aggregates with unconstrained nominal types
17783
17784 @noindent
17785 In such cases the aggregate itself establishes the subtype, so that
17786 associations with @code{others} cannot be used. GNAT determines the
17787 bounds for the actual subtype of the aggregate, and allocates the
17788 aggregate statically as well. No code is generated for the following:
17789
17790 @smallexample @c ada
17791 type One_Unc is array (natural range <>) of integer;
17792 Cr_Unc : constant One_Unc := (12,24,36);
17793 @end smallexample
17794
17795 @node Aggregates with static bounds
17796 @subsection Aggregates with static bounds
17797
17798 @noindent
17799 In all previous examples the aggregate was the initial (and immutable) value
17800 of a constant. If the aggregate initializes a variable, then code is generated
17801 for it as a combination of individual assignments and loops over the target
17802 object. The declarations
17803
17804 @smallexample @c ada
17805 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17806 Cr_Var2 : One_Dim := (others > -1);
17807 @end smallexample
17808
17809 @noindent
17810 generate the equivalent of
17811
17812 @smallexample @c ada
17813 Cr_Var1 (1) := 2;
17814 Cr_Var1 (2) := 3;
17815 Cr_Var1 (3) := 5;
17816 Cr_Var1 (4) := 11;
17817
17818 for I in Cr_Var2'range loop
17819 Cr_Var2 (I) := -1;
17820 end loop;
17821 @end smallexample
17822
17823 @node Aggregates with non-static bounds
17824 @subsection Aggregates with non-static bounds
17825
17826 @noindent
17827 If the bounds of the aggregate are not statically compatible with the bounds
17828 of the nominal subtype of the target, then constraint checks have to be
17829 generated on the bounds. For a multidimensional array, constraint checks may
17830 have to be applied to sub-arrays individually, if they do not have statically
17831 compatible subtypes.
17832
17833 @node Aggregates in assignment statements
17834 @subsection Aggregates in assignment statements
17835
17836 @noindent
17837 In general, aggregate assignment requires the construction of a temporary,
17838 and a copy from the temporary to the target of the assignment. This is because
17839 it is not always possible to convert the assignment into a series of individual
17840 component assignments. For example, consider the simple case:
17841
17842 @smallexample @c ada
17843 A := (A(2), A(1));
17844 @end smallexample
17845
17846 @noindent
17847 This cannot be converted into:
17848
17849 @smallexample @c ada
17850 A(1) := A(2);
17851 A(2) := A(1);
17852 @end smallexample
17853
17854 @noindent
17855 So the aggregate has to be built first in a separate location, and then
17856 copied into the target. GNAT recognizes simple cases where this intermediate
17857 step is not required, and the assignments can be performed in place, directly
17858 into the target. The following sufficient criteria are applied:
17859
17860 @itemize @bullet
17861 @item
17862 The bounds of the aggregate are static, and the associations are static.
17863 @item
17864 The components of the aggregate are static constants, names of
17865 simple variables that are not renamings, or expressions not involving
17866 indexed components whose operands obey these rules.
17867 @end itemize
17868
17869 @noindent
17870 If any of these conditions are violated, the aggregate will be built in
17871 a temporary (created either by the front-end or the code generator) and then
17872 that temporary will be copied onto the target.
17873
17874 @node The Size of Discriminated Records with Default Discriminants
17875 @section The Size of Discriminated Records with Default Discriminants
17876
17877 @noindent
17878 If a discriminated type @code{T} has discriminants with default values, it is
17879 possible to declare an object of this type without providing an explicit
17880 constraint:
17881
17882 @smallexample @c ada
17883 @group
17884 type Size is range 1..100;
17885
17886 type Rec (D : Size := 15) is record
17887 Name : String (1..D);
17888 end T;
17889
17890 Word : Rec;
17891 @end group
17892 @end smallexample
17893
17894 @noindent
17895 Such an object is said to be @emph{unconstrained}.
17896 The discriminant of the object
17897 can be modified by a full assignment to the object, as long as it preserves the
17898 relation between the value of the discriminant, and the value of the components
17899 that depend on it:
17900
17901 @smallexample @c ada
17902 @group
17903 Word := (3, "yes");
17904
17905 Word := (5, "maybe");
17906
17907 Word := (5, "no"); -- raises Constraint_Error
17908 @end group
17909 @end smallexample
17910
17911 @noindent
17912 In order to support this behavior efficiently, an unconstrained object is
17913 given the maximum size that any value of the type requires. In the case
17914 above, @code{Word} has storage for the discriminant and for
17915 a @code{String} of length 100.
17916 It is important to note that unconstrained objects do not require dynamic
17917 allocation. It would be an improper implementation to place on the heap those
17918 components whose size depends on discriminants. (This improper implementation
17919 was used by some Ada83 compilers, where the @code{Name} component above
17920 would have
17921 been stored as a pointer to a dynamic string). Following the principle that
17922 dynamic storage management should never be introduced implicitly,
17923 an Ada compiler should reserve the full size for an unconstrained declared
17924 object, and place it on the stack.
17925
17926 This maximum size approach
17927 has been a source of surprise to some users, who expect the default
17928 values of the discriminants to determine the size reserved for an
17929 unconstrained object: ``If the default is 15, why should the object occupy
17930 a larger size?''
17931 The answer, of course, is that the discriminant may be later modified,
17932 and its full range of values must be taken into account. This is why the
17933 declaration:
17934
17935 @smallexample
17936 @group
17937 type Rec (D : Positive := 15) is record
17938 Name : String (1..D);
17939 end record;
17940
17941 Too_Large : Rec;
17942 @end group
17943 @end smallexample
17944
17945 @noindent
17946 is flagged by the compiler with a warning:
17947 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17948 because the required size includes @code{Positive'Last}
17949 bytes. As the first example indicates, the proper approach is to declare an
17950 index type of ``reasonable'' range so that unconstrained objects are not too
17951 large.
17952
17953 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17954 created in the heap by means of an allocator, then it is @emph{not}
17955 unconstrained:
17956 it is constrained by the default values of the discriminants, and those values
17957 cannot be modified by full assignment. This is because in the presence of
17958 aliasing all views of the object (which may be manipulated by different tasks,
17959 say) must be consistent, so it is imperative that the object, once created,
17960 remain invariant.
17961
17962 @node Strict Conformance to the Ada Reference Manual
17963 @section Strict Conformance to the Ada Reference Manual
17964
17965 @noindent
17966 The dynamic semantics defined by the Ada Reference Manual impose a set of
17967 run-time checks to be generated. By default, the GNAT compiler will insert many
17968 run-time checks into the compiled code, including most of those required by the
17969 Ada Reference Manual. However, there are three checks that are not enabled
17970 in the default mode for efficiency reasons: arithmetic overflow checking for
17971 integer operations (including division by zero), checks for access before
17972 elaboration on subprogram calls, and stack overflow checking (most operating
17973 systems do not perform this check by default).
17974
17975 Strict conformance to the Ada Reference Manual can be achieved by adding
17976 three compiler options for overflow checking for integer operations
17977 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17978 calls and generic instantiations (@option{-gnatE}), and stack overflow
17979 checking (@option{-fstack-check}).
17980
17981 Note that the result of a floating point arithmetic operation in overflow and
17982 invalid situations, when the @code{Machine_Overflows} attribute of the result
17983 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17984 case for machines compliant with the IEEE floating-point standard, but on
17985 machines that are not fully compliant with this standard, such as Alpha, the
17986 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17987 behavior (although at the cost of a significant performance penalty), so
17988 infinite and NaN values are properly generated.
17989
17990
17991 @node Implementation of Ada 2012 Features
17992 @chapter Implementation of Ada 2012 Features
17993 @cindex Ada 2012 implementation status
17994
17995 This chapter contains a complete list of Ada 2012 features that have been
17996 implemented as of GNAT version 6.4. Generally, these features are only
17997 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17998 @cindex @option{-gnat12} option
17999 or if the configuration pragma @code{Ada_2012} is used.
18000 @cindex pragma @code{Ada_2012}
18001 @cindex configuration pragma @code{Ada_2012}
18002 @cindex @code{Ada_2012} configuration pragma
18003 However, new pragmas, attributes, and restrictions are
18004 unconditionally available, since the Ada 95 standard allows the addition of
18005 new pragmas, attributes, and restrictions (there are exceptions, which are
18006 documented in the individual descriptions), and also certain packages
18007 were made available in earlier versions of Ada.
18008
18009 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
18010 This date shows the implementation date of the feature. Any wavefront
18011 subsequent to this date will contain the indicated feature, as will any
18012 subsequent releases. A date of 0000-00-00 means that GNAT has always
18013 implemented the feature, or implemented it as soon as it appeared as a
18014 binding interpretation.
18015
18016 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
18017 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
18018 The features are ordered based on the relevant sections of the Ada
18019 Reference Manual (``RM''). When a given AI relates to multiple points
18020 in the RM, the earliest is used.
18021
18022 A complete description of the AIs may be found in
18023 @url{www.ada-auth.org/ai05-summary.html}.
18024
18025 @itemize @bullet
18026
18027 @item
18028 @emph{AI-0176 Quantified expressions (2010-09-29)}
18029 @cindex AI-0176 (Ada 2012 feature)
18030
18031 @noindent
18032 Both universally and existentially quantified expressions are implemented.
18033 They use the new syntax for iterators proposed in AI05-139-2, as well as
18034 the standard Ada loop syntax.
18035
18036 @noindent
18037 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
18038
18039 @item
18040 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
18041 @cindex AI-0079 (Ada 2012 feature)
18042
18043 @noindent
18044 Wide characters in the unicode category @i{other_format} are now allowed in
18045 source programs between tokens, but not within a token such as an identifier.
18046
18047 @noindent
18048 RM References: 2.01 (4/2) 2.02 (7)
18049
18050 @item
18051 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
18052 @cindex AI-0091 (Ada 2012 feature)
18053
18054 @noindent
18055 Wide characters in the unicode category @i{other_format} are not permitted
18056 within an identifier, since this can be a security problem. The error
18057 message for this case has been improved to be more specific, but GNAT has
18058 never allowed such characters to appear in identifiers.
18059
18060 @noindent
18061 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)
18062
18063 @item
18064 @emph{AI-0100 Placement of pragmas (2010-07-01)}
18065 @cindex AI-0100 (Ada 2012 feature)
18066
18067 @noindent
18068 This AI is an earlier version of AI-163. It simplifies the rules
18069 for legal placement of pragmas. In the case of lists that allow pragmas, if
18070 the list may have no elements, then the list may consist solely of pragmas.
18071
18072 @noindent
18073 RM References: 2.08 (7)
18074
18075 @item
18076 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
18077 @cindex AI-0163 (Ada 2012 feature)
18078
18079 @noindent
18080 A statement sequence may be composed entirely of pragmas. It is no longer
18081 necessary to add a dummy @code{null} statement to make the sequence legal.
18082
18083 @noindent
18084 RM References: 2.08 (7) 2.08 (16)
18085
18086
18087 @item
18088 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
18089 @cindex AI-0080 (Ada 2012 feature)
18090
18091 @noindent
18092 This is an editorial change only, described as non-testable in the AI.
18093
18094 @noindent
18095 RM References: 3.01 (7)
18096
18097
18098 @item
18099 @emph{AI-0183 Aspect specifications (2010-08-16)}
18100 @cindex AI-0183 (Ada 2012 feature)
18101
18102 @noindent
18103 Aspect specifications have been fully implemented except for pre and post-
18104 conditions, and type invariants, which have their own separate AI's. All
18105 forms of declarations listed in the AI are supported. The following is a
18106 list of the aspects supported (with GNAT implementation aspects marked)
18107
18108 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
18109 @item @code{Ada_2005} @tab -- GNAT
18110 @item @code{Ada_2012} @tab -- GNAT
18111 @item @code{Address} @tab
18112 @item @code{Alignment} @tab
18113 @item @code{Atomic} @tab
18114 @item @code{Atomic_Components} @tab
18115 @item @code{Bit_Order} @tab
18116 @item @code{Component_Size} @tab
18117 @item @code{Contract_Case} @tab -- GNAT
18118 @item @code{Discard_Names} @tab
18119 @item @code{External_Tag} @tab
18120 @item @code{Favor_Top_Level} @tab -- GNAT
18121 @item @code{Inline} @tab
18122 @item @code{Inline_Always} @tab -- GNAT
18123 @item @code{Invariant} @tab -- GNAT
18124 @item @code{Machine_Radix} @tab
18125 @item @code{No_Return} @tab
18126 @item @code{Object_Size} @tab -- GNAT
18127 @item @code{Pack} @tab
18128 @item @code{Persistent_BSS} @tab -- GNAT
18129 @item @code{Post} @tab
18130 @item @code{Pre} @tab
18131 @item @code{Predicate} @tab
18132 @item @code{Preelaborable_Initialization} @tab
18133 @item @code{Pure_Function} @tab -- GNAT
18134 @item @code{Remote_Access_Type} @tab -- GNAT
18135 @item @code{Shared} @tab -- GNAT
18136 @item @code{Size} @tab
18137 @item @code{Storage_Pool} @tab
18138 @item @code{Storage_Size} @tab
18139 @item @code{Stream_Size} @tab
18140 @item @code{Suppress} @tab
18141 @item @code{Suppress_Debug_Info} @tab -- GNAT
18142 @item @code{Test_Case} @tab -- GNAT
18143 @item @code{Type_Invariant} @tab
18144 @item @code{Unchecked_Union} @tab
18145 @item @code{Universal_Aliasing} @tab -- GNAT
18146 @item @code{Unmodified} @tab -- GNAT
18147 @item @code{Unreferenced} @tab -- GNAT
18148 @item @code{Unreferenced_Objects} @tab -- GNAT
18149 @item @code{Unsuppress} @tab
18150 @item @code{Value_Size} @tab -- GNAT
18151 @item @code{Volatile} @tab
18152 @item @code{Volatile_Components}
18153 @item @code{Warnings} @tab -- GNAT
18154 @end multitable
18155
18156 @noindent
18157 Note that for aspects with an expression, e.g. @code{Size}, the expression is
18158 treated like a default expression (visibility is analyzed at the point of
18159 occurrence of the aspect, but evaluation of the expression occurs at the
18160 freeze point of the entity involved.
18161
18162 @noindent
18163 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
18164 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
18165 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
18166 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
18167 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
18168 13.03.01 (0)
18169
18170
18171 @item
18172 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
18173 @cindex AI-0128 (Ada 2012 feature)
18174
18175 @noindent
18176 If an equality operator ("=") is declared for a type, then the implicitly
18177 declared inequality operator ("/=") is a primitive operation of the type.
18178 This is the only reasonable interpretation, and is the one always implemented
18179 by GNAT, but the RM was not entirely clear in making this point.
18180
18181 @noindent
18182 RM References: 3.02.03 (6) 6.06 (6)
18183
18184 @item
18185 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
18186 @cindex AI-0003 (Ada 2012 feature)
18187
18188 @noindent
18189 In Ada 2012, a qualified expression is considered to be syntactically a name,
18190 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
18191 useful in disambiguating some cases of overloading.
18192
18193 @noindent
18194 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
18195 5.04 (7)
18196
18197 @item
18198 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
18199 @cindex AI-0120 (Ada 2012 feature)
18200
18201 @noindent
18202 This is an RM editorial change only. The section that lists objects that are
18203 constant failed to include the current instance of a protected object
18204 within a protected function. This has always been treated as a constant
18205 in GNAT.
18206
18207 @noindent
18208 RM References: 3.03 (21)
18209
18210 @item
18211 @emph{AI-0008 General access to constrained objects (0000-00-00)}
18212 @cindex AI-0008 (Ada 2012 feature)
18213
18214 @noindent
18215 The wording in the RM implied that if you have a general access to a
18216 constrained object, it could be used to modify the discriminants. This was
18217 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
18218 has always done so in this situation.
18219
18220 @noindent
18221 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
18222
18223
18224 @item
18225 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
18226 @cindex AI-0093 (Ada 2012 feature)
18227
18228 @noindent
18229 This is an editorial change only, to make more widespread use of the Ada 2012
18230 ``immutably limited''.
18231
18232 @noindent
18233 RM References: 3.03 (23.4/3)
18234
18235
18236
18237 @item
18238 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
18239 @cindex AI-0096 (Ada 2012 feature)
18240
18241 @noindent
18242 In general it is illegal for a type derived from a formal limited type to be
18243 nonlimited. This AI makes an exception to this rule: derivation is legal
18244 if it appears in the private part of the generic, and the formal type is not
18245 tagged. If the type is tagged, the legality check must be applied to the
18246 private part of the package.
18247
18248 @noindent
18249 RM References: 3.04 (5.1/2) 6.02 (7)
18250
18251
18252 @item
18253 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
18254 @cindex AI-0181 (Ada 2012 feature)
18255
18256 @noindent
18257 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
18258 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
18259 @code{Image} and @code{Value} attributes for the character types. Strictly
18260 speaking this is an inconsistency with Ada 95, but in practice the use of
18261 these attributes is so obscure that it will not cause problems.
18262
18263 @noindent
18264 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
18265
18266
18267 @item
18268 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
18269 @cindex AI-0182 (Ada 2012 feature)
18270
18271 @noindent
18272 This AI allows @code{Character'Value} to accept the string @code{'?'} where
18273 @code{?} is any character including non-graphic control characters. GNAT has
18274 always accepted such strings. It also allows strings such as
18275 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
18276 permission and raises @code{Constraint_Error}, as is certainly still
18277 permitted.
18278
18279 @noindent
18280 RM References: 3.05 (56/2)
18281
18282
18283 @item
18284 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
18285 @cindex AI-0214 (Ada 2012 feature)
18286
18287 @noindent
18288 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
18289 to have default expressions by allowing them when the type is limited. It
18290 is often useful to define a default value for a discriminant even though
18291 it can't be changed by assignment.
18292
18293 @noindent
18294 RM References: 3.07 (9.1/2) 3.07.02 (3)
18295
18296
18297 @item
18298 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
18299 @cindex AI-0102 (Ada 2012 feature)
18300
18301 @noindent
18302 It is illegal to assign an anonymous access constant to an anonymous access
18303 variable. The RM did not have a clear rule to prevent this, but GNAT has
18304 always generated an error for this usage.
18305
18306 @noindent
18307 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
18308
18309
18310 @item
18311 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
18312 @cindex AI-0158 (Ada 2012 feature)
18313
18314 @noindent
18315 This AI extends the syntax of membership tests to simplify complex conditions
18316 that can be expressed as membership in a subset of values of any type. It
18317 introduces syntax for a list of expressions that may be used in loop contexts
18318 as well.
18319
18320 @noindent
18321 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
18322
18323
18324 @item
18325 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
18326 @cindex AI-0173 (Ada 2012 feature)
18327
18328 @noindent
18329 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
18330 with the tag of an abstract type, and @code{False} otherwise.
18331
18332 @noindent
18333 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
18334
18335
18336
18337 @item
18338 @emph{AI-0076 function with controlling result (0000-00-00)}
18339 @cindex AI-0076 (Ada 2012 feature)
18340
18341 @noindent
18342 This is an editorial change only. The RM defines calls with controlling
18343 results, but uses the term ``function with controlling result'' without an
18344 explicit definition.
18345
18346 @noindent
18347 RM References: 3.09.02 (2/2)
18348
18349
18350 @item
18351 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
18352 @cindex AI-0126 (Ada 2012 feature)
18353
18354 @noindent
18355 This AI clarifies dispatching rules, and simply confirms that dispatching
18356 executes the operation of the parent type when there is no explicitly or
18357 implicitly declared operation for the descendant type. This has always been
18358 the case in all versions of GNAT.
18359
18360 @noindent
18361 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
18362
18363
18364 @item
18365 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
18366 @cindex AI-0097 (Ada 2012 feature)
18367
18368 @noindent
18369 The RM as written implied that in some cases it was possible to create an
18370 object of an abstract type, by having an abstract extension inherit a non-
18371 abstract constructor from its parent type. This mistake has been corrected
18372 in GNAT and in the RM, and this construct is now illegal.
18373
18374 @noindent
18375 RM References: 3.09.03 (4/2)
18376
18377
18378 @item
18379 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
18380 @cindex AI-0203 (Ada 2012 feature)
18381
18382 @noindent
18383 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
18384 permitted such usage.
18385
18386 @noindent
18387 RM References: 3.09.03 (8/3)
18388
18389
18390 @item
18391 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
18392 @cindex AI-0198 (Ada 2012 feature)
18393
18394 @noindent
18395 This AI resolves a conflict between two rules involving inherited abstract
18396 operations and predefined operators. If a derived numeric type inherits
18397 an abstract operator, it overrides the predefined one. This interpretation
18398 was always the one implemented in GNAT.
18399
18400 @noindent
18401 RM References: 3.09.03 (4/3)
18402
18403 @item
18404 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
18405 @cindex AI-0073 (Ada 2012 feature)
18406
18407 @noindent
18408 This AI covers a number of issues regarding returning abstract types. In
18409 particular generic functions cannot have abstract result types or access
18410 result types designated an abstract type. There are some other cases which
18411 are detailed in the AI. Note that this binding interpretation has not been
18412 retrofitted to operate before Ada 2012 mode, since it caused a significant
18413 number of regressions.
18414
18415 @noindent
18416 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
18417
18418
18419 @item
18420 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
18421 @cindex AI-0070 (Ada 2012 feature)
18422
18423 @noindent
18424 This is an editorial change only, there are no testable consequences short of
18425 checking for the absence of generated code for an interface declaration.
18426
18427 @noindent
18428 RM References: 3.09.04 (18/2)
18429
18430
18431 @item
18432 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
18433 @cindex AI-0208 (Ada 2012 feature)
18434
18435 @noindent
18436 The wording in the Ada 2005 RM concerning characteristics of incomplete views
18437 was incorrect and implied that some programs intended to be legal were now
18438 illegal. GNAT had never considered such programs illegal, so it has always
18439 implemented the intent of this AI.
18440
18441 @noindent
18442 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
18443
18444
18445 @item
18446 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
18447 @cindex AI-0162 (Ada 2012 feature)
18448
18449 @noindent
18450 Incomplete types are made more useful by allowing them to be completed by
18451 private types and private extensions.
18452
18453 @noindent
18454 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
18455
18456
18457
18458 @item
18459 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
18460 @cindex AI-0098 (Ada 2012 feature)
18461
18462 @noindent
18463 An unintentional omission in the RM implied some inconsistent restrictions on
18464 the use of anonymous access to subprogram values. These restrictions were not
18465 intentional, and have never been enforced by GNAT.
18466
18467 @noindent
18468 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
18469
18470
18471 @item
18472 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
18473 @cindex AI-0199 (Ada 2012 feature)
18474
18475 @noindent
18476 A choice list in a record aggregate can include several components of
18477 (distinct) anonymous access types as long as they have matching designated
18478 subtypes.
18479
18480 @noindent
18481 RM References: 4.03.01 (16)
18482
18483
18484 @item
18485 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
18486 @cindex AI-0220 (Ada 2012 feature)
18487
18488 @noindent
18489 This AI addresses a wording problem in the RM that appears to permit some
18490 complex cases of aggregates with non-static discriminants. GNAT has always
18491 implemented the intended semantics.
18492
18493 @noindent
18494 RM References: 4.03.01 (17)
18495
18496 @item
18497 @emph{AI-0147 Conditional expressions (2009-03-29)}
18498 @cindex AI-0147 (Ada 2012 feature)
18499
18500 @noindent
18501 Conditional expressions are permitted. The form of such an expression is:
18502
18503 @smallexample
18504 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
18505 @end smallexample
18506
18507 The parentheses can be omitted in contexts where parentheses are present
18508 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
18509 clause is omitted, @b{else True} is assumed;
18510 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
18511 @emph{(A implies B)} in standard logic.
18512
18513 @noindent
18514 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
18515 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
18516
18517
18518 @item
18519 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
18520 @cindex AI-0037 (Ada 2012 feature)
18521
18522 @noindent
18523 This AI confirms that an association of the form @code{Indx => <>} in an
18524 array aggregate must raise @code{Constraint_Error} if @code{Indx}
18525 is out of range. The RM specified a range check on other associations, but
18526 not when the value of the association was defaulted. GNAT has always inserted
18527 a constraint check on the index value.
18528
18529 @noindent
18530 RM References: 4.03.03 (29)
18531
18532
18533 @item
18534 @emph{AI-0123 Composability of equality (2010-04-13)}
18535 @cindex AI-0123 (Ada 2012 feature)
18536
18537 @noindent
18538 Equality of untagged record composes, so that the predefined equality for a
18539 composite type that includes a component of some untagged record type
18540 @code{R} uses the equality operation of @code{R} (which may be user-defined
18541 or predefined). This makes the behavior of untagged records identical to that
18542 of tagged types in this respect.
18543
18544 This change is an incompatibility with previous versions of Ada, but it
18545 corrects a non-uniformity that was often a source of confusion. Analysis of
18546 a large number of industrial programs indicates that in those rare cases
18547 where a composite type had an untagged record component with a user-defined
18548 equality, either there was no use of the composite equality, or else the code
18549 expected the same composability as for tagged types, and thus had a bug that
18550 would be fixed by this change.
18551
18552 @noindent
18553 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18554 8.05.04 (8)
18555
18556
18557 @item
18558 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18559 @cindex AI-0088 (Ada 2012 feature)
18560
18561 @noindent
18562 This AI clarifies the equivalence rule given for the dynamic semantics of
18563 exponentiation: the value of the operation can be obtained by repeated
18564 multiplication, but the operation can be implemented otherwise (for example
18565 using the familiar divide-by-two-and-square algorithm, even if this is less
18566 accurate), and does not imply repeated reads of a volatile base.
18567
18568 @noindent
18569 RM References: 4.05.06 (11)
18570
18571 @item
18572 @emph{AI-0188 Case expressions (2010-01-09)}
18573 @cindex AI-0188 (Ada 2012 feature)
18574
18575 @noindent
18576 Case expressions are permitted. This allows use of constructs such as:
18577 @smallexample
18578 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18579 @end smallexample
18580
18581 @noindent
18582 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18583
18584 @item
18585 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18586 @cindex AI-0104 (Ada 2012 feature)
18587
18588 @noindent
18589 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18590 @code{Constraint_Error} because the default value of the allocated object is
18591 @b{null}. This useless construct is illegal in Ada 2012.
18592
18593 @noindent
18594 RM References: 4.08 (2)
18595
18596 @item
18597 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18598 @cindex AI-0157 (Ada 2012 feature)
18599
18600 @noindent
18601 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18602 deallocation of a pointer for which a static storage size clause of zero
18603 has been given) is now illegal and is detected as such. GNAT
18604 previously gave a warning but not an error.
18605
18606 @noindent
18607 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18608
18609 @item
18610 @emph{AI-0179 Statement not required after label (2010-04-10)}
18611 @cindex AI-0179 (Ada 2012 feature)
18612
18613 @noindent
18614 It is not necessary to have a statement following a label, so a label
18615 can appear at the end of a statement sequence without the need for putting a
18616 null statement afterwards, but it is not allowable to have only labels and
18617 no real statements in a statement sequence.
18618
18619 @noindent
18620 RM References: 5.01 (2)
18621
18622
18623 @item
18624 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18625 @cindex AI-139-2 (Ada 2012 feature)
18626
18627 @noindent
18628 The new syntax for iterating over arrays and containers is now implemented.
18629 Iteration over containers is for now limited to read-only iterators. Only
18630 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18631
18632 @noindent
18633 RM References: 5.05
18634
18635 @item
18636 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18637 @cindex AI-0134 (Ada 2012 feature)
18638
18639 @noindent
18640 For full conformance, the profiles of anonymous-access-to-subprogram
18641 parameters must match. GNAT has always enforced this rule.
18642
18643 @noindent
18644 RM References: 6.03.01 (18)
18645
18646 @item
18647 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18648 @cindex AI-0207 (Ada 2012 feature)
18649
18650 @noindent
18651 This AI confirms that access_to_constant indication must match for mode
18652 conformance. This was implemented in GNAT when the qualifier was originally
18653 introduced in Ada 2005.
18654
18655 @noindent
18656 RM References: 6.03.01 (16/2)
18657
18658
18659 @item
18660 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18661 @cindex AI-0046 (Ada 2012 feature)
18662
18663 @noindent
18664 For full conformance, in the case of access parameters, the null exclusion
18665 must match (either both or neither must have @code{@b{not null}}).
18666
18667 @noindent
18668 RM References: 6.03.02 (18)
18669
18670
18671 @item
18672 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18673 @cindex AI-0118 (Ada 2012 feature)
18674
18675 @noindent
18676 This AI clarifies the rules for named associations in subprogram calls and
18677 generic instantiations. The rules have been in place since Ada 83.
18678
18679 @noindent
18680 RM References: 6.04.01 (2) 12.03 (9)
18681
18682
18683 @item
18684 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18685 @cindex AI-0196 (Ada 2012 feature)
18686
18687 @noindent
18688 Null exclusion checks are not made for @code{@b{out}} parameters when
18689 evaluating the actual parameters. GNAT has never generated these checks.
18690
18691 @noindent
18692 RM References: 6.04.01 (13)
18693
18694 @item
18695 @emph{AI-0015 Constant return objects (0000-00-00)}
18696 @cindex AI-0015 (Ada 2012 feature)
18697
18698 @noindent
18699 The return object declared in an @i{extended_return_statement} may be
18700 declared constant. This was always intended, and GNAT has always allowed it.
18701
18702 @noindent
18703 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18704 6.05 (5.7/2)
18705
18706
18707 @item
18708 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18709 @cindex AI-0032 (Ada 2012 feature)
18710
18711 @noindent
18712 If a function returns a class-wide type, the object of an extended return
18713 statement can be declared with a specific type that is covered by the class-
18714 wide type. This has been implemented in GNAT since the introduction of
18715 extended returns. Note AI-0103 complements this AI by imposing matching
18716 rules for constrained return types.
18717
18718 @noindent
18719 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18720 6.05 (8/2)
18721
18722 @item
18723 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18724 @cindex AI-0103 (Ada 2012 feature)
18725
18726 @noindent
18727 If the return subtype of a function is an elementary type or a constrained
18728 type, the subtype indication in an extended return statement must match
18729 statically this return subtype.
18730
18731 @noindent
18732 RM References: 6.05 (5.2/2)
18733
18734
18735 @item
18736 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18737 @cindex AI-0058 (Ada 2012 feature)
18738
18739 @noindent
18740 The RM had some incorrect wording implying wrong treatment of abnormal
18741 completion in an extended return. GNAT has always implemented the intended
18742 correct semantics as described by this AI.
18743
18744 @noindent
18745 RM References: 6.05 (22/2)
18746
18747
18748 @item
18749 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18750 @cindex AI-0050 (Ada 2012 feature)
18751
18752 @noindent
18753 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
18754 not take advantage of these incorrect permissions in any case.
18755
18756 @noindent
18757 RM References: 6.05 (24/2)
18758
18759
18760 @item
18761 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18762 @cindex AI-0125 (Ada 2012 feature)
18763
18764 @noindent
18765 In Ada 2012, the declaration of a primitive operation of a type extension
18766 or private extension can also override an inherited primitive that is not
18767 visible at the point of this declaration.
18768
18769 @noindent
18770 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18771
18772 @item
18773 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18774 @cindex AI-0062 (Ada 2012 feature)
18775
18776 @noindent
18777 A full constant may have a null exclusion even if its associated deferred
18778 constant does not. GNAT has always allowed this.
18779
18780 @noindent
18781 RM References: 7.04 (6/2) 7.04 (7.1/2)
18782
18783
18784 @item
18785 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18786 @cindex AI-0178 (Ada 2012 feature)
18787
18788 @noindent
18789 This AI clarifies the role of incomplete views and plugs an omission in the
18790 RM. GNAT always correctly restricted the use of incomplete views and types.
18791
18792 @noindent
18793 RM References: 7.05 (3/2) 7.05 (6/2)
18794
18795 @item
18796 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18797 @cindex AI-0087 (Ada 2012 feature)
18798
18799 @noindent
18800 The actual for a formal nonlimited derived type cannot be limited. In
18801 particular, a formal derived type that extends a limited interface but which
18802 is not explicitly limited cannot be instantiated with a limited type.
18803
18804 @noindent
18805 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18806
18807 @item
18808 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18809 @cindex AI-0099 (Ada 2012 feature)
18810
18811 @noindent
18812 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18813 and therefore depends on the run-time characteristics of an object (i.e. its
18814 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18815 this to affect any implementation''.
18816
18817 @noindent
18818 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18819
18820
18821
18822 @item
18823 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18824 @cindex AI-0064 (Ada 2012 feature)
18825
18826 @noindent
18827 This is an editorial change only. The intended behavior is already checked
18828 by an existing ACATS test, which GNAT has always executed correctly.
18829
18830 @noindent
18831 RM References: 7.06.01 (17.1/1)
18832
18833 @item
18834 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18835 @cindex AI-0026 (Ada 2012 feature)
18836
18837 @noindent
18838 Record representation clauses concerning Unchecked_Union types cannot mention
18839 the discriminant of the type. The type of a component declared in the variant
18840 part of an Unchecked_Union cannot be controlled, have controlled components,
18841 nor have protected or task parts. If an Unchecked_Union type is declared
18842 within the body of a generic unit or its descendants, then the type of a
18843 component declared in the variant part cannot be a formal private type or a
18844 formal private extension declared within the same generic unit.
18845
18846 @noindent
18847 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18848
18849
18850 @item
18851 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18852 @cindex AI-0205 (Ada 2012 feature)
18853
18854 @noindent
18855 This AI corrects a simple omission in the RM. Return objects have always
18856 been visible within an extended return statement.
18857
18858 @noindent
18859 RM References: 8.03 (17)
18860
18861
18862 @item
18863 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18864 @cindex AI-0042 (Ada 2012 feature)
18865
18866 @noindent
18867 This AI fixes a wording gap in the RM. An operation of a synchronized
18868 interface can be implemented by a protected or task entry, but the abstract
18869 operation is not being overridden in the usual sense, and it must be stated
18870 separately that this implementation is legal. This has always been the case
18871 in GNAT.
18872
18873 @noindent
18874 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18875
18876 @item
18877 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18878 @cindex AI-0030 (Ada 2012 feature)
18879
18880 @noindent
18881 Requeue is permitted to a protected, synchronized or task interface primitive
18882 providing it is known that the overriding operation is an entry. Otherwise
18883 the requeue statement has the same effect as a procedure call. Use of pragma
18884 @code{Implemented} provides a way to impose a static requirement on the
18885 overriding operation by adhering to one of the implementation kinds: entry,
18886 protected procedure or any of the above.
18887
18888 @noindent
18889 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18890 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18891
18892
18893 @item
18894 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18895 @cindex AI-0201 (Ada 2012 feature)
18896
18897 @noindent
18898 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18899 attribute, then individual components may not be addressable by independent
18900 tasks. However, if the representation clause has no effect (is confirming),
18901 then independence is not compromised. Furthermore, in GNAT, specification of
18902 other appropriately addressable component sizes (e.g. 16 for 8-bit
18903 characters) also preserves independence. GNAT now gives very clear warnings
18904 both for the declaration of such a type, and for any assignment to its components.
18905
18906 @noindent
18907 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18908
18909 @item
18910 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18911 @cindex AI-0009 (Ada 2012 feature)
18912
18913 @noindent
18914 This AI introduces the new pragmas @code{Independent} and
18915 @code{Independent_Components},
18916 which control guaranteeing independence of access to objects and components.
18917 The AI also requires independence not unaffected by confirming rep clauses.
18918
18919 @noindent
18920 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18921 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18922
18923
18924 @item
18925 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18926 @cindex AI-0072 (Ada 2012 feature)
18927
18928 @noindent
18929 This AI clarifies that task signalling for reading @code{'Terminated} only
18930 occurs if the result is True. GNAT semantics has always been consistent with
18931 this notion of task signalling.
18932
18933 @noindent
18934 RM References: 9.10 (6.1/1)
18935
18936 @item
18937 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18938 @cindex AI-0108 (Ada 2012 feature)
18939
18940 @noindent
18941 This AI confirms that an incomplete type from a limited view does not have
18942 discriminants. This has always been the case in GNAT.
18943
18944 @noindent
18945 RM References: 10.01.01 (12.3/2)
18946
18947 @item
18948 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18949 @cindex AI-0129 (Ada 2012 feature)
18950
18951 @noindent
18952 This AI clarifies the description of limited views: a limited view of a
18953 package includes only one view of a type that has an incomplete declaration
18954 and a full declaration (there is no possible ambiguity in a client package).
18955 This AI also fixes an omission: a nested package in the private part has no
18956 limited view. GNAT always implemented this correctly.
18957
18958 @noindent
18959 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18960
18961
18962
18963 @item
18964 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18965 @cindex AI-0077 (Ada 2012 feature)
18966
18967 @noindent
18968 This AI clarifies that a declaration does not include a context clause,
18969 and confirms that it is illegal to have a context in which both a limited
18970 and a nonlimited view of a package are accessible. Such double visibility
18971 was always rejected by GNAT.
18972
18973 @noindent
18974 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18975
18976 @item
18977 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18978 @cindex AI-0122 (Ada 2012 feature)
18979
18980 @noindent
18981 This AI clarifies the visibility of private children of generic units within
18982 instantiations of a parent. GNAT has always handled this correctly.
18983
18984 @noindent
18985 RM References: 10.01.02 (12/2)
18986
18987
18988
18989 @item
18990 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18991 @cindex AI-0040 (Ada 2012 feature)
18992
18993 @noindent
18994 This AI confirms that a limited with clause in a child unit cannot name
18995 an ancestor of the unit. This has always been checked in GNAT.
18996
18997 @noindent
18998 RM References: 10.01.02 (20/2)
18999
19000 @item
19001 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
19002 @cindex AI-0132 (Ada 2012 feature)
19003
19004 @noindent
19005 This AI fills a gap in the description of library unit pragmas. The pragma
19006 clearly must apply to a library unit, even if it does not carry the name
19007 of the enclosing unit. GNAT has always enforced the required check.
19008
19009 @noindent
19010 RM References: 10.01.05 (7)
19011
19012
19013 @item
19014 @emph{AI-0034 Categorization of limited views (0000-00-00)}
19015 @cindex AI-0034 (Ada 2012 feature)
19016
19017 @noindent
19018 The RM makes certain limited with clauses illegal because of categorization
19019 considerations, when the corresponding normal with would be legal. This is
19020 not intended, and GNAT has always implemented the recommended behavior.
19021
19022 @noindent
19023 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
19024
19025
19026 @item
19027 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
19028 @cindex AI-0035 (Ada 2012 feature)
19029
19030 @noindent
19031 This AI remedies some inconsistencies in the legality rules for Pure units.
19032 Derived access types are legal in a pure unit (on the assumption that the
19033 rule for a zero storage pool size has been enforced on the ancestor type).
19034 The rules are enforced in generic instances and in subunits. GNAT has always
19035 implemented the recommended behavior.
19036
19037 @noindent
19038 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)
19039
19040
19041 @item
19042 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
19043 @cindex AI-0219 (Ada 2012 feature)
19044
19045 @noindent
19046 This AI refines the rules for the cases with limited parameters which do not
19047 allow the implementations to omit ``redundant''. GNAT now properly conforms
19048 to the requirements of this binding interpretation.
19049
19050 @noindent
19051 RM References: 10.02.01 (18/2)
19052
19053 @item
19054 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
19055 @cindex AI-0043 (Ada 2012 feature)
19056
19057 @noindent
19058 This AI covers various omissions in the RM regarding the raising of
19059 exceptions. GNAT has always implemented the intended semantics.
19060
19061 @noindent
19062 RM References: 11.04.01 (10.1/2) 11 (2)
19063
19064
19065 @item
19066 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
19067 @cindex AI-0200 (Ada 2012 feature)
19068
19069 @noindent
19070 This AI plugs a gap in the RM which appeared to allow some obviously intended
19071 illegal instantiations. GNAT has never allowed these instantiations.
19072
19073 @noindent
19074 RM References: 12.07 (16)
19075
19076
19077 @item
19078 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
19079 @cindex AI-0112 (Ada 2012 feature)
19080
19081 @noindent
19082 This AI concerns giving names to various representation aspects, but the
19083 practical effect is simply to make the use of duplicate
19084 @code{Atomic}[@code{_Components}],
19085 @code{Volatile}[@code{_Components}] and
19086 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
19087 now performs this required check.
19088
19089 @noindent
19090 RM References: 13.01 (8)
19091
19092 @item
19093 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
19094 @cindex AI-0106 (Ada 2012 feature)
19095
19096 @noindent
19097 The RM appeared to allow representation pragmas on generic formal parameters,
19098 but this was not intended, and GNAT has never permitted this usage.
19099
19100 @noindent
19101 RM References: 13.01 (9.1/1)
19102
19103
19104 @item
19105 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
19106 @cindex AI-0012 (Ada 2012 feature)
19107
19108 @noindent
19109 It is now illegal to give an inappropriate component size or a pragma
19110 @code{Pack} that attempts to change the component size in the case of atomic
19111 or aliased components. Previously GNAT ignored such an attempt with a
19112 warning.
19113
19114 @noindent
19115 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
19116
19117
19118 @item
19119 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
19120 @cindex AI-0039 (Ada 2012 feature)
19121
19122 @noindent
19123 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
19124 for stream attributes, but these were never useful and are now illegal. GNAT
19125 has always regarded such expressions as illegal.
19126
19127 @noindent
19128 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
19129
19130
19131 @item
19132 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
19133 @cindex AI-0095 (Ada 2012 feature)
19134
19135 @noindent
19136 The prefix of @code{'Address} cannot statically denote a subprogram with
19137 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
19138 @code{Program_Error} if the prefix denotes a subprogram with convention
19139 @code{Intrinsic}.
19140
19141 @noindent
19142 RM References: 13.03 (11/1)
19143
19144
19145 @item
19146 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
19147 @cindex AI-0116 (Ada 2012 feature)
19148
19149 @noindent
19150 This AI requires that the alignment of a class-wide object be no greater
19151 than the alignment of any type in the class. GNAT has always followed this
19152 recommendation.
19153
19154 @noindent
19155 RM References: 13.03 (29) 13.11 (16)
19156
19157
19158 @item
19159 @emph{AI-0146 Type invariants (2009-09-21)}
19160 @cindex AI-0146 (Ada 2012 feature)
19161
19162 @noindent
19163 Type invariants may be specified for private types using the aspect notation.
19164 Aspect @code{Type_Invariant} may be specified for any private type,
19165 @code{Type_Invariant'Class} can
19166 only be specified for tagged types, and is inherited by any descendent of the
19167 tagged types. The invariant is a boolean expression that is tested for being
19168 true in the following situations: conversions to the private type, object
19169 declarations for the private type that are default initialized, and
19170 [@b{in}] @b{out}
19171 parameters and returned result on return from any primitive operation for
19172 the type that is visible to a client.
19173 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
19174 @code{Invariant'Class} for @code{Type_Invariant'Class}.
19175
19176 @noindent
19177 RM References: 13.03.03 (00)
19178
19179 @item
19180 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
19181 @cindex AI-0078 (Ada 2012 feature)
19182
19183 @noindent
19184 In Ada 2012, compilers are required to support unchecked conversion where the
19185 target alignment is a multiple of the source alignment. GNAT always supported
19186 this case (and indeed all cases of differing alignments, doing copies where
19187 required if the alignment was reduced).
19188
19189 @noindent
19190 RM References: 13.09 (7)
19191
19192
19193 @item
19194 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
19195 @cindex AI-0195 (Ada 2012 feature)
19196
19197 @noindent
19198 The handling of invalid values is now designated to be implementation
19199 defined. This is a documentation change only, requiring Annex M in the GNAT
19200 Reference Manual to document this handling.
19201 In GNAT, checks for invalid values are made
19202 only when necessary to avoid erroneous behavior. Operations like assignments
19203 which cannot cause erroneous behavior ignore the possibility of invalid
19204 values and do not do a check. The date given above applies only to the
19205 documentation change, this behavior has always been implemented by GNAT.
19206
19207 @noindent
19208 RM References: 13.09.01 (10)
19209
19210 @item
19211 @emph{AI-0193 Alignment of allocators (2010-09-16)}
19212 @cindex AI-0193 (Ada 2012 feature)
19213
19214 @noindent
19215 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
19216 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
19217 of size.
19218
19219 @noindent
19220 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
19221 13.11.01 (2) 13.11.01 (3)
19222
19223
19224 @item
19225 @emph{AI-0177 Parameterized expressions (2010-07-10)}
19226 @cindex AI-0177 (Ada 2012 feature)
19227
19228 @noindent
19229 The new Ada 2012 notion of parameterized expressions is implemented. The form
19230 is:
19231 @smallexample
19232 @i{function specification} @b{is} (@i{expression})
19233 @end smallexample
19234
19235 @noindent
19236 This is exactly equivalent to the
19237 corresponding function body that returns the expression, but it can appear
19238 in a package spec. Note that the expression must be parenthesized.
19239
19240 @noindent
19241 RM References: 13.11.01 (3/2)
19242
19243 @item
19244 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
19245 @cindex AI-0033 (Ada 2012 feature)
19246
19247 @noindent
19248 Neither of these two pragmas may appear within a generic template, because
19249 the generic might be instantiated at other than the library level.
19250
19251 @noindent
19252 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
19253
19254
19255 @item
19256 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
19257 @cindex AI-0161 (Ada 2012 feature)
19258
19259 @noindent
19260 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
19261 of the default stream attributes for elementary types. If this restriction is
19262 in force, then it is necessary to provide explicit subprograms for any
19263 stream attributes used.
19264
19265 @noindent
19266 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
19267
19268 @item
19269 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
19270 @cindex AI-0194 (Ada 2012 feature)
19271
19272 @noindent
19273 The @code{Stream_Size} attribute returns the default number of bits in the
19274 stream representation of the given type.
19275 This value is not affected by the presence
19276 of stream subprogram attributes for the type. GNAT has always implemented
19277 this interpretation.
19278
19279 @noindent
19280 RM References: 13.13.02 (1.2/2)
19281
19282 @item
19283 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
19284 @cindex AI-0109 (Ada 2012 feature)
19285
19286 @noindent
19287 This AI is an editorial change only. It removes the need for a tag check
19288 that can never fail.
19289
19290 @noindent
19291 RM References: 13.13.02 (34/2)
19292
19293 @item
19294 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
19295 @cindex AI-0007 (Ada 2012 feature)
19296
19297 @noindent
19298 The RM as written appeared to limit the possibilities of declaring read
19299 attribute procedures for private scalar types. This limitation was not
19300 intended, and has never been enforced by GNAT.
19301
19302 @noindent
19303 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
19304
19305
19306 @item
19307 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
19308 @cindex AI-0065 (Ada 2012 feature)
19309
19310 @noindent
19311 This AI clarifies the fact that all remote access types support external
19312 streaming. This fixes an obvious oversight in the definition of the
19313 language, and GNAT always implemented the intended correct rules.
19314
19315 @noindent
19316 RM References: 13.13.02 (52/2)
19317
19318 @item
19319 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
19320 @cindex AI-0019 (Ada 2012 feature)
19321
19322 @noindent
19323 The RM suggests that primitive subprograms of a specific tagged type are
19324 frozen when the tagged type is frozen. This would be an incompatible change
19325 and is not intended. GNAT has never attempted this kind of freezing and its
19326 behavior is consistent with the recommendation of this AI.
19327
19328 @noindent
19329 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)
19330
19331 @item
19332 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
19333 @cindex AI-0017 (Ada 2012 feature)
19334
19335 @noindent
19336 So-called ``Taft-amendment types'' (i.e., types that are completed in package
19337 bodies) are not frozen by the occurrence of bodies in the
19338 enclosing declarative part. GNAT always implemented this properly.
19339
19340 @noindent
19341 RM References: 13.14 (3/1)
19342
19343
19344 @item
19345 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
19346 @cindex AI-0060 (Ada 2012 feature)
19347
19348 @noindent
19349 This AI extends the definition of remote access types to include access
19350 to limited, synchronized, protected or task class-wide interface types.
19351 GNAT already implemented this extension.
19352
19353 @noindent
19354 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
19355
19356 @item
19357 @emph{AI-0114 Classification of letters (0000-00-00)}
19358 @cindex AI-0114 (Ada 2012 feature)
19359
19360 @noindent
19361 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
19362 181 (@code{MICRO SIGN}), and
19363 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
19364 lower case letters by Unicode.
19365 However, they are not allowed in identifiers, and they
19366 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
19367 This behavior is consistent with that defined in Ada 95.
19368
19369 @noindent
19370 RM References: A.03.02 (59) A.04.06 (7)
19371
19372
19373 @item
19374 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
19375 @cindex AI-0185 (Ada 2012 feature)
19376
19377 @noindent
19378 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
19379 classification functions for @code{Wide_Character} and
19380 @code{Wide_Wide_Character}, as well as providing
19381 case folding routines for @code{Wide_[Wide_]Character} and
19382 @code{Wide_[Wide_]String}.
19383
19384 @noindent
19385 RM References: A.03.05 (0) A.03.06 (0)
19386
19387
19388 @item
19389 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
19390 @cindex AI-0031 (Ada 2012 feature)
19391
19392 @noindent
19393 A new version of @code{Find_Token} is added to all relevant string packages,
19394 with an extra parameter @code{From}. Instead of starting at the first
19395 character of the string, the search for a matching Token starts at the
19396 character indexed by the value of @code{From}.
19397 These procedures are available in all versions of Ada
19398 but if used in versions earlier than Ada 2012 they will generate a warning
19399 that an Ada 2012 subprogram is being used.
19400
19401 @noindent
19402 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
19403 A.04.05 (46)
19404
19405
19406 @item
19407 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
19408 @cindex AI-0056 (Ada 2012 feature)
19409
19410 @noindent
19411 The wording in the Ada 2005 RM implied an incompatible handling of the
19412 @code{Index} functions, resulting in raising an exception instead of
19413 returning zero in some situations.
19414 This was not intended and has been corrected.
19415 GNAT always returned zero, and is thus consistent with this AI.
19416
19417 @noindent
19418 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
19419
19420
19421 @item
19422 @emph{AI-0137 String encoding package (2010-03-25)}
19423 @cindex AI-0137 (Ada 2012 feature)
19424
19425 @noindent
19426 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
19427 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
19428 and @code{Wide_Wide_Strings} have been
19429 implemented. These packages (whose documentation can be found in the spec
19430 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
19431 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
19432 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
19433 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
19434 UTF-16), as well as conversions between the different UTF encodings. With
19435 the exception of @code{Wide_Wide_Strings}, these packages are available in
19436 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
19437 The @code{Wide_Wide_Strings package}
19438 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
19439 mode since it uses @code{Wide_Wide_Character}).
19440
19441 @noindent
19442 RM References: A.04.11
19443
19444 @item
19445 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
19446 @cindex AI-0038 (Ada 2012 feature)
19447
19448 @noindent
19449 These are minor errors in the description on three points. The intent on
19450 all these points has always been clear, and GNAT has always implemented the
19451 correct intended semantics.
19452
19453 @noindent
19454 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)
19455
19456 @item
19457 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
19458 @cindex AI-0044 (Ada 2012 feature)
19459
19460 @noindent
19461 This AI places restrictions on allowed instantiations of generic containers.
19462 These restrictions are not checked by the compiler, so there is nothing to
19463 change in the implementation. This affects only the RM documentation.
19464
19465 @noindent
19466 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)
19467
19468 @item
19469 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
19470 @cindex AI-0127 (Ada 2012 feature)
19471
19472 @noindent
19473 This package provides an interface for identifying the current locale.
19474
19475 @noindent
19476 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
19477 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
19478
19479
19480
19481 @item
19482 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
19483 @cindex AI-0002 (Ada 2012 feature)
19484
19485 @noindent
19486 The compiler is not required to support exporting an Ada subprogram with
19487 convention C if there are parameters or a return type of an unconstrained
19488 array type (such as @code{String}). GNAT allows such declarations but
19489 generates warnings. It is possible, but complicated, to write the
19490 corresponding C code and certainly such code would be specific to GNAT and
19491 non-portable.
19492
19493 @noindent
19494 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
19495
19496
19497 @item
19498 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
19499 @cindex AI05-0216 (Ada 2012 feature)
19500
19501 @noindent
19502 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
19503 forbid tasks declared locally within subprograms, or functions returning task
19504 objects, and that is the implementation that GNAT has always provided.
19505 However the language in the RM was not sufficiently clear on this point.
19506 Thus this is a documentation change in the RM only.
19507
19508 @noindent
19509 RM References: D.07 (3/3)
19510
19511 @item
19512 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
19513 @cindex AI-0211 (Ada 2012 feature)
19514
19515 @noindent
19516 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
19517 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
19518
19519 @noindent
19520 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
19521
19522 @item
19523 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
19524 @cindex AI-0190 (Ada 2012 feature)
19525
19526 @noindent
19527 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
19528 used to control storage pools globally.
19529 In particular, you can force every access
19530 type that is used for allocation (@b{new}) to have an explicit storage pool,
19531 or you can declare a pool globally to be used for all access types that lack
19532 an explicit one.
19533
19534 @noindent
19535 RM References: D.07 (8)
19536
19537 @item
19538 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19539 @cindex AI-0189 (Ada 2012 feature)
19540
19541 @noindent
19542 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19543 which says that no dynamic allocation will occur once elaboration is
19544 completed.
19545 In general this requires a run-time check, which is not required, and which
19546 GNAT does not attempt. But the static cases of allocators in a task body or
19547 in the body of the main program are detected and flagged at compile or bind
19548 time.
19549
19550 @noindent
19551 RM References: D.07 (19.1/2) H.04 (23.3/2)
19552
19553 @item
19554 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19555 @cindex AI-0171 (Ada 2012 feature)
19556
19557 @noindent
19558 A new package @code{System.Multiprocessors} is added, together with the
19559 definition of pragma @code{CPU} for controlling task affinity. A new no
19560 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19561 is added to the Ravenscar profile.
19562
19563 @noindent
19564 RM References: D.13.01 (4/2) D.16
19565
19566
19567 @item
19568 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19569 @cindex AI-0210 (Ada 2012 feature)
19570
19571 @noindent
19572 This is a documentation only issue regarding wording of metric requirements,
19573 that does not affect the implementation of the compiler.
19574
19575 @noindent
19576 RM References: D.15 (24/2)
19577
19578
19579 @item
19580 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19581 @cindex AI-0206 (Ada 2012 feature)
19582
19583 @noindent
19584 Remote types packages are now allowed to depend on preelaborated packages.
19585 This was formerly considered illegal.
19586
19587 @noindent
19588 RM References: E.02.02 (6)
19589
19590
19591
19592 @item
19593 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19594 @cindex AI-0152 (Ada 2012 feature)
19595
19596 @noindent
19597 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19598 where the type of the returned value is an anonymous access type.
19599
19600 @noindent
19601 RM References: H.04 (8/1)
19602 @end itemize
19603
19604
19605 @node Obsolescent Features
19606 @chapter Obsolescent Features
19607
19608 @noindent
19609 This chapter describes features that are provided by GNAT, but are
19610 considered obsolescent since there are preferred ways of achieving
19611 the same effect. These features are provided solely for historical
19612 compatibility purposes.
19613
19614 @menu
19615 * pragma No_Run_Time::
19616 * pragma Ravenscar::
19617 * pragma Restricted_Run_Time::
19618 @end menu
19619
19620 @node pragma No_Run_Time
19621 @section pragma No_Run_Time
19622
19623 The pragma @code{No_Run_Time} is used to achieve an affect similar
19624 to the use of the "Zero Foot Print" configurable run time, but without
19625 requiring a specially configured run time. The result of using this
19626 pragma, which must be used for all units in a partition, is to restrict
19627 the use of any language features requiring run-time support code. The
19628 preferred usage is to use an appropriately configured run-time that
19629 includes just those features that are to be made accessible.
19630
19631 @node pragma Ravenscar
19632 @section pragma Ravenscar
19633
19634 The pragma @code{Ravenscar} has exactly the same effect as pragma
19635 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19636 is part of the new Ada 2005 standard.
19637
19638 @node pragma Restricted_Run_Time
19639 @section pragma Restricted_Run_Time
19640
19641 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19642 pragma @code{Profile (Restricted)}. The latter usage is
19643 preferred since the Ada 2005 pragma @code{Profile} is intended for
19644 this kind of implementation dependent addition.
19645
19646 @include fdl.texi
19647 @c GNU Free Documentation License
19648
19649 @node Index,,GNU Free Documentation License, Top
19650 @unnumbered Index
19651
19652 @printindex cp
19653
19654 @contents
19655
19656 @bye