09fcb145fa4e9a2630010e0a55f537c3ba5c18ff
[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-2008, 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 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Obsolescent Features::
85 * GNU Free Documentation License::
86 * Index::
87
88 --- The Detailed Node Listing ---
89
90 About This Guide
91
92 * What This Reference Manual Contains::
93 * Related Information::
94
95 Implementation Defined Pragmas
96
97 * Pragma Abort_Defer::
98 * Pragma Ada_83::
99 * Pragma Ada_95::
100 * Pragma Ada_05::
101 * Pragma Ada_2005::
102 * Pragma Ada_12::
103 * Pragma Ada_2012::
104 * Pragma Annotate::
105 * Pragma Assert::
106 * Pragma Assume_No_Invalid_Values::
107 * Pragma Ast_Entry::
108 * Pragma C_Pass_By_Copy::
109 * Pragma Check::
110 * Pragma Check_Name::
111 * Pragma Check_Policy::
112 * Pragma Comment::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Compiler_Unit::
117 * Pragma Complete_Representation::
118 * Pragma Complex_Representation::
119 * Pragma Component_Alignment::
120 * Pragma Convention_Identifier::
121 * Pragma CPP_Class::
122 * Pragma CPP_Constructor::
123 * Pragma CPP_Virtual::
124 * Pragma CPP_Vtable::
125 * Pragma Debug::
126 * Pragma Debug_Policy::
127 * Pragma Detect_Blocking::
128 * Pragma Elaboration_Checks::
129 * Pragma Eliminate::
130 * Pragma Export_Exception::
131 * Pragma Export_Function::
132 * Pragma Export_Object::
133 * Pragma Export_Procedure::
134 * Pragma Export_Value::
135 * Pragma Export_Valued_Procedure::
136 * Pragma Extend_System::
137 * Pragma Extensions_Allowed::
138 * Pragma External::
139 * Pragma External_Name_Casing::
140 * Pragma Fast_Math::
141 * Pragma Favor_Top_Level::
142 * Pragma Finalize_Storage_Only::
143 * Pragma Float_Representation::
144 * Pragma Ident::
145 * Pragma Implemented_By_Entry::
146 * Pragma Implicit_Packing::
147 * Pragma Import_Exception::
148 * Pragma Import_Function::
149 * Pragma Import_Object::
150 * Pragma Import_Procedure::
151 * Pragma Import_Valued_Procedure::
152 * Pragma Initialize_Scalars::
153 * Pragma Inline_Always::
154 * Pragma Inline_Generic::
155 * Pragma Interface::
156 * Pragma Interface_Name::
157 * Pragma Interrupt_Handler::
158 * Pragma Interrupt_State::
159 * Pragma Keep_Names::
160 * Pragma License::
161 * Pragma Link_With::
162 * Pragma Linker_Alias::
163 * Pragma Linker_Constructor::
164 * Pragma Linker_Destructor::
165 * Pragma Linker_Section::
166 * Pragma Long_Float::
167 * Pragma Machine_Attribute::
168 * Pragma Main::
169 * Pragma Main_Storage::
170 * Pragma No_Body::
171 * Pragma No_Return::
172 * Pragma No_Strict_Aliasing ::
173 * Pragma Normalize_Scalars::
174 * Pragma Obsolescent::
175 * Pragma Optimize_Alignment::
176 * Pragma Ordered::
177 * Pragma Passive::
178 * Pragma Persistent_BSS::
179 * Pragma Polling::
180 * Pragma Postcondition::
181 * Pragma Precondition::
182 * Pragma Profile (Ravenscar)::
183 * Pragma Profile (Restricted)::
184 * Pragma Psect_Object::
185 * Pragma Pure_Function::
186 * Pragma Restriction_Warnings::
187 * Pragma Shared::
188 * Pragma Short_Circuit_And_Or::
189 * Pragma Source_File_Name::
190 * Pragma Source_File_Name_Project::
191 * Pragma Source_Reference::
192 * Pragma Stream_Convert::
193 * Pragma Style_Checks::
194 * Pragma Subtitle::
195 * Pragma Suppress::
196 * Pragma Suppress_All::
197 * Pragma Suppress_Exception_Locations::
198 * Pragma Suppress_Initialization::
199 * Pragma Task_Info::
200 * Pragma Task_Name::
201 * Pragma Task_Storage::
202 * Pragma Thread_Local_Storage::
203 * Pragma Time_Slice::
204 * Pragma Title::
205 * Pragma Unchecked_Union::
206 * Pragma Unimplemented_Unit::
207 * Pragma Universal_Aliasing ::
208 * Pragma Universal_Data::
209 * Pragma Unmodified::
210 * Pragma Unreferenced::
211 * Pragma Unreferenced_Objects::
212 * Pragma Unreserve_All_Interrupts::
213 * Pragma Unsuppress::
214 * Pragma Use_VADS_Size::
215 * Pragma Validity_Checks::
216 * Pragma Volatile::
217 * Pragma Warnings::
218 * Pragma Weak_External::
219 * Pragma Wide_Character_Encoding::
220
221 Implementation Defined Attributes
222
223 * Abort_Signal::
224 * Address_Size::
225 * Asm_Input::
226 * Asm_Output::
227 * AST_Entry::
228 * Bit::
229 * Bit_Position::
230 * Compiler_Version::
231 * Code_Address::
232 * Default_Bit_Order::
233 * Elaborated::
234 * Elab_Body::
235 * Elab_Spec::
236 * Emax::
237 * Enabled::
238 * Enum_Rep::
239 * Enum_Val::
240 * Epsilon::
241 * Fixed_Value::
242 * Has_Access_Values::
243 * Has_Discriminants::
244 * Img::
245 * Integer_Value::
246 * Invalid_Value::
247 * Large::
248 * Machine_Size::
249 * Mantissa::
250 * Max_Interrupt_Priority::
251 * Max_Priority::
252 * Maximum_Alignment::
253 * Mechanism_Code::
254 * Null_Parameter::
255 * Object_Size::
256 * Old::
257 * Passed_By_Reference::
258 * Pool_Address::
259 * Range_Length::
260 * Result::
261 * Safe_Emax::
262 * Safe_Large::
263 * Small::
264 * Storage_Unit::
265 * Stub_Type::
266 * Target_Name::
267 * Tick::
268 * To_Address::
269 * Type_Class::
270 * UET_Address::
271 * Unconstrained_Array::
272 * Universal_Literal_String::
273 * Unrestricted_Access::
274 * VADS_Size::
275 * Value_Size::
276 * Wchar_T_Size::
277 * Word_Size::
278
279 The Implementation of Standard I/O
280
281 * Standard I/O Packages::
282 * FORM Strings::
283 * Direct_IO::
284 * Sequential_IO::
285 * Text_IO::
286 * Wide_Text_IO::
287 * Wide_Wide_Text_IO::
288 * Stream_IO::
289 * Text Translation::
290 * Shared Files::
291 * Filenames encoding::
292 * Open Modes::
293 * Operations on C Streams::
294 * Interfacing to C Streams::
295
296 The GNAT Library
297
298 * Ada.Characters.Latin_9 (a-chlat9.ads)::
299 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
300 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
301 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
302 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
303 * Ada.Command_Line.Environment (a-colien.ads)::
304 * Ada.Command_Line.Remove (a-colire.ads)::
305 * Ada.Command_Line.Response_File (a-clrefi.ads)::
306 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
307 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
308 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
309 * Ada.Exceptions.Traceback (a-exctra.ads)::
310 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
311 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
312 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
313 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
314 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
315 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
316 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
317 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
318 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
319 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
320 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
321 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
322 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
323 * GNAT.Altivec (g-altive.ads)::
324 * GNAT.Altivec.Conversions (g-altcon.ads)::
325 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
326 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
327 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
328 * GNAT.Array_Split (g-arrspl.ads)::
329 * GNAT.AWK (g-awk.ads)::
330 * GNAT.Bounded_Buffers (g-boubuf.ads)::
331 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
332 * GNAT.Bubble_Sort (g-bubsor.ads)::
333 * GNAT.Bubble_Sort_A (g-busora.ads)::
334 * GNAT.Bubble_Sort_G (g-busorg.ads)::
335 * GNAT.Byte_Order_Mark (g-byorma.ads)::
336 * GNAT.Byte_Swapping (g-bytswa.ads)::
337 * GNAT.Calendar (g-calend.ads)::
338 * GNAT.Calendar.Time_IO (g-catiio.ads)::
339 * GNAT.Case_Util (g-casuti.ads)::
340 * GNAT.CGI (g-cgi.ads)::
341 * GNAT.CGI.Cookie (g-cgicoo.ads)::
342 * GNAT.CGI.Debug (g-cgideb.ads)::
343 * GNAT.Command_Line (g-comlin.ads)::
344 * GNAT.Compiler_Version (g-comver.ads)::
345 * GNAT.Ctrl_C (g-ctrl_c.ads)::
346 * GNAT.CRC32 (g-crc32.ads)::
347 * GNAT.Current_Exception (g-curexc.ads)::
348 * GNAT.Debug_Pools (g-debpoo.ads)::
349 * GNAT.Debug_Utilities (g-debuti.ads)::
350 * GNAT.Decode_String (g-decstr.ads)::
351 * GNAT.Decode_UTF8_String (g-deutst.ads)::
352 * GNAT.Directory_Operations (g-dirope.ads)::
353 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
354 * GNAT.Dynamic_HTables (g-dynhta.ads)::
355 * GNAT.Dynamic_Tables (g-dyntab.ads)::
356 * GNAT.Encode_String (g-encstr.ads)::
357 * GNAT.Encode_UTF8_String (g-enutst.ads)::
358 * GNAT.Exception_Actions (g-excact.ads)::
359 * GNAT.Exception_Traces (g-exctra.ads)::
360 * GNAT.Exceptions (g-except.ads)::
361 * GNAT.Expect (g-expect.ads)::
362 * GNAT.Float_Control (g-flocon.ads)::
363 * GNAT.Heap_Sort (g-heasor.ads)::
364 * GNAT.Heap_Sort_A (g-hesora.ads)::
365 * GNAT.Heap_Sort_G (g-hesorg.ads)::
366 * GNAT.HTable (g-htable.ads)::
367 * GNAT.IO (g-io.ads)::
368 * GNAT.IO_Aux (g-io_aux.ads)::
369 * GNAT.Lock_Files (g-locfil.ads)::
370 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
371 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
372 * GNAT.MD5 (g-md5.ads)::
373 * GNAT.Memory_Dump (g-memdum.ads)::
374 * GNAT.Most_Recent_Exception (g-moreex.ads)::
375 * GNAT.OS_Lib (g-os_lib.ads)::
376 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
377 * GNAT.Random_Numbers (g-rannum.ads)::
378 * GNAT.Regexp (g-regexp.ads)::
379 * GNAT.Registry (g-regist.ads)::
380 * GNAT.Regpat (g-regpat.ads)::
381 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
382 * GNAT.Semaphores (g-semaph.ads)::
383 * GNAT.Serial_Communications (g-sercom.ads)::
384 * GNAT.SHA1 (g-sha1.ads)::
385 * GNAT.SHA224 (g-sha224.ads)::
386 * GNAT.SHA256 (g-sha256.ads)::
387 * GNAT.SHA384 (g-sha384.ads)::
388 * GNAT.SHA512 (g-sha512.ads)::
389 * GNAT.Signals (g-signal.ads)::
390 * GNAT.Sockets (g-socket.ads)::
391 * GNAT.Source_Info (g-souinf.ads)::
392 * GNAT.Spelling_Checker (g-speche.ads)::
393 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
394 * GNAT.Spitbol.Patterns (g-spipat.ads)::
395 * GNAT.Spitbol (g-spitbo.ads)::
396 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
397 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
398 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
399 * GNAT.SSE (g-sse.ads)::
400 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
401 * GNAT.Strings (g-string.ads)::
402 * GNAT.String_Split (g-strspl.ads)::
403 * GNAT.Table (g-table.ads)::
404 * GNAT.Task_Lock (g-tasloc.ads)::
405 * GNAT.Threads (g-thread.ads)::
406 * GNAT.Time_Stamp (g-timsta.ads)::
407 * GNAT.Traceback (g-traceb.ads)::
408 * GNAT.Traceback.Symbolic (g-trasym.ads)::
409 * GNAT.UTF_32 (g-utf_32.ads)::
410 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
411 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
412 * GNAT.Wide_String_Split (g-wistsp.ads)::
413 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
414 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
415 * Interfaces.C.Extensions (i-cexten.ads)::
416 * Interfaces.C.Streams (i-cstrea.ads)::
417 * Interfaces.CPP (i-cpp.ads)::
418 * Interfaces.Packed_Decimal (i-pacdec.ads)::
419 * Interfaces.VxWorks (i-vxwork.ads)::
420 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
421 * System.Address_Image (s-addima.ads)::
422 * System.Assertions (s-assert.ads)::
423 * System.Memory (s-memory.ads)::
424 * System.Partition_Interface (s-parint.ads)::
425 * System.Pool_Global (s-pooglo.ads)::
426 * System.Pool_Local (s-pooloc.ads)::
427 * System.Restrictions (s-restri.ads)::
428 * System.Rident (s-rident.ads)::
429 * System.Strings.Stream_Ops (s-ststop.ads)::
430 * System.Task_Info (s-tasinf.ads)::
431 * System.Wch_Cnv (s-wchcnv.ads)::
432 * System.Wch_Con (s-wchcon.ads)::
433
434 Text_IO
435
436 * Text_IO Stream Pointer Positioning::
437 * Text_IO Reading and Writing Non-Regular Files::
438 * Get_Immediate::
439 * Treating Text_IO Files as Streams::
440 * Text_IO Extensions::
441 * Text_IO Facilities for Unbounded Strings::
442
443 Wide_Text_IO
444
445 * Wide_Text_IO Stream Pointer Positioning::
446 * Wide_Text_IO Reading and Writing Non-Regular Files::
447
448 Wide_Wide_Text_IO
449
450 * Wide_Wide_Text_IO Stream Pointer Positioning::
451 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
452
453 Interfacing to Other Languages
454
455 * Interfacing to C::
456 * Interfacing to C++::
457 * Interfacing to COBOL::
458 * Interfacing to Fortran::
459 * Interfacing to non-GNAT Ada code::
460
461 Specialized Needs Annexes
462
463 Implementation of Specific Ada Features
464 * Machine Code Insertions::
465 * GNAT Implementation of Tasking::
466 * GNAT Implementation of Shared Passive Packages::
467 * Code Generation for Array Aggregates::
468 * The Size of Discriminated Records with Default Discriminants::
469 * Strict Conformance to the Ada Reference Manual::
470
471 Obsolescent Features
472
473 GNU Free Documentation License
474
475 Index
476 @end menu
477
478 @end ifnottex
479
480 @node About This Guide
481 @unnumbered About This Guide
482
483 @noindent
484 This manual contains useful information in writing programs using the
485 @value{EDITION} compiler. It includes information on implementation dependent
486 characteristics of @value{EDITION}, including all the information required by
487 Annex M of the Ada language standard.
488
489 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
490 Ada 83 compatibility mode.
491 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
492 but you can override with a compiler switch
493 to explicitly specify the language version.
494 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
495 @value{EDITION} User's Guide}, for details on these switches.)
496 Throughout this manual, references to ``Ada'' without a year suffix
497 apply to both the Ada 95 and Ada 2005 versions of the language.
498
499 Ada is designed to be highly portable.
500 In general, a program will have the same effect even when compiled by
501 different compilers on different platforms.
502 However, since Ada is designed to be used in a
503 wide variety of applications, it also contains a number of system
504 dependent features to be used in interfacing to the external world.
505 @cindex Implementation-dependent features
506 @cindex Portability
507
508 Note: Any program that makes use of implementation-dependent features
509 may be non-portable. You should follow good programming practice and
510 isolate and clearly document any sections of your program that make use
511 of these features in a non-portable manner.
512
513 @ifset PROEDITION
514 For ease of exposition, ``GNAT Pro'' will be referred to simply as
515 ``GNAT'' in the remainder of this document.
516 @end ifset
517
518 @menu
519 * What This Reference Manual Contains::
520 * Conventions::
521 * Related Information::
522 @end menu
523
524 @node What This Reference Manual Contains
525 @unnumberedsec What This Reference Manual Contains
526
527 @noindent
528 This reference manual contains the following chapters:
529
530 @itemize @bullet
531 @item
532 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
533 pragmas, which can be used to extend and enhance the functionality of the
534 compiler.
535
536 @item
537 @ref{Implementation Defined Attributes}, lists GNAT
538 implementation-dependent attributes which can be used to extend and
539 enhance the functionality of the compiler.
540
541 @item
542 @ref{Implementation Advice}, provides information on generally
543 desirable behavior which are not requirements that all compilers must
544 follow since it cannot be provided on all systems, or which may be
545 undesirable on some systems.
546
547 @item
548 @ref{Implementation Defined Characteristics}, provides a guide to
549 minimizing implementation dependent features.
550
551 @item
552 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
553 implemented by GNAT, and how they can be imported into user
554 application programs.
555
556 @item
557 @ref{Representation Clauses and Pragmas}, describes in detail the
558 way that GNAT represents data, and in particular the exact set
559 of representation clauses and pragmas that is accepted.
560
561 @item
562 @ref{Standard Library Routines}, provides a listing of packages and a
563 brief description of the functionality that is provided by Ada's
564 extensive set of standard library routines as implemented by GNAT@.
565
566 @item
567 @ref{The Implementation of Standard I/O}, details how the GNAT
568 implementation of the input-output facilities.
569
570 @item
571 @ref{The GNAT Library}, is a catalog of packages that complement
572 the Ada predefined library.
573
574 @item
575 @ref{Interfacing to Other Languages}, describes how programs
576 written in Ada using GNAT can be interfaced to other programming
577 languages.
578
579 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
580 of the specialized needs annexes.
581
582 @item
583 @ref{Implementation of Specific Ada Features}, discusses issues related
584 to GNAT's implementation of machine code insertions, tasking, and several
585 other features.
586
587 @item
588 @ref{Obsolescent Features} documents implementation dependent features,
589 including pragmas and attributes, which are considered obsolescent, since
590 there are other preferred ways of achieving the same results. These
591 obsolescent forms are retained for backwards compatibility.
592
593 @end itemize
594
595 @cindex Ada 95 Language Reference Manual
596 @cindex Ada 2005 Language Reference Manual
597 @noindent
598 This reference manual assumes a basic familiarity with the Ada 95 language, as
599 described in the International Standard ANSI/ISO/IEC-8652:1995,
600 January 1995.
601 It does not require knowledge of the new features introduced by Ada 2005,
602 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
603 and Amendment 1).
604 Both reference manuals are included in the GNAT documentation
605 package.
606
607 @node Conventions
608 @unnumberedsec Conventions
609 @cindex Conventions, typographical
610 @cindex Typographical conventions
611
612 @noindent
613 Following are examples of the typographical and graphic conventions used
614 in this guide:
615
616 @itemize @bullet
617 @item
618 @code{Functions}, @code{utility program names}, @code{standard names},
619 and @code{classes}.
620
621 @item
622 @code{Option flags}
623
624 @item
625 @file{File names}, @samp{button names}, and @samp{field names}.
626
627 @item
628 @code{Variables}, @env{environment variables}, and @var{metasyntactic
629 variables}.
630
631 @item
632 @emph{Emphasis}.
633
634 @item
635 [optional information or parameters]
636
637 @item
638 Examples are described by text
639 @smallexample
640 and then shown this way.
641 @end smallexample
642 @end itemize
643
644 @noindent
645 Commands that are entered by the user are preceded in this manual by the
646 characters @samp{$ } (dollar sign followed by space). If your system uses this
647 sequence as a prompt, then the commands will appear exactly as you see them
648 in the manual. If your system uses some other prompt, then the command will
649 appear with the @samp{$} replaced by whatever prompt character you are using.
650
651 @node Related Information
652 @unnumberedsec Related Information
653 @noindent
654 See the following documents for further information on GNAT:
655
656 @itemize @bullet
657 @item
658 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
659 @value{EDITION} User's Guide}, which provides information on how to use the
660 GNAT compiler system.
661
662 @item
663 @cite{Ada 95 Reference Manual}, which contains all reference
664 material for the Ada 95 programming language.
665
666 @item
667 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
668 of the Ada 95 standard. The annotations describe
669 detailed aspects of the design decision, and in particular contain useful
670 sections on Ada 83 compatibility.
671
672 @item
673 @cite{Ada 2005 Reference Manual}, which contains all reference
674 material for the Ada 2005 programming language.
675
676 @item
677 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
678 of the Ada 2005 standard. The annotations describe
679 detailed aspects of the design decision, and in particular contain useful
680 sections on Ada 83 and Ada 95 compatibility.
681
682 @item
683 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
684 which contains specific information on compatibility between GNAT and
685 DEC Ada 83 systems.
686
687 @item
688 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
689 describes in detail the pragmas and attributes provided by the DEC Ada 83
690 compiler system.
691
692 @end itemize
693
694 @node Implementation Defined Pragmas
695 @chapter Implementation Defined Pragmas
696
697 @noindent
698 Ada defines a set of pragmas that can be used to supply additional
699 information to the compiler. These language defined pragmas are
700 implemented in GNAT and work as described in the Ada Reference Manual.
701
702 In addition, Ada allows implementations to define additional pragmas
703 whose meaning is defined by the implementation. GNAT provides a number
704 of these implementation-defined pragmas, which can be used to extend
705 and enhance the functionality of the compiler. This section of the GNAT
706 Reference Manual describes these additional pragmas.
707
708 Note that any program using these pragmas might not be portable to other
709 compilers (although GNAT implements this set of pragmas on all
710 platforms). Therefore if portability to other compilers is an important
711 consideration, the use of these pragmas should be minimized.
712
713 @menu
714 * Pragma Abort_Defer::
715 * Pragma Ada_83::
716 * Pragma Ada_95::
717 * Pragma Ada_05::
718 * Pragma Ada_2005::
719 * Pragma Ada_12::
720 * Pragma Ada_2012::
721 * Pragma Annotate::
722 * Pragma Assert::
723 * Pragma Assume_No_Invalid_Values::
724 * Pragma Ast_Entry::
725 * Pragma C_Pass_By_Copy::
726 * Pragma Check::
727 * Pragma Check_Name::
728 * Pragma Check_Policy::
729 * Pragma Comment::
730 * Pragma Common_Object::
731 * Pragma Compile_Time_Error::
732 * Pragma Compile_Time_Warning::
733 * Pragma Compiler_Unit::
734 * Pragma Complete_Representation::
735 * Pragma Complex_Representation::
736 * Pragma Component_Alignment::
737 * Pragma Convention_Identifier::
738 * Pragma CPP_Class::
739 * Pragma CPP_Constructor::
740 * Pragma CPP_Virtual::
741 * Pragma CPP_Vtable::
742 * Pragma Debug::
743 * Pragma Debug_Policy::
744 * Pragma Detect_Blocking::
745 * Pragma Elaboration_Checks::
746 * Pragma Eliminate::
747 * Pragma Export_Exception::
748 * Pragma Export_Function::
749 * Pragma Export_Object::
750 * Pragma Export_Procedure::
751 * Pragma Export_Value::
752 * Pragma Export_Valued_Procedure::
753 * Pragma Extend_System::
754 * Pragma Extensions_Allowed::
755 * Pragma External::
756 * Pragma External_Name_Casing::
757 * Pragma Fast_Math::
758 * Pragma Favor_Top_Level::
759 * Pragma Finalize_Storage_Only::
760 * Pragma Float_Representation::
761 * Pragma Ident::
762 * Pragma Implemented_By_Entry::
763 * Pragma Implicit_Packing::
764 * Pragma Import_Exception::
765 * Pragma Import_Function::
766 * Pragma Import_Object::
767 * Pragma Import_Procedure::
768 * Pragma Import_Valued_Procedure::
769 * Pragma Initialize_Scalars::
770 * Pragma Inline_Always::
771 * Pragma Inline_Generic::
772 * Pragma Interface::
773 * Pragma Interface_Name::
774 * Pragma Interrupt_Handler::
775 * Pragma Interrupt_State::
776 * Pragma Keep_Names::
777 * Pragma License::
778 * Pragma Link_With::
779 * Pragma Linker_Alias::
780 * Pragma Linker_Constructor::
781 * Pragma Linker_Destructor::
782 * Pragma Linker_Section::
783 * Pragma Long_Float::
784 * Pragma Machine_Attribute::
785 * Pragma Main::
786 * Pragma Main_Storage::
787 * Pragma No_Body::
788 * Pragma No_Return::
789 * Pragma No_Strict_Aliasing::
790 * Pragma Normalize_Scalars::
791 * Pragma Obsolescent::
792 * Pragma Optimize_Alignment::
793 * Pragma Ordered::
794 * Pragma Passive::
795 * Pragma Persistent_BSS::
796 * Pragma Polling::
797 * Pragma Postcondition::
798 * Pragma Precondition::
799 * Pragma Profile (Ravenscar)::
800 * Pragma Profile (Restricted)::
801 * Pragma Psect_Object::
802 * Pragma Pure_Function::
803 * Pragma Restriction_Warnings::
804 * Pragma Shared::
805 * Pragma Short_Circuit_And_Or::
806 * Pragma Source_File_Name::
807 * Pragma Source_File_Name_Project::
808 * Pragma Source_Reference::
809 * Pragma Stream_Convert::
810 * Pragma Style_Checks::
811 * Pragma Subtitle::
812 * Pragma Suppress::
813 * Pragma Suppress_All::
814 * Pragma Suppress_Exception_Locations::
815 * Pragma Suppress_Initialization::
816 * Pragma Task_Info::
817 * Pragma Task_Name::
818 * Pragma Task_Storage::
819 * Pragma Thread_Local_Storage::
820 * Pragma Time_Slice::
821 * Pragma Title::
822 * Pragma Unchecked_Union::
823 * Pragma Unimplemented_Unit::
824 * Pragma Universal_Aliasing ::
825 * Pragma Universal_Data::
826 * Pragma Unmodified::
827 * Pragma Unreferenced::
828 * Pragma Unreferenced_Objects::
829 * Pragma Unreserve_All_Interrupts::
830 * Pragma Unsuppress::
831 * Pragma Use_VADS_Size::
832 * Pragma Validity_Checks::
833 * Pragma Volatile::
834 * Pragma Warnings::
835 * Pragma Weak_External::
836 * Pragma Wide_Character_Encoding::
837 @end menu
838
839 @node Pragma Abort_Defer
840 @unnumberedsec Pragma Abort_Defer
841 @findex Abort_Defer
842 @cindex Deferring aborts
843 @noindent
844 Syntax:
845 @smallexample
846 pragma Abort_Defer;
847 @end smallexample
848
849 @noindent
850 This pragma must appear at the start of the statement sequence of a
851 handled sequence of statements (right after the @code{begin}). It has
852 the effect of deferring aborts for the sequence of statements (but not
853 for the declarations or handlers, if any, associated with this statement
854 sequence).
855
856 @node Pragma Ada_83
857 @unnumberedsec Pragma Ada_83
858 @findex Ada_83
859 @noindent
860 Syntax:
861 @smallexample @c ada
862 pragma Ada_83;
863 @end smallexample
864
865 @noindent
866 A configuration pragma that establishes Ada 83 mode for the unit to
867 which it applies, regardless of the mode set by the command line
868 switches. In Ada 83 mode, GNAT attempts to be as compatible with
869 the syntax and semantics of Ada 83, as defined in the original Ada
870 83 Reference Manual as possible. In particular, the keywords added by Ada 95
871 and Ada 2005 are not recognized, optional package bodies are allowed,
872 and generics may name types with unknown discriminants without using
873 the @code{(<>)} notation. In addition, some but not all of the additional
874 restrictions of Ada 83 are enforced.
875
876 Ada 83 mode is intended for two purposes. Firstly, it allows existing
877 Ada 83 code to be compiled and adapted to GNAT with less effort.
878 Secondly, it aids in keeping code backwards compatible with Ada 83.
879 However, there is no guarantee that code that is processed correctly
880 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
881 83 compiler, since GNAT does not enforce all the additional checks
882 required by Ada 83.
883
884 @node Pragma Ada_95
885 @unnumberedsec Pragma Ada_95
886 @findex Ada_95
887 @noindent
888 Syntax:
889 @smallexample @c ada
890 pragma Ada_95;
891 @end smallexample
892
893 @noindent
894 A configuration pragma that establishes Ada 95 mode for the unit to which
895 it applies, regardless of the mode set by the command line switches.
896 This mode is set automatically for the @code{Ada} and @code{System}
897 packages and their children, so you need not specify it in these
898 contexts. This pragma is useful when writing a reusable component that
899 itself uses Ada 95 features, but which is intended to be usable from
900 either Ada 83 or Ada 95 programs.
901
902 @node Pragma Ada_05
903 @unnumberedsec Pragma Ada_05
904 @findex Ada_05
905 @noindent
906 Syntax:
907 @smallexample @c ada
908 pragma Ada_05;
909 @end smallexample
910
911 @noindent
912 A configuration pragma that establishes Ada 2005 mode for the unit to which
913 it applies, regardless of the mode set by the command line switches.
914 This pragma is useful when writing a reusable component that
915 itself uses Ada 2005 features, but which is intended to be usable from
916 either Ada 83 or Ada 95 programs.
917
918 @node Pragma Ada_2005
919 @unnumberedsec Pragma Ada_2005
920 @findex Ada_2005
921 @noindent
922 Syntax:
923 @smallexample @c ada
924 pragma Ada_2005;
925 @end smallexample
926
927 @noindent
928 This configuration pragma is a synonym for pragma Ada_05 and has the
929 same syntax and effect.
930
931 @node Pragma Ada_12
932 @unnumberedsec Pragma Ada_12
933 @findex Ada_12
934 @noindent
935 Syntax:
936 @smallexample @c ada
937 pragma Ada_12;
938 @end smallexample
939
940 @noindent
941 A configuration pragma that establishes Ada 2012 mode for the unit to which
942 it applies, regardless of the mode set by the command line switches.
943 This mode is set automatically for the @code{Ada} and @code{System}
944 packages and their children, so you need not specify it in these
945 contexts. This pragma is useful when writing a reusable component that
946 itself uses Ada 2012 features, but which is intended to be usable from
947 Ada 83, Ada 95, or Ada 2005 programs.
948
949 @node Pragma Ada_2012
950 @unnumberedsec Pragma Ada_2012
951 @findex Ada_2005
952 @noindent
953 Syntax:
954 @smallexample @c ada
955 pragma Ada_2012;
956 @end smallexample
957
958 @noindent
959 This configuration pragma is a synonym for pragma Ada_12 and has the
960 same syntax and effect.
961
962 @node Pragma Annotate
963 @unnumberedsec Pragma Annotate
964 @findex Annotate
965 @noindent
966 Syntax:
967 @smallexample @c ada
968 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
969
970 ARG ::= NAME | EXPRESSION
971 @end smallexample
972
973 @noindent
974 This pragma is used to annotate programs. @var{identifier} identifies
975 the type of annotation. GNAT verifies that it is an identifier, but does
976 not otherwise analyze it. The second optional identifier is also left
977 unanalyzed, and by convention is used to control the action of the tool to
978 which the annotation is addressed. The remaining @var{arg} arguments
979 can be either string literals or more generally expressions.
980 String literals are assumed to be either of type
981 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
982 depending on the character literals they contain.
983 All other kinds of arguments are analyzed as expressions, and must be
984 unambiguous.
985
986 The analyzed pragma is retained in the tree, but not otherwise processed
987 by any part of the GNAT compiler. This pragma is intended for use by
988 external tools, including ASIS@.
989
990 @node Pragma Assert
991 @unnumberedsec Pragma Assert
992 @findex Assert
993 @noindent
994 Syntax:
995 @smallexample @c ada
996 pragma Assert (
997 boolean_EXPRESSION
998 [, string_EXPRESSION]);
999 @end smallexample
1000
1001 @noindent
1002 The effect of this pragma depends on whether the corresponding command
1003 line switch is set to activate assertions. The pragma expands into code
1004 equivalent to the following:
1005
1006 @smallexample @c ada
1007 if assertions-enabled then
1008 if not boolean_EXPRESSION then
1009 System.Assertions.Raise_Assert_Failure
1010 (string_EXPRESSION);
1011 end if;
1012 end if;
1013 @end smallexample
1014
1015 @noindent
1016 The string argument, if given, is the message that will be associated
1017 with the exception occurrence if the exception is raised. If no second
1018 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1019 where @var{file} is the name of the source file containing the assert,
1020 and @var{nnn} is the line number of the assert. A pragma is not a
1021 statement, so if a statement sequence contains nothing but a pragma
1022 assert, then a null statement is required in addition, as in:
1023
1024 @smallexample @c ada
1025 @dots{}
1026 if J > 3 then
1027 pragma Assert (K > 3, "Bad value for K");
1028 null;
1029 end if;
1030 @end smallexample
1031
1032 @noindent
1033 Note that, as with the @code{if} statement to which it is equivalent, the
1034 type of the expression is either @code{Standard.Boolean}, or any type derived
1035 from this standard type.
1036
1037 If assertions are disabled (switch @option{-gnata} not used), then there
1038 is no run-time effect (and in particular, any side effects from the
1039 expression will not occur at run time). (The expression is still
1040 analyzed at compile time, and may cause types to be frozen if they are
1041 mentioned here for the first time).
1042
1043 If assertions are enabled, then the given expression is tested, and if
1044 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1045 which results in the raising of @code{Assert_Failure} with the given message.
1046
1047 You should generally avoid side effects in the expression arguments of
1048 this pragma, because these side effects will turn on and off with the
1049 setting of the assertions mode, resulting in assertions that have an
1050 effect on the program. However, the expressions are analyzed for
1051 semantic correctness whether or not assertions are enabled, so turning
1052 assertions on and off cannot affect the legality of a program.
1053
1054 @node Pragma Assume_No_Invalid_Values
1055 @unnumberedsec Pragma Assume_No_Invalid_Values
1056 @findex Assume_No_Invalid_Values
1057 @cindex Invalid representations
1058 @cindex Invalid values
1059 @noindent
1060 Syntax:
1061 @smallexample @c ada
1062 pragma Assume_No_Invalid_Values (On | Off);
1063 @end smallexample
1064
1065 @noindent
1066 This is a configuration pragma that controls the assumptions made by the
1067 compiler about the occurrence of invalid representations (invalid values)
1068 in the code.
1069
1070 The default behavior (corresponding to an Off argument for this pragma), is
1071 to assume that values may in general be invalid unless the compiler can
1072 prove they are valid. Consider the following example:
1073
1074 @smallexample @c ada
1075 V1 : Integer range 1 .. 10;
1076 V2 : Integer range 11 .. 20;
1077 ...
1078 for J in V2 .. V1 loop
1079 ...
1080 end loop;
1081 @end smallexample
1082
1083 @noindent
1084 if V1 and V2 have valid values, then the loop is known at compile
1085 time not to execute since the lower bound must be greater than the
1086 upper bound. However in default mode, no such assumption is made,
1087 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1088 is given, the compiler will assume that any occurrence of a variable
1089 other than in an explicit @code{'Valid} test always has a valid
1090 value, and the loop above will be optimized away.
1091
1092 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1093 you know your code is free of uninitialized variables and other
1094 possible sources of invalid representations, and may result in
1095 more efficient code. A program that accesses an invalid representation
1096 with this pragma in effect is erroneous, so no guarantees can be made
1097 about its behavior.
1098
1099 It is peculiar though permissible to use this pragma in conjunction
1100 with validity checking (-gnatVa). In such cases, accessing invalid
1101 values will generally give an exception, though formally the program
1102 is erroneous so there are no guarantees that this will always be the
1103 case, and it is recommended that these two options not be used together.
1104
1105 @node Pragma Ast_Entry
1106 @unnumberedsec Pragma Ast_Entry
1107 @cindex OpenVMS
1108 @findex Ast_Entry
1109 @noindent
1110 Syntax:
1111 @smallexample @c ada
1112 pragma AST_Entry (entry_IDENTIFIER);
1113 @end smallexample
1114
1115 @noindent
1116 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1117 argument is the simple name of a single entry; at most one @code{AST_Entry}
1118 pragma is allowed for any given entry. This pragma must be used in
1119 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1120 the entry declaration and in the same task type specification or single task
1121 as the entry to which it applies. This pragma specifies that the given entry
1122 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1123 resulting from an OpenVMS system service call. The pragma does not affect
1124 normal use of the entry. For further details on this pragma, see the
1125 DEC Ada Language Reference Manual, section 9.12a.
1126
1127 @node Pragma C_Pass_By_Copy
1128 @unnumberedsec Pragma C_Pass_By_Copy
1129 @cindex Passing by copy
1130 @findex C_Pass_By_Copy
1131 @noindent
1132 Syntax:
1133 @smallexample @c ada
1134 pragma C_Pass_By_Copy
1135 ([Max_Size =>] static_integer_EXPRESSION);
1136 @end smallexample
1137
1138 @noindent
1139 Normally the default mechanism for passing C convention records to C
1140 convention subprograms is to pass them by reference, as suggested by RM
1141 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1142 this default, by requiring that record formal parameters be passed by
1143 copy if all of the following conditions are met:
1144
1145 @itemize @bullet
1146 @item
1147 The size of the record type does not exceed the value specified for
1148 @code{Max_Size}.
1149 @item
1150 The record type has @code{Convention C}.
1151 @item
1152 The formal parameter has this record type, and the subprogram has a
1153 foreign (non-Ada) convention.
1154 @end itemize
1155
1156 @noindent
1157 If these conditions are met the argument is passed by copy, i.e.@: in a
1158 manner consistent with what C expects if the corresponding formal in the
1159 C prototype is a struct (rather than a pointer to a struct).
1160
1161 You can also pass records by copy by specifying the convention
1162 @code{C_Pass_By_Copy} for the record type, or by using the extended
1163 @code{Import} and @code{Export} pragmas, which allow specification of
1164 passing mechanisms on a parameter by parameter basis.
1165
1166 @node Pragma Check
1167 @unnumberedsec Pragma Check
1168 @cindex Assertions
1169 @cindex Named assertions
1170 @findex Check
1171 @noindent
1172 Syntax:
1173 @smallexample @c ada
1174 pragma Check (
1175 [Name =>] Identifier,
1176 [Check =>] Boolean_EXPRESSION
1177 [, [Message =>] string_EXPRESSION] );
1178 @end smallexample
1179
1180 @noindent
1181 This pragma is similar to the predefined pragma @code{Assert} except that an
1182 extra identifier argument is present. In conjunction with pragma
1183 @code{Check_Policy}, this can be used to define groups of assertions that can
1184 be independently controlled. The identifier @code{Assertion} is special, it
1185 refers to the normal set of pragma @code{Assert} statements. The identifiers
1186 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1187 names, so these three names would normally not be used directly in a pragma
1188 @code{Check}.
1189
1190 Checks introduced by this pragma are normally deactivated by default. They can
1191 be activated either by the command line option @option{-gnata}, which turns on
1192 all checks, or individually controlled using pragma @code{Check_Policy}.
1193
1194 @node Pragma Check_Name
1195 @unnumberedsec Pragma Check_Name
1196 @cindex Defining check names
1197 @cindex Check names, defining
1198 @findex Check_Name
1199 @noindent
1200 Syntax:
1201 @smallexample @c ada
1202 pragma Check_Name (check_name_IDENTIFIER);
1203 @end smallexample
1204
1205 @noindent
1206 This is a configuration pragma that defines a new implementation
1207 defined check name (unless IDENTIFIER matches one of the predefined
1208 check names, in which case the pragma has no effect). Check names
1209 are global to a partition, so if two or more configuration pragmas
1210 are present in a partition mentioning the same name, only one new
1211 check name is introduced.
1212
1213 An implementation defined check name introduced with this pragma may
1214 be used in only three contexts: @code{pragma Suppress},
1215 @code{pragma Unsuppress},
1216 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1217 any of these three cases, the check name must be visible. A check
1218 name is visible if it is in the configuration pragmas applying to
1219 the current unit, or if it appears at the start of any unit that
1220 is part of the dependency set of the current unit (e.g., units that
1221 are mentioned in @code{with} clauses).
1222
1223 @node Pragma Check_Policy
1224 @unnumberedsec Pragma Check_Policy
1225 @cindex Controlling assertions
1226 @cindex Assertions, control
1227 @cindex Check pragma control
1228 @cindex Named assertions
1229 @findex Check
1230 @noindent
1231 Syntax:
1232 @smallexample @c ada
1233 pragma Check_Policy
1234 ([Name =>] Identifier,
1235 [Policy =>] POLICY_IDENTIFIER);
1236
1237 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1238 @end smallexample
1239
1240 @noindent
1241 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1242 except that it controls sets of named assertions introduced using the
1243 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1244 @code{Assertion_Policy}) can be used within a declarative part, in which case
1245 it controls the status to the end of the corresponding construct (in a manner
1246 identical to pragma @code{Suppress)}.
1247
1248 The identifier given as the first argument corresponds to a name used in
1249 associated @code{Check} pragmas. For example, if the pragma:
1250
1251 @smallexample @c ada
1252 pragma Check_Policy (Critical_Error, Off);
1253 @end smallexample
1254
1255 @noindent
1256 is given, then subsequent @code{Check} pragmas whose first argument is also
1257 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1258 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1259 @code{Check_Policy} with this identifier is similar to the normal
1260 @code{Assertion_Policy} pragma except that it can appear within a
1261 declarative part).
1262
1263 The special identifiers @code{Precondition} and @code{Postcondition} control
1264 the status of preconditions and postconditions. If a @code{Precondition} pragma
1265 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1266 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1267 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1268 are recognized.
1269
1270 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1271 to turn on corresponding checks. The default for a set of checks for which no
1272 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1273 @option{-gnata} is given, which turns on all checks by default.
1274
1275 The check policy settings @code{Check} and @code{Ignore} are also recognized
1276 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1277 compatibility with the standard @code{Assertion_Policy} pragma.
1278
1279 @node Pragma Comment
1280 @unnumberedsec Pragma Comment
1281 @findex Comment
1282 @noindent
1283 Syntax:
1284
1285 @smallexample @c ada
1286 pragma Comment (static_string_EXPRESSION);
1287 @end smallexample
1288
1289 @noindent
1290 This is almost identical in effect to pragma @code{Ident}. It allows the
1291 placement of a comment into the object file and hence into the
1292 executable file if the operating system permits such usage. The
1293 difference is that @code{Comment}, unlike @code{Ident}, has
1294 no limitations on placement of the pragma (it can be placed
1295 anywhere in the main source unit), and if more than one pragma
1296 is used, all comments are retained.
1297
1298 @node Pragma Common_Object
1299 @unnumberedsec Pragma Common_Object
1300 @findex Common_Object
1301 @noindent
1302 Syntax:
1303
1304 @smallexample @c ada
1305 pragma Common_Object (
1306 [Internal =>] LOCAL_NAME
1307 [, [External =>] EXTERNAL_SYMBOL]
1308 [, [Size =>] EXTERNAL_SYMBOL] );
1309
1310 EXTERNAL_SYMBOL ::=
1311 IDENTIFIER
1312 | static_string_EXPRESSION
1313 @end smallexample
1314
1315 @noindent
1316 This pragma enables the shared use of variables stored in overlaid
1317 linker areas corresponding to the use of @code{COMMON}
1318 in Fortran. The single
1319 object @var{LOCAL_NAME} is assigned to the area designated by
1320 the @var{External} argument.
1321 You may define a record to correspond to a series
1322 of fields. The @var{Size} argument
1323 is syntax checked in GNAT, but otherwise ignored.
1324
1325 @code{Common_Object} is not supported on all platforms. If no
1326 support is available, then the code generator will issue a message
1327 indicating that the necessary attribute for implementation of this
1328 pragma is not available.
1329
1330 @node Pragma Compile_Time_Error
1331 @unnumberedsec Pragma Compile_Time_Error
1332 @findex Compile_Time_Error
1333 @noindent
1334 Syntax:
1335
1336 @smallexample @c ada
1337 pragma Compile_Time_Error
1338 (boolean_EXPRESSION, static_string_EXPRESSION);
1339 @end smallexample
1340
1341 @noindent
1342 This pragma can be used to generate additional compile time
1343 error messages. It
1344 is particularly useful in generics, where errors can be issued for
1345 specific problematic instantiations. The first parameter is a boolean
1346 expression. The pragma is effective only if the value of this expression
1347 is known at compile time, and has the value True. The set of expressions
1348 whose values are known at compile time includes all static boolean
1349 expressions, and also other values which the compiler can determine
1350 at compile time (e.g., the size of a record type set by an explicit
1351 size representation clause, or the value of a variable which was
1352 initialized to a constant and is known not to have been modified).
1353 If these conditions are met, an error message is generated using
1354 the value given as the second argument. This string value may contain
1355 embedded ASCII.LF characters to break the message into multiple lines.
1356
1357 @node Pragma Compile_Time_Warning
1358 @unnumberedsec Pragma Compile_Time_Warning
1359 @findex Compile_Time_Warning
1360 @noindent
1361 Syntax:
1362
1363 @smallexample @c ada
1364 pragma Compile_Time_Warning
1365 (boolean_EXPRESSION, static_string_EXPRESSION);
1366 @end smallexample
1367
1368 @noindent
1369 Same as pragma Compile_Time_Error, except a warning is issued instead
1370 of an error message. Note that if this pragma is used in a package that
1371 is with'ed by a client, the client will get the warning even though it
1372 is issued by a with'ed package (normally warnings in with'ed units are
1373 suppressed, but this is a special exception to that rule).
1374
1375 One typical use is within a generic where compile time known characteristics
1376 of formal parameters are tested, and warnings given appropriately. Another use
1377 with a first parameter of True is to warn a client about use of a package,
1378 for example that it is not fully implemented.
1379
1380 @node Pragma Compiler_Unit
1381 @unnumberedsec Pragma Compiler_Unit
1382 @findex Compiler_Unit
1383 @noindent
1384 Syntax:
1385
1386 @smallexample @c ada
1387 pragma Compiler_Unit;
1388 @end smallexample
1389
1390 @noindent
1391 This pragma is intended only for internal use in the GNAT run-time library.
1392 It indicates that the unit is used as part of the compiler build. The effect
1393 is to disallow constructs (raise with message, conditional expressions etc)
1394 that would cause trouble when bootstrapping using an older version of GNAT.
1395 For the exact list of restrictions, see the compiler sources and references
1396 to Is_Compiler_Unit.
1397
1398 @node Pragma Complete_Representation
1399 @unnumberedsec Pragma Complete_Representation
1400 @findex Complete_Representation
1401 @noindent
1402 Syntax:
1403
1404 @smallexample @c ada
1405 pragma Complete_Representation;
1406 @end smallexample
1407
1408 @noindent
1409 This pragma must appear immediately within a record representation
1410 clause. Typical placements are before the first component clause
1411 or after the last component clause. The effect is to give an error
1412 message if any component is missing a component clause. This pragma
1413 may be used to ensure that a record representation clause is
1414 complete, and that this invariant is maintained if fields are
1415 added to the record in the future.
1416
1417 @node Pragma Complex_Representation
1418 @unnumberedsec Pragma Complex_Representation
1419 @findex Complex_Representation
1420 @noindent
1421 Syntax:
1422
1423 @smallexample @c ada
1424 pragma Complex_Representation
1425 ([Entity =>] LOCAL_NAME);
1426 @end smallexample
1427
1428 @noindent
1429 The @var{Entity} argument must be the name of a record type which has
1430 two fields of the same floating-point type. The effect of this pragma is
1431 to force gcc to use the special internal complex representation form for
1432 this record, which may be more efficient. Note that this may result in
1433 the code for this type not conforming to standard ABI (application
1434 binary interface) requirements for the handling of record types. For
1435 example, in some environments, there is a requirement for passing
1436 records by pointer, and the use of this pragma may result in passing
1437 this type in floating-point registers.
1438
1439 @node Pragma Component_Alignment
1440 @unnumberedsec Pragma Component_Alignment
1441 @cindex Alignments of components
1442 @findex Component_Alignment
1443 @noindent
1444 Syntax:
1445
1446 @smallexample @c ada
1447 pragma Component_Alignment (
1448 [Form =>] ALIGNMENT_CHOICE
1449 [, [Name =>] type_LOCAL_NAME]);
1450
1451 ALIGNMENT_CHOICE ::=
1452 Component_Size
1453 | Component_Size_4
1454 | Storage_Unit
1455 | Default
1456 @end smallexample
1457
1458 @noindent
1459 Specifies the alignment of components in array or record types.
1460 The meaning of the @var{Form} argument is as follows:
1461
1462 @table @code
1463 @findex Component_Size
1464 @item Component_Size
1465 Aligns scalar components and subcomponents of the array or record type
1466 on boundaries appropriate to their inherent size (naturally
1467 aligned). For example, 1-byte components are aligned on byte boundaries,
1468 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1469 integer components are aligned on 4-byte boundaries and so on. These
1470 alignment rules correspond to the normal rules for C compilers on all
1471 machines except the VAX@.
1472
1473 @findex Component_Size_4
1474 @item Component_Size_4
1475 Naturally aligns components with a size of four or fewer
1476 bytes. Components that are larger than 4 bytes are placed on the next
1477 4-byte boundary.
1478
1479 @findex Storage_Unit
1480 @item Storage_Unit
1481 Specifies that array or record components are byte aligned, i.e.@:
1482 aligned on boundaries determined by the value of the constant
1483 @code{System.Storage_Unit}.
1484
1485 @cindex OpenVMS
1486 @item Default
1487 Specifies that array or record components are aligned on default
1488 boundaries, appropriate to the underlying hardware or operating system or
1489 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1490 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1491 the @code{Default} choice is the same as @code{Component_Size} (natural
1492 alignment).
1493 @end table
1494
1495 @noindent
1496 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1497 refer to a local record or array type, and the specified alignment
1498 choice applies to the specified type. The use of
1499 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1500 @code{Component_Alignment} pragma to be ignored. The use of
1501 @code{Component_Alignment} together with a record representation clause
1502 is only effective for fields not specified by the representation clause.
1503
1504 If the @code{Name} parameter is absent, the pragma can be used as either
1505 a configuration pragma, in which case it applies to one or more units in
1506 accordance with the normal rules for configuration pragmas, or it can be
1507 used within a declarative part, in which case it applies to types that
1508 are declared within this declarative part, or within any nested scope
1509 within this declarative part. In either case it specifies the alignment
1510 to be applied to any record or array type which has otherwise standard
1511 representation.
1512
1513 If the alignment for a record or array type is not specified (using
1514 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1515 clause), the GNAT uses the default alignment as described previously.
1516
1517 @node Pragma Convention_Identifier
1518 @unnumberedsec Pragma Convention_Identifier
1519 @findex Convention_Identifier
1520 @cindex Conventions, synonyms
1521 @noindent
1522 Syntax:
1523
1524 @smallexample @c ada
1525 pragma Convention_Identifier (
1526 [Name =>] IDENTIFIER,
1527 [Convention =>] convention_IDENTIFIER);
1528 @end smallexample
1529
1530 @noindent
1531 This pragma provides a mechanism for supplying synonyms for existing
1532 convention identifiers. The @code{Name} identifier can subsequently
1533 be used as a synonym for the given convention in other pragmas (including
1534 for example pragma @code{Import} or another @code{Convention_Identifier}
1535 pragma). As an example of the use of this, suppose you had legacy code
1536 which used Fortran77 as the identifier for Fortran. Then the pragma:
1537
1538 @smallexample @c ada
1539 pragma Convention_Identifier (Fortran77, Fortran);
1540 @end smallexample
1541
1542 @noindent
1543 would allow the use of the convention identifier @code{Fortran77} in
1544 subsequent code, avoiding the need to modify the sources. As another
1545 example, you could use this to parametrize convention requirements
1546 according to systems. Suppose you needed to use @code{Stdcall} on
1547 windows systems, and @code{C} on some other system, then you could
1548 define a convention identifier @code{Library} and use a single
1549 @code{Convention_Identifier} pragma to specify which convention
1550 would be used system-wide.
1551
1552 @node Pragma CPP_Class
1553 @unnumberedsec Pragma CPP_Class
1554 @findex CPP_Class
1555 @cindex Interfacing with C++
1556 @noindent
1557 Syntax:
1558
1559 @smallexample @c ada
1560 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1561 @end smallexample
1562
1563 @noindent
1564 The argument denotes an entity in the current declarative region that is
1565 declared as a record type. It indicates that the type corresponds to an
1566 externally declared C++ class type, and is to be laid out the same way
1567 that C++ would lay out the type. If the C++ class has virtual primitives
1568 then the record must be declared as a tagged record type.
1569
1570 Types for which @code{CPP_Class} is specified do not have assignment or
1571 equality operators defined (such operations can be imported or declared
1572 as subprograms as required). Initialization is allowed only by constructor
1573 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1574 limited if not explicitly declared as limited or derived from a limited
1575 type, and an error is issued in that case.
1576
1577 Pragma @code{CPP_Class} is intended primarily for automatic generation
1578 using an automatic binding generator tool.
1579 See @ref{Interfacing to C++} for related information.
1580
1581 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1582 for backward compatibility but its functionality is available
1583 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1584
1585 @node Pragma CPP_Constructor
1586 @unnumberedsec Pragma CPP_Constructor
1587 @cindex Interfacing with C++
1588 @findex CPP_Constructor
1589 @noindent
1590 Syntax:
1591
1592 @smallexample @c ada
1593 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1594 [, [External_Name =>] static_string_EXPRESSION ]
1595 [, [Link_Name =>] static_string_EXPRESSION ]);
1596 @end smallexample
1597
1598 @noindent
1599 This pragma identifies an imported function (imported in the usual way
1600 with pragma @code{Import}) as corresponding to a C++ constructor. If
1601 @code{External_Name} and @code{Link_Name} are not specified then the
1602 @code{Entity} argument is a name that must have been previously mentioned
1603 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1604 must be of one of the following forms:
1605
1606 @itemize @bullet
1607 @item
1608 @code{function @var{Fname} return @var{T}}
1609
1610 @itemize @bullet
1611 @item
1612 @code{function @var{Fname} return @var{T}'Class}
1613
1614 @item
1615 @code{function @var{Fname} (@dots{}) return @var{T}}
1616 @end itemize
1617
1618 @item
1619 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1620 @end itemize
1621
1622 @noindent
1623 where @var{T} is a limited record type imported from C++ with pragma
1624 @code{Import} and @code{Convention} = @code{CPP}.
1625
1626 The first two forms import the default constructor, used when an object
1627 of type @var{T} is created on the Ada side with no explicit constructor.
1628 The latter two forms cover all the non-default constructors of the type.
1629 See the GNAT users guide for details.
1630
1631 If no constructors are imported, it is impossible to create any objects
1632 on the Ada side and the type is implicitly declared abstract.
1633
1634 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1635 using an automatic binding generator tool.
1636 See @ref{Interfacing to C++} for more related information.
1637
1638 Note: The use of functions returning class-wide types for constructors is
1639 currently obsolete. They are supported for backward compatibility. The
1640 use of functions returning the type T leave the Ada sources more clear
1641 because the imported C++ constructors always return an object of type T;
1642 that is, they never return an object whose type is a descendant of type T.
1643
1644 @node Pragma CPP_Virtual
1645 @unnumberedsec Pragma CPP_Virtual
1646 @cindex Interfacing to C++
1647 @findex CPP_Virtual
1648 @noindent
1649 This pragma is now obsolete has has no effect because GNAT generates
1650 the same object layout than the G++ compiler.
1651
1652 See @ref{Interfacing to C++} for related information.
1653
1654 @node Pragma CPP_Vtable
1655 @unnumberedsec Pragma CPP_Vtable
1656 @cindex Interfacing with C++
1657 @findex CPP_Vtable
1658 @noindent
1659 This pragma is now obsolete has has no effect because GNAT generates
1660 the same object layout than the G++ compiler.
1661
1662 See @ref{Interfacing to C++} for related information.
1663
1664 @node Pragma Debug
1665 @unnumberedsec Pragma Debug
1666 @findex Debug
1667 @noindent
1668 Syntax:
1669
1670 @smallexample @c ada
1671 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1672
1673 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1674 PROCEDURE_NAME
1675 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1676 @end smallexample
1677
1678 @noindent
1679 The procedure call argument has the syntactic form of an expression, meeting
1680 the syntactic requirements for pragmas.
1681
1682 If debug pragmas are not enabled or if the condition is present and evaluates
1683 to False, this pragma has no effect. If debug pragmas are enabled, the
1684 semantics of the pragma is exactly equivalent to the procedure call statement
1685 corresponding to the argument with a terminating semicolon. Pragmas are
1686 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1687 intersperse calls to debug procedures in the middle of declarations. Debug
1688 pragmas can be enabled either by use of the command line switch @option{-gnata}
1689 or by use of the configuration pragma @code{Debug_Policy}.
1690
1691 @node Pragma Debug_Policy
1692 @unnumberedsec Pragma Debug_Policy
1693 @findex Debug_Policy
1694 @noindent
1695 Syntax:
1696
1697 @smallexample @c ada
1698 pragma Debug_Policy (CHECK | IGNORE);
1699 @end smallexample
1700
1701 @noindent
1702 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1703 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1704 This pragma overrides the effect of the @option{-gnata} switch on the
1705 command line.
1706
1707 @node Pragma Detect_Blocking
1708 @unnumberedsec Pragma Detect_Blocking
1709 @findex Detect_Blocking
1710 @noindent
1711 Syntax:
1712
1713 @smallexample @c ada
1714 pragma Detect_Blocking;
1715 @end smallexample
1716
1717 @noindent
1718 This is a configuration pragma that forces the detection of potentially
1719 blocking operations within a protected operation, and to raise Program_Error
1720 if that happens.
1721
1722 @node Pragma Elaboration_Checks
1723 @unnumberedsec Pragma Elaboration_Checks
1724 @cindex Elaboration control
1725 @findex Elaboration_Checks
1726 @noindent
1727 Syntax:
1728
1729 @smallexample @c ada
1730 pragma Elaboration_Checks (Dynamic | Static);
1731 @end smallexample
1732
1733 @noindent
1734 This is a configuration pragma that provides control over the
1735 elaboration model used by the compilation affected by the
1736 pragma. If the parameter is @code{Dynamic},
1737 then the dynamic elaboration
1738 model described in the Ada Reference Manual is used, as though
1739 the @option{-gnatE} switch had been specified on the command
1740 line. If the parameter is @code{Static}, then the default GNAT static
1741 model is used. This configuration pragma overrides the setting
1742 of the command line. For full details on the elaboration models
1743 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1744 gnat_ugn, @value{EDITION} User's Guide}.
1745
1746 @node Pragma Eliminate
1747 @unnumberedsec Pragma Eliminate
1748 @cindex Elimination of unused subprograms
1749 @findex Eliminate
1750 @noindent
1751 Syntax:
1752
1753 @smallexample @c ada
1754 pragma Eliminate (
1755 [Unit_Name =>] IDENTIFIER |
1756 SELECTED_COMPONENT);
1757
1758 pragma Eliminate (
1759 [Unit_Name =>] IDENTIFIER |
1760 SELECTED_COMPONENT,
1761 [Entity =>] IDENTIFIER |
1762 SELECTED_COMPONENT |
1763 STRING_LITERAL
1764 [,OVERLOADING_RESOLUTION]);
1765
1766 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1767 SOURCE_LOCATION
1768
1769 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1770 FUNCTION_PROFILE
1771
1772 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1773
1774 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1775 Result_Type => result_SUBTYPE_NAME]
1776
1777 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1778 SUBTYPE_NAME ::= STRING_VALUE
1779
1780 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1781 SOURCE_TRACE ::= STRING_VALUE
1782
1783 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1784 @end smallexample
1785
1786 @noindent
1787 This pragma indicates that the given entity is not used outside the
1788 compilation unit it is defined in. The entity must be an explicitly declared
1789 subprogram; this includes generic subprogram instances and
1790 subprograms declared in generic package instances.
1791
1792 If the entity to be eliminated is a library level subprogram, then
1793 the first form of pragma @code{Eliminate} is used with only a single argument.
1794 In this form, the @code{Unit_Name} argument specifies the name of the
1795 library level unit to be eliminated.
1796
1797 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1798 are required. If item is an entity of a library package, then the first
1799 argument specifies the unit name, and the second argument specifies
1800 the particular entity. If the second argument is in string form, it must
1801 correspond to the internal manner in which GNAT stores entity names (see
1802 compilation unit Namet in the compiler sources for details).
1803
1804 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1805 to distinguish between overloaded subprograms. If a pragma does not contain
1806 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1807 subprograms denoted by the first two parameters.
1808
1809 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1810 to be eliminated in a manner similar to that used for the extended
1811 @code{Import} and @code{Export} pragmas, except that the subtype names are
1812 always given as strings. At the moment, this form of distinguishing
1813 overloaded subprograms is implemented only partially, so we do not recommend
1814 using it for practical subprogram elimination.
1815
1816 Note that in case of a parameterless procedure its profile is represented
1817 as @code{Parameter_Types => ("")}
1818
1819 Alternatively, the @code{Source_Location} parameter is used to specify
1820 which overloaded alternative is to be eliminated by pointing to the
1821 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1822 source text. The string literal (or concatenation of string literals)
1823 given as SOURCE_TRACE must have the following format:
1824
1825 @smallexample @c ada
1826 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1827
1828 LBRACKET ::= [
1829 RBRACKET ::= ]
1830
1831 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1832 FILE_NAME ::= STRING_LITERAL
1833 LINE_NUMBER ::= DIGIT @{DIGIT@}
1834 @end smallexample
1835
1836 SOURCE_TRACE should be the short name of the source file (with no directory
1837 information), and LINE_NUMBER is supposed to point to the line where the
1838 defining name of the subprogram is located.
1839
1840 For the subprograms that are not a part of generic instantiations, only one
1841 SOURCE_LOCATION is used. If a subprogram is declared in a package
1842 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1843 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1844 second one denotes the declaration of the corresponding subprogram in the
1845 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1846 in case of nested instantiations.
1847
1848 The effect of the pragma is to allow the compiler to eliminate
1849 the code or data associated with the named entity. Any reference to
1850 an eliminated entity outside the compilation unit it is defined in,
1851 causes a compile time or link time error.
1852
1853 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1854 in a system independent manner, with unused entities eliminated, without
1855 the requirement of modifying the source text. Normally the required set
1856 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1857 tool. Elimination of unused entities local to a compilation unit is
1858 automatic, without requiring the use of pragma @code{Eliminate}.
1859
1860 Note that the reason this pragma takes string literals where names might
1861 be expected is that a pragma @code{Eliminate} can appear in a context where the
1862 relevant names are not visible.
1863
1864 Note that any change in the source files that includes removing, splitting of
1865 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1866 parameter illegal.
1867
1868 It is legal to use pragma Eliminate where the referenced entity is a
1869 dispatching operation, but it is not clear what this would mean, since
1870 in general the call does not know which entity is actually being called.
1871 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1872
1873 @node Pragma Export_Exception
1874 @unnumberedsec Pragma Export_Exception
1875 @cindex OpenVMS
1876 @findex Export_Exception
1877 @noindent
1878 Syntax:
1879
1880 @smallexample @c ada
1881 pragma Export_Exception (
1882 [Internal =>] LOCAL_NAME
1883 [, [External =>] EXTERNAL_SYMBOL]
1884 [, [Form =>] Ada | VMS]
1885 [, [Code =>] static_integer_EXPRESSION]);
1886
1887 EXTERNAL_SYMBOL ::=
1888 IDENTIFIER
1889 | static_string_EXPRESSION
1890 @end smallexample
1891
1892 @noindent
1893 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1894 causes the specified exception to be propagated outside of the Ada program,
1895 so that it can be handled by programs written in other OpenVMS languages.
1896 This pragma establishes an external name for an Ada exception and makes the
1897 name available to the OpenVMS Linker as a global symbol. For further details
1898 on this pragma, see the
1899 DEC Ada Language Reference Manual, section 13.9a3.2.
1900
1901 @node Pragma Export_Function
1902 @unnumberedsec Pragma Export_Function
1903 @cindex Argument passing mechanisms
1904 @findex Export_Function
1905
1906 @noindent
1907 Syntax:
1908
1909 @smallexample @c ada
1910 pragma Export_Function (
1911 [Internal =>] LOCAL_NAME
1912 [, [External =>] EXTERNAL_SYMBOL]
1913 [, [Parameter_Types =>] PARAMETER_TYPES]
1914 [, [Result_Type =>] result_SUBTYPE_MARK]
1915 [, [Mechanism =>] MECHANISM]
1916 [, [Result_Mechanism =>] MECHANISM_NAME]);
1917
1918 EXTERNAL_SYMBOL ::=
1919 IDENTIFIER
1920 | static_string_EXPRESSION
1921 | ""
1922
1923 PARAMETER_TYPES ::=
1924 null
1925 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1926
1927 TYPE_DESIGNATOR ::=
1928 subtype_NAME
1929 | subtype_Name ' Access
1930
1931 MECHANISM ::=
1932 MECHANISM_NAME
1933 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1934
1935 MECHANISM_ASSOCIATION ::=
1936 [formal_parameter_NAME =>] MECHANISM_NAME
1937
1938 MECHANISM_NAME ::=
1939 Value
1940 | Reference
1941 | Descriptor [([Class =>] CLASS_NAME)]
1942 | Short_Descriptor [([Class =>] CLASS_NAME)]
1943
1944 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1945 @end smallexample
1946
1947 @noindent
1948 Use this pragma to make a function externally callable and optionally
1949 provide information on mechanisms to be used for passing parameter and
1950 result values. We recommend, for the purposes of improving portability,
1951 this pragma always be used in conjunction with a separate pragma
1952 @code{Export}, which must precede the pragma @code{Export_Function}.
1953 GNAT does not require a separate pragma @code{Export}, but if none is
1954 present, @code{Convention Ada} is assumed, which is usually
1955 not what is wanted, so it is usually appropriate to use this
1956 pragma in conjunction with a @code{Export} or @code{Convention}
1957 pragma that specifies the desired foreign convention.
1958 Pragma @code{Export_Function}
1959 (and @code{Export}, if present) must appear in the same declarative
1960 region as the function to which they apply.
1961
1962 @var{internal_name} must uniquely designate the function to which the
1963 pragma applies. If more than one function name exists of this name in
1964 the declarative part you must use the @code{Parameter_Types} and
1965 @code{Result_Type} parameters is mandatory to achieve the required
1966 unique designation. @var{subtype_mark}s in these parameters must
1967 exactly match the subtypes in the corresponding function specification,
1968 using positional notation to match parameters with subtype marks.
1969 The form with an @code{'Access} attribute can be used to match an
1970 anonymous access parameter.
1971
1972 @cindex OpenVMS
1973 @cindex Passing by descriptor
1974 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1975 The default behavior for Export_Function is to accept either 64bit or
1976 32bit descriptors unless short_descriptor is specified, then only 32bit
1977 descriptors are accepted.
1978
1979 @cindex Suppressing external name
1980 Special treatment is given if the EXTERNAL is an explicit null
1981 string or a static string expressions that evaluates to the null
1982 string. In this case, no external name is generated. This form
1983 still allows the specification of parameter mechanisms.
1984
1985 @node Pragma Export_Object
1986 @unnumberedsec Pragma Export_Object
1987 @findex Export_Object
1988 @noindent
1989 Syntax:
1990
1991 @smallexample @c ada
1992 pragma Export_Object
1993 [Internal =>] LOCAL_NAME
1994 [, [External =>] EXTERNAL_SYMBOL]
1995 [, [Size =>] EXTERNAL_SYMBOL]
1996
1997 EXTERNAL_SYMBOL ::=
1998 IDENTIFIER
1999 | static_string_EXPRESSION
2000 @end smallexample
2001
2002 @noindent
2003 This pragma designates an object as exported, and apart from the
2004 extended rules for external symbols, is identical in effect to the use of
2005 the normal @code{Export} pragma applied to an object. You may use a
2006 separate Export pragma (and you probably should from the point of view
2007 of portability), but it is not required. @var{Size} is syntax checked,
2008 but otherwise ignored by GNAT@.
2009
2010 @node Pragma Export_Procedure
2011 @unnumberedsec Pragma Export_Procedure
2012 @findex Export_Procedure
2013 @noindent
2014 Syntax:
2015
2016 @smallexample @c ada
2017 pragma Export_Procedure (
2018 [Internal =>] LOCAL_NAME
2019 [, [External =>] EXTERNAL_SYMBOL]
2020 [, [Parameter_Types =>] PARAMETER_TYPES]
2021 [, [Mechanism =>] MECHANISM]);
2022
2023 EXTERNAL_SYMBOL ::=
2024 IDENTIFIER
2025 | static_string_EXPRESSION
2026 | ""
2027
2028 PARAMETER_TYPES ::=
2029 null
2030 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2031
2032 TYPE_DESIGNATOR ::=
2033 subtype_NAME
2034 | subtype_Name ' Access
2035
2036 MECHANISM ::=
2037 MECHANISM_NAME
2038 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2039
2040 MECHANISM_ASSOCIATION ::=
2041 [formal_parameter_NAME =>] MECHANISM_NAME
2042
2043 MECHANISM_NAME ::=
2044 Value
2045 | Reference
2046 | Descriptor [([Class =>] CLASS_NAME)]
2047 | Short_Descriptor [([Class =>] CLASS_NAME)]
2048
2049 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2050 @end smallexample
2051
2052 @noindent
2053 This pragma is identical to @code{Export_Function} except that it
2054 applies to a procedure rather than a function and the parameters
2055 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2056 GNAT does not require a separate pragma @code{Export}, but if none is
2057 present, @code{Convention Ada} is assumed, which is usually
2058 not what is wanted, so it is usually appropriate to use this
2059 pragma in conjunction with a @code{Export} or @code{Convention}
2060 pragma that specifies the desired foreign convention.
2061
2062 @cindex OpenVMS
2063 @cindex Passing by descriptor
2064 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2065 The default behavior for Export_Procedure is to accept either 64bit or
2066 32bit descriptors unless short_descriptor is specified, then only 32bit
2067 descriptors are accepted.
2068
2069 @cindex Suppressing external name
2070 Special treatment is given if the EXTERNAL is an explicit null
2071 string or a static string expressions that evaluates to the null
2072 string. In this case, no external name is generated. This form
2073 still allows the specification of parameter mechanisms.
2074
2075 @node Pragma Export_Value
2076 @unnumberedsec Pragma Export_Value
2077 @findex Export_Value
2078 @noindent
2079 Syntax:
2080
2081 @smallexample @c ada
2082 pragma Export_Value (
2083 [Value =>] static_integer_EXPRESSION,
2084 [Link_Name =>] static_string_EXPRESSION);
2085 @end smallexample
2086
2087 @noindent
2088 This pragma serves to export a static integer value for external use.
2089 The first argument specifies the value to be exported. The Link_Name
2090 argument specifies the symbolic name to be associated with the integer
2091 value. This pragma is useful for defining a named static value in Ada
2092 that can be referenced in assembly language units to be linked with
2093 the application. This pragma is currently supported only for the
2094 AAMP target and is ignored for other targets.
2095
2096 @node Pragma Export_Valued_Procedure
2097 @unnumberedsec Pragma Export_Valued_Procedure
2098 @findex Export_Valued_Procedure
2099 @noindent
2100 Syntax:
2101
2102 @smallexample @c ada
2103 pragma Export_Valued_Procedure (
2104 [Internal =>] LOCAL_NAME
2105 [, [External =>] EXTERNAL_SYMBOL]
2106 [, [Parameter_Types =>] PARAMETER_TYPES]
2107 [, [Mechanism =>] MECHANISM]);
2108
2109 EXTERNAL_SYMBOL ::=
2110 IDENTIFIER
2111 | static_string_EXPRESSION
2112 | ""
2113
2114 PARAMETER_TYPES ::=
2115 null
2116 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2117
2118 TYPE_DESIGNATOR ::=
2119 subtype_NAME
2120 | subtype_Name ' Access
2121
2122 MECHANISM ::=
2123 MECHANISM_NAME
2124 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2125
2126 MECHANISM_ASSOCIATION ::=
2127 [formal_parameter_NAME =>] MECHANISM_NAME
2128
2129 MECHANISM_NAME ::=
2130 Value
2131 | Reference
2132 | Descriptor [([Class =>] CLASS_NAME)]
2133 | Short_Descriptor [([Class =>] CLASS_NAME)]
2134
2135 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2136 @end smallexample
2137
2138 @noindent
2139 This pragma is identical to @code{Export_Procedure} except that the
2140 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2141 mode @code{OUT}, and externally the subprogram is treated as a function
2142 with this parameter as the result of the function. GNAT provides for
2143 this capability to allow the use of @code{OUT} and @code{IN OUT}
2144 parameters in interfacing to external functions (which are not permitted
2145 in Ada functions).
2146 GNAT does not require a separate pragma @code{Export}, but if none is
2147 present, @code{Convention Ada} is assumed, which is almost certainly
2148 not what is wanted since the whole point of this pragma is to interface
2149 with foreign language functions, so it is usually appropriate to use this
2150 pragma in conjunction with a @code{Export} or @code{Convention}
2151 pragma that specifies the desired foreign convention.
2152
2153 @cindex OpenVMS
2154 @cindex Passing by descriptor
2155 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2156 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2157 32bit descriptors unless short_descriptor is specified, then only 32bit
2158 descriptors are accepted.
2159
2160 @cindex Suppressing external name
2161 Special treatment is given if the EXTERNAL is an explicit null
2162 string or a static string expressions that evaluates to the null
2163 string. In this case, no external name is generated. This form
2164 still allows the specification of parameter mechanisms.
2165
2166 @node Pragma Extend_System
2167 @unnumberedsec Pragma Extend_System
2168 @cindex @code{system}, extending
2169 @cindex Dec Ada 83
2170 @findex Extend_System
2171 @noindent
2172 Syntax:
2173
2174 @smallexample @c ada
2175 pragma Extend_System ([Name =>] IDENTIFIER);
2176 @end smallexample
2177
2178 @noindent
2179 This pragma is used to provide backwards compatibility with other
2180 implementations that extend the facilities of package @code{System}. In
2181 GNAT, @code{System} contains only the definitions that are present in
2182 the Ada RM@. However, other implementations, notably the DEC Ada 83
2183 implementation, provide many extensions to package @code{System}.
2184
2185 For each such implementation accommodated by this pragma, GNAT provides a
2186 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2187 implementation, which provides the required additional definitions. You
2188 can use this package in two ways. You can @code{with} it in the normal
2189 way and access entities either by selection or using a @code{use}
2190 clause. In this case no special processing is required.
2191
2192 However, if existing code contains references such as
2193 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2194 definitions provided in package @code{System}, you may use this pragma
2195 to extend visibility in @code{System} in a non-standard way that
2196 provides greater compatibility with the existing code. Pragma
2197 @code{Extend_System} is a configuration pragma whose single argument is
2198 the name of the package containing the extended definition
2199 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2200 control of this pragma will be processed using special visibility
2201 processing that looks in package @code{System.Aux_@var{xxx}} where
2202 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2203 package @code{System}, but not found in package @code{System}.
2204
2205 You can use this pragma either to access a predefined @code{System}
2206 extension supplied with the compiler, for example @code{Aux_DEC} or
2207 you can construct your own extension unit following the above
2208 definition. Note that such a package is a child of @code{System}
2209 and thus is considered part of the implementation. To compile
2210 it you will have to use the appropriate switch for compiling
2211 system units. @xref{Top, @value{EDITION} User's Guide, About This
2212 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2213
2214 @node Pragma Extensions_Allowed
2215 @unnumberedsec Pragma Extensions_Allowed
2216 @cindex Ada Extensions
2217 @cindex GNAT Extensions
2218 @findex Extensions_Allowed
2219 @noindent
2220 Syntax:
2221
2222 @smallexample @c ada
2223 pragma Extensions_Allowed (On | Off);
2224 @end smallexample
2225
2226 @noindent
2227 This configuration pragma enables or disables the implementation
2228 extension mode (the use of Off as a parameter cancels the effect
2229 of the @option{-gnatX} command switch).
2230
2231 In extension mode, the latest version of the Ada language is
2232 implemented (currently Ada 2012), and in addition a small number
2233 of GNAT specific extensions are recognized as follows:
2234
2235 @table @asis
2236 @item Constrained attribute for generic objects
2237 The @code{Constrained} attribute is permitted for objects of
2238 generic types. The result indicates if the corresponding actual
2239 is constrained.
2240
2241 @end table
2242
2243 @node Pragma External
2244 @unnumberedsec Pragma External
2245 @findex External
2246 @noindent
2247 Syntax:
2248
2249 @smallexample @c ada
2250 pragma External (
2251 [ Convention =>] convention_IDENTIFIER,
2252 [ Entity =>] LOCAL_NAME
2253 [, [External_Name =>] static_string_EXPRESSION ]
2254 [, [Link_Name =>] static_string_EXPRESSION ]);
2255 @end smallexample
2256
2257 @noindent
2258 This pragma is identical in syntax and semantics to pragma
2259 @code{Export} as defined in the Ada Reference Manual. It is
2260 provided for compatibility with some Ada 83 compilers that
2261 used this pragma for exactly the same purposes as pragma
2262 @code{Export} before the latter was standardized.
2263
2264 @node Pragma External_Name_Casing
2265 @unnumberedsec Pragma External_Name_Casing
2266 @cindex Dec Ada 83 casing compatibility
2267 @cindex External Names, casing
2268 @cindex Casing of External names
2269 @findex External_Name_Casing
2270 @noindent
2271 Syntax:
2272
2273 @smallexample @c ada
2274 pragma External_Name_Casing (
2275 Uppercase | Lowercase
2276 [, Uppercase | Lowercase | As_Is]);
2277 @end smallexample
2278
2279 @noindent
2280 This pragma provides control over the casing of external names associated
2281 with Import and Export pragmas. There are two cases to consider:
2282
2283 @table @asis
2284 @item Implicit external names
2285 Implicit external names are derived from identifiers. The most common case
2286 arises when a standard Ada Import or Export pragma is used with only two
2287 arguments, as in:
2288
2289 @smallexample @c ada
2290 pragma Import (C, C_Routine);
2291 @end smallexample
2292
2293 @noindent
2294 Since Ada is a case-insensitive language, the spelling of the identifier in
2295 the Ada source program does not provide any information on the desired
2296 casing of the external name, and so a convention is needed. In GNAT the
2297 default treatment is that such names are converted to all lower case
2298 letters. This corresponds to the normal C style in many environments.
2299 The first argument of pragma @code{External_Name_Casing} can be used to
2300 control this treatment. If @code{Uppercase} is specified, then the name
2301 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2302 then the normal default of all lower case letters will be used.
2303
2304 This same implicit treatment is also used in the case of extended DEC Ada 83
2305 compatible Import and Export pragmas where an external name is explicitly
2306 specified using an identifier rather than a string.
2307
2308 @item Explicit external names
2309 Explicit external names are given as string literals. The most common case
2310 arises when a standard Ada Import or Export pragma is used with three
2311 arguments, as in:
2312
2313 @smallexample @c ada
2314 pragma Import (C, C_Routine, "C_routine");
2315 @end smallexample
2316
2317 @noindent
2318 In this case, the string literal normally provides the exact casing required
2319 for the external name. The second argument of pragma
2320 @code{External_Name_Casing} may be used to modify this behavior.
2321 If @code{Uppercase} is specified, then the name
2322 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2323 then the name will be forced to all lowercase letters. A specification of
2324 @code{As_Is} provides the normal default behavior in which the casing is
2325 taken from the string provided.
2326 @end table
2327
2328 @noindent
2329 This pragma may appear anywhere that a pragma is valid. In particular, it
2330 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2331 case it applies to all subsequent compilations, or it can be used as a program
2332 unit pragma, in which case it only applies to the current unit, or it can
2333 be used more locally to control individual Import/Export pragmas.
2334
2335 It is primarily intended for use with OpenVMS systems, where many
2336 compilers convert all symbols to upper case by default. For interfacing to
2337 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2338 the pragma:
2339
2340 @smallexample @c ada
2341 pragma External_Name_Casing (Uppercase, Uppercase);
2342 @end smallexample
2343
2344 @noindent
2345 to enforce the upper casing of all external symbols.
2346
2347 @node Pragma Fast_Math
2348 @unnumberedsec Pragma Fast_Math
2349 @findex Fast_Math
2350 @noindent
2351 Syntax:
2352
2353 @smallexample @c ada
2354 pragma Fast_Math;
2355 @end smallexample
2356
2357 @noindent
2358 This is a configuration pragma which activates a mode in which speed is
2359 considered more important for floating-point operations than absolutely
2360 accurate adherence to the requirements of the standard. Currently the
2361 following operations are affected:
2362
2363 @table @asis
2364 @item Complex Multiplication
2365 The normal simple formula for complex multiplication can result in intermediate
2366 overflows for numbers near the end of the range. The Ada standard requires that
2367 this situation be detected and corrected by scaling, but in Fast_Math mode such
2368 cases will simply result in overflow. Note that to take advantage of this you
2369 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2370 under control of the pragma, rather than use the preinstantiated versions.
2371 @end table
2372
2373 @node Pragma Favor_Top_Level
2374 @unnumberedsec Pragma Favor_Top_Level
2375 @findex Favor_Top_Level
2376 @noindent
2377 Syntax:
2378
2379 @smallexample @c ada
2380 pragma Favor_Top_Level (type_NAME);
2381 @end smallexample
2382
2383 @noindent
2384 The named type must be an access-to-subprogram type. This pragma is an
2385 efficiency hint to the compiler, regarding the use of 'Access or
2386 'Unrestricted_Access on nested (non-library-level) subprograms. The
2387 pragma means that nested subprograms are not used with this type, or
2388 are rare, so that the generated code should be efficient in the
2389 top-level case. When this pragma is used, dynamically generated
2390 trampolines may be used on some targets for nested subprograms.
2391 See also the No_Implicit_Dynamic_Code restriction.
2392
2393 @node Pragma Finalize_Storage_Only
2394 @unnumberedsec Pragma Finalize_Storage_Only
2395 @findex Finalize_Storage_Only
2396 @noindent
2397 Syntax:
2398
2399 @smallexample @c ada
2400 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2401 @end smallexample
2402
2403 @noindent
2404 This pragma allows the compiler not to emit a Finalize call for objects
2405 defined at the library level. This is mostly useful for types where
2406 finalization is only used to deal with storage reclamation since in most
2407 environments it is not necessary to reclaim memory just before terminating
2408 execution, hence the name.
2409
2410 @node Pragma Float_Representation
2411 @unnumberedsec Pragma Float_Representation
2412 @cindex OpenVMS
2413 @findex Float_Representation
2414 @noindent
2415 Syntax:
2416
2417 @smallexample @c ada
2418 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2419
2420 FLOAT_REP ::= VAX_Float | IEEE_Float
2421 @end smallexample
2422
2423 @noindent
2424 In the one argument form, this pragma is a configuration pragma which
2425 allows control over the internal representation chosen for the predefined
2426 floating point types declared in the packages @code{Standard} and
2427 @code{System}. On all systems other than OpenVMS, the argument must
2428 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2429 argument may be @code{VAX_Float} to specify the use of the VAX float
2430 format for the floating-point types in Standard. This requires that
2431 the standard runtime libraries be recompiled.
2432
2433 The two argument form specifies the representation to be used for
2434 the specified floating-point type. On all systems other than OpenVMS,
2435 the argument must
2436 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2437 argument may be @code{VAX_Float} to specify the use of the VAX float
2438 format, as follows:
2439
2440 @itemize @bullet
2441 @item
2442 For digits values up to 6, F float format will be used.
2443 @item
2444 For digits values from 7 to 9, G float format will be used.
2445 @item
2446 For digits values from 10 to 15, F float format will be used.
2447 @item
2448 Digits values above 15 are not allowed.
2449 @end itemize
2450
2451 @node Pragma Ident
2452 @unnumberedsec Pragma Ident
2453 @findex Ident
2454 @noindent
2455 Syntax:
2456
2457 @smallexample @c ada
2458 pragma Ident (static_string_EXPRESSION);
2459 @end smallexample
2460
2461 @noindent
2462 This pragma provides a string identification in the generated object file,
2463 if the system supports the concept of this kind of identification string.
2464 This pragma is allowed only in the outermost declarative part or
2465 declarative items of a compilation unit. If more than one @code{Ident}
2466 pragma is given, only the last one processed is effective.
2467 @cindex OpenVMS
2468 On OpenVMS systems, the effect of the pragma is identical to the effect of
2469 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2470 maximum allowed length is 31 characters, so if it is important to
2471 maintain compatibility with this compiler, you should obey this length
2472 limit.
2473
2474 @node Pragma Implemented_By_Entry
2475 @unnumberedsec Pragma Implemented_By_Entry
2476 @findex Implemented_By_Entry
2477 @noindent
2478 Syntax:
2479
2480 @smallexample @c ada
2481 pragma Implemented_By_Entry (LOCAL_NAME);
2482 @end smallexample
2483
2484 @noindent
2485 This is a representation pragma which applies to protected, synchronized and
2486 task interface primitives. If the pragma is applied to primitive operation Op
2487 of interface Iface, it is illegal to override Op in a type that implements
2488 Iface, with anything other than an entry.
2489
2490 @smallexample @c ada
2491 type Iface is protected interface;
2492 procedure Do_Something (Object : in out Iface) is abstract;
2493 pragma Implemented_By_Entry (Do_Something);
2494
2495 protected type P is new Iface with
2496 procedure Do_Something; -- Illegal
2497 end P;
2498
2499 task type T is new Iface with
2500 entry Do_Something; -- Legal
2501 end T;
2502 @end smallexample
2503
2504 @noindent
2505 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2506 is intended to be used in conjunction with dispatching requeue statements as
2507 described in AI05-0030. Should the ARG decide on an official name and syntax,
2508 this pragma will become language-defined rather than GNAT-specific.
2509
2510 @node Pragma Implicit_Packing
2511 @unnumberedsec Pragma Implicit_Packing
2512 @findex Implicit_Packing
2513 @noindent
2514 Syntax:
2515
2516 @smallexample @c ada
2517 pragma Implicit_Packing;
2518 @end smallexample
2519
2520 @noindent
2521 This is a configuration pragma that requests implicit packing for packed
2522 arrays for which a size clause is given but no explicit pragma Pack or
2523 specification of Component_Size is present. It also applies to records
2524 where no record representation clause is present. Consider this example:
2525
2526 @smallexample @c ada
2527 type R is array (0 .. 7) of Boolean;
2528 for R'Size use 8;
2529 @end smallexample
2530
2531 @noindent
2532 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2533 does not change the layout of a composite object. So the Size clause in the
2534 above example is normally rejected, since the default layout of the array uses
2535 8-bit components, and thus the array requires a minimum of 64 bits.
2536
2537 If this declaration is compiled in a region of code covered by an occurrence
2538 of the configuration pragma Implicit_Packing, then the Size clause in this
2539 and similar examples will cause implicit packing and thus be accepted. For
2540 this implicit packing to occur, the type in question must be an array of small
2541 components whose size is known at compile time, and the Size clause must
2542 specify the exact size that corresponds to the length of the array multiplied
2543 by the size in bits of the component type.
2544 @cindex Array packing
2545
2546 Similarly, the following example shows the use in the record case
2547
2548 @smallexample @c ada
2549 type r is record
2550 a, b, c, d, e, f, g, h : boolean;
2551 chr : character;
2552 end record;
2553 for r'size use 16;
2554 @end smallexample
2555
2556 @noindent
2557 Without a pragma Pack, each Boolean field requires 8 bits, so the
2558 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2559 sufficient. The use of pragma Implciit_Packing allows this record
2560 declaration to compile without an explicit pragma Pack.
2561 @node Pragma Import_Exception
2562 @unnumberedsec Pragma Import_Exception
2563 @cindex OpenVMS
2564 @findex Import_Exception
2565 @noindent
2566 Syntax:
2567
2568 @smallexample @c ada
2569 pragma Import_Exception (
2570 [Internal =>] LOCAL_NAME
2571 [, [External =>] EXTERNAL_SYMBOL]
2572 [, [Form =>] Ada | VMS]
2573 [, [Code =>] static_integer_EXPRESSION]);
2574
2575 EXTERNAL_SYMBOL ::=
2576 IDENTIFIER
2577 | static_string_EXPRESSION
2578 @end smallexample
2579
2580 @noindent
2581 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2582 It allows OpenVMS conditions (for example, from OpenVMS system services or
2583 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2584 The pragma specifies that the exception associated with an exception
2585 declaration in an Ada program be defined externally (in non-Ada code).
2586 For further details on this pragma, see the
2587 DEC Ada Language Reference Manual, section 13.9a.3.1.
2588
2589 @node Pragma Import_Function
2590 @unnumberedsec Pragma Import_Function
2591 @findex Import_Function
2592 @noindent
2593 Syntax:
2594
2595 @smallexample @c ada
2596 pragma Import_Function (
2597 [Internal =>] LOCAL_NAME,
2598 [, [External =>] EXTERNAL_SYMBOL]
2599 [, [Parameter_Types =>] PARAMETER_TYPES]
2600 [, [Result_Type =>] SUBTYPE_MARK]
2601 [, [Mechanism =>] MECHANISM]
2602 [, [Result_Mechanism =>] MECHANISM_NAME]
2603 [, [First_Optional_Parameter =>] IDENTIFIER]);
2604
2605 EXTERNAL_SYMBOL ::=
2606 IDENTIFIER
2607 | static_string_EXPRESSION
2608
2609 PARAMETER_TYPES ::=
2610 null
2611 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2612
2613 TYPE_DESIGNATOR ::=
2614 subtype_NAME
2615 | subtype_Name ' Access
2616
2617 MECHANISM ::=
2618 MECHANISM_NAME
2619 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2620
2621 MECHANISM_ASSOCIATION ::=
2622 [formal_parameter_NAME =>] MECHANISM_NAME
2623
2624 MECHANISM_NAME ::=
2625 Value
2626 | Reference
2627 | Descriptor [([Class =>] CLASS_NAME)]
2628 | Short_Descriptor [([Class =>] CLASS_NAME)]
2629
2630 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2631 @end smallexample
2632
2633 @noindent
2634 This pragma is used in conjunction with a pragma @code{Import} to
2635 specify additional information for an imported function. The pragma
2636 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2637 @code{Import_Function} pragma and both must appear in the same
2638 declarative part as the function specification.
2639
2640 The @var{Internal} argument must uniquely designate
2641 the function to which the
2642 pragma applies. If more than one function name exists of this name in
2643 the declarative part you must use the @code{Parameter_Types} and
2644 @var{Result_Type} parameters to achieve the required unique
2645 designation. Subtype marks in these parameters must exactly match the
2646 subtypes in the corresponding function specification, using positional
2647 notation to match parameters with subtype marks.
2648 The form with an @code{'Access} attribute can be used to match an
2649 anonymous access parameter.
2650
2651 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2652 parameters to specify passing mechanisms for the
2653 parameters and result. If you specify a single mechanism name, it
2654 applies to all parameters. Otherwise you may specify a mechanism on a
2655 parameter by parameter basis using either positional or named
2656 notation. If the mechanism is not specified, the default mechanism
2657 is used.
2658
2659 @cindex OpenVMS
2660 @cindex Passing by descriptor
2661 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2662 The default behavior for Import_Function is to pass a 64bit descriptor
2663 unless short_descriptor is specified, then a 32bit descriptor is passed.
2664
2665 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2666 It specifies that the designated parameter and all following parameters
2667 are optional, meaning that they are not passed at the generated code
2668 level (this is distinct from the notion of optional parameters in Ada
2669 where the parameters are passed anyway with the designated optional
2670 parameters). All optional parameters must be of mode @code{IN} and have
2671 default parameter values that are either known at compile time
2672 expressions, or uses of the @code{'Null_Parameter} attribute.
2673
2674 @node Pragma Import_Object
2675 @unnumberedsec Pragma Import_Object
2676 @findex Import_Object
2677 @noindent
2678 Syntax:
2679
2680 @smallexample @c ada
2681 pragma Import_Object
2682 [Internal =>] LOCAL_NAME
2683 [, [External =>] EXTERNAL_SYMBOL]
2684 [, [Size =>] EXTERNAL_SYMBOL]);
2685
2686 EXTERNAL_SYMBOL ::=
2687 IDENTIFIER
2688 | static_string_EXPRESSION
2689 @end smallexample
2690
2691 @noindent
2692 This pragma designates an object as imported, and apart from the
2693 extended rules for external symbols, is identical in effect to the use of
2694 the normal @code{Import} pragma applied to an object. Unlike the
2695 subprogram case, you need not use a separate @code{Import} pragma,
2696 although you may do so (and probably should do so from a portability
2697 point of view). @var{size} is syntax checked, but otherwise ignored by
2698 GNAT@.
2699
2700 @node Pragma Import_Procedure
2701 @unnumberedsec Pragma Import_Procedure
2702 @findex Import_Procedure
2703 @noindent
2704 Syntax:
2705
2706 @smallexample @c ada
2707 pragma Import_Procedure (
2708 [Internal =>] LOCAL_NAME
2709 [, [External =>] EXTERNAL_SYMBOL]
2710 [, [Parameter_Types =>] PARAMETER_TYPES]
2711 [, [Mechanism =>] MECHANISM]
2712 [, [First_Optional_Parameter =>] IDENTIFIER]);
2713
2714 EXTERNAL_SYMBOL ::=
2715 IDENTIFIER
2716 | static_string_EXPRESSION
2717
2718 PARAMETER_TYPES ::=
2719 null
2720 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2721
2722 TYPE_DESIGNATOR ::=
2723 subtype_NAME
2724 | subtype_Name ' Access
2725
2726 MECHANISM ::=
2727 MECHANISM_NAME
2728 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2729
2730 MECHANISM_ASSOCIATION ::=
2731 [formal_parameter_NAME =>] MECHANISM_NAME
2732
2733 MECHANISM_NAME ::=
2734 Value
2735 | Reference
2736 | Descriptor [([Class =>] CLASS_NAME)]
2737 | Short_Descriptor [([Class =>] CLASS_NAME)]
2738
2739 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2740 @end smallexample
2741
2742 @noindent
2743 This pragma is identical to @code{Import_Function} except that it
2744 applies to a procedure rather than a function and the parameters
2745 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2746
2747 @node Pragma Import_Valued_Procedure
2748 @unnumberedsec Pragma Import_Valued_Procedure
2749 @findex Import_Valued_Procedure
2750 @noindent
2751 Syntax:
2752
2753 @smallexample @c ada
2754 pragma Import_Valued_Procedure (
2755 [Internal =>] LOCAL_NAME
2756 [, [External =>] EXTERNAL_SYMBOL]
2757 [, [Parameter_Types =>] PARAMETER_TYPES]
2758 [, [Mechanism =>] MECHANISM]
2759 [, [First_Optional_Parameter =>] IDENTIFIER]);
2760
2761 EXTERNAL_SYMBOL ::=
2762 IDENTIFIER
2763 | static_string_EXPRESSION
2764
2765 PARAMETER_TYPES ::=
2766 null
2767 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2768
2769 TYPE_DESIGNATOR ::=
2770 subtype_NAME
2771 | subtype_Name ' Access
2772
2773 MECHANISM ::=
2774 MECHANISM_NAME
2775 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2776
2777 MECHANISM_ASSOCIATION ::=
2778 [formal_parameter_NAME =>] MECHANISM_NAME
2779
2780 MECHANISM_NAME ::=
2781 Value
2782 | Reference
2783 | Descriptor [([Class =>] CLASS_NAME)]
2784 | Short_Descriptor [([Class =>] CLASS_NAME)]
2785
2786 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2787 @end smallexample
2788
2789 @noindent
2790 This pragma is identical to @code{Import_Procedure} except that the
2791 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2792 mode @code{OUT}, and externally the subprogram is treated as a function
2793 with this parameter as the result of the function. The purpose of this
2794 capability is to allow the use of @code{OUT} and @code{IN OUT}
2795 parameters in interfacing to external functions (which are not permitted
2796 in Ada functions). You may optionally use the @code{Mechanism}
2797 parameters to specify passing mechanisms for the parameters.
2798 If you specify a single mechanism name, it applies to all parameters.
2799 Otherwise you may specify a mechanism on a parameter by parameter
2800 basis using either positional or named notation. If the mechanism is not
2801 specified, the default mechanism is used.
2802
2803 Note that it is important to use this pragma in conjunction with a separate
2804 pragma Import that specifies the desired convention, since otherwise the
2805 default convention is Ada, which is almost certainly not what is required.
2806
2807 @node Pragma Initialize_Scalars
2808 @unnumberedsec Pragma Initialize_Scalars
2809 @findex Initialize_Scalars
2810 @cindex debugging with Initialize_Scalars
2811 @noindent
2812 Syntax:
2813
2814 @smallexample @c ada
2815 pragma Initialize_Scalars;
2816 @end smallexample
2817
2818 @noindent
2819 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2820 two important differences. First, there is no requirement for the pragma
2821 to be used uniformly in all units of a partition, in particular, it is fine
2822 to use this just for some or all of the application units of a partition,
2823 without needing to recompile the run-time library.
2824
2825 In the case where some units are compiled with the pragma, and some without,
2826 then a declaration of a variable where the type is defined in package
2827 Standard or is locally declared will always be subject to initialization,
2828 as will any declaration of a scalar variable. For composite variables,
2829 whether the variable is initialized may also depend on whether the package
2830 in which the type of the variable is declared is compiled with the pragma.
2831
2832 The other important difference is that you can control the value used
2833 for initializing scalar objects. At bind time, you can select several
2834 options for initialization. You can
2835 initialize with invalid values (similar to Normalize_Scalars, though for
2836 Initialize_Scalars it is not always possible to determine the invalid
2837 values in complex cases like signed component fields with non-standard
2838 sizes). You can also initialize with high or
2839 low values, or with a specified bit pattern. See the users guide for binder
2840 options for specifying these cases.
2841
2842 This means that you can compile a program, and then without having to
2843 recompile the program, you can run it with different values being used
2844 for initializing otherwise uninitialized values, to test if your program
2845 behavior depends on the choice. Of course the behavior should not change,
2846 and if it does, then most likely you have an erroneous reference to an
2847 uninitialized value.
2848
2849 It is even possible to change the value at execution time eliminating even
2850 the need to rebind with a different switch using an environment variable.
2851 See the GNAT users guide for details.
2852
2853 Note that pragma @code{Initialize_Scalars} is particularly useful in
2854 conjunction with the enhanced validity checking that is now provided
2855 in GNAT, which checks for invalid values under more conditions.
2856 Using this feature (see description of the @option{-gnatV} flag in the
2857 users guide) in conjunction with pragma @code{Initialize_Scalars}
2858 provides a powerful new tool to assist in the detection of problems
2859 caused by uninitialized variables.
2860
2861 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2862 effect on the generated code. This may cause your code to be
2863 substantially larger. It may also cause an increase in the amount
2864 of stack required, so it is probably a good idea to turn on stack
2865 checking (see description of stack checking in the GNAT users guide)
2866 when using this pragma.
2867
2868 @node Pragma Inline_Always
2869 @unnumberedsec Pragma Inline_Always
2870 @findex Inline_Always
2871 @noindent
2872 Syntax:
2873
2874 @smallexample @c ada
2875 pragma Inline_Always (NAME [, NAME]);
2876 @end smallexample
2877
2878 @noindent
2879 Similar to pragma @code{Inline} except that inlining is not subject to
2880 the use of option @option{-gnatn} and the inlining happens regardless of
2881 whether this option is used.
2882
2883 @node Pragma Inline_Generic
2884 @unnumberedsec Pragma Inline_Generic
2885 @findex Inline_Generic
2886 @noindent
2887 Syntax:
2888
2889 @smallexample @c ada
2890 pragma Inline_Generic (generic_package_NAME);
2891 @end smallexample
2892
2893 @noindent
2894 This is implemented for compatibility with DEC Ada 83 and is recognized,
2895 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2896 by default when using GNAT@.
2897
2898 @node Pragma Interface
2899 @unnumberedsec Pragma Interface
2900 @findex Interface
2901 @noindent
2902 Syntax:
2903
2904 @smallexample @c ada
2905 pragma Interface (
2906 [Convention =>] convention_identifier,
2907 [Entity =>] local_NAME
2908 [, [External_Name =>] static_string_expression]
2909 [, [Link_Name =>] static_string_expression]);
2910 @end smallexample
2911
2912 @noindent
2913 This pragma is identical in syntax and semantics to
2914 the standard Ada pragma @code{Import}. It is provided for compatibility
2915 with Ada 83. The definition is upwards compatible both with pragma
2916 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2917 with some extended implementations of this pragma in certain Ada 83
2918 implementations. The only difference between pragma @code{Interface}
2919 and pragma @code{Import} is that there is special circuitry to allow
2920 both pragmas to appear for the same subprogram entity (normally it
2921 is illegal to have multiple @code{Import} pragmas. This is useful in
2922 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2923 Ada 83 compilers.
2924
2925 @node Pragma Interface_Name
2926 @unnumberedsec Pragma Interface_Name
2927 @findex Interface_Name
2928 @noindent
2929 Syntax:
2930
2931 @smallexample @c ada
2932 pragma Interface_Name (
2933 [Entity =>] LOCAL_NAME
2934 [, [External_Name =>] static_string_EXPRESSION]
2935 [, [Link_Name =>] static_string_EXPRESSION]);
2936 @end smallexample
2937
2938 @noindent
2939 This pragma provides an alternative way of specifying the interface name
2940 for an interfaced subprogram, and is provided for compatibility with Ada
2941 83 compilers that use the pragma for this purpose. You must provide at
2942 least one of @var{External_Name} or @var{Link_Name}.
2943
2944 @node Pragma Interrupt_Handler
2945 @unnumberedsec Pragma Interrupt_Handler
2946 @findex Interrupt_Handler
2947 @noindent
2948 Syntax:
2949
2950 @smallexample @c ada
2951 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2952 @end smallexample
2953
2954 @noindent
2955 This program unit pragma is supported for parameterless protected procedures
2956 as described in Annex C of the Ada Reference Manual. On the AAMP target
2957 the pragma can also be specified for nonprotected parameterless procedures
2958 that are declared at the library level (which includes procedures
2959 declared at the top level of a library package). In the case of AAMP,
2960 when this pragma is applied to a nonprotected procedure, the instruction
2961 @code{IERET} is generated for returns from the procedure, enabling
2962 maskable interrupts, in place of the normal return instruction.
2963
2964 @node Pragma Interrupt_State
2965 @unnumberedsec Pragma Interrupt_State
2966 @findex Interrupt_State
2967 @noindent
2968 Syntax:
2969
2970 @smallexample @c ada
2971 pragma Interrupt_State
2972 ([Name =>] value,
2973 [State =>] SYSTEM | RUNTIME | USER);
2974 @end smallexample
2975
2976 @noindent
2977 Normally certain interrupts are reserved to the implementation. Any attempt
2978 to attach an interrupt causes Program_Error to be raised, as described in
2979 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2980 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2981 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2982 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2983 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2984 Ada exceptions, or used to implement run-time functions such as the
2985 @code{abort} statement and stack overflow checking.
2986
2987 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2988 such uses of interrupts. It subsumes the functionality of pragma
2989 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2990 available on Windows or VMS. On all other platforms than VxWorks,
2991 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2992 and may be used to mark interrupts required by the board support package
2993 as reserved.
2994
2995 Interrupts can be in one of three states:
2996 @itemize @bullet
2997 @item System
2998
2999 The interrupt is reserved (no Ada handler can be installed), and the
3000 Ada run-time may not install a handler. As a result you are guaranteed
3001 standard system default action if this interrupt is raised.
3002
3003 @item Runtime
3004
3005 The interrupt is reserved (no Ada handler can be installed). The run time
3006 is allowed to install a handler for internal control purposes, but is
3007 not required to do so.
3008
3009 @item User
3010
3011 The interrupt is unreserved. The user may install a handler to provide
3012 some other action.
3013 @end itemize
3014
3015 @noindent
3016 These states are the allowed values of the @code{State} parameter of the
3017 pragma. The @code{Name} parameter is a value of the type
3018 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3019 @code{Ada.Interrupts.Names}.
3020
3021 This is a configuration pragma, and the binder will check that there
3022 are no inconsistencies between different units in a partition in how a
3023 given interrupt is specified. It may appear anywhere a pragma is legal.
3024
3025 The effect is to move the interrupt to the specified state.
3026
3027 By declaring interrupts to be SYSTEM, you guarantee the standard system
3028 action, such as a core dump.
3029
3030 By declaring interrupts to be USER, you guarantee that you can install
3031 a handler.
3032
3033 Note that certain signals on many operating systems cannot be caught and
3034 handled by applications. In such cases, the pragma is ignored. See the
3035 operating system documentation, or the value of the array @code{Reserved}
3036 declared in the spec of package @code{System.OS_Interface}.
3037
3038 Overriding the default state of signals used by the Ada runtime may interfere
3039 with an application's runtime behavior in the cases of the synchronous signals,
3040 and in the case of the signal used to implement the @code{abort} statement.
3041
3042 @node Pragma Keep_Names
3043 @unnumberedsec Pragma Keep_Names
3044 @findex Keep_Names
3045 @noindent
3046 Syntax:
3047
3048 @smallexample @c ada
3049 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3050 @end smallexample
3051
3052 @noindent
3053 The @var{LOCAL_NAME} argument
3054 must refer to an enumeration first subtype
3055 in the current declarative part. The effect is to retain the enumeration
3056 literal names for use by @code{Image} and @code{Value} even if a global
3057 @code{Discard_Names} pragma applies. This is useful when you want to
3058 generally suppress enumeration literal names and for example you therefore
3059 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3060 want to retain the names for specific enumeration types.
3061
3062 @node Pragma License
3063 @unnumberedsec Pragma License
3064 @findex License
3065 @cindex License checking
3066 @noindent
3067 Syntax:
3068
3069 @smallexample @c ada
3070 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3071 @end smallexample
3072
3073 @noindent
3074 This pragma is provided to allow automated checking for appropriate license
3075 conditions with respect to the standard and modified GPL@. A pragma
3076 @code{License}, which is a configuration pragma that typically appears at
3077 the start of a source file or in a separate @file{gnat.adc} file, specifies
3078 the licensing conditions of a unit as follows:
3079
3080 @itemize @bullet
3081 @item Unrestricted
3082 This is used for a unit that can be freely used with no license restrictions.
3083 Examples of such units are public domain units, and units from the Ada
3084 Reference Manual.
3085
3086 @item GPL
3087 This is used for a unit that is licensed under the unmodified GPL, and which
3088 therefore cannot be @code{with}'ed by a restricted unit.
3089
3090 @item Modified_GPL
3091 This is used for a unit licensed under the GNAT modified GPL that includes
3092 a special exception paragraph that specifically permits the inclusion of
3093 the unit in programs without requiring the entire program to be released
3094 under the GPL@.
3095
3096 @item Restricted
3097 This is used for a unit that is restricted in that it is not permitted to
3098 depend on units that are licensed under the GPL@. Typical examples are
3099 proprietary code that is to be released under more restrictive license
3100 conditions. Note that restricted units are permitted to @code{with} units
3101 which are licensed under the modified GPL (this is the whole point of the
3102 modified GPL).
3103
3104 @end itemize
3105
3106 @noindent
3107 Normally a unit with no @code{License} pragma is considered to have an
3108 unknown license, and no checking is done. However, standard GNAT headers
3109 are recognized, and license information is derived from them as follows.
3110
3111 @itemize @bullet
3112
3113 A GNAT license header starts with a line containing 78 hyphens. The following
3114 comment text is searched for the appearance of any of the following strings.
3115
3116 If the string ``GNU General Public License'' is found, then the unit is assumed
3117 to have GPL license, unless the string ``As a special exception'' follows, in
3118 which case the license is assumed to be modified GPL@.
3119
3120 If one of the strings
3121 ``This specification is adapted from the Ada Semantic Interface'' or
3122 ``This specification is derived from the Ada Reference Manual'' is found
3123 then the unit is assumed to be unrestricted.
3124 @end itemize
3125
3126 @noindent
3127 These default actions means that a program with a restricted license pragma
3128 will automatically get warnings if a GPL unit is inappropriately
3129 @code{with}'ed. For example, the program:
3130
3131 @smallexample @c ada
3132 with Sem_Ch3;
3133 with GNAT.Sockets;
3134 procedure Secret_Stuff is
3135 @dots{}
3136 end Secret_Stuff
3137 @end smallexample
3138
3139 @noindent
3140 if compiled with pragma @code{License} (@code{Restricted}) in a
3141 @file{gnat.adc} file will generate the warning:
3142
3143 @smallexample
3144 1. with Sem_Ch3;
3145 |
3146 >>> license of withed unit "Sem_Ch3" is incompatible
3147
3148 2. with GNAT.Sockets;
3149 3. procedure Secret_Stuff is
3150 @end smallexample
3151
3152 @noindent
3153 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3154 compiler and is licensed under the
3155 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3156 run time, and is therefore licensed under the modified GPL@.
3157
3158 @node Pragma Link_With
3159 @unnumberedsec Pragma Link_With
3160 @findex Link_With
3161 @noindent
3162 Syntax:
3163
3164 @smallexample @c ada
3165 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3166 @end smallexample
3167
3168 @noindent
3169 This pragma is provided for compatibility with certain Ada 83 compilers.
3170 It has exactly the same effect as pragma @code{Linker_Options} except
3171 that spaces occurring within one of the string expressions are treated
3172 as separators. For example, in the following case:
3173
3174 @smallexample @c ada
3175 pragma Link_With ("-labc -ldef");
3176 @end smallexample
3177
3178 @noindent
3179 results in passing the strings @code{-labc} and @code{-ldef} as two
3180 separate arguments to the linker. In addition pragma Link_With allows
3181 multiple arguments, with the same effect as successive pragmas.
3182
3183 @node Pragma Linker_Alias
3184 @unnumberedsec Pragma Linker_Alias
3185 @findex Linker_Alias
3186 @noindent
3187 Syntax:
3188
3189 @smallexample @c ada
3190 pragma Linker_Alias (
3191 [Entity =>] LOCAL_NAME,
3192 [Target =>] static_string_EXPRESSION);
3193 @end smallexample
3194
3195 @noindent
3196 @var{LOCAL_NAME} must refer to an object that is declared at the library
3197 level. This pragma establishes the given entity as a linker alias for the
3198 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3199 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3200 @var{static_string_EXPRESSION} in the object file, that is to say no space
3201 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3202 to the same address as @var{static_string_EXPRESSION} by the linker.
3203
3204 The actual linker name for the target must be used (e.g.@: the fully
3205 encoded name with qualification in Ada, or the mangled name in C++),
3206 or it must be declared using the C convention with @code{pragma Import}
3207 or @code{pragma Export}.
3208
3209 Not all target machines support this pragma. On some of them it is accepted
3210 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3211
3212 @smallexample @c ada
3213 -- Example of the use of pragma Linker_Alias
3214
3215 package p is
3216 i : Integer := 1;
3217 pragma Export (C, i);
3218
3219 new_name_for_i : Integer;
3220 pragma Linker_Alias (new_name_for_i, "i");
3221 end p;
3222 @end smallexample
3223
3224 @node Pragma Linker_Constructor
3225 @unnumberedsec Pragma Linker_Constructor
3226 @findex Linker_Constructor
3227 @noindent
3228 Syntax:
3229
3230 @smallexample @c ada
3231 pragma Linker_Constructor (procedure_LOCAL_NAME);
3232 @end smallexample
3233
3234 @noindent
3235 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3236 is declared at the library level. A procedure to which this pragma is
3237 applied will be treated as an initialization routine by the linker.
3238 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3239 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3240 of the executable is called (or immediately after the shared library is
3241 loaded if the procedure is linked in a shared library), in particular
3242 before the Ada run-time environment is set up.
3243
3244 Because of these specific contexts, the set of operations such a procedure
3245 can perform is very limited and the type of objects it can manipulate is
3246 essentially restricted to the elementary types. In particular, it must only
3247 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3248
3249 This pragma is used by GNAT to implement auto-initialization of shared Stand
3250 Alone Libraries, which provides a related capability without the restrictions
3251 listed above. Where possible, the use of Stand Alone Libraries is preferable
3252 to the use of this pragma.
3253
3254 @node Pragma Linker_Destructor
3255 @unnumberedsec Pragma Linker_Destructor
3256 @findex Linker_Destructor
3257 @noindent
3258 Syntax:
3259
3260 @smallexample @c ada
3261 pragma Linker_Destructor (procedure_LOCAL_NAME);
3262 @end smallexample
3263
3264 @noindent
3265 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3266 is declared at the library level. A procedure to which this pragma is
3267 applied will be treated as a finalization routine by the linker.
3268 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3269 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3270 of the executable has exited (or immediately before the shared library
3271 is unloaded if the procedure is linked in a shared library), in particular
3272 after the Ada run-time environment is shut down.
3273
3274 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3275 because of these specific contexts.
3276
3277 @node Pragma Linker_Section
3278 @unnumberedsec Pragma Linker_Section
3279 @findex Linker_Section
3280 @noindent
3281 Syntax:
3282
3283 @smallexample @c ada
3284 pragma Linker_Section (
3285 [Entity =>] LOCAL_NAME,
3286 [Section =>] static_string_EXPRESSION);
3287 @end smallexample
3288
3289 @noindent
3290 @var{LOCAL_NAME} must refer to an object that is declared at the library
3291 level. This pragma specifies the name of the linker section for the given
3292 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3293 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3294 section of the executable (assuming the linker doesn't rename the section).
3295
3296 The compiler normally places library-level objects in standard sections
3297 depending on their type: procedures and functions generally go in the
3298 @code{.text} section, initialized variables in the @code{.data} section
3299 and uninitialized variables in the @code{.bss} section.
3300
3301 Other, special sections may exist on given target machines to map special
3302 hardware, for example I/O ports or flash memory. This pragma is a means to
3303 defer the final layout of the executable to the linker, thus fully working
3304 at the symbolic level with the compiler.
3305
3306 Some file formats do not support arbitrary sections so not all target
3307 machines support this pragma. The use of this pragma may cause a program
3308 execution to be erroneous if it is used to place an entity into an
3309 inappropriate section (e.g.@: a modified variable into the @code{.text}
3310 section). See also @code{pragma Persistent_BSS}.
3311
3312 @smallexample @c ada
3313 -- Example of the use of pragma Linker_Section
3314
3315 package IO_Card is
3316 Port_A : Integer;
3317 pragma Volatile (Port_A);
3318 pragma Linker_Section (Port_A, ".bss.port_a");
3319
3320 Port_B : Integer;
3321 pragma Volatile (Port_B);
3322 pragma Linker_Section (Port_B, ".bss.port_b");
3323 end IO_Card;
3324 @end smallexample
3325
3326 @node Pragma Long_Float
3327 @unnumberedsec Pragma Long_Float
3328 @cindex OpenVMS
3329 @findex Long_Float
3330 @noindent
3331 Syntax:
3332
3333 @smallexample @c ada
3334 pragma Long_Float (FLOAT_FORMAT);
3335
3336 FLOAT_FORMAT ::= D_Float | G_Float
3337 @end smallexample
3338
3339 @noindent
3340 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3341 It allows control over the internal representation chosen for the predefined
3342 type @code{Long_Float} and for floating point type representations with
3343 @code{digits} specified in the range 7 through 15.
3344 For further details on this pragma, see the
3345 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3346 this pragma, the standard runtime libraries must be recompiled.
3347
3348 @node Pragma Machine_Attribute
3349 @unnumberedsec Pragma Machine_Attribute
3350 @findex Machine_Attribute
3351 @noindent
3352 Syntax:
3353
3354 @smallexample @c ada
3355 pragma Machine_Attribute (
3356 [Entity =>] LOCAL_NAME,
3357 [Attribute_Name =>] static_string_EXPRESSION
3358 [, [Info =>] static_EXPRESSION] );
3359 @end smallexample
3360
3361 @noindent
3362 Machine-dependent attributes can be specified for types and/or
3363 declarations. This pragma is semantically equivalent to
3364 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3365 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3366 in GNU C, where @code{@var{attribute_name}} is recognized by the
3367 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3368 specific macro. A string literal for the optional parameter @var{info}
3369 is transformed into an identifier, which may make this pragma unusable
3370 for some attributes. @xref{Target Attributes,, Defining target-specific
3371 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3372 Internals}, further information.
3373
3374 @node Pragma Main
3375 @unnumberedsec Pragma Main
3376 @cindex OpenVMS
3377 @findex Main
3378 @noindent
3379 Syntax:
3380
3381 @smallexample @c ada
3382 pragma Main
3383 (MAIN_OPTION [, MAIN_OPTION]);
3384
3385 MAIN_OPTION ::=
3386 [Stack_Size =>] static_integer_EXPRESSION
3387 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3388 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3389 @end smallexample
3390
3391 @noindent
3392 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3393 no effect in GNAT, other than being syntax checked.
3394
3395 @node Pragma Main_Storage
3396 @unnumberedsec Pragma Main_Storage
3397 @cindex OpenVMS
3398 @findex Main_Storage
3399 @noindent
3400 Syntax:
3401
3402 @smallexample @c ada
3403 pragma Main_Storage
3404 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3405
3406 MAIN_STORAGE_OPTION ::=
3407 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3408 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3409 @end smallexample
3410
3411 @noindent
3412 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3413 no effect in GNAT, other than being syntax checked. Note that the pragma
3414 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3415
3416 @node Pragma No_Body
3417 @unnumberedsec Pragma No_Body
3418 @findex No_Body
3419 @noindent
3420 Syntax:
3421
3422 @smallexample @c ada
3423 pragma No_Body;
3424 @end smallexample
3425
3426 @noindent
3427 There are a number of cases in which a package spec does not require a body,
3428 and in fact a body is not permitted. GNAT will not permit the spec to be
3429 compiled if there is a body around. The pragma No_Body allows you to provide
3430 a body file, even in a case where no body is allowed. The body file must
3431 contain only comments and a single No_Body pragma. This is recognized by
3432 the compiler as indicating that no body is logically present.
3433
3434 This is particularly useful during maintenance when a package is modified in
3435 such a way that a body needed before is no longer needed. The provision of a
3436 dummy body with a No_Body pragma ensures that there is no interference from
3437 earlier versions of the package body.
3438
3439 @node Pragma No_Return
3440 @unnumberedsec Pragma No_Return
3441 @findex No_Return
3442 @noindent
3443 Syntax:
3444
3445 @smallexample @c ada
3446 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3447 @end smallexample
3448
3449 @noindent
3450 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3451 declarations in the current declarative part. A procedure to which this
3452 pragma is applied may not contain any explicit @code{return} statements.
3453 In addition, if the procedure contains any implicit returns from falling
3454 off the end of a statement sequence, then execution of that implicit
3455 return will cause Program_Error to be raised.
3456
3457 One use of this pragma is to identify procedures whose only purpose is to raise
3458 an exception. Another use of this pragma is to suppress incorrect warnings
3459 about missing returns in functions, where the last statement of a function
3460 statement sequence is a call to such a procedure.
3461
3462 Note that in Ada 2005 mode, this pragma is part of the language, and is
3463 identical in effect to the pragma as implemented in Ada 95 mode.
3464
3465 @node Pragma No_Strict_Aliasing
3466 @unnumberedsec Pragma No_Strict_Aliasing
3467 @findex No_Strict_Aliasing
3468 @noindent
3469 Syntax:
3470
3471 @smallexample @c ada
3472 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3473 @end smallexample
3474
3475 @noindent
3476 @var{type_LOCAL_NAME} must refer to an access type
3477 declaration in the current declarative part. The effect is to inhibit
3478 strict aliasing optimization for the given type. The form with no
3479 arguments is a configuration pragma which applies to all access types
3480 declared in units to which the pragma applies. For a detailed
3481 description of the strict aliasing optimization, and the situations
3482 in which it must be suppressed, see @ref{Optimization and Strict
3483 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3484
3485 @node Pragma Normalize_Scalars
3486 @unnumberedsec Pragma Normalize_Scalars
3487 @findex Normalize_Scalars
3488 @noindent
3489 Syntax:
3490
3491 @smallexample @c ada
3492 pragma Normalize_Scalars;
3493 @end smallexample
3494
3495 @noindent
3496 This is a language defined pragma which is fully implemented in GNAT@. The
3497 effect is to cause all scalar objects that are not otherwise initialized
3498 to be initialized. The initial values are implementation dependent and
3499 are as follows:
3500
3501 @table @code
3502 @item Standard.Character
3503 @noindent
3504 Objects whose root type is Standard.Character are initialized to
3505 Character'Last unless the subtype range excludes NUL (in which case
3506 NUL is used). This choice will always generate an invalid value if
3507 one exists.
3508
3509 @item Standard.Wide_Character
3510 @noindent
3511 Objects whose root type is Standard.Wide_Character are initialized to
3512 Wide_Character'Last unless the subtype range excludes NUL (in which case
3513 NUL is used). This choice will always generate an invalid value if
3514 one exists.
3515
3516 @item Standard.Wide_Wide_Character
3517 @noindent
3518 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3519 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3520 which case NUL is used). This choice will always generate an invalid value if
3521 one exists.
3522
3523 @item Integer types
3524 @noindent
3525 Objects of an integer type are treated differently depending on whether
3526 negative values are present in the subtype. If no negative values are
3527 present, then all one bits is used as the initial value except in the
3528 special case where zero is excluded from the subtype, in which case
3529 all zero bits are used. This choice will always generate an invalid
3530 value if one exists.
3531
3532 For subtypes with negative values present, the largest negative number
3533 is used, except in the unusual case where this largest negative number
3534 is in the subtype, and the largest positive number is not, in which case
3535 the largest positive value is used. This choice will always generate
3536 an invalid value if one exists.
3537
3538 @item Floating-Point Types
3539 Objects of all floating-point types are initialized to all 1-bits. For
3540 standard IEEE format, this corresponds to a NaN (not a number) which is
3541 indeed an invalid value.
3542
3543 @item Fixed-Point Types
3544 Objects of all fixed-point types are treated as described above for integers,
3545 with the rules applying to the underlying integer value used to represent
3546 the fixed-point value.
3547
3548 @item Modular types
3549 Objects of a modular type are initialized to all one bits, except in
3550 the special case where zero is excluded from the subtype, in which
3551 case all zero bits are used. This choice will always generate an
3552 invalid value if one exists.
3553
3554 @item Enumeration types
3555 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3556 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3557 whose Pos value is zero, in which case a code of zero is used. This choice
3558 will always generate an invalid value if one exists.
3559
3560 @end table
3561
3562 @node Pragma Obsolescent
3563 @unnumberedsec Pragma Obsolescent
3564 @findex Obsolescent
3565 @noindent
3566 Syntax:
3567
3568 @smallexample @c ada
3569 pragma Obsolescent;
3570
3571 pragma Obsolescent (
3572 [Message =>] static_string_EXPRESSION
3573 [,[Version =>] Ada_05]]);
3574
3575 pragma Obsolescent (
3576 [Entity =>] NAME
3577 [,[Message =>] static_string_EXPRESSION
3578 [,[Version =>] Ada_05]] );
3579 @end smallexample
3580
3581 @noindent
3582 This pragma can occur immediately following a declaration of an entity,
3583 including the case of a record component. If no Entity argument is present,
3584 then this declaration is the one to which the pragma applies. If an Entity
3585 parameter is present, it must either match the name of the entity in this
3586 declaration, or alternatively, the pragma can immediately follow an enumeration
3587 type declaration, where the Entity argument names one of the enumeration
3588 literals.
3589
3590 This pragma is used to indicate that the named entity
3591 is considered obsolescent and should not be used. Typically this is
3592 used when an API must be modified by eventually removing or modifying
3593 existing subprograms or other entities. The pragma can be used at an
3594 intermediate stage when the entity is still present, but will be
3595 removed later.
3596
3597 The effect of this pragma is to output a warning message on a reference to
3598 an entity thus marked that the subprogram is obsolescent if the appropriate
3599 warning option in the compiler is activated. If the Message parameter is
3600 present, then a second warning message is given containing this text. In
3601 addition, a reference to the eneity is considered to be a violation of pragma
3602 Restrictions (No_Obsolescent_Features).
3603
3604 This pragma can also be used as a program unit pragma for a package,
3605 in which case the entity name is the name of the package, and the
3606 pragma indicates that the entire package is considered
3607 obsolescent. In this case a client @code{with}'ing such a package
3608 violates the restriction, and the @code{with} statement is
3609 flagged with warnings if the warning option is set.
3610
3611 If the Version parameter is present (which must be exactly
3612 the identifier Ada_05, no other argument is allowed), then the
3613 indication of obsolescence applies only when compiling in Ada 2005
3614 mode. This is primarily intended for dealing with the situations
3615 in the predefined library where subprograms or packages
3616 have become defined as obsolescent in Ada 2005
3617 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3618
3619 The following examples show typical uses of this pragma:
3620
3621 @smallexample @c ada
3622 package p is
3623 pragma Obsolescent (p, Message => "use pp instead of p");
3624 end p;
3625
3626 package q is
3627 procedure q2;
3628 pragma Obsolescent ("use q2new instead");
3629
3630 type R is new integer;
3631 pragma Obsolescent
3632 (Entity => R,
3633 Message => "use RR in Ada 2005",
3634 Version => Ada_05);
3635
3636 type M is record
3637 F1 : Integer;
3638 F2 : Integer;
3639 pragma Obsolescent;
3640 F3 : Integer;
3641 end record;
3642
3643 type E is (a, bc, 'd', quack);
3644 pragma Obsolescent (Entity => bc)
3645 pragma Obsolescent (Entity => 'd')
3646
3647 function "+"
3648 (a, b : character) return character;
3649 pragma Obsolescent (Entity => "+");
3650 end;
3651 @end smallexample
3652
3653 @noindent
3654 Note that, as for all pragmas, if you use a pragma argument identifier,
3655 then all subsequent parameters must also use a pragma argument identifier.
3656 So if you specify "Entity =>" for the Entity argument, and a Message
3657 argument is present, it must be preceded by "Message =>".
3658
3659 @node Pragma Optimize_Alignment
3660 @unnumberedsec Pragma Optimize_Alignment
3661 @findex Optimize_Alignment
3662 @cindex Alignment, default settings
3663 @noindent
3664 Syntax:
3665
3666 @smallexample @c ada
3667 pragma Optimize_Alignment (TIME | SPACE | OFF);
3668 @end smallexample
3669
3670 @noindent
3671 This is a configuration pragma which affects the choice of default alignments
3672 for types where no alignment is explicitly specified. There is a time/space
3673 trade-off in the selection of these values. Large alignments result in more
3674 efficient code, at the expense of larger data space, since sizes have to be
3675 increased to match these alignments. Smaller alignments save space, but the
3676 access code is slower. The normal choice of default alignments (which is what
3677 you get if you do not use this pragma, or if you use an argument of OFF),
3678 tries to balance these two requirements.
3679
3680 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3681 First any packed record is given an alignment of 1. Second, if a size is given
3682 for the type, then the alignment is chosen to avoid increasing this size. For
3683 example, consider:
3684
3685 @smallexample @c ada
3686 type R is record
3687 X : Integer;
3688 Y : Character;
3689 end record;
3690
3691 for R'Size use 5*8;
3692 @end smallexample
3693
3694 @noindent
3695 In the default mode, this type gets an alignment of 4, so that access to the
3696 Integer field X are efficient. But this means that objects of the type end up
3697 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3698 allowed to be bigger than the size of the type, but it can waste space if for
3699 example fields of type R appear in an enclosing record. If the above type is
3700 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3701
3702 Specifying TIME causes larger default alignments to be chosen in the case of
3703 small types with sizes that are not a power of 2. For example, consider:
3704
3705 @smallexample @c ada
3706 type R is record
3707 A : Character;
3708 B : Character;
3709 C : Boolean;
3710 end record;
3711
3712 pragma Pack (R);
3713 for R'Size use 17;
3714 @end smallexample
3715
3716 @noindent
3717 The default alignment for this record is normally 1, but if this type is
3718 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3719 to 4, which wastes space for objects of the type, since they are now 4 bytes
3720 long, but results in more efficient access when the whole record is referenced.
3721
3722 As noted above, this is a configuration pragma, and there is a requirement
3723 that all units in a partition be compiled with a consistent setting of the
3724 optimization setting. This would normally be achieved by use of a configuration
3725 pragma file containing the appropriate setting. The exception to this rule is
3726 that units with an explicit configuration pragma in the same file as the source
3727 unit are excluded from the consistency check, as are all predefined units. The
3728 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3729 pragma appears at the start of the file.
3730
3731 @node Pragma Ordered
3732 @unnumberedsec Pragma Ordered
3733 @findex Ordered
3734 @findex pragma @code{Ordered}
3735 @noindent
3736 Syntax:
3737
3738 @smallexample @c ada
3739 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3740 @end smallexample
3741
3742 @noindent
3743 Most enumeration types are from a conceptual point of view unordered.
3744 For example, consider:
3745
3746 @smallexample @c ada
3747 type Color is (Red, Blue, Green, Yellow);
3748 @end smallexample
3749
3750 @noindent
3751 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3752 but really these relations make no sense; the enumeration type merely
3753 specifies a set of possible colors, and the order is unimportant.
3754
3755 For unordered enumeration types, it is generally a good idea if
3756 clients avoid comparisons (other than equality or inequality) and
3757 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3758 other than the unit where the type is declared, its body, and its subunits.)
3759 For example, if code buried in some client says:
3760
3761 @smallexample @c ada
3762 if Current_Color < Yellow then ...
3763 if Current_Color in Blue .. Green then ...
3764 @end smallexample
3765
3766 @noindent
3767 then the client code is relying on the order, which is undesirable.
3768 It makes the code hard to read and creates maintenance difficulties if
3769 entries have to be added to the enumeration type. Instead,
3770 the code in the client should list the possibilities, or an
3771 appropriate subtype should be declared in the unit that declares
3772 the original enumeration type. E.g., the following subtype could
3773 be declared along with the type @code{Color}:
3774
3775 @smallexample @c ada
3776 subtype RBG is Color range Red .. Green;
3777 @end smallexample
3778
3779 @noindent
3780 and then the client could write:
3781
3782 @smallexample @c ada
3783 if Current_Color in RBG then ...
3784 if Current_Color = Blue or Current_Color = Green then ...
3785 @end smallexample
3786
3787 @noindent
3788 However, some enumeration types are legitimately ordered from a conceptual
3789 point of view. For example, if you declare:
3790
3791 @smallexample @c ada
3792 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3793 @end smallexample
3794
3795 @noindent
3796 then the ordering imposed by the language is reasonable, and
3797 clients can depend on it, writing for example:
3798
3799 @smallexample @c ada
3800 if D in Mon .. Fri then ...
3801 if D < Wed then ...
3802 @end smallexample
3803
3804 @noindent
3805 The pragma @option{Ordered} is provided to mark enumeration types that
3806 are conceptually ordered, alerting the reader that clients may depend
3807 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3808 rather than one to mark them as unordered, since in our experience,
3809 the great majority of enumeration types are conceptually unordered.
3810
3811 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3812 and @code{Wide_Wide_Character}
3813 are considered to be ordered types, so each is declared with a
3814 pragma @code{Ordered} in package @code{Standard}.
3815
3816 Normally pragma @code{Ordered} serves only as documentation and a guide for
3817 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3818 requests warnings for inappropriate uses (comparisons and explicit
3819 subranges) for unordered types. If this switch is used, then any
3820 enumeration type not marked with pragma @code{Ordered} will be considered
3821 as unordered, and will generate warnings for inappropriate uses.
3822
3823 For additional information please refer to the description of the
3824 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3825
3826 @node Pragma Passive
3827 @unnumberedsec Pragma Passive
3828 @findex Passive
3829 @noindent
3830 Syntax:
3831
3832 @smallexample @c ada
3833 pragma Passive [(Semaphore | No)];
3834 @end smallexample
3835
3836 @noindent
3837 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3838 compatibility with DEC Ada 83 implementations, where it is used within a
3839 task definition to request that a task be made passive. If the argument
3840 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3841 treats the pragma as an assertion that the containing task is passive
3842 and that optimization of context switch with this task is permitted and
3843 desired. If the argument @code{No} is present, the task must not be
3844 optimized. GNAT does not attempt to optimize any tasks in this manner
3845 (since protected objects are available in place of passive tasks).
3846
3847 @node Pragma Persistent_BSS
3848 @unnumberedsec Pragma Persistent_BSS
3849 @findex Persistent_BSS
3850 @noindent
3851 Syntax:
3852
3853 @smallexample @c ada
3854 pragma Persistent_BSS [(LOCAL_NAME)]
3855 @end smallexample
3856
3857 @noindent
3858 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3859 section. On some targets the linker and loader provide for special
3860 treatment of this section, allowing a program to be reloaded without
3861 affecting the contents of this data (hence the name persistent).
3862
3863 There are two forms of usage. If an argument is given, it must be the
3864 local name of a library level object, with no explicit initialization
3865 and whose type is potentially persistent. If no argument is given, then
3866 the pragma is a configuration pragma, and applies to all library level
3867 objects with no explicit initialization of potentially persistent types.
3868
3869 A potentially persistent type is a scalar type, or a non-tagged,
3870 non-discriminated record, all of whose components have no explicit
3871 initialization and are themselves of a potentially persistent type,
3872 or an array, all of whose constraints are static, and whose component
3873 type is potentially persistent.
3874
3875 If this pragma is used on a target where this feature is not supported,
3876 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3877
3878 @node Pragma Polling
3879 @unnumberedsec Pragma Polling
3880 @findex Polling
3881 @noindent
3882 Syntax:
3883
3884 @smallexample @c ada
3885 pragma Polling (ON | OFF);
3886 @end smallexample
3887
3888 @noindent
3889 This pragma controls the generation of polling code. This is normally off.
3890 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3891 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3892 runtime library, and can be found in file @file{a-excpol.adb}.
3893
3894 Pragma @code{Polling} can appear as a configuration pragma (for example it
3895 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3896 can be used in the statement or declaration sequence to control polling
3897 more locally.
3898
3899 A call to the polling routine is generated at the start of every loop and
3900 at the start of every subprogram call. This guarantees that the @code{Poll}
3901 routine is called frequently, and places an upper bound (determined by
3902 the complexity of the code) on the period between two @code{Poll} calls.
3903
3904 The primary purpose of the polling interface is to enable asynchronous
3905 aborts on targets that cannot otherwise support it (for example Windows
3906 NT), but it may be used for any other purpose requiring periodic polling.
3907 The standard version is null, and can be replaced by a user program. This
3908 will require re-compilation of the @code{Ada.Exceptions} package that can
3909 be found in files @file{a-except.ads} and @file{a-except.adb}.
3910
3911 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3912 distribution) is used to enable the asynchronous abort capability on
3913 targets that do not normally support the capability. The version of
3914 @code{Poll} in this file makes a call to the appropriate runtime routine
3915 to test for an abort condition.
3916
3917 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3918 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3919 details.
3920
3921 @node Pragma Postcondition
3922 @unnumberedsec Pragma Postcondition
3923 @cindex Postconditions
3924 @cindex Checks, postconditions
3925 @findex Postconditions
3926 @noindent
3927 Syntax:
3928
3929 @smallexample @c ada
3930 pragma Postcondition (
3931 [Check =>] Boolean_Expression
3932 [,[Message =>] String_Expression]);
3933 @end smallexample
3934
3935 @noindent
3936 The @code{Postcondition} pragma allows specification of automatic
3937 postcondition checks for subprograms. These checks are similar to
3938 assertions, but are automatically inserted just prior to the return
3939 statements of the subprogram with which they are associated (including
3940 implicit returns at the end of procedure bodies and associated
3941 exception handlers).
3942
3943 In addition, the boolean expression which is the condition which
3944 must be true may contain references to function'Result in the case
3945 of a function to refer to the returned value.
3946
3947 @code{Postcondition} pragmas may appear either immediate following the
3948 (separate) declaration of a subprogram, or at the start of the
3949 declarations of a subprogram body. Only other pragmas may intervene
3950 (that is appear between the subprogram declaration and its
3951 postconditions, or appear before the postcondition in the
3952 declaration sequence in a subprogram body). In the case of a
3953 postcondition appearing after a subprogram declaration, the
3954 formal arguments of the subprogram are visible, and can be
3955 referenced in the postcondition expressions.
3956
3957 The postconditions are collected and automatically tested just
3958 before any return (implicit or explicit) in the subprogram body.
3959 A postcondition is only recognized if postconditions are active
3960 at the time the pragma is encountered. The compiler switch @option{gnata}
3961 turns on all postconditions by default, and pragma @code{Check_Policy}
3962 with an identifier of @code{Postcondition} can also be used to
3963 control whether postconditions are active.
3964
3965 The general approach is that postconditions are placed in the spec
3966 if they represent functional aspects which make sense to the client.
3967 For example we might have:
3968
3969 @smallexample @c ada
3970 function Direction return Integer;
3971 pragma Postcondition
3972 (Direction'Result = +1
3973 or else
3974 Direction'Result = -1);
3975 @end smallexample
3976
3977 @noindent
3978 which serves to document that the result must be +1 or -1, and
3979 will test that this is the case at run time if postcondition
3980 checking is active.
3981
3982 Postconditions within the subprogram body can be used to
3983 check that some internal aspect of the implementation,
3984 not visible to the client, is operating as expected.
3985 For instance if a square root routine keeps an internal
3986 counter of the number of times it is called, then we
3987 might have the following postcondition:
3988
3989 @smallexample @c ada
3990 Sqrt_Calls : Natural := 0;
3991
3992 function Sqrt (Arg : Float) return Float is
3993 pragma Postcondition
3994 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3995 ...
3996 end Sqrt
3997 @end smallexample
3998
3999 @noindent
4000 As this example, shows, the use of the @code{Old} attribute
4001 is often useful in postconditions to refer to the state on
4002 entry to the subprogram.
4003
4004 Note that postconditions are only checked on normal returns
4005 from the subprogram. If an abnormal return results from
4006 raising an exception, then the postconditions are not checked.
4007
4008 If a postcondition fails, then the exception
4009 @code{System.Assertions.Assert_Failure} is raised. If
4010 a message argument was supplied, then the given string
4011 will be used as the exception message. If no message
4012 argument was supplied, then the default message has
4013 the form "Postcondition failed at file:line". The
4014 exception is raised in the context of the subprogram
4015 body, so it is possible to catch postcondition failures
4016 within the subprogram body itself.
4017
4018 Within a package spec, normal visibility rules
4019 in Ada would prevent forward references within a
4020 postcondition pragma to functions defined later in
4021 the same package. This would introduce undesirable
4022 ordering constraints. To avoid this problem, all
4023 postcondition pragmas are analyzed at the end of
4024 the package spec, allowing forward references.
4025
4026 The following example shows that this even allows
4027 mutually recursive postconditions as in:
4028
4029 @smallexample @c ada
4030 package Parity_Functions is
4031 function Odd (X : Natural) return Boolean;
4032 pragma Postcondition
4033 (Odd'Result =
4034 (x = 1
4035 or else
4036 (x /= 0 and then Even (X - 1))));
4037
4038 function Even (X : Natural) return Boolean;
4039 pragma Postcondition
4040 (Even'Result =
4041 (x = 0
4042 or else
4043 (x /= 1 and then Odd (X - 1))));
4044
4045 end Parity_Functions;
4046 @end smallexample
4047
4048 @noindent
4049 There are no restrictions on the complexity or form of
4050 conditions used within @code{Postcondition} pragmas.
4051 The following example shows that it is even possible
4052 to verify performance behavior.
4053
4054 @smallexample @c ada
4055 package Sort is
4056
4057 Performance : constant Float;
4058 -- Performance constant set by implementation
4059 -- to match target architecture behavior.
4060
4061 procedure Treesort (Arg : String);
4062 -- Sorts characters of argument using N*logN sort
4063 pragma Postcondition
4064 (Float (Clock - Clock'Old) <=
4065 Float (Arg'Length) *
4066 log (Float (Arg'Length)) *
4067 Performance);
4068 end Sort;
4069 @end smallexample
4070
4071 @noindent
4072 Note: postcondition pragmas associated with subprograms that are
4073 marked as Inline_Always, or those marked as Inline with front-end
4074 inlining (-gnatN option set) are accepted and legality-checked
4075 by the compiler, but are ignored at run-time even if postcondition
4076 checking is enabled.
4077
4078 @node Pragma Precondition
4079 @unnumberedsec Pragma Precondition
4080 @cindex Preconditions
4081 @cindex Checks, preconditions
4082 @findex Preconditions
4083 @noindent
4084 Syntax:
4085
4086 @smallexample @c ada
4087 pragma Precondition (
4088 [Check =>] Boolean_Expression
4089 [,[Message =>] String_Expression]);
4090 @end smallexample
4091
4092 @noindent
4093 The @code{Precondition} pragma is similar to @code{Postcondition}
4094 except that the corresponding checks take place immediately upon
4095 entry to the subprogram, and if a precondition fails, the exception
4096 is raised in the context of the caller, and the attribute 'Result
4097 cannot be used within the precondition expression.
4098
4099 Otherwise, the placement and visibility rules are identical to those
4100 described for postconditions. The following is an example of use
4101 within a package spec:
4102
4103 @smallexample @c ada
4104 package Math_Functions is
4105 ...
4106 function Sqrt (Arg : Float) return Float;
4107 pragma Precondition (Arg >= 0.0)
4108 ...
4109 end Math_Functions;
4110 @end smallexample
4111
4112 @noindent
4113 @code{Precondition} pragmas may appear either immediate following the
4114 (separate) declaration of a subprogram, or at the start of the
4115 declarations of a subprogram body. Only other pragmas may intervene
4116 (that is appear between the subprogram declaration and its
4117 postconditions, or appear before the postcondition in the
4118 declaration sequence in a subprogram body).
4119
4120 Note: postcondition pragmas associated with subprograms that are
4121 marked as Inline_Always, or those marked as Inline with front-end
4122 inlining (-gnatN option set) are accepted and legality-checked
4123 by the compiler, but are ignored at run-time even if postcondition
4124 checking is enabled.
4125
4126 @node Pragma Profile (Ravenscar)
4127 @unnumberedsec Pragma Profile (Ravenscar)
4128 @findex Ravenscar
4129 @noindent
4130 Syntax:
4131
4132 @smallexample @c ada
4133 pragma Profile (Ravenscar);
4134 @end smallexample
4135
4136 @noindent
4137 A configuration pragma that establishes the following set of configuration
4138 pragmas:
4139
4140 @table @code
4141 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4142 [RM D.2.2] Tasks are dispatched following a preemptive
4143 priority-ordered scheduling policy.
4144
4145 @item Locking_Policy (Ceiling_Locking)
4146 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4147 the ceiling priority of the corresponding protected object.
4148 @c
4149 @c @item Detect_Blocking
4150 @c This pragma forces the detection of potentially blocking operations within a
4151 @c protected operation, and to raise Program_Error if that happens.
4152 @end table
4153 @noindent
4154
4155 plus the following set of restrictions:
4156
4157 @table @code
4158 @item Max_Entry_Queue_Length = 1
4159 Defines the maximum number of calls that are queued on a (protected) entry.
4160 Note that this restrictions is checked at run time. Violation of this
4161 restriction results in the raising of Program_Error exception at the point of
4162 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4163 always 1 and hence no task can be queued on a protected entry.
4164
4165 @item Max_Protected_Entries = 1
4166 [RM D.7] Specifies the maximum number of entries per protected type. The
4167 bounds of every entry family of a protected unit shall be static, or shall be
4168 defined by a discriminant of a subtype whose corresponding bound is static.
4169 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4170
4171 @item Max_Task_Entries = 0
4172 [RM D.7] Specifies the maximum number of entries
4173 per task. The bounds of every entry family
4174 of a task unit shall be static, or shall be
4175 defined by a discriminant of a subtype whose
4176 corresponding bound is static. A value of zero
4177 indicates that no rendezvous are possible. For
4178 the Profile (Ravenscar), the value of Max_Task_Entries is always
4179 0 (zero).
4180
4181 @item No_Abort_Statements
4182 [RM D.7] There are no abort_statements, and there are
4183 no calls to Task_Identification.Abort_Task.
4184
4185 @item No_Asynchronous_Control
4186 There are no semantic dependences on the package
4187 Asynchronous_Task_Control.
4188
4189 @item No_Calendar
4190 There are no semantic dependencies on the package Ada.Calendar.
4191
4192 @item No_Dynamic_Attachment
4193 There is no call to any of the operations defined in package Ada.Interrupts
4194 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4195 Detach_Handler, and Reference).
4196
4197 @item No_Dynamic_Priorities
4198 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4199
4200 @item No_Implicit_Heap_Allocations
4201 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4202
4203 @item No_Local_Protected_Objects
4204 Protected objects and access types that designate
4205 such objects shall be declared only at library level.
4206
4207 @item No_Local_Timing_Events
4208 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4209 declared at the library level.
4210
4211 @item No_Protected_Type_Allocators
4212 There are no allocators for protected types or
4213 types containing protected subcomponents.
4214
4215 @item No_Relative_Delay
4216 There are no delay_relative statements.
4217
4218 @item No_Requeue_Statements
4219 Requeue statements are not allowed.
4220
4221 @item No_Select_Statements
4222 There are no select_statements.
4223
4224 @item No_Specific_Termination_Handlers
4225 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4226 or to Ada.Task_Termination.Specific_Handler.
4227
4228 @item No_Task_Allocators
4229 [RM D.7] There are no allocators for task types
4230 or types containing task subcomponents.
4231
4232 @item No_Task_Attributes_Package
4233 There are no semantic dependencies on the Ada.Task_Attributes package.
4234
4235 @item No_Task_Hierarchy
4236 [RM D.7] All (non-environment) tasks depend
4237 directly on the environment task of the partition.
4238
4239 @item No_Task_Termination
4240 Tasks which terminate are erroneous.
4241
4242 @item No_Unchecked_Conversion
4243 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4244
4245 @item No_Unchecked_Deallocation
4246 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4247
4248 @item Simple_Barriers
4249 Entry barrier condition expressions shall be either static
4250 boolean expressions or boolean objects which are declared in
4251 the protected type which contains the entry.
4252 @end table
4253
4254 @noindent
4255 This set of configuration pragmas and restrictions correspond to the
4256 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4257 published by the @cite{International Real-Time Ada Workshop}, 1997,
4258 and whose most recent description is available at
4259 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4260
4261 The original definition of the profile was revised at subsequent IRTAW
4262 meetings. It has been included in the ISO
4263 @cite{Guide for the Use of the Ada Programming Language in High
4264 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4265 the next revision of the standard. The formal definition given by
4266 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4267 AI-305) available at
4268 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4269 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4270 respectively.
4271
4272 The above set is a superset of the restrictions provided by pragma
4273 @code{Profile (Restricted)}, it includes six additional restrictions
4274 (@code{Simple_Barriers}, @code{No_Select_Statements},
4275 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4276 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4277 that pragma @code{Profile (Ravenscar)}, like the pragma
4278 @code{Profile (Restricted)},
4279 automatically causes the use of a simplified,
4280 more efficient version of the tasking run-time system.
4281
4282 @node Pragma Profile (Restricted)
4283 @unnumberedsec Pragma Profile (Restricted)
4284 @findex Restricted Run Time
4285 @noindent
4286 Syntax:
4287
4288 @smallexample @c ada
4289 pragma Profile (Restricted);
4290 @end smallexample
4291
4292 @noindent
4293 A configuration pragma that establishes the following set of restrictions:
4294
4295 @itemize @bullet
4296 @item No_Abort_Statements
4297 @item No_Entry_Queue
4298 @item No_Task_Hierarchy
4299 @item No_Task_Allocators
4300 @item No_Dynamic_Priorities
4301 @item No_Terminate_Alternatives
4302 @item No_Dynamic_Attachment
4303 @item No_Protected_Type_Allocators
4304 @item No_Local_Protected_Objects
4305 @item No_Requeue_Statements
4306 @item No_Task_Attributes_Package
4307 @item Max_Asynchronous_Select_Nesting = 0
4308 @item Max_Task_Entries = 0
4309 @item Max_Protected_Entries = 1
4310 @item Max_Select_Alternatives = 0
4311 @end itemize
4312
4313 @noindent
4314 This set of restrictions causes the automatic selection of a simplified
4315 version of the run time that provides improved performance for the
4316 limited set of tasking functionality permitted by this set of restrictions.
4317
4318 @node Pragma Psect_Object
4319 @unnumberedsec Pragma Psect_Object
4320 @findex Psect_Object
4321 @noindent
4322 Syntax:
4323
4324 @smallexample @c ada
4325 pragma Psect_Object (
4326 [Internal =>] LOCAL_NAME,
4327 [, [External =>] EXTERNAL_SYMBOL]
4328 [, [Size =>] EXTERNAL_SYMBOL]);
4329
4330 EXTERNAL_SYMBOL ::=
4331 IDENTIFIER
4332 | static_string_EXPRESSION
4333 @end smallexample
4334
4335 @noindent
4336 This pragma is identical in effect to pragma @code{Common_Object}.
4337
4338 @node Pragma Pure_Function
4339 @unnumberedsec Pragma Pure_Function
4340 @findex Pure_Function
4341 @noindent
4342 Syntax:
4343
4344 @smallexample @c ada
4345 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4346 @end smallexample
4347
4348 @noindent
4349 This pragma appears in the same declarative part as a function
4350 declaration (or a set of function declarations if more than one
4351 overloaded declaration exists, in which case the pragma applies
4352 to all entities). It specifies that the function @code{Entity} is
4353 to be considered pure for the purposes of code generation. This means
4354 that the compiler can assume that there are no side effects, and
4355 in particular that two calls with identical arguments produce the
4356 same result. It also means that the function can be used in an
4357 address clause.
4358
4359 Note that, quite deliberately, there are no static checks to try
4360 to ensure that this promise is met, so @code{Pure_Function} can be used
4361 with functions that are conceptually pure, even if they do modify
4362 global variables. For example, a square root function that is
4363 instrumented to count the number of times it is called is still
4364 conceptually pure, and can still be optimized, even though it
4365 modifies a global variable (the count). Memo functions are another
4366 example (where a table of previous calls is kept and consulted to
4367 avoid re-computation).
4368
4369 @findex Pure
4370 Note: Most functions in a @code{Pure} package are automatically pure, and
4371 there is no need to use pragma @code{Pure_Function} for such functions. One
4372 exception is any function that has at least one formal of type
4373 @code{System.Address} or a type derived from it. Such functions are not
4374 considered pure by default, since the compiler assumes that the
4375 @code{Address} parameter may be functioning as a pointer and that the
4376 referenced data may change even if the address value does not.
4377 Similarly, imported functions are not considered to be pure by default,
4378 since there is no way of checking that they are in fact pure. The use
4379 of pragma @code{Pure_Function} for such a function will override these default
4380 assumption, and cause the compiler to treat a designated subprogram as pure
4381 in these cases.
4382
4383 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4384 applies to the underlying renamed function. This can be used to
4385 disambiguate cases of overloading where some but not all functions
4386 in a set of overloaded functions are to be designated as pure.
4387
4388 If pragma @code{Pure_Function} is applied to a library level function, the
4389 function is also considered pure from an optimization point of view, but the
4390 unit is not a Pure unit in the categorization sense. So for example, a function
4391 thus marked is free to @code{with} non-pure units.
4392
4393 @node Pragma Restriction_Warnings
4394 @unnumberedsec Pragma Restriction_Warnings
4395 @findex Restriction_Warnings
4396 @noindent
4397 Syntax:
4398
4399 @smallexample @c ada
4400 pragma Restriction_Warnings
4401 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4402 @end smallexample
4403
4404 @noindent
4405 This pragma allows a series of restriction identifiers to be
4406 specified (the list of allowed identifiers is the same as for
4407 pragma @code{Restrictions}). For each of these identifiers
4408 the compiler checks for violations of the restriction, but
4409 generates a warning message rather than an error message
4410 if the restriction is violated.
4411
4412 @node Pragma Shared
4413 @unnumberedsec Pragma Shared
4414 @findex Shared
4415
4416 @noindent
4417 This pragma is provided for compatibility with Ada 83. The syntax and
4418 semantics are identical to pragma Atomic.
4419
4420 @node Pragma Short_Circuit_And_Or
4421 @unnumberedsec Pragma Short_Circuit_And_Or
4422 @findex Short_Circuit_And_Or
4423
4424 @noindent
4425 This configuration pragma causes any occurrence of the AND operator applied to
4426 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4427 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4428 may be useful in the context of certification protocols requiring the use of
4429 short-circuited logical operators. If this configuration pragma occurs locally
4430 within the file being compiled, it applies only to the file being compiled.
4431 There is no requirement that all units in a partition use this option.
4432
4433 semantics are identical to pragma Atomic.
4434 @node Pragma Source_File_Name
4435 @unnumberedsec Pragma Source_File_Name
4436 @findex Source_File_Name
4437 @noindent
4438 Syntax:
4439
4440 @smallexample @c ada
4441 pragma Source_File_Name (
4442 [Unit_Name =>] unit_NAME,
4443 Spec_File_Name => STRING_LITERAL,
4444 [Index => INTEGER_LITERAL]);
4445
4446 pragma Source_File_Name (
4447 [Unit_Name =>] unit_NAME,
4448 Body_File_Name => STRING_LITERAL,
4449 [Index => INTEGER_LITERAL]);
4450 @end smallexample
4451
4452 @noindent
4453 Use this to override the normal naming convention. It is a configuration
4454 pragma, and so has the usual applicability of configuration pragmas
4455 (i.e.@: it applies to either an entire partition, or to all units in a
4456 compilation, or to a single unit, depending on how it is used.
4457 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4458 the second argument is required, and indicates whether this is the file
4459 name for the spec or for the body.
4460
4461 The optional Index argument should be used when a file contains multiple
4462 units, and when you do not want to use @code{gnatchop} to separate then
4463 into multiple files (which is the recommended procedure to limit the
4464 number of recompilations that are needed when some sources change).
4465 For instance, if the source file @file{source.ada} contains
4466
4467 @smallexample @c ada
4468 package B is
4469 ...
4470 end B;
4471
4472 with B;
4473 procedure A is
4474 begin
4475 ..
4476 end A;
4477 @end smallexample
4478
4479 you could use the following configuration pragmas:
4480
4481 @smallexample @c ada
4482 pragma Source_File_Name
4483 (B, Spec_File_Name => "source.ada", Index => 1);
4484 pragma Source_File_Name
4485 (A, Body_File_Name => "source.ada", Index => 2);
4486 @end smallexample
4487
4488 Note that the @code{gnatname} utility can also be used to generate those
4489 configuration pragmas.
4490
4491 Another form of the @code{Source_File_Name} pragma allows
4492 the specification of patterns defining alternative file naming schemes
4493 to apply to all files.
4494
4495 @smallexample @c ada
4496 pragma Source_File_Name
4497 ( [Spec_File_Name =>] STRING_LITERAL
4498 [,[Casing =>] CASING_SPEC]
4499 [,[Dot_Replacement =>] STRING_LITERAL]);
4500
4501 pragma Source_File_Name
4502 ( [Body_File_Name =>] STRING_LITERAL
4503 [,[Casing =>] CASING_SPEC]
4504 [,[Dot_Replacement =>] STRING_LITERAL]);
4505
4506 pragma Source_File_Name
4507 ( [Subunit_File_Name =>] STRING_LITERAL
4508 [,[Casing =>] CASING_SPEC]
4509 [,[Dot_Replacement =>] STRING_LITERAL]);
4510
4511 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4512 @end smallexample
4513
4514 @noindent
4515 The first argument is a pattern that contains a single asterisk indicating
4516 the point at which the unit name is to be inserted in the pattern string
4517 to form the file name. The second argument is optional. If present it
4518 specifies the casing of the unit name in the resulting file name string.
4519 The default is lower case. Finally the third argument allows for systematic
4520 replacement of any dots in the unit name by the specified string literal.
4521
4522 A pragma Source_File_Name cannot appear after a
4523 @ref{Pragma Source_File_Name_Project}.
4524
4525 For more details on the use of the @code{Source_File_Name} pragma,
4526 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4527 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4528 User's Guide}.
4529
4530 @node Pragma Source_File_Name_Project
4531 @unnumberedsec Pragma Source_File_Name_Project
4532 @findex Source_File_Name_Project
4533 @noindent
4534
4535 This pragma has the same syntax and semantics as pragma Source_File_Name.
4536 It is only allowed as a stand alone configuration pragma.
4537 It cannot appear after a @ref{Pragma Source_File_Name}, and
4538 most importantly, once pragma Source_File_Name_Project appears,
4539 no further Source_File_Name pragmas are allowed.
4540
4541 The intention is that Source_File_Name_Project pragmas are always
4542 generated by the Project Manager in a manner consistent with the naming
4543 specified in a project file, and when naming is controlled in this manner,
4544 it is not permissible to attempt to modify this naming scheme using
4545 Source_File_Name pragmas (which would not be known to the project manager).
4546
4547 @node Pragma Source_Reference
4548 @unnumberedsec Pragma Source_Reference
4549 @findex Source_Reference
4550 @noindent
4551 Syntax:
4552
4553 @smallexample @c ada
4554 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4555 @end smallexample
4556
4557 @noindent
4558 This pragma must appear as the first line of a source file.
4559 @var{integer_literal} is the logical line number of the line following
4560 the pragma line (for use in error messages and debugging
4561 information). @var{string_literal} is a static string constant that
4562 specifies the file name to be used in error messages and debugging
4563 information. This is most notably used for the output of @code{gnatchop}
4564 with the @option{-r} switch, to make sure that the original unchopped
4565 source file is the one referred to.
4566
4567 The second argument must be a string literal, it cannot be a static
4568 string expression other than a string literal. This is because its value
4569 is needed for error messages issued by all phases of the compiler.
4570
4571 @node Pragma Stream_Convert
4572 @unnumberedsec Pragma Stream_Convert
4573 @findex Stream_Convert
4574 @noindent
4575 Syntax:
4576
4577 @smallexample @c ada
4578 pragma Stream_Convert (
4579 [Entity =>] type_LOCAL_NAME,
4580 [Read =>] function_NAME,
4581 [Write =>] function_NAME);
4582 @end smallexample
4583
4584 @noindent
4585 This pragma provides an efficient way of providing stream functions for
4586 types defined in packages. Not only is it simpler to use than declaring
4587 the necessary functions with attribute representation clauses, but more
4588 significantly, it allows the declaration to made in such a way that the
4589 stream packages are not loaded unless they are needed. The use of
4590 the Stream_Convert pragma adds no overhead at all, unless the stream
4591 attributes are actually used on the designated type.
4592
4593 The first argument specifies the type for which stream functions are
4594 provided. The second parameter provides a function used to read values
4595 of this type. It must name a function whose argument type may be any
4596 subtype, and whose returned type must be the type given as the first
4597 argument to the pragma.
4598
4599 The meaning of the @var{Read}
4600 parameter is that if a stream attribute directly
4601 or indirectly specifies reading of the type given as the first parameter,
4602 then a value of the type given as the argument to the Read function is
4603 read from the stream, and then the Read function is used to convert this
4604 to the required target type.
4605
4606 Similarly the @var{Write} parameter specifies how to treat write attributes
4607 that directly or indirectly apply to the type given as the first parameter.
4608 It must have an input parameter of the type specified by the first parameter,
4609 and the return type must be the same as the input type of the Read function.
4610 The effect is to first call the Write function to convert to the given stream
4611 type, and then write the result type to the stream.
4612
4613 The Read and Write functions must not be overloaded subprograms. If necessary
4614 renamings can be supplied to meet this requirement.
4615 The usage of this attribute is best illustrated by a simple example, taken
4616 from the GNAT implementation of package Ada.Strings.Unbounded:
4617
4618 @smallexample @c ada
4619 function To_Unbounded (S : String)
4620 return Unbounded_String
4621 renames To_Unbounded_String;
4622
4623 pragma Stream_Convert
4624 (Unbounded_String, To_Unbounded, To_String);
4625 @end smallexample
4626
4627 @noindent
4628 The specifications of the referenced functions, as given in the Ada
4629 Reference Manual are:
4630
4631 @smallexample @c ada
4632 function To_Unbounded_String (Source : String)
4633 return Unbounded_String;
4634
4635 function To_String (Source : Unbounded_String)
4636 return String;
4637 @end smallexample
4638
4639 @noindent
4640 The effect is that if the value of an unbounded string is written to a stream,
4641 then the representation of the item in the stream is in the same format that
4642 would be used for @code{Standard.String'Output}, and this same representation
4643 is expected when a value of this type is read from the stream. Note that the
4644 value written always includes the bounds, even for Unbounded_String'Write,
4645 since Unbounded_String is not an array type.
4646
4647 @node Pragma Style_Checks
4648 @unnumberedsec Pragma Style_Checks
4649 @findex Style_Checks
4650 @noindent
4651 Syntax:
4652
4653 @smallexample @c ada
4654 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4655 On | Off [, LOCAL_NAME]);
4656 @end smallexample
4657
4658 @noindent
4659 This pragma is used in conjunction with compiler switches to control the
4660 built in style checking provided by GNAT@. The compiler switches, if set,
4661 provide an initial setting for the switches, and this pragma may be used
4662 to modify these settings, or the settings may be provided entirely by
4663 the use of the pragma. This pragma can be used anywhere that a pragma
4664 is legal, including use as a configuration pragma (including use in
4665 the @file{gnat.adc} file).
4666
4667 The form with a string literal specifies which style options are to be
4668 activated. These are additive, so they apply in addition to any previously
4669 set style check options. The codes for the options are the same as those
4670 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4671 For example the following two methods can be used to enable
4672 layout checking:
4673
4674 @itemize @bullet
4675 @item
4676 @smallexample @c ada
4677 pragma Style_Checks ("l");
4678 @end smallexample
4679
4680 @item
4681 @smallexample
4682 gcc -c -gnatyl @dots{}
4683 @end smallexample
4684 @end itemize
4685
4686 @noindent
4687 The form ALL_CHECKS activates all standard checks (its use is equivalent
4688 to the use of the @code{gnaty} switch with no options. @xref{Top,
4689 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4690 @value{EDITION} User's Guide}, for details.)
4691
4692 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4693 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4694 options (i.e. equivalent to -gnatyg).
4695
4696 The forms with @code{Off} and @code{On}
4697 can be used to temporarily disable style checks
4698 as shown in the following example:
4699
4700 @smallexample @c ada
4701 @iftex
4702 @leftskip=0cm
4703 @end iftex
4704 pragma Style_Checks ("k"); -- requires keywords in lower case
4705 pragma Style_Checks (Off); -- turn off style checks
4706 NULL; -- this will not generate an error message
4707 pragma Style_Checks (On); -- turn style checks back on
4708 NULL; -- this will generate an error message
4709 @end smallexample
4710
4711 @noindent
4712 Finally the two argument form is allowed only if the first argument is
4713 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4714 for the specified entity, as shown in the following example:
4715
4716 @smallexample @c ada
4717 @iftex
4718 @leftskip=0cm
4719 @end iftex
4720 pragma Style_Checks ("r"); -- require consistency of identifier casing
4721 Arg : Integer;
4722 Rf1 : Integer := ARG; -- incorrect, wrong case
4723 pragma Style_Checks (Off, Arg);
4724 Rf2 : Integer := ARG; -- OK, no error
4725 @end smallexample
4726
4727 @node Pragma Subtitle
4728 @unnumberedsec Pragma Subtitle
4729 @findex Subtitle
4730 @noindent
4731 Syntax:
4732
4733 @smallexample @c ada
4734 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4735 @end smallexample
4736
4737 @noindent
4738 This pragma is recognized for compatibility with other Ada compilers
4739 but is ignored by GNAT@.
4740
4741 @node Pragma Suppress
4742 @unnumberedsec Pragma Suppress
4743 @findex Suppress
4744 @noindent
4745 Syntax:
4746
4747 @smallexample @c ada
4748 pragma Suppress (Identifier [, [On =>] Name]);
4749 @end smallexample
4750
4751 @noindent
4752 This is a standard pragma, and supports all the check names required in
4753 the RM. It is included here because GNAT recognizes one additional check
4754 name: @code{Alignment_Check} which can be used to suppress alignment checks
4755 on addresses used in address clauses. Such checks can also be suppressed
4756 by suppressing range checks, but the specific use of @code{Alignment_Check}
4757 allows suppression of alignment checks without suppressing other range checks.
4758
4759 Note that pragma Suppress gives the compiler permission to omit
4760 checks, but does not require the compiler to omit checks. The compiler
4761 will generate checks if they are essentially free, even when they are
4762 suppressed. In particular, if the compiler can prove that a certain
4763 check will necessarily fail, it will generate code to do an
4764 unconditional ``raise'', even if checks are suppressed. The compiler
4765 warns in this case.
4766
4767 Of course, run-time checks are omitted whenever the compiler can prove
4768 that they will not fail, whether or not checks are suppressed.
4769
4770 @node Pragma Suppress_All
4771 @unnumberedsec Pragma Suppress_All
4772 @findex Suppress_All
4773 @noindent
4774 Syntax:
4775
4776 @smallexample @c ada
4777 pragma Suppress_All;
4778 @end smallexample
4779
4780 @noindent
4781 This pragma can only appear immediately following a compilation
4782 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4783 which it follows. This pragma is implemented for compatibility with DEC
4784 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4785 configuration pragma is the preferred usage in GNAT@.
4786
4787 @node Pragma Suppress_Exception_Locations
4788 @unnumberedsec Pragma Suppress_Exception_Locations
4789 @findex Suppress_Exception_Locations
4790 @noindent
4791 Syntax:
4792
4793 @smallexample @c ada
4794 pragma Suppress_Exception_Locations;
4795 @end smallexample
4796
4797 @noindent
4798 In normal mode, a raise statement for an exception by default generates
4799 an exception message giving the file name and line number for the location
4800 of the raise. This is useful for debugging and logging purposes, but this
4801 entails extra space for the strings for the messages. The configuration
4802 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4803 generation of these strings, with the result that space is saved, but the
4804 exception message for such raises is null. This configuration pragma may
4805 appear in a global configuration pragma file, or in a specific unit as
4806 usual. It is not required that this pragma be used consistently within
4807 a partition, so it is fine to have some units within a partition compiled
4808 with this pragma and others compiled in normal mode without it.
4809
4810 @node Pragma Suppress_Initialization
4811 @unnumberedsec Pragma Suppress_Initialization
4812 @findex Suppress_Initialization
4813 @cindex Suppressing initialization
4814 @cindex Initialization, suppression of
4815 @noindent
4816 Syntax:
4817
4818 @smallexample @c ada
4819 pragma Suppress_Initialization ([Entity =>] type_Name);
4820 @end smallexample
4821
4822 @noindent
4823 This pragma suppresses any implicit or explicit initialization
4824 associated with the given type name for all variables of this type.
4825
4826 @node Pragma Task_Info
4827 @unnumberedsec Pragma Task_Info
4828 @findex Task_Info
4829 @noindent
4830 Syntax
4831
4832 @smallexample @c ada
4833 pragma Task_Info (EXPRESSION);
4834 @end smallexample
4835
4836 @noindent
4837 This pragma appears within a task definition (like pragma
4838 @code{Priority}) and applies to the task in which it appears. The
4839 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4840 The @code{Task_Info} pragma provides system dependent control over
4841 aspects of tasking implementation, for example, the ability to map
4842 tasks to specific processors. For details on the facilities available
4843 for the version of GNAT that you are using, see the documentation
4844 in the spec of package System.Task_Info in the runtime
4845 library.
4846
4847 @node Pragma Task_Name
4848 @unnumberedsec Pragma Task_Name
4849 @findex Task_Name
4850 @noindent
4851 Syntax
4852
4853 @smallexample @c ada
4854 pragma Task_Name (string_EXPRESSION);
4855 @end smallexample
4856
4857 @noindent
4858 This pragma appears within a task definition (like pragma
4859 @code{Priority}) and applies to the task in which it appears. The
4860 argument must be of type String, and provides a name to be used for
4861 the task instance when the task is created. Note that this expression
4862 is not required to be static, and in particular, it can contain
4863 references to task discriminants. This facility can be used to
4864 provide different names for different tasks as they are created,
4865 as illustrated in the example below.
4866
4867 The task name is recorded internally in the run-time structures
4868 and is accessible to tools like the debugger. In addition the
4869 routine @code{Ada.Task_Identification.Image} will return this
4870 string, with a unique task address appended.
4871
4872 @smallexample @c ada
4873 -- Example of the use of pragma Task_Name
4874
4875 with Ada.Task_Identification;
4876 use Ada.Task_Identification;
4877 with Text_IO; use Text_IO;
4878 procedure t3 is
4879
4880 type Astring is access String;
4881
4882 task type Task_Typ (Name : access String) is
4883 pragma Task_Name (Name.all);
4884 end Task_Typ;
4885
4886 task body Task_Typ is
4887 Nam : constant String := Image (Current_Task);
4888 begin
4889 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4890 end Task_Typ;
4891
4892 type Ptr_Task is access Task_Typ;
4893 Task_Var : Ptr_Task;
4894
4895 begin
4896 Task_Var :=
4897 new Task_Typ (new String'("This is task 1"));
4898 Task_Var :=
4899 new Task_Typ (new String'("This is task 2"));
4900 end;
4901 @end smallexample
4902
4903 @node Pragma Task_Storage
4904 @unnumberedsec Pragma Task_Storage
4905 @findex Task_Storage
4906 Syntax:
4907
4908 @smallexample @c ada
4909 pragma Task_Storage (
4910 [Task_Type =>] LOCAL_NAME,
4911 [Top_Guard =>] static_integer_EXPRESSION);
4912 @end smallexample
4913
4914 @noindent
4915 This pragma specifies the length of the guard area for tasks. The guard
4916 area is an additional storage area allocated to a task. A value of zero
4917 means that either no guard area is created or a minimal guard area is
4918 created, depending on the target. This pragma can appear anywhere a
4919 @code{Storage_Size} attribute definition clause is allowed for a task
4920 type.
4921
4922 @node Pragma Thread_Local_Storage
4923 @unnumberedsec Pragma Thread_Local_Storage
4924 @findex Thread_Local_Storage
4925 @cindex Task specific storage
4926 @cindex TLS (Thread Local Storage)
4927 Syntax:
4928
4929 @smallexample @c ada
4930 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4931 @end smallexample
4932
4933 @noindent
4934 This pragma specifies that the specified entity, which must be
4935 a variable declared in a library level package, is to be marked as
4936 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4937 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4938 (and hence each Ada task) to see a distinct copy of the variable.
4939
4940 The variable may not have default initialization, and if there is
4941 an explicit initialization, it must be either @code{null} for an
4942 access variable, or a static expression for a scalar variable.
4943 This provides a low level mechanism similar to that provided by
4944 the @code{Ada.Task_Attributes} package, but much more efficient
4945 and is also useful in writing interface code that will interact
4946 with foreign threads.
4947
4948 If this pragma is used on a system where @code{TLS} is not supported,
4949 then an error message will be generated and the program will be rejected.
4950
4951 @node Pragma Time_Slice
4952 @unnumberedsec Pragma Time_Slice
4953 @findex Time_Slice
4954 @noindent
4955 Syntax:
4956
4957 @smallexample @c ada
4958 pragma Time_Slice (static_duration_EXPRESSION);
4959 @end smallexample
4960
4961 @noindent
4962 For implementations of GNAT on operating systems where it is possible
4963 to supply a time slice value, this pragma may be used for this purpose.
4964 It is ignored if it is used in a system that does not allow this control,
4965 or if it appears in other than the main program unit.
4966 @cindex OpenVMS
4967 Note that the effect of this pragma is identical to the effect of the
4968 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4969
4970 @node Pragma Title
4971 @unnumberedsec Pragma Title
4972 @findex Title
4973 @noindent
4974 Syntax:
4975
4976 @smallexample @c ada
4977 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4978
4979 TITLING_OPTION ::=
4980 [Title =>] STRING_LITERAL,
4981 | [Subtitle =>] STRING_LITERAL
4982 @end smallexample
4983
4984 @noindent
4985 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4986 pragma used in DEC Ada 83 implementations to provide a title and/or
4987 subtitle for the program listing. The program listing generated by GNAT
4988 does not have titles or subtitles.
4989
4990 Unlike other pragmas, the full flexibility of named notation is allowed
4991 for this pragma, i.e.@: the parameters may be given in any order if named
4992 notation is used, and named and positional notation can be mixed
4993 following the normal rules for procedure calls in Ada.
4994
4995 @node Pragma Unchecked_Union
4996 @unnumberedsec Pragma Unchecked_Union
4997 @cindex Unions in C
4998 @findex Unchecked_Union
4999 @noindent
5000 Syntax:
5001
5002 @smallexample @c ada
5003 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5004 @end smallexample
5005
5006 @noindent
5007 This pragma is used to specify a representation of a record type that is
5008 equivalent to a C union. It was introduced as a GNAT implementation defined
5009 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5010 pragma, making it language defined, and GNAT fully implements this extended
5011 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5012 details, consult the Ada 2005 Reference Manual, section B.3.3.
5013
5014 @node Pragma Unimplemented_Unit
5015 @unnumberedsec Pragma Unimplemented_Unit
5016 @findex Unimplemented_Unit
5017 @noindent
5018 Syntax:
5019
5020 @smallexample @c ada
5021 pragma Unimplemented_Unit;
5022 @end smallexample
5023
5024 @noindent
5025 If this pragma occurs in a unit that is processed by the compiler, GNAT
5026 aborts with the message @samp{@var{xxx} not implemented}, where
5027 @var{xxx} is the name of the current compilation unit. This pragma is
5028 intended to allow the compiler to handle unimplemented library units in
5029 a clean manner.
5030
5031 The abort only happens if code is being generated. Thus you can use
5032 specs of unimplemented packages in syntax or semantic checking mode.
5033
5034 @node Pragma Universal_Aliasing
5035 @unnumberedsec Pragma Universal_Aliasing
5036 @findex Universal_Aliasing
5037 @noindent
5038 Syntax:
5039
5040 @smallexample @c ada
5041 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5042 @end smallexample
5043
5044 @noindent
5045 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5046 declarative part. The effect is to inhibit strict type-based aliasing
5047 optimization for the given type. In other words, the effect is as though
5048 access types designating this type were subject to pragma No_Strict_Aliasing.
5049 For a detailed description of the strict aliasing optimization, and the
5050 situations in which it must be suppressed, @xref{Optimization and Strict
5051 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5052
5053 @node Pragma Universal_Data
5054 @unnumberedsec Pragma Universal_Data
5055 @findex Universal_Data
5056 @noindent
5057 Syntax:
5058
5059 @smallexample @c ada
5060 pragma Universal_Data [(library_unit_Name)];
5061 @end smallexample
5062
5063 @noindent
5064 This pragma is supported only for the AAMP target and is ignored for
5065 other targets. The pragma specifies that all library-level objects
5066 (Counter 0 data) associated with the library unit are to be accessed
5067 and updated using universal addressing (24-bit addresses for AAMP5)
5068 rather than the default of 16-bit Data Environment (DENV) addressing.
5069 Use of this pragma will generally result in less efficient code for
5070 references to global data associated with the library unit, but
5071 allows such data to be located anywhere in memory. This pragma is
5072 a library unit pragma, but can also be used as a configuration pragma
5073 (including use in the @file{gnat.adc} file). The functionality
5074 of this pragma is also available by applying the -univ switch on the
5075 compilations of units where universal addressing of the data is desired.
5076
5077 @node Pragma Unmodified
5078 @unnumberedsec Pragma Unmodified
5079 @findex Unmodified
5080 @cindex Warnings, unmodified
5081 @noindent
5082 Syntax:
5083
5084 @smallexample @c ada
5085 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5086 @end smallexample
5087
5088 @noindent
5089 This pragma signals that the assignable entities (variables,
5090 @code{out} parameters, @code{in out} parameters) whose names are listed are
5091 deliberately not assigned in the current source unit. This
5092 suppresses warnings about the
5093 entities being referenced but not assigned, and in addition a warning will be
5094 generated if one of these entities is in fact assigned in the
5095 same unit as the pragma (or in the corresponding body, or one
5096 of its subunits).
5097
5098 This is particularly useful for clearly signaling that a particular
5099 parameter is not modified, even though the spec suggests that it might
5100 be.
5101
5102 @node Pragma Unreferenced
5103 @unnumberedsec Pragma Unreferenced
5104 @findex Unreferenced
5105 @cindex Warnings, unreferenced
5106 @noindent
5107 Syntax:
5108
5109 @smallexample @c ada
5110 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5111 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5112 @end smallexample
5113
5114 @noindent
5115 This pragma signals that the entities whose names are listed are
5116 deliberately not referenced in the current source unit. This
5117 suppresses warnings about the
5118 entities being unreferenced, and in addition a warning will be
5119 generated if one of these entities is in fact referenced in the
5120 same unit as the pragma (or in the corresponding body, or one
5121 of its subunits).
5122
5123 This is particularly useful for clearly signaling that a particular
5124 parameter is not referenced in some particular subprogram implementation
5125 and that this is deliberate. It can also be useful in the case of
5126 objects declared only for their initialization or finalization side
5127 effects.
5128
5129 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5130 current scope, then the entity most recently declared is the one to which
5131 the pragma applies. Note that in the case of accept formals, the pragma
5132 Unreferenced may appear immediately after the keyword @code{do} which
5133 allows the indication of whether or not accept formals are referenced
5134 or not to be given individually for each accept statement.
5135
5136 The left hand side of an assignment does not count as a reference for the
5137 purpose of this pragma. Thus it is fine to assign to an entity for which
5138 pragma Unreferenced is given.
5139
5140 Note that if a warning is desired for all calls to a given subprogram,
5141 regardless of whether they occur in the same unit as the subprogram
5142 declaration, then this pragma should not be used (calls from another
5143 unit would not be flagged); pragma Obsolescent can be used instead
5144 for this purpose, see @xref{Pragma Obsolescent}.
5145
5146 The second form of pragma @code{Unreferenced} is used within a context
5147 clause. In this case the arguments must be unit names of units previously
5148 mentioned in @code{with} clauses (similar to the usage of pragma
5149 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5150 units and unreferenced entities within these units.
5151
5152 @node Pragma Unreferenced_Objects
5153 @unnumberedsec Pragma Unreferenced_Objects
5154 @findex Unreferenced_Objects
5155 @cindex Warnings, unreferenced
5156 @noindent
5157 Syntax:
5158
5159 @smallexample @c ada
5160 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5161 @end smallexample
5162
5163 @noindent
5164 This pragma signals that for the types or subtypes whose names are
5165 listed, objects which are declared with one of these types or subtypes may
5166 not be referenced, and if no references appear, no warnings are given.
5167
5168 This is particularly useful for objects which are declared solely for their
5169 initialization and finalization effect. Such variables are sometimes referred
5170 to as RAII variables (Resource Acquisition Is Initialization). Using this
5171 pragma on the relevant type (most typically a limited controlled type), the
5172 compiler will automatically suppress unwanted warnings about these variables
5173 not being referenced.
5174
5175 @node Pragma Unreserve_All_Interrupts
5176 @unnumberedsec Pragma Unreserve_All_Interrupts
5177 @findex Unreserve_All_Interrupts
5178 @noindent
5179 Syntax:
5180
5181 @smallexample @c ada
5182 pragma Unreserve_All_Interrupts;
5183 @end smallexample
5184
5185 @noindent
5186 Normally certain interrupts are reserved to the implementation. Any attempt
5187 to attach an interrupt causes Program_Error to be raised, as described in
5188 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5189 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5190 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5191 interrupt execution.
5192
5193 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5194 a program, then all such interrupts are unreserved. This allows the
5195 program to handle these interrupts, but disables their standard
5196 functions. For example, if this pragma is used, then pressing
5197 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5198 a program can then handle the @code{SIGINT} interrupt as it chooses.
5199
5200 For a full list of the interrupts handled in a specific implementation,
5201 see the source code for the spec of @code{Ada.Interrupts.Names} in
5202 file @file{a-intnam.ads}. This is a target dependent file that contains the
5203 list of interrupts recognized for a given target. The documentation in
5204 this file also specifies what interrupts are affected by the use of
5205 the @code{Unreserve_All_Interrupts} pragma.
5206
5207 For a more general facility for controlling what interrupts can be
5208 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5209 of the @code{Unreserve_All_Interrupts} pragma.
5210
5211 @node Pragma Unsuppress
5212 @unnumberedsec Pragma Unsuppress
5213 @findex Unsuppress
5214 @noindent
5215 Syntax:
5216
5217 @smallexample @c ada
5218 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5219 @end smallexample
5220
5221 @noindent
5222 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5223 there is no corresponding pragma @code{Suppress} in effect, it has no
5224 effect. The range of the effect is the same as for pragma
5225 @code{Suppress}. The meaning of the arguments is identical to that used
5226 in pragma @code{Suppress}.
5227
5228 One important application is to ensure that checks are on in cases where
5229 code depends on the checks for its correct functioning, so that the code
5230 will compile correctly even if the compiler switches are set to suppress
5231 checks.
5232
5233 @node Pragma Use_VADS_Size
5234 @unnumberedsec Pragma Use_VADS_Size
5235 @cindex @code{Size}, VADS compatibility
5236 @findex Use_VADS_Size
5237 @noindent
5238 Syntax:
5239
5240 @smallexample @c ada
5241 pragma Use_VADS_Size;
5242 @end smallexample
5243
5244 @noindent
5245 This is a configuration pragma. In a unit to which it applies, any use
5246 of the 'Size attribute is automatically interpreted as a use of the
5247 'VADS_Size attribute. Note that this may result in incorrect semantic
5248 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5249 the handling of existing code which depends on the interpretation of Size
5250 as implemented in the VADS compiler. See description of the VADS_Size
5251 attribute for further details.
5252
5253 @node Pragma Validity_Checks
5254 @unnumberedsec Pragma Validity_Checks
5255 @findex Validity_Checks
5256 @noindent
5257 Syntax:
5258
5259 @smallexample @c ada
5260 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5261 @end smallexample
5262
5263 @noindent
5264 This pragma is used in conjunction with compiler switches to control the
5265 built-in validity checking provided by GNAT@. The compiler switches, if set
5266 provide an initial setting for the switches, and this pragma may be used
5267 to modify these settings, or the settings may be provided entirely by
5268 the use of the pragma. This pragma can be used anywhere that a pragma
5269 is legal, including use as a configuration pragma (including use in
5270 the @file{gnat.adc} file).
5271
5272 The form with a string literal specifies which validity options are to be
5273 activated. The validity checks are first set to include only the default
5274 reference manual settings, and then a string of letters in the string
5275 specifies the exact set of options required. The form of this string
5276 is exactly as described for the @option{-gnatVx} compiler switch (see the
5277 GNAT users guide for details). For example the following two methods
5278 can be used to enable validity checking for mode @code{in} and
5279 @code{in out} subprogram parameters:
5280
5281 @itemize @bullet
5282 @item
5283 @smallexample @c ada
5284 pragma Validity_Checks ("im");
5285 @end smallexample
5286
5287 @item
5288 @smallexample
5289 gcc -c -gnatVim @dots{}
5290 @end smallexample
5291 @end itemize
5292
5293 @noindent
5294 The form ALL_CHECKS activates all standard checks (its use is equivalent
5295 to the use of the @code{gnatva} switch.
5296
5297 The forms with @code{Off} and @code{On}
5298 can be used to temporarily disable validity checks
5299 as shown in the following example:
5300
5301 @smallexample @c ada
5302 @iftex
5303 @leftskip=0cm
5304 @end iftex
5305 pragma Validity_Checks ("c"); -- validity checks for copies
5306 pragma Validity_Checks (Off); -- turn off validity checks
5307 A := B; -- B will not be validity checked
5308 pragma Validity_Checks (On); -- turn validity checks back on
5309 A := C; -- C will be validity checked
5310 @end smallexample
5311
5312 @node Pragma Volatile
5313 @unnumberedsec Pragma Volatile
5314 @findex Volatile
5315 @noindent
5316 Syntax:
5317
5318 @smallexample @c ada
5319 pragma Volatile (LOCAL_NAME);
5320 @end smallexample
5321
5322 @noindent
5323 This pragma is defined by the Ada Reference Manual, and the GNAT
5324 implementation is fully conformant with this definition. The reason it
5325 is mentioned in this section is that a pragma of the same name was supplied
5326 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5327 implementation of pragma Volatile is upwards compatible with the
5328 implementation in DEC Ada 83.
5329
5330 @node Pragma Warnings
5331 @unnumberedsec Pragma Warnings
5332 @findex Warnings
5333 @noindent
5334 Syntax:
5335
5336 @smallexample @c ada
5337 pragma Warnings (On | Off);
5338 pragma Warnings (On | Off, LOCAL_NAME);
5339 pragma Warnings (static_string_EXPRESSION);
5340 pragma Warnings (On | Off, static_string_EXPRESSION);
5341 @end smallexample
5342
5343 @noindent
5344 Normally warnings are enabled, with the output being controlled by
5345 the command line switch. Warnings (@code{Off}) turns off generation of
5346 warnings until a Warnings (@code{On}) is encountered or the end of the
5347 current unit. If generation of warnings is turned off using this
5348 pragma, then no warning messages are output, regardless of the
5349 setting of the command line switches.
5350
5351 The form with a single argument may be used as a configuration pragma.
5352
5353 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5354 the specified entity. This suppression is effective from the point where
5355 it occurs till the end of the extended scope of the variable (similar to
5356 the scope of @code{Suppress}).
5357
5358 The form with a single static_string_EXPRESSION argument provides more precise
5359 control over which warnings are active. The string is a list of letters
5360 specifying which warnings are to be activated and which deactivated. The
5361 code for these letters is the same as the string used in the command
5362 line switch controlling warnings. For a brief summary, use the gnatmake
5363 command with no arguments, which will generate usage information containing
5364 the list of warnings switches supported. For
5365 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5366 User's Guide}.
5367
5368 @noindent
5369 The specified warnings will be in effect until the end of the program
5370 or another pragma Warnings is encountered. The effect of the pragma is
5371 cumulative. Initially the set of warnings is the standard default set
5372 as possibly modified by compiler switches. Then each pragma Warning
5373 modifies this set of warnings as specified. This form of the pragma may
5374 also be used as a configuration pragma.
5375
5376 The fourth form, with an On|Off parameter and a string, is used to
5377 control individual messages, based on their text. The string argument
5378 is a pattern that is used to match against the text of individual
5379 warning messages (not including the initial "warning: " tag).
5380
5381 The pattern may contain asterisks, which match zero or more characters in
5382 the message. For example, you can use
5383 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5384 message @code{warning: 960 bits of "a" unused}. No other regular
5385 expression notations are permitted. All characters other than asterisk in
5386 these three specific cases are treated as literal characters in the match.
5387
5388 There are two ways to use this pragma. The OFF form can be used as a
5389 configuration pragma. The effect is to suppress all warnings (if any)
5390 that match the pattern string throughout the compilation.
5391
5392 The second usage is to suppress a warning locally, and in this case, two
5393 pragmas must appear in sequence:
5394
5395 @smallexample @c ada
5396 pragma Warnings (Off, Pattern);
5397 @dots{} code where given warning is to be suppressed
5398 pragma Warnings (On, Pattern);
5399 @end smallexample
5400
5401 @noindent
5402 In this usage, the pattern string must match in the Off and On pragmas,
5403 and at least one matching warning must be suppressed.
5404
5405 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5406 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5407 be useful in checking whether obsolete pragmas in existing programs are hiding
5408 real problems.
5409
5410 Note: pragma Warnings does not affect the processing of style messages. See
5411 separate entry for pragma Style_Checks for control of style messages.
5412
5413 @node Pragma Weak_External
5414 @unnumberedsec Pragma Weak_External
5415 @findex Weak_External
5416 @noindent
5417 Syntax:
5418
5419 @smallexample @c ada
5420 pragma Weak_External ([Entity =>] LOCAL_NAME);
5421 @end smallexample
5422
5423 @noindent
5424 @var{LOCAL_NAME} must refer to an object that is declared at the library
5425 level. This pragma specifies that the given entity should be marked as a
5426 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5427 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5428 of a regular symbol, that is to say a symbol that does not have to be
5429 resolved by the linker if used in conjunction with a pragma Import.
5430
5431 When a weak symbol is not resolved by the linker, its address is set to
5432 zero. This is useful in writing interfaces to external modules that may
5433 or may not be linked in the final executable, for example depending on
5434 configuration settings.
5435
5436 If a program references at run time an entity to which this pragma has been
5437 applied, and the corresponding symbol was not resolved at link time, then
5438 the execution of the program is erroneous. It is not erroneous to take the
5439 Address of such an entity, for example to guard potential references,
5440 as shown in the example below.
5441
5442 Some file formats do not support weak symbols so not all target machines
5443 support this pragma.
5444
5445 @smallexample @c ada
5446 -- Example of the use of pragma Weak_External
5447
5448 package External_Module is
5449 key : Integer;
5450 pragma Import (C, key);
5451 pragma Weak_External (key);
5452 function Present return boolean;
5453 end External_Module;
5454
5455 with System; use System;
5456 package body External_Module is
5457 function Present return boolean is
5458 begin
5459 return key'Address /= System.Null_Address;
5460 end Present;
5461 end External_Module;
5462 @end smallexample
5463
5464 @node Pragma Wide_Character_Encoding
5465 @unnumberedsec Pragma Wide_Character_Encoding
5466 @findex Wide_Character_Encoding
5467 @noindent
5468 Syntax:
5469
5470 @smallexample @c ada
5471 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5472 @end smallexample
5473
5474 @noindent
5475 This pragma specifies the wide character encoding to be used in program
5476 source text appearing subsequently. It is a configuration pragma, but may
5477 also be used at any point that a pragma is allowed, and it is permissible
5478 to have more than one such pragma in a file, allowing multiple encodings
5479 to appear within the same file.
5480
5481 The argument can be an identifier or a character literal. In the identifier
5482 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5483 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5484 case it is correspondingly one of the characters @samp{h}, @samp{u},
5485 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5486
5487 Note that when the pragma is used within a file, it affects only the
5488 encoding within that file, and does not affect withed units, specs,
5489 or subunits.
5490
5491 @node Implementation Defined Attributes
5492 @chapter Implementation Defined Attributes
5493 Ada defines (throughout the Ada reference manual,
5494 summarized in Annex K),
5495 a set of attributes that provide useful additional functionality in all
5496 areas of the language. These language defined attributes are implemented
5497 in GNAT and work as described in the Ada Reference Manual.
5498
5499 In addition, Ada allows implementations to define additional
5500 attributes whose meaning is defined by the implementation. GNAT provides
5501 a number of these implementation-dependent attributes which can be used
5502 to extend and enhance the functionality of the compiler. This section of
5503 the GNAT reference manual describes these additional attributes.
5504
5505 Note that any program using these attributes may not be portable to
5506 other compilers (although GNAT implements this set of attributes on all
5507 platforms). Therefore if portability to other compilers is an important
5508 consideration, you should minimize the use of these attributes.
5509
5510 @menu
5511 * Abort_Signal::
5512 * Address_Size::
5513 * Asm_Input::
5514 * Asm_Output::
5515 * AST_Entry::
5516 * Bit::
5517 * Bit_Position::
5518 * Compiler_Version::
5519 * Code_Address::
5520 * Default_Bit_Order::
5521 * Elaborated::
5522 * Elab_Body::
5523 * Elab_Spec::
5524 * Emax::
5525 * Enabled::
5526 * Enum_Rep::
5527 * Enum_Val::
5528 * Epsilon::
5529 * Fixed_Value::
5530 * Has_Access_Values::
5531 * Has_Discriminants::
5532 * Img::
5533 * Integer_Value::
5534 * Invalid_Value::
5535 * Large::
5536 * Machine_Size::
5537 * Mantissa::
5538 * Max_Interrupt_Priority::
5539 * Max_Priority::
5540 * Maximum_Alignment::
5541 * Mechanism_Code::
5542 * Null_Parameter::
5543 * Object_Size::
5544 * Old::
5545 * Passed_By_Reference::
5546 * Pool_Address::
5547 * Range_Length::
5548 * Result::
5549 * Safe_Emax::
5550 * Safe_Large::
5551 * Small::
5552 * Storage_Unit::
5553 * Stub_Type::
5554 * Target_Name::
5555 * Tick::
5556 * To_Address::
5557 * Type_Class::
5558 * UET_Address::
5559 * Unconstrained_Array::
5560 * Universal_Literal_String::
5561 * Unrestricted_Access::
5562 * VADS_Size::
5563 * Value_Size::
5564 * Wchar_T_Size::
5565 * Word_Size::
5566 @end menu
5567
5568 @node Abort_Signal
5569 @unnumberedsec Abort_Signal
5570 @findex Abort_Signal
5571 @noindent
5572 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5573 prefix) provides the entity for the special exception used to signal
5574 task abort or asynchronous transfer of control. Normally this attribute
5575 should only be used in the tasking runtime (it is highly peculiar, and
5576 completely outside the normal semantics of Ada, for a user program to
5577 intercept the abort exception).
5578
5579 @node Address_Size
5580 @unnumberedsec Address_Size
5581 @cindex Size of @code{Address}
5582 @findex Address_Size
5583 @noindent
5584 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5585 prefix) is a static constant giving the number of bits in an
5586 @code{Address}. It is the same value as System.Address'Size,
5587 but has the advantage of being static, while a direct
5588 reference to System.Address'Size is non-static because Address
5589 is a private type.
5590
5591 @node Asm_Input
5592 @unnumberedsec Asm_Input
5593 @findex Asm_Input
5594 @noindent
5595 The @code{Asm_Input} attribute denotes a function that takes two
5596 parameters. The first is a string, the second is an expression of the
5597 type designated by the prefix. The first (string) argument is required
5598 to be a static expression, and is the constraint for the parameter,
5599 (e.g.@: what kind of register is required). The second argument is the
5600 value to be used as the input argument. The possible values for the
5601 constant are the same as those used in the RTL, and are dependent on
5602 the configuration file used to built the GCC back end.
5603 @ref{Machine Code Insertions}
5604
5605 @node Asm_Output
5606 @unnumberedsec Asm_Output
5607 @findex Asm_Output
5608 @noindent
5609 The @code{Asm_Output} attribute denotes a function that takes two
5610 parameters. The first is a string, the second is the name of a variable
5611 of the type designated by the attribute prefix. The first (string)
5612 argument is required to be a static expression and designates the
5613 constraint for the parameter (e.g.@: what kind of register is
5614 required). The second argument is the variable to be updated with the
5615 result. The possible values for constraint are the same as those used in
5616 the RTL, and are dependent on the configuration file used to build the
5617 GCC back end. If there are no output operands, then this argument may
5618 either be omitted, or explicitly given as @code{No_Output_Operands}.
5619 @ref{Machine Code Insertions}
5620
5621 @node AST_Entry
5622 @unnumberedsec AST_Entry
5623 @cindex OpenVMS
5624 @findex AST_Entry
5625 @noindent
5626 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5627 the name of an entry, it yields a value of the predefined type AST_Handler
5628 (declared in the predefined package System, as extended by the use of
5629 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5630 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5631 Language Reference Manual}, section 9.12a.
5632
5633 @node Bit
5634 @unnumberedsec Bit
5635 @findex Bit
5636 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5637 offset within the storage unit (byte) that contains the first bit of
5638 storage allocated for the object. The value of this attribute is of the
5639 type @code{Universal_Integer}, and is always a non-negative number not
5640 exceeding the value of @code{System.Storage_Unit}.
5641
5642 For an object that is a variable or a constant allocated in a register,
5643 the value is zero. (The use of this attribute does not force the
5644 allocation of a variable to memory).
5645
5646 For an object that is a formal parameter, this attribute applies
5647 to either the matching actual parameter or to a copy of the
5648 matching actual parameter.
5649
5650 For an access object the value is zero. Note that
5651 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5652 designated object. Similarly for a record component
5653 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5654 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5655 are subject to index checks.
5656
5657 This attribute is designed to be compatible with the DEC Ada 83 definition
5658 and implementation of the @code{Bit} attribute.
5659
5660 @node Bit_Position
5661 @unnumberedsec Bit_Position
5662 @findex Bit_Position
5663 @noindent
5664 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5665 of the fields of the record type, yields the bit
5666 offset within the record contains the first bit of
5667 storage allocated for the object. The value of this attribute is of the
5668 type @code{Universal_Integer}. The value depends only on the field
5669 @var{C} and is independent of the alignment of
5670 the containing record @var{R}.
5671
5672 @node Compiler_Version
5673 @unnumberedsec Compiler_Version
5674 @findex Compiler_Version
5675 @noindent
5676 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5677 prefix) yields a static string identifying the version of the compiler
5678 being used to compile the unit containing the attribute reference. A
5679 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5680
5681 @node Code_Address
5682 @unnumberedsec Code_Address
5683 @findex Code_Address
5684 @cindex Subprogram address
5685 @cindex Address of subprogram code
5686 @noindent
5687 The @code{'Address}
5688 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5689 intended effect seems to be to provide
5690 an address value which can be used to call the subprogram by means of
5691 an address clause as in the following example:
5692
5693 @smallexample @c ada
5694 procedure K is @dots{}
5695
5696 procedure L;
5697 for L'Address use K'Address;
5698 pragma Import (Ada, L);
5699 @end smallexample
5700
5701 @noindent
5702 A call to @code{L} is then expected to result in a call to @code{K}@.
5703 In Ada 83, where there were no access-to-subprogram values, this was
5704 a common work-around for getting the effect of an indirect call.
5705 GNAT implements the above use of @code{Address} and the technique
5706 illustrated by the example code works correctly.
5707
5708 However, for some purposes, it is useful to have the address of the start
5709 of the generated code for the subprogram. On some architectures, this is
5710 not necessarily the same as the @code{Address} value described above.
5711 For example, the @code{Address} value may reference a subprogram
5712 descriptor rather than the subprogram itself.
5713
5714 The @code{'Code_Address} attribute, which can only be applied to
5715 subprogram entities, always returns the address of the start of the
5716 generated code of the specified subprogram, which may or may not be
5717 the same value as is returned by the corresponding @code{'Address}
5718 attribute.
5719
5720 @node Default_Bit_Order
5721 @unnumberedsec Default_Bit_Order
5722 @cindex Big endian
5723 @cindex Little endian
5724 @findex Default_Bit_Order
5725 @noindent
5726 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5727 permissible prefix), provides the value @code{System.Default_Bit_Order}
5728 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5729 @code{Low_Order_First}). This is used to construct the definition of
5730 @code{Default_Bit_Order} in package @code{System}.
5731
5732 @node Elaborated
5733 @unnumberedsec Elaborated
5734 @findex Elaborated
5735 @noindent
5736 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5737 value is a Boolean which indicates whether or not the given unit has been
5738 elaborated. This attribute is primarily intended for internal use by the
5739 generated code for dynamic elaboration checking, but it can also be used
5740 in user programs. The value will always be True once elaboration of all
5741 units has been completed. An exception is for units which need no
5742 elaboration, the value is always False for such units.
5743
5744 @node Elab_Body
5745 @unnumberedsec Elab_Body
5746 @findex Elab_Body
5747 @noindent
5748 This attribute can only be applied to a program unit name. It returns
5749 the entity for the corresponding elaboration procedure for elaborating
5750 the body of the referenced unit. This is used in the main generated
5751 elaboration procedure by the binder and is not normally used in any
5752 other context. However, there may be specialized situations in which it
5753 is useful to be able to call this elaboration procedure from Ada code,
5754 e.g.@: if it is necessary to do selective re-elaboration to fix some
5755 error.
5756
5757 @node Elab_Spec
5758 @unnumberedsec Elab_Spec
5759 @findex Elab_Spec
5760 @noindent
5761 This attribute can only be applied to a program unit name. It returns
5762 the entity for the corresponding elaboration procedure for elaborating
5763 the spec of the referenced unit. This is used in the main
5764 generated elaboration procedure by the binder and is not normally used
5765 in any other context. However, there may be specialized situations in
5766 which it is useful to be able to call this elaboration procedure from
5767 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5768 some error.
5769
5770 @node Emax
5771 @unnumberedsec Emax
5772 @cindex Ada 83 attributes
5773 @findex Emax
5774 @noindent
5775 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5776 the Ada 83 reference manual for an exact description of the semantics of
5777 this attribute.
5778
5779 @node Enabled
5780 @unnumberedsec Enabled
5781 @findex Enabled
5782 @noindent
5783 The @code{Enabled} attribute allows an application program to check at compile
5784 time to see if the designated check is currently enabled. The prefix is a
5785 simple identifier, referencing any predefined check name (other than
5786 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5787 no argument is given for the attribute, the check is for the general state
5788 of the check, if an argument is given, then it is an entity name, and the
5789 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5790 given naming the entity (if not, then the argument is ignored).
5791
5792 Note that instantiations inherit the check status at the point of the
5793 instantiation, so a useful idiom is to have a library package that
5794 introduces a check name with @code{pragma Check_Name}, and then contains
5795 generic packages or subprograms which use the @code{Enabled} attribute
5796 to see if the check is enabled. A user of this package can then issue
5797 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5798 the package or subprogram, controlling whether the check will be present.
5799
5800 @node Enum_Rep
5801 @unnumberedsec Enum_Rep
5802 @cindex Representation of enums
5803 @findex Enum_Rep
5804 @noindent
5805 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5806 function with the following spec:
5807
5808 @smallexample @c ada
5809 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5810 return @i{Universal_Integer};
5811 @end smallexample
5812
5813 @noindent
5814 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5815 enumeration type or to a non-overloaded enumeration
5816 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5817 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5818 enumeration literal or object.
5819
5820 The function returns the representation value for the given enumeration
5821 value. This will be equal to value of the @code{Pos} attribute in the
5822 absence of an enumeration representation clause. This is a static
5823 attribute (i.e.@: the result is static if the argument is static).
5824
5825 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5826 in which case it simply returns the integer value. The reason for this
5827 is to allow it to be used for @code{(<>)} discrete formal arguments in
5828 a generic unit that can be instantiated with either enumeration types
5829 or integer types. Note that if @code{Enum_Rep} is used on a modular
5830 type whose upper bound exceeds the upper bound of the largest signed
5831 integer type, and the argument is a variable, so that the universal
5832 integer calculation is done at run time, then the call to @code{Enum_Rep}
5833 may raise @code{Constraint_Error}.
5834
5835 @node Enum_Val
5836 @unnumberedsec Enum_Val
5837 @cindex Representation of enums
5838 @findex Enum_Val
5839 @noindent
5840 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
5841 function with the following spec:
5842
5843 @smallexample @c ada
5844 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
5845 return @var{S}'Base};
5846 @end smallexample
5847
5848 @noindent
5849 The function returns the enumeration value whose representation matches the
5850 argument, or raises Constraint_Error if no enumeration literal of the type
5851 has the matching value.
5852 This will be equal to value of the @code{Val} attribute in the
5853 absence of an enumeration representation clause. This is a static
5854 attribute (i.e.@: the result is static if the argument is static).
5855
5856 @node Epsilon
5857 @unnumberedsec Epsilon
5858 @cindex Ada 83 attributes
5859 @findex Epsilon
5860 @noindent
5861 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5862 the Ada 83 reference manual for an exact description of the semantics of
5863 this attribute.
5864
5865 @node Fixed_Value
5866 @unnumberedsec Fixed_Value
5867 @findex Fixed_Value
5868 @noindent
5869 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5870 function with the following specification:
5871
5872 @smallexample @c ada
5873 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5874 return @var{S};
5875 @end smallexample
5876
5877 @noindent
5878 The value returned is the fixed-point value @var{V} such that
5879
5880 @smallexample @c ada
5881 @var{V} = Arg * @var{S}'Small
5882 @end smallexample
5883
5884 @noindent
5885 The effect is thus similar to first converting the argument to the
5886 integer type used to represent @var{S}, and then doing an unchecked
5887 conversion to the fixed-point type. The difference is
5888 that there are full range checks, to ensure that the result is in range.
5889 This attribute is primarily intended for use in implementation of the
5890 input-output functions for fixed-point values.
5891
5892 @node Has_Access_Values
5893 @unnumberedsec Has_Access_Values
5894 @cindex Access values, testing for
5895 @findex Has_Access_Values
5896 @noindent
5897 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5898 is a Boolean value which is True if the is an access type, or is a composite
5899 type with a component (at any nesting depth) that is an access type, and is
5900 False otherwise.
5901 The intended use of this attribute is in conjunction with generic
5902 definitions. If the attribute is applied to a generic private type, it
5903 indicates whether or not the corresponding actual type has access values.
5904
5905 @node Has_Discriminants
5906 @unnumberedsec Has_Discriminants
5907 @cindex Discriminants, testing for
5908 @findex Has_Discriminants
5909 @noindent
5910 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5911 is a Boolean value which is True if the type has discriminants, and False
5912 otherwise. The intended use of this attribute is in conjunction with generic
5913 definitions. If the attribute is applied to a generic private type, it
5914 indicates whether or not the corresponding actual type has discriminants.
5915
5916 @node Img
5917 @unnumberedsec Img
5918 @findex Img
5919 @noindent
5920 The @code{Img} attribute differs from @code{Image} in that it may be
5921 applied to objects as well as types, in which case it gives the
5922 @code{Image} for the subtype of the object. This is convenient for
5923 debugging:
5924
5925 @smallexample @c ada
5926 Put_Line ("X = " & X'Img);
5927 @end smallexample
5928
5929 @noindent
5930 has the same meaning as the more verbose:
5931
5932 @smallexample @c ada
5933 Put_Line ("X = " & @var{T}'Image (X));
5934 @end smallexample
5935
5936 @noindent
5937 where @var{T} is the (sub)type of the object @code{X}.
5938
5939 @node Integer_Value
5940 @unnumberedsec Integer_Value
5941 @findex Integer_Value
5942 @noindent
5943 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5944 function with the following spec:
5945
5946 @smallexample @c ada
5947 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5948 return @var{S};
5949 @end smallexample
5950
5951 @noindent
5952 The value returned is the integer value @var{V}, such that
5953
5954 @smallexample @c ada
5955 Arg = @var{V} * @var{T}'Small
5956 @end smallexample
5957
5958 @noindent
5959 where @var{T} is the type of @code{Arg}.
5960 The effect is thus similar to first doing an unchecked conversion from
5961 the fixed-point type to its corresponding implementation type, and then
5962 converting the result to the target integer type. The difference is
5963 that there are full range checks, to ensure that the result is in range.
5964 This attribute is primarily intended for use in implementation of the
5965 standard input-output functions for fixed-point values.
5966
5967 @node Invalid_Value
5968 @unnumberedsec Invalid_Value
5969 @findex Invalid_Value
5970 @noindent
5971 For every scalar type S, S'Invalid_Value returns an undefined value of the
5972 type. If possible this value is an invalid representation for the type. The
5973 value returned is identical to the value used to initialize an otherwise
5974 uninitialized value of the type if pragma Initialize_Scalars is used,
5975 including the ability to modify the value with the binder -Sxx flag and
5976 relevant environment variables at run time.
5977
5978 @node Large
5979 @unnumberedsec Large
5980 @cindex Ada 83 attributes
5981 @findex Large
5982 @noindent
5983 The @code{Large} attribute is provided for compatibility with Ada 83. See
5984 the Ada 83 reference manual for an exact description of the semantics of
5985 this attribute.
5986
5987 @node Machine_Size
5988 @unnumberedsec Machine_Size
5989 @findex Machine_Size
5990 @noindent
5991 This attribute is identical to the @code{Object_Size} attribute. It is
5992 provided for compatibility with the DEC Ada 83 attribute of this name.
5993
5994 @node Mantissa
5995 @unnumberedsec Mantissa
5996 @cindex Ada 83 attributes
5997 @findex Mantissa
5998 @noindent
5999 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6000 the Ada 83 reference manual for an exact description of the semantics of
6001 this attribute.
6002
6003 @node Max_Interrupt_Priority
6004 @unnumberedsec Max_Interrupt_Priority
6005 @cindex Interrupt priority, maximum
6006 @findex Max_Interrupt_Priority
6007 @noindent
6008 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6009 permissible prefix), provides the same value as
6010 @code{System.Max_Interrupt_Priority}.
6011
6012 @node Max_Priority
6013 @unnumberedsec Max_Priority
6014 @cindex Priority, maximum
6015 @findex Max_Priority
6016 @noindent
6017 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6018 prefix) provides the same value as @code{System.Max_Priority}.
6019
6020 @node Maximum_Alignment
6021 @unnumberedsec Maximum_Alignment
6022 @cindex Alignment, maximum
6023 @findex Maximum_Alignment
6024 @noindent
6025 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6026 permissible prefix) provides the maximum useful alignment value for the
6027 target. This is a static value that can be used to specify the alignment
6028 for an object, guaranteeing that it is properly aligned in all
6029 cases.
6030
6031 @node Mechanism_Code
6032 @unnumberedsec Mechanism_Code
6033 @cindex Return values, passing mechanism
6034 @cindex Parameters, passing mechanism
6035 @findex Mechanism_Code
6036 @noindent
6037 @code{@var{function}'Mechanism_Code} yields an integer code for the
6038 mechanism used for the result of function, and
6039 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6040 used for formal parameter number @var{n} (a static integer value with 1
6041 meaning the first parameter) of @var{subprogram}. The code returned is:
6042
6043 @table @asis
6044 @item 1
6045 by copy (value)
6046 @item 2
6047 by reference
6048 @item 3
6049 by descriptor (default descriptor class)
6050 @item 4
6051 by descriptor (UBS: unaligned bit string)
6052 @item 5
6053 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6054 @item 6
6055 by descriptor (UBA: unaligned bit array)
6056 @item 7
6057 by descriptor (S: string, also scalar access type parameter)
6058 @item 8
6059 by descriptor (SB: string with arbitrary bounds)
6060 @item 9
6061 by descriptor (A: contiguous array)
6062 @item 10
6063 by descriptor (NCA: non-contiguous array)
6064 @end table
6065
6066 @noindent
6067 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6068 @cindex OpenVMS
6069
6070 @node Null_Parameter
6071 @unnumberedsec Null_Parameter
6072 @cindex Zero address, passing
6073 @findex Null_Parameter
6074 @noindent
6075 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6076 type or subtype @var{T} allocated at machine address zero. The attribute
6077 is allowed only as the default expression of a formal parameter, or as
6078 an actual expression of a subprogram call. In either case, the
6079 subprogram must be imported.
6080
6081 The identity of the object is represented by the address zero in the
6082 argument list, independent of the passing mechanism (explicit or
6083 default).
6084
6085 This capability is needed to specify that a zero address should be
6086 passed for a record or other composite object passed by reference.
6087 There is no way of indicating this without the @code{Null_Parameter}
6088 attribute.
6089
6090 @node Object_Size
6091 @unnumberedsec Object_Size
6092 @cindex Size, used for objects
6093 @findex Object_Size
6094 @noindent
6095 The size of an object is not necessarily the same as the size of the type
6096 of an object. This is because by default object sizes are increased to be
6097 a multiple of the alignment of the object. For example,
6098 @code{Natural'Size} is
6099 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6100 Similarly, a record containing an integer and a character:
6101
6102 @smallexample @c ada
6103 type Rec is record
6104 I : Integer;
6105 C : Character;
6106 end record;
6107 @end smallexample
6108
6109 @noindent
6110 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6111 alignment will be 4, because of the
6112 integer field, and so the default size of record objects for this type
6113 will be 64 (8 bytes).
6114
6115 @node Old
6116 @unnumberedsec Old
6117 @cindex Capturing Old values
6118 @cindex Postconditions
6119 @noindent
6120 The attribute Prefix'Old can be used within a
6121 subprogram to refer to the value of the prefix on entry. So for
6122 example if you have an argument of a record type X called Arg1,
6123 you can refer to Arg1.Field'Old which yields the value of
6124 Arg1.Field on entry. The implementation simply involves generating
6125 an object declaration which captures the value on entry. Any
6126 prefix is allowed except one of a limited type (since limited
6127 types cannot be copied to capture their values) or a local variable
6128 (since it does not exist at subprogram entry time).
6129
6130 The following example shows the use of 'Old to implement
6131 a test of a postcondition:
6132
6133 @smallexample @c ada
6134 with Old_Pkg;
6135 procedure Old is
6136 begin
6137 Old_Pkg.Incr;
6138 end Old;
6139
6140 package Old_Pkg is
6141 procedure Incr;
6142 end Old_Pkg;
6143
6144 package body Old_Pkg is
6145 Count : Natural := 0;
6146
6147 procedure Incr is
6148 begin
6149 ... code manipulating the value of Count
6150
6151 pragma Assert (Count = Count'Old + 1);
6152 end Incr;
6153 end Old_Pkg;
6154 @end smallexample
6155
6156 @noindent
6157 Note that it is allowed to apply 'Old to a constant entity, but this will
6158 result in a warning, since the old and new values will always be the same.
6159
6160 @node Passed_By_Reference
6161 @unnumberedsec Passed_By_Reference
6162 @cindex Parameters, when passed by reference
6163 @findex Passed_By_Reference
6164 @noindent
6165 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6166 a value of type @code{Boolean} value that is @code{True} if the type is
6167 normally passed by reference and @code{False} if the type is normally
6168 passed by copy in calls. For scalar types, the result is always @code{False}
6169 and is static. For non-scalar types, the result is non-static.
6170
6171 @node Pool_Address
6172 @unnumberedsec Pool_Address
6173 @cindex Parameters, when passed by reference
6174 @findex Pool_Address
6175 @noindent
6176 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6177 of X within its storage pool. This is the same as
6178 @code{@var{X}'Address}, except that for an unconstrained array whose
6179 bounds are allocated just before the first component,
6180 @code{@var{X}'Pool_Address} returns the address of those bounds,
6181 whereas @code{@var{X}'Address} returns the address of the first
6182 component.
6183
6184 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6185 the object is allocated'', which could be a user-defined storage pool,
6186 the global heap, on the stack, or in a static memory area. For an
6187 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6188 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6189
6190 @node Range_Length
6191 @unnumberedsec Range_Length
6192 @findex Range_Length
6193 @noindent
6194 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6195 the number of values represented by the subtype (zero for a null
6196 range). The result is static for static subtypes. @code{Range_Length}
6197 applied to the index subtype of a one dimensional array always gives the
6198 same result as @code{Range} applied to the array itself.
6199
6200 @node Result
6201 @unnumberedsec Result
6202 @findex Result
6203 @noindent
6204 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6205 for a function. The prefix must be the name of the corresponding function. This
6206 is used to refer to the result of the function in the postcondition expression.
6207 For a further discussion of the use of this attribute and examples of its use,
6208 see the description of pragma Postcondition.
6209
6210 @node Safe_Emax
6211 @unnumberedsec Safe_Emax
6212 @cindex Ada 83 attributes
6213 @findex Safe_Emax
6214 @noindent
6215 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6216 the Ada 83 reference manual for an exact description of the semantics of
6217 this attribute.
6218
6219 @node Safe_Large
6220 @unnumberedsec Safe_Large
6221 @cindex Ada 83 attributes
6222 @findex Safe_Large
6223 @noindent
6224 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6225 the Ada 83 reference manual for an exact description of the semantics of
6226 this attribute.
6227
6228 @node Small
6229 @unnumberedsec Small
6230 @cindex Ada 83 attributes
6231 @findex Small
6232 @noindent
6233 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6234 fixed-point types.
6235 GNAT also allows this attribute to be applied to floating-point types
6236 for compatibility with Ada 83. See
6237 the Ada 83 reference manual for an exact description of the semantics of
6238 this attribute when applied to floating-point types.
6239
6240 @node Storage_Unit
6241 @unnumberedsec Storage_Unit
6242 @findex Storage_Unit
6243 @noindent
6244 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6245 prefix) provides the same value as @code{System.Storage_Unit}.
6246
6247 @node Stub_Type
6248 @unnumberedsec Stub_Type
6249 @findex Stub_Type
6250 @noindent
6251 The GNAT implementation of remote access-to-classwide types is
6252 organized as described in AARM section E.4 (20.t): a value of an RACW type
6253 (designating a remote object) is represented as a normal access
6254 value, pointing to a "stub" object which in turn contains the
6255 necessary information to contact the designated remote object. A
6256 call on any dispatching operation of such a stub object does the
6257 remote call, if necessary, using the information in the stub object
6258 to locate the target partition, etc.
6259
6260 For a prefix @code{T} that denotes a remote access-to-classwide type,
6261 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6262
6263 By construction, the layout of @code{T'Stub_Type} is identical to that of
6264 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6265 unit @code{System.Partition_Interface}. Use of this attribute will create
6266 an implicit dependency on this unit.
6267
6268 @node Target_Name
6269 @unnumberedsec Target_Name
6270 @findex Target_Name
6271 @noindent
6272 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6273 prefix) provides a static string value that identifies the target
6274 for the current compilation. For GCC implementations, this is the
6275 standard gcc target name without the terminating slash (for
6276 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6277
6278 @node Tick
6279 @unnumberedsec Tick
6280 @findex Tick
6281 @noindent
6282 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6283 provides the same value as @code{System.Tick},
6284
6285 @node To_Address
6286 @unnumberedsec To_Address
6287 @findex To_Address
6288 @noindent
6289 The @code{System'To_Address}
6290 (@code{System} is the only permissible prefix)
6291 denotes a function identical to
6292 @code{System.Storage_Elements.To_Address} except that
6293 it is a static attribute. This means that if its argument is
6294 a static expression, then the result of the attribute is a
6295 static expression. The result is that such an expression can be
6296 used in contexts (e.g.@: preelaborable packages) which require a
6297 static expression and where the function call could not be used
6298 (since the function call is always non-static, even if its
6299 argument is static).
6300
6301 @node Type_Class
6302 @unnumberedsec Type_Class
6303 @findex Type_Class
6304 @noindent
6305 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6306 the value of the type class for the full type of @var{type}. If
6307 @var{type} is a generic formal type, the value is the value for the
6308 corresponding actual subtype. The value of this attribute is of type
6309 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6310
6311 @smallexample @c ada
6312 type Type_Class is
6313 (Type_Class_Enumeration,
6314 Type_Class_Integer,
6315 Type_Class_Fixed_Point,
6316 Type_Class_Floating_Point,
6317 Type_Class_Array,
6318 Type_Class_Record,
6319 Type_Class_Access,
6320 Type_Class_Task,
6321 Type_Class_Address);
6322 @end smallexample
6323
6324 @noindent
6325 Protected types yield the value @code{Type_Class_Task}, which thus
6326 applies to all concurrent types. This attribute is designed to
6327 be compatible with the DEC Ada 83 attribute of the same name.
6328
6329 @node UET_Address
6330 @unnumberedsec UET_Address
6331 @findex UET_Address
6332 @noindent
6333 The @code{UET_Address} attribute can only be used for a prefix which
6334 denotes a library package. It yields the address of the unit exception
6335 table when zero cost exception handling is used. This attribute is
6336 intended only for use within the GNAT implementation. See the unit
6337 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6338 for details on how this attribute is used in the implementation.
6339
6340 @node Unconstrained_Array
6341 @unnumberedsec Unconstrained_Array
6342 @findex Unconstrained_Array
6343 @noindent
6344 The @code{Unconstrained_Array} attribute can be used with a prefix that
6345 denotes any type or subtype. It is a static attribute that yields
6346 @code{True} if the prefix designates an unconstrained array,
6347 and @code{False} otherwise. In a generic instance, the result is
6348 still static, and yields the result of applying this test to the
6349 generic actual.
6350
6351 @node Universal_Literal_String
6352 @unnumberedsec Universal_Literal_String
6353 @cindex Named numbers, representation of
6354 @findex Universal_Literal_String
6355 @noindent
6356 The prefix of @code{Universal_Literal_String} must be a named
6357 number. The static result is the string consisting of the characters of
6358 the number as defined in the original source. This allows the user
6359 program to access the actual text of named numbers without intermediate
6360 conversions and without the need to enclose the strings in quotes (which
6361 would preclude their use as numbers). This is used internally for the
6362 construction of values of the floating-point attributes from the file
6363 @file{ttypef.ads}, but may also be used by user programs.
6364
6365 For example, the following program prints the first 50 digits of pi:
6366
6367 @smallexample @c ada
6368 with Text_IO; use Text_IO;
6369 with Ada.Numerics;
6370 procedure Pi is
6371 begin
6372 Put (Ada.Numerics.Pi'Universal_Literal_String);
6373 end;
6374 @end smallexample
6375
6376 @node Unrestricted_Access
6377 @unnumberedsec Unrestricted_Access
6378 @cindex @code{Access}, unrestricted
6379 @findex Unrestricted_Access
6380 @noindent
6381 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6382 except that all accessibility and aliased view checks are omitted. This
6383 is a user-beware attribute. It is similar to
6384 @code{Address}, for which it is a desirable replacement where the value
6385 desired is an access type. In other words, its effect is identical to
6386 first applying the @code{Address} attribute and then doing an unchecked
6387 conversion to a desired access type. In GNAT, but not necessarily in
6388 other implementations, the use of static chains for inner level
6389 subprograms means that @code{Unrestricted_Access} applied to a
6390 subprogram yields a value that can be called as long as the subprogram
6391 is in scope (normal Ada accessibility rules restrict this usage).
6392
6393 It is possible to use @code{Unrestricted_Access} for any type, but care
6394 must be exercised if it is used to create pointers to unconstrained
6395 objects. In this case, the resulting pointer has the same scope as the
6396 context of the attribute, and may not be returned to some enclosing
6397 scope. For instance, a function cannot use @code{Unrestricted_Access}
6398 to create a unconstrained pointer and then return that value to the
6399 caller.
6400
6401 @node VADS_Size
6402 @unnumberedsec VADS_Size
6403 @cindex @code{Size}, VADS compatibility
6404 @findex VADS_Size
6405 @noindent
6406 The @code{'VADS_Size} attribute is intended to make it easier to port
6407 legacy code which relies on the semantics of @code{'Size} as implemented
6408 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6409 same semantic interpretation. In particular, @code{'VADS_Size} applied
6410 to a predefined or other primitive type with no Size clause yields the
6411 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6412 typical machines). In addition @code{'VADS_Size} applied to an object
6413 gives the result that would be obtained by applying the attribute to
6414 the corresponding type.
6415
6416 @node Value_Size
6417 @unnumberedsec Value_Size
6418 @cindex @code{Size}, setting for not-first subtype
6419 @findex Value_Size
6420 @code{@var{type}'Value_Size} is the number of bits required to represent
6421 a value of the given subtype. It is the same as @code{@var{type}'Size},
6422 but, unlike @code{Size}, may be set for non-first subtypes.
6423
6424 @node Wchar_T_Size
6425 @unnumberedsec Wchar_T_Size
6426 @findex Wchar_T_Size
6427 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6428 prefix) provides the size in bits of the C @code{wchar_t} type
6429 primarily for constructing the definition of this type in
6430 package @code{Interfaces.C}.
6431
6432 @node Word_Size
6433 @unnumberedsec Word_Size
6434 @findex Word_Size
6435 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6436 prefix) provides the value @code{System.Word_Size}.
6437
6438 @c ------------------------
6439 @node Implementation Advice
6440 @chapter Implementation Advice
6441 @noindent
6442 The main text of the Ada Reference Manual describes the required
6443 behavior of all Ada compilers, and the GNAT compiler conforms to
6444 these requirements.
6445
6446 In addition, there are sections throughout the Ada Reference Manual headed
6447 by the phrase ``Implementation advice''. These sections are not normative,
6448 i.e., they do not specify requirements that all compilers must
6449 follow. Rather they provide advice on generally desirable behavior. You
6450 may wonder why they are not requirements. The most typical answer is
6451 that they describe behavior that seems generally desirable, but cannot
6452 be provided on all systems, or which may be undesirable on some systems.
6453
6454 As far as practical, GNAT follows the implementation advice sections in
6455 the Ada Reference Manual. This chapter contains a table giving the
6456 reference manual section number, paragraph number and several keywords
6457 for each advice. Each entry consists of the text of the advice followed
6458 by the GNAT interpretation of this advice. Most often, this simply says
6459 ``followed'', which means that GNAT follows the advice. However, in a
6460 number of cases, GNAT deliberately deviates from this advice, in which
6461 case the text describes what GNAT does and why.
6462
6463 @cindex Error detection
6464 @unnumberedsec 1.1.3(20): Error Detection
6465 @sp 1
6466 @cartouche
6467 If an implementation detects the use of an unsupported Specialized Needs
6468 Annex feature at run time, it should raise @code{Program_Error} if
6469 feasible.
6470 @end cartouche
6471 Not relevant. All specialized needs annex features are either supported,
6472 or diagnosed at compile time.
6473
6474 @cindex Child Units
6475 @unnumberedsec 1.1.3(31): Child Units
6476 @sp 1
6477 @cartouche
6478 If an implementation wishes to provide implementation-defined
6479 extensions to the functionality of a language-defined library unit, it
6480 should normally do so by adding children to the library unit.
6481 @end cartouche
6482 Followed.
6483
6484 @cindex Bounded errors
6485 @unnumberedsec 1.1.5(12): Bounded Errors
6486 @sp 1
6487 @cartouche
6488 If an implementation detects a bounded error or erroneous
6489 execution, it should raise @code{Program_Error}.
6490 @end cartouche
6491 Followed in all cases in which the implementation detects a bounded
6492 error or erroneous execution. Not all such situations are detected at
6493 runtime.
6494
6495 @cindex Pragmas
6496 @unnumberedsec 2.8(16): Pragmas
6497 @sp 1
6498 @cartouche
6499 Normally, implementation-defined pragmas should have no semantic effect
6500 for error-free programs; that is, if the implementation-defined pragmas
6501 are removed from a working program, the program should still be legal,
6502 and should still have the same semantics.
6503 @end cartouche
6504 The following implementation defined pragmas are exceptions to this
6505 rule:
6506
6507 @table @code
6508 @item Abort_Defer
6509 Affects semantics
6510 @item Ada_83
6511 Affects legality
6512 @item Assert
6513 Affects semantics
6514 @item CPP_Class
6515 Affects semantics
6516 @item CPP_Constructor
6517 Affects semantics
6518 @item Debug
6519 Affects semantics
6520 @item Interface_Name
6521 Affects semantics
6522 @item Machine_Attribute
6523 Affects semantics
6524 @item Unimplemented_Unit
6525 Affects legality
6526 @item Unchecked_Union
6527 Affects semantics
6528 @end table
6529
6530 @noindent
6531 In each of the above cases, it is essential to the purpose of the pragma
6532 that this advice not be followed. For details see the separate section
6533 on implementation defined pragmas.
6534
6535 @unnumberedsec 2.8(17-19): Pragmas
6536 @sp 1
6537 @cartouche
6538 Normally, an implementation should not define pragmas that can
6539 make an illegal program legal, except as follows:
6540 @end cartouche
6541 @sp 1
6542 @cartouche
6543 A pragma used to complete a declaration, such as a pragma @code{Import};
6544 @end cartouche
6545 @sp 1
6546 @cartouche
6547 A pragma used to configure the environment by adding, removing, or
6548 replacing @code{library_items}.
6549 @end cartouche
6550 See response to paragraph 16 of this same section.
6551
6552 @cindex Character Sets
6553 @cindex Alternative Character Sets
6554 @unnumberedsec 3.5.2(5): Alternative Character Sets
6555 @sp 1
6556 @cartouche
6557 If an implementation supports a mode with alternative interpretations
6558 for @code{Character} and @code{Wide_Character}, the set of graphic
6559 characters of @code{Character} should nevertheless remain a proper
6560 subset of the set of graphic characters of @code{Wide_Character}. Any
6561 character set ``localizations'' should be reflected in the results of
6562 the subprograms defined in the language-defined package
6563 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6564 an alternative interpretation of @code{Character}, the implementation should
6565 also support a corresponding change in what is a legal
6566 @code{identifier_letter}.
6567 @end cartouche
6568 Not all wide character modes follow this advice, in particular the JIS
6569 and IEC modes reflect standard usage in Japan, and in these encoding,
6570 the upper half of the Latin-1 set is not part of the wide-character
6571 subset, since the most significant bit is used for wide character
6572 encoding. However, this only applies to the external forms. Internally
6573 there is no such restriction.
6574
6575 @cindex Integer types
6576 @unnumberedsec 3.5.4(28): Integer Types
6577
6578 @sp 1
6579 @cartouche
6580 An implementation should support @code{Long_Integer} in addition to
6581 @code{Integer} if the target machine supports 32-bit (or longer)
6582 arithmetic. No other named integer subtypes are recommended for package
6583 @code{Standard}. Instead, appropriate named integer subtypes should be
6584 provided in the library package @code{Interfaces} (see B.2).
6585 @end cartouche
6586 @code{Long_Integer} is supported. Other standard integer types are supported
6587 so this advice is not fully followed. These types
6588 are supported for convenient interface to C, and so that all hardware
6589 types of the machine are easily available.
6590 @unnumberedsec 3.5.4(29): Integer Types
6591
6592 @sp 1
6593 @cartouche
6594 An implementation for a two's complement machine should support
6595 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6596 implementation should support a non-binary modules up to @code{Integer'Last}.
6597 @end cartouche
6598 Followed.
6599
6600 @cindex Enumeration values
6601 @unnumberedsec 3.5.5(8): Enumeration Values
6602 @sp 1
6603 @cartouche
6604 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6605 subtype, if the value of the operand does not correspond to the internal
6606 code for any enumeration literal of its type (perhaps due to an
6607 un-initialized variable), then the implementation should raise
6608 @code{Program_Error}. This is particularly important for enumeration
6609 types with noncontiguous internal codes specified by an
6610 enumeration_representation_clause.
6611 @end cartouche
6612 Followed.
6613
6614 @cindex Float types
6615 @unnumberedsec 3.5.7(17): Float Types
6616 @sp 1
6617 @cartouche
6618 An implementation should support @code{Long_Float} in addition to
6619 @code{Float} if the target machine supports 11 or more digits of
6620 precision. No other named floating point subtypes are recommended for
6621 package @code{Standard}. Instead, appropriate named floating point subtypes
6622 should be provided in the library package @code{Interfaces} (see B.2).
6623 @end cartouche
6624 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6625 former provides improved compatibility with other implementations
6626 supporting this type. The latter corresponds to the highest precision
6627 floating-point type supported by the hardware. On most machines, this
6628 will be the same as @code{Long_Float}, but on some machines, it will
6629 correspond to the IEEE extended form. The notable case is all ia32
6630 (x86) implementations, where @code{Long_Long_Float} corresponds to
6631 the 80-bit extended precision format supported in hardware on this
6632 processor. Note that the 128-bit format on SPARC is not supported,
6633 since this is a software rather than a hardware format.
6634
6635 @cindex Multidimensional arrays
6636 @cindex Arrays, multidimensional
6637 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6638 @sp 1
6639 @cartouche
6640 An implementation should normally represent multidimensional arrays in
6641 row-major order, consistent with the notation used for multidimensional
6642 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6643 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6644 column-major order should be used instead (see B.5, ``Interfacing with
6645 Fortran'').
6646 @end cartouche
6647 Followed.
6648
6649 @findex Duration'Small
6650 @unnumberedsec 9.6(30-31): Duration'Small
6651 @sp 1
6652 @cartouche
6653 Whenever possible in an implementation, the value of @code{Duration'Small}
6654 should be no greater than 100 microseconds.
6655 @end cartouche
6656 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6657
6658 @sp 1
6659 @cartouche
6660 The time base for @code{delay_relative_statements} should be monotonic;
6661 it need not be the same time base as used for @code{Calendar.Clock}.
6662 @end cartouche
6663 Followed.
6664
6665 @unnumberedsec 10.2.1(12): Consistent Representation
6666 @sp 1
6667 @cartouche
6668 In an implementation, a type declared in a pre-elaborated package should
6669 have the same representation in every elaboration of a given version of
6670 the package, whether the elaborations occur in distinct executions of
6671 the same program, or in executions of distinct programs or partitions
6672 that include the given version.
6673 @end cartouche
6674 Followed, except in the case of tagged types. Tagged types involve
6675 implicit pointers to a local copy of a dispatch table, and these pointers
6676 have representations which thus depend on a particular elaboration of the
6677 package. It is not easy to see how it would be possible to follow this
6678 advice without severely impacting efficiency of execution.
6679
6680 @cindex Exception information
6681 @unnumberedsec 11.4.1(19): Exception Information
6682 @sp 1
6683 @cartouche
6684 @code{Exception_Message} by default and @code{Exception_Information}
6685 should produce information useful for
6686 debugging. @code{Exception_Message} should be short, about one
6687 line. @code{Exception_Information} can be long. @code{Exception_Message}
6688 should not include the
6689 @code{Exception_Name}. @code{Exception_Information} should include both
6690 the @code{Exception_Name} and the @code{Exception_Message}.
6691 @end cartouche
6692 Followed. For each exception that doesn't have a specified
6693 @code{Exception_Message}, the compiler generates one containing the location
6694 of the raise statement. This location has the form ``file:line'', where
6695 file is the short file name (without path information) and line is the line
6696 number in the file. Note that in the case of the Zero Cost Exception
6697 mechanism, these messages become redundant with the Exception_Information that
6698 contains a full backtrace of the calling sequence, so they are disabled.
6699 To disable explicitly the generation of the source location message, use the
6700 Pragma @code{Discard_Names}.
6701
6702 @cindex Suppression of checks
6703 @cindex Checks, suppression of
6704 @unnumberedsec 11.5(28): Suppression of Checks
6705 @sp 1
6706 @cartouche
6707 The implementation should minimize the code executed for checks that
6708 have been suppressed.
6709 @end cartouche
6710 Followed.
6711
6712 @cindex Representation clauses
6713 @unnumberedsec 13.1 (21-24): Representation Clauses
6714 @sp 1
6715 @cartouche
6716 The recommended level of support for all representation items is
6717 qualified as follows:
6718 @end cartouche
6719 @sp 1
6720 @cartouche
6721 An implementation need not support representation items containing
6722 non-static expressions, except that an implementation should support a
6723 representation item for a given entity if each non-static expression in
6724 the representation item is a name that statically denotes a constant
6725 declared before the entity.
6726 @end cartouche
6727 Followed. In fact, GNAT goes beyond the recommended level of support
6728 by allowing nonstatic expressions in some representation clauses even
6729 without the need to declare constants initialized with the values of
6730 such expressions.
6731 For example:
6732
6733 @smallexample @c ada
6734 X : Integer;
6735 Y : Float;
6736 for Y'Address use X'Address;>>
6737 @end smallexample
6738
6739 @sp 1
6740 @cartouche
6741 An implementation need not support a specification for the @code{Size}
6742 for a given composite subtype, nor the size or storage place for an
6743 object (including a component) of a given composite subtype, unless the
6744 constraints on the subtype and its composite subcomponents (if any) are
6745 all static constraints.
6746 @end cartouche
6747 Followed. Size Clauses are not permitted on non-static components, as
6748 described above.
6749
6750 @sp 1
6751 @cartouche
6752 An aliased component, or a component whose type is by-reference, should
6753 always be allocated at an addressable location.
6754 @end cartouche
6755 Followed.
6756
6757 @cindex Packed types
6758 @unnumberedsec 13.2(6-8): Packed Types
6759 @sp 1
6760 @cartouche
6761 If a type is packed, then the implementation should try to minimize
6762 storage allocated to objects of the type, possibly at the expense of
6763 speed of accessing components, subject to reasonable complexity in
6764 addressing calculations.
6765 @end cartouche
6766 @sp 1
6767 @cartouche
6768 The recommended level of support pragma @code{Pack} is:
6769
6770 For a packed record type, the components should be packed as tightly as
6771 possible subject to the Sizes of the component subtypes, and subject to
6772 any @code{record_representation_clause} that applies to the type; the
6773 implementation may, but need not, reorder components or cross aligned
6774 word boundaries to improve the packing. A component whose @code{Size} is
6775 greater than the word size may be allocated an integral number of words.
6776 @end cartouche
6777 Followed. Tight packing of arrays is supported for all component sizes
6778 up to 64-bits. If the array component size is 1 (that is to say, if
6779 the component is a boolean type or an enumeration type with two values)
6780 then values of the type are implicitly initialized to zero. This
6781 happens both for objects of the packed type, and for objects that have a
6782 subcomponent of the packed type.
6783
6784 @sp 1
6785 @cartouche
6786 An implementation should support Address clauses for imported
6787 subprograms.
6788 @end cartouche
6789 Followed.
6790 @cindex @code{Address} clauses
6791 @unnumberedsec 13.3(14-19): Address Clauses
6792
6793 @sp 1
6794 @cartouche
6795 For an array @var{X}, @code{@var{X}'Address} should point at the first
6796 component of the array, and not at the array bounds.
6797 @end cartouche
6798 Followed.
6799
6800 @sp 1
6801 @cartouche
6802 The recommended level of support for the @code{Address} attribute is:
6803
6804 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6805 object that is aliased or of a by-reference type, or is an entity whose
6806 @code{Address} has been specified.
6807 @end cartouche
6808 Followed. A valid address will be produced even if none of those
6809 conditions have been met. If necessary, the object is forced into
6810 memory to ensure the address is valid.
6811
6812 @sp 1
6813 @cartouche
6814 An implementation should support @code{Address} clauses for imported
6815 subprograms.
6816 @end cartouche
6817 Followed.
6818
6819 @sp 1
6820 @cartouche
6821 Objects (including subcomponents) that are aliased or of a by-reference
6822 type should be allocated on storage element boundaries.
6823 @end cartouche
6824 Followed.
6825
6826 @sp 1
6827 @cartouche
6828 If the @code{Address} of an object is specified, or it is imported or exported,
6829 then the implementation should not perform optimizations based on
6830 assumptions of no aliases.
6831 @end cartouche
6832 Followed.
6833
6834 @cindex @code{Alignment} clauses
6835 @unnumberedsec 13.3(29-35): Alignment Clauses
6836 @sp 1
6837 @cartouche
6838 The recommended level of support for the @code{Alignment} attribute for
6839 subtypes is:
6840
6841 An implementation should support specified Alignments that are factors
6842 and multiples of the number of storage elements per word, subject to the
6843 following:
6844 @end cartouche
6845 Followed.
6846
6847 @sp 1
6848 @cartouche
6849 An implementation need not support specified @code{Alignment}s for
6850 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6851 loaded and stored by available machine instructions.
6852 @end cartouche
6853 Followed.
6854
6855 @sp 1
6856 @cartouche
6857 An implementation need not support specified @code{Alignment}s that are
6858 greater than the maximum @code{Alignment} the implementation ever returns by
6859 default.
6860 @end cartouche
6861 Followed.
6862
6863 @sp 1
6864 @cartouche
6865 The recommended level of support for the @code{Alignment} attribute for
6866 objects is:
6867
6868 Same as above, for subtypes, but in addition:
6869 @end cartouche
6870 Followed.
6871
6872 @sp 1
6873 @cartouche
6874 For stand-alone library-level objects of statically constrained
6875 subtypes, the implementation should support all @code{Alignment}s
6876 supported by the target linker. For example, page alignment is likely to
6877 be supported for such objects, but not for subtypes.
6878 @end cartouche
6879 Followed.
6880
6881 @cindex @code{Size} clauses
6882 @unnumberedsec 13.3(42-43): Size Clauses
6883 @sp 1
6884 @cartouche
6885 The recommended level of support for the @code{Size} attribute of
6886 objects is:
6887
6888 A @code{Size} clause should be supported for an object if the specified
6889 @code{Size} is at least as large as its subtype's @code{Size}, and
6890 corresponds to a size in storage elements that is a multiple of the
6891 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6892 @end cartouche
6893 Followed.
6894
6895 @unnumberedsec 13.3(50-56): Size Clauses
6896 @sp 1
6897 @cartouche
6898 If the @code{Size} of a subtype is specified, and allows for efficient
6899 independent addressability (see 9.10) on the target architecture, then
6900 the @code{Size} of the following objects of the subtype should equal the
6901 @code{Size} of the subtype:
6902
6903 Aliased objects (including components).
6904 @end cartouche
6905 Followed.
6906
6907 @sp 1
6908 @cartouche
6909 @code{Size} clause on a composite subtype should not affect the
6910 internal layout of components.
6911 @end cartouche
6912 Followed. But note that this can be overridden by use of the implementation
6913 pragma Implicit_Packing in the case of packed arrays.
6914
6915 @sp 1
6916 @cartouche
6917 The recommended level of support for the @code{Size} attribute of subtypes is:
6918 @end cartouche
6919 @sp 1
6920 @cartouche
6921 The @code{Size} (if not specified) of a static discrete or fixed point
6922 subtype should be the number of bits needed to represent each value
6923 belonging to the subtype using an unbiased representation, leaving space
6924 for a sign bit only if the subtype contains negative values. If such a
6925 subtype is a first subtype, then an implementation should support a
6926 specified @code{Size} for it that reflects this representation.
6927 @end cartouche
6928 Followed.
6929
6930 @sp 1
6931 @cartouche
6932 For a subtype implemented with levels of indirection, the @code{Size}
6933 should include the size of the pointers, but not the size of what they
6934 point at.
6935 @end cartouche
6936 Followed.
6937
6938 @cindex @code{Component_Size} clauses
6939 @unnumberedsec 13.3(71-73): Component Size Clauses
6940 @sp 1
6941 @cartouche
6942 The recommended level of support for the @code{Component_Size}
6943 attribute is:
6944 @end cartouche
6945 @sp 1
6946 @cartouche
6947 An implementation need not support specified @code{Component_Sizes} that are
6948 less than the @code{Size} of the component subtype.
6949 @end cartouche
6950 Followed.
6951
6952 @sp 1
6953 @cartouche
6954 An implementation should support specified @code{Component_Size}s that
6955 are factors and multiples of the word size. For such
6956 @code{Component_Size}s, the array should contain no gaps between
6957 components. For other @code{Component_Size}s (if supported), the array
6958 should contain no gaps between components when packing is also
6959 specified; the implementation should forbid this combination in cases
6960 where it cannot support a no-gaps representation.
6961 @end cartouche
6962 Followed.
6963
6964 @cindex Enumeration representation clauses
6965 @cindex Representation clauses, enumeration
6966 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6967 @sp 1
6968 @cartouche
6969 The recommended level of support for enumeration representation clauses
6970 is:
6971
6972 An implementation need not support enumeration representation clauses
6973 for boolean types, but should at minimum support the internal codes in
6974 the range @code{System.Min_Int.System.Max_Int}.
6975 @end cartouche
6976 Followed.
6977
6978 @cindex Record representation clauses
6979 @cindex Representation clauses, records
6980 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6981 @sp 1
6982 @cartouche
6983 The recommended level of support for
6984 @*@code{record_representation_clauses} is:
6985
6986 An implementation should support storage places that can be extracted
6987 with a load, mask, shift sequence of machine code, and set with a load,
6988 shift, mask, store sequence, given the available machine instructions
6989 and run-time model.
6990 @end cartouche
6991 Followed.
6992
6993 @sp 1
6994 @cartouche
6995 A storage place should be supported if its size is equal to the
6996 @code{Size} of the component subtype, and it starts and ends on a
6997 boundary that obeys the @code{Alignment} of the component subtype.
6998 @end cartouche
6999 Followed.
7000
7001 @sp 1
7002 @cartouche
7003 If the default bit ordering applies to the declaration of a given type,
7004 then for a component whose subtype's @code{Size} is less than the word
7005 size, any storage place that does not cross an aligned word boundary
7006 should be supported.
7007 @end cartouche
7008 Followed.
7009
7010 @sp 1
7011 @cartouche
7012 An implementation may reserve a storage place for the tag field of a
7013 tagged type, and disallow other components from overlapping that place.
7014 @end cartouche
7015 Followed. The storage place for the tag field is the beginning of the tagged
7016 record, and its size is Address'Size. GNAT will reject an explicit component
7017 clause for the tag field.
7018
7019 @sp 1
7020 @cartouche
7021 An implementation need not support a @code{component_clause} for a
7022 component of an extension part if the storage place is not after the
7023 storage places of all components of the parent type, whether or not
7024 those storage places had been specified.
7025 @end cartouche
7026 Followed. The above advice on record representation clauses is followed,
7027 and all mentioned features are implemented.
7028
7029 @cindex Storage place attributes
7030 @unnumberedsec 13.5.2(5): Storage Place Attributes
7031 @sp 1
7032 @cartouche
7033 If a component is represented using some form of pointer (such as an
7034 offset) to the actual data of the component, and this data is contiguous
7035 with the rest of the object, then the storage place attributes should
7036 reflect the place of the actual data, not the pointer. If a component is
7037 allocated discontinuously from the rest of the object, then a warning
7038 should be generated upon reference to one of its storage place
7039 attributes.
7040 @end cartouche
7041 Followed. There are no such components in GNAT@.
7042
7043 @cindex Bit ordering
7044 @unnumberedsec 13.5.3(7-8): Bit Ordering
7045 @sp 1
7046 @cartouche
7047 The recommended level of support for the non-default bit ordering is:
7048 @end cartouche
7049 @sp 1
7050 @cartouche
7051 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7052 should support the non-default bit ordering in addition to the default
7053 bit ordering.
7054 @end cartouche
7055 Followed. Word size does not equal storage size in this implementation.
7056 Thus non-default bit ordering is not supported.
7057
7058 @cindex @code{Address}, as private type
7059 @unnumberedsec 13.7(37): Address as Private
7060 @sp 1
7061 @cartouche
7062 @code{Address} should be of a private type.
7063 @end cartouche
7064 Followed.
7065
7066 @cindex Operations, on @code{Address}
7067 @cindex @code{Address}, operations of
7068 @unnumberedsec 13.7.1(16): Address Operations
7069 @sp 1
7070 @cartouche
7071 Operations in @code{System} and its children should reflect the target
7072 environment semantics as closely as is reasonable. For example, on most
7073 machines, it makes sense for address arithmetic to ``wrap around''.
7074 Operations that do not make sense should raise @code{Program_Error}.
7075 @end cartouche
7076 Followed. Address arithmetic is modular arithmetic that wraps around. No
7077 operation raises @code{Program_Error}, since all operations make sense.
7078
7079 @cindex Unchecked conversion
7080 @unnumberedsec 13.9(14-17): Unchecked Conversion
7081 @sp 1
7082 @cartouche
7083 The @code{Size} of an array object should not include its bounds; hence,
7084 the bounds should not be part of the converted data.
7085 @end cartouche
7086 Followed.
7087
7088 @sp 1
7089 @cartouche
7090 The implementation should not generate unnecessary run-time checks to
7091 ensure that the representation of @var{S} is a representation of the
7092 target type. It should take advantage of the permission to return by
7093 reference when possible. Restrictions on unchecked conversions should be
7094 avoided unless required by the target environment.
7095 @end cartouche
7096 Followed. There are no restrictions on unchecked conversion. A warning is
7097 generated if the source and target types do not have the same size since
7098 the semantics in this case may be target dependent.
7099
7100 @sp 1
7101 @cartouche
7102 The recommended level of support for unchecked conversions is:
7103 @end cartouche
7104 @sp 1
7105 @cartouche
7106 Unchecked conversions should be supported and should be reversible in
7107 the cases where this clause defines the result. To enable meaningful use
7108 of unchecked conversion, a contiguous representation should be used for
7109 elementary subtypes, for statically constrained array subtypes whose
7110 component subtype is one of the subtypes described in this paragraph,
7111 and for record subtypes without discriminants whose component subtypes
7112 are described in this paragraph.
7113 @end cartouche
7114 Followed.
7115
7116 @cindex Heap usage, implicit
7117 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7118 @sp 1
7119 @cartouche
7120 An implementation should document any cases in which it dynamically
7121 allocates heap storage for a purpose other than the evaluation of an
7122 allocator.
7123 @end cartouche
7124 Followed, the only other points at which heap storage is dynamically
7125 allocated are as follows:
7126
7127 @itemize @bullet
7128 @item
7129 At initial elaboration time, to allocate dynamically sized global
7130 objects.
7131
7132 @item
7133 To allocate space for a task when a task is created.
7134
7135 @item
7136 To extend the secondary stack dynamically when needed. The secondary
7137 stack is used for returning variable length results.
7138 @end itemize
7139
7140 @sp 1
7141 @cartouche
7142 A default (implementation-provided) storage pool for an
7143 access-to-constant type should not have overhead to support deallocation of
7144 individual objects.
7145 @end cartouche
7146 Followed.
7147
7148 @sp 1
7149 @cartouche
7150 A storage pool for an anonymous access type should be created at the
7151 point of an allocator for the type, and be reclaimed when the designated
7152 object becomes inaccessible.
7153 @end cartouche
7154 Followed.
7155
7156 @cindex Unchecked deallocation
7157 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7158 @sp 1
7159 @cartouche
7160 For a standard storage pool, @code{Free} should actually reclaim the
7161 storage.
7162 @end cartouche
7163 Followed.
7164
7165 @cindex Stream oriented attributes
7166 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7167 @sp 1
7168 @cartouche
7169 If a stream element is the same size as a storage element, then the
7170 normal in-memory representation should be used by @code{Read} and
7171 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7172 should use the smallest number of stream elements needed to represent
7173 all values in the base range of the scalar type.
7174 @end cartouche
7175
7176 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7177 which specifies using the size of the first subtype.
7178 However, such an implementation is based on direct binary
7179 representations and is therefore target- and endianness-dependent.
7180 To address this issue, GNAT also supplies an alternate implementation
7181 of the stream attributes @code{Read} and @code{Write},
7182 which uses the target-independent XDR standard representation
7183 for scalar types.
7184 @cindex XDR representation
7185 @cindex @code{Read} attribute
7186 @cindex @code{Write} attribute
7187 @cindex Stream oriented attributes
7188 The XDR implementation is provided as an alternative body of the
7189 @code{System.Stream_Attributes} package, in the file
7190 @file{s-stratt-xdr.adb} in the GNAT library.
7191 There is no @file{s-stratt-xdr.ads} file.
7192 In order to install the XDR implementation, do the following:
7193 @enumerate
7194 @item Replace the default implementation of the
7195 @code{System.Stream_Attributes} package with the XDR implementation.
7196 For example on a Unix platform issue the commands:
7197 @smallexample
7198 $ mv s-stratt.adb s-stratt-default.adb
7199 $ mv s-stratt-xdr.adb s-stratt.adb
7200 @end smallexample
7201
7202 @item
7203 Rebuild the GNAT run-time library as documented in
7204 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7205 @end enumerate
7206
7207 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7208 @sp 1
7209 @cartouche
7210 If an implementation provides additional named predefined integer types,
7211 then the names should end with @samp{Integer} as in
7212 @samp{Long_Integer}. If an implementation provides additional named
7213 predefined floating point types, then the names should end with
7214 @samp{Float} as in @samp{Long_Float}.
7215 @end cartouche
7216 Followed.
7217
7218 @findex Ada.Characters.Handling
7219 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7220 @sp 1
7221 @cartouche
7222 If an implementation provides a localized definition of @code{Character}
7223 or @code{Wide_Character}, then the effects of the subprograms in
7224 @code{Characters.Handling} should reflect the localizations. See also
7225 3.5.2.
7226 @end cartouche
7227 Followed. GNAT provides no such localized definitions.
7228
7229 @cindex Bounded-length strings
7230 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7231 @sp 1
7232 @cartouche
7233 Bounded string objects should not be implemented by implicit pointers
7234 and dynamic allocation.
7235 @end cartouche
7236 Followed. No implicit pointers or dynamic allocation are used.
7237
7238 @cindex Random number generation
7239 @unnumberedsec A.5.2(46-47): Random Number Generation
7240 @sp 1
7241 @cartouche
7242 Any storage associated with an object of type @code{Generator} should be
7243 reclaimed on exit from the scope of the object.
7244 @end cartouche
7245 Followed.
7246
7247 @sp 1
7248 @cartouche
7249 If the generator period is sufficiently long in relation to the number
7250 of distinct initiator values, then each possible value of
7251 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7252 random numbers that does not, in a practical sense, overlap the sequence
7253 initiated by any other value. If this is not possible, then the mapping
7254 between initiator values and generator states should be a rapidly
7255 varying function of the initiator value.
7256 @end cartouche
7257 Followed. The generator period is sufficiently long for the first
7258 condition here to hold true.
7259
7260 @findex Get_Immediate
7261 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7262 @sp 1
7263 @cartouche
7264 The @code{Get_Immediate} procedures should be implemented with
7265 unbuffered input. For a device such as a keyboard, input should be
7266 @dfn{available} if a key has already been typed, whereas for a disk
7267 file, input should always be available except at end of file. For a file
7268 associated with a keyboard-like device, any line-editing features of the
7269 underlying operating system should be disabled during the execution of
7270 @code{Get_Immediate}.
7271 @end cartouche
7272 Followed on all targets except VxWorks. For VxWorks, there is no way to
7273 provide this functionality that does not result in the input buffer being
7274 flushed before the @code{Get_Immediate} call. A special unit
7275 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7276 this functionality.
7277
7278 @findex Export
7279 @unnumberedsec B.1(39-41): Pragma @code{Export}
7280 @sp 1
7281 @cartouche
7282 If an implementation supports pragma @code{Export} to a given language,
7283 then it should also allow the main subprogram to be written in that
7284 language. It should support some mechanism for invoking the elaboration
7285 of the Ada library units included in the system, and for invoking the
7286 finalization of the environment task. On typical systems, the
7287 recommended mechanism is to provide two subprograms whose link names are
7288 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7289 elaboration code for library units. @code{adafinal} should contain the
7290 finalization code. These subprograms should have no effect the second
7291 and subsequent time they are called.
7292 @end cartouche
7293 Followed.
7294
7295 @sp 1
7296 @cartouche
7297 Automatic elaboration of pre-elaborated packages should be
7298 provided when pragma @code{Export} is supported.
7299 @end cartouche
7300 Followed when the main program is in Ada. If the main program is in a
7301 foreign language, then
7302 @code{adainit} must be called to elaborate pre-elaborated
7303 packages.
7304
7305 @sp 1
7306 @cartouche
7307 For each supported convention @var{L} other than @code{Intrinsic}, an
7308 implementation should support @code{Import} and @code{Export} pragmas
7309 for objects of @var{L}-compatible types and for subprograms, and pragma
7310 @code{Convention} for @var{L}-eligible types and for subprograms,
7311 presuming the other language has corresponding features. Pragma
7312 @code{Convention} need not be supported for scalar types.
7313 @end cartouche
7314 Followed.
7315
7316 @cindex Package @code{Interfaces}
7317 @findex Interfaces
7318 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7319 @sp 1
7320 @cartouche
7321 For each implementation-defined convention identifier, there should be a
7322 child package of package Interfaces with the corresponding name. This
7323 package should contain any declarations that would be useful for
7324 interfacing to the language (implementation) represented by the
7325 convention. Any declarations useful for interfacing to any language on
7326 the given hardware architecture should be provided directly in
7327 @code{Interfaces}.
7328 @end cartouche
7329 Followed. An additional package not defined
7330 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7331 for interfacing to C++.
7332
7333 @sp 1
7334 @cartouche
7335 An implementation supporting an interface to C, COBOL, or Fortran should
7336 provide the corresponding package or packages described in the following
7337 clauses.
7338 @end cartouche
7339 Followed. GNAT provides all the packages described in this section.
7340
7341 @cindex C, interfacing with
7342 @unnumberedsec B.3(63-71): Interfacing with C
7343 @sp 1
7344 @cartouche
7345 An implementation should support the following interface correspondences
7346 between Ada and C@.
7347 @end cartouche
7348 Followed.
7349
7350 @sp 1
7351 @cartouche
7352 An Ada procedure corresponds to a void-returning C function.
7353 @end cartouche
7354 Followed.
7355
7356 @sp 1
7357 @cartouche
7358 An Ada function corresponds to a non-void C function.
7359 @end cartouche
7360 Followed.
7361
7362 @sp 1
7363 @cartouche
7364 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7365 function.
7366 @end cartouche
7367 Followed.
7368
7369 @sp 1
7370 @cartouche
7371 An Ada @code{in} parameter of an access-to-object type with designated
7372 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7373 where @var{t} is the C type corresponding to the Ada type @var{T}.
7374 @end cartouche
7375 Followed.
7376
7377 @sp 1
7378 @cartouche
7379 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7380 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7381 argument to a C function, where @var{t} is the C type corresponding to
7382 the Ada type @var{T}. In the case of an elementary @code{out} or
7383 @code{in out} parameter, a pointer to a temporary copy is used to
7384 preserve by-copy semantics.
7385 @end cartouche
7386 Followed.
7387
7388 @sp 1
7389 @cartouche
7390 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7391 @code{@var{t}*} argument to a C function, where @var{t} is the C
7392 structure corresponding to the Ada type @var{T}.
7393 @end cartouche
7394 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7395 pragma, or Convention, or by explicitly specifying the mechanism for a given
7396 call using an extended import or export pragma.
7397
7398 @sp 1
7399 @cartouche
7400 An Ada parameter of an array type with component type @var{T}, of any
7401 mode, is passed as a @code{@var{t}*} argument to a C function, where
7402 @var{t} is the C type corresponding to the Ada type @var{T}.
7403 @end cartouche
7404 Followed.
7405
7406 @sp 1
7407 @cartouche
7408 An Ada parameter of an access-to-subprogram type is passed as a pointer
7409 to a C function whose prototype corresponds to the designated
7410 subprogram's specification.
7411 @end cartouche
7412 Followed.
7413
7414 @cindex COBOL, interfacing with
7415 @unnumberedsec B.4(95-98): Interfacing with COBOL
7416 @sp 1
7417 @cartouche
7418 An Ada implementation should support the following interface
7419 correspondences between Ada and COBOL@.
7420 @end cartouche
7421 Followed.
7422
7423 @sp 1
7424 @cartouche
7425 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7426 the COBOL type corresponding to @var{T}.
7427 @end cartouche
7428 Followed.
7429
7430 @sp 1
7431 @cartouche
7432 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7433 the corresponding COBOL type.
7434 @end cartouche
7435 Followed.
7436
7437 @sp 1
7438 @cartouche
7439 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7440 COBOL type corresponding to the Ada parameter type; for scalars, a local
7441 copy is used if necessary to ensure by-copy semantics.
7442 @end cartouche
7443 Followed.
7444
7445 @cindex Fortran, interfacing with
7446 @unnumberedsec B.5(22-26): Interfacing with Fortran
7447 @sp 1
7448 @cartouche
7449 An Ada implementation should support the following interface
7450 correspondences between Ada and Fortran:
7451 @end cartouche
7452 Followed.
7453
7454 @sp 1
7455 @cartouche
7456 An Ada procedure corresponds to a Fortran subroutine.
7457 @end cartouche
7458 Followed.
7459
7460 @sp 1
7461 @cartouche
7462 An Ada function corresponds to a Fortran function.
7463 @end cartouche
7464 Followed.
7465
7466 @sp 1
7467 @cartouche
7468 An Ada parameter of an elementary, array, or record type @var{T} is
7469 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7470 the Fortran type corresponding to the Ada type @var{T}, and where the
7471 INTENT attribute of the corresponding dummy argument matches the Ada
7472 formal parameter mode; the Fortran implementation's parameter passing
7473 conventions are used. For elementary types, a local copy is used if
7474 necessary to ensure by-copy semantics.
7475 @end cartouche
7476 Followed.
7477
7478 @sp 1
7479 @cartouche
7480 An Ada parameter of an access-to-subprogram type is passed as a
7481 reference to a Fortran procedure whose interface corresponds to the
7482 designated subprogram's specification.
7483 @end cartouche
7484 Followed.
7485
7486 @cindex Machine operations
7487 @unnumberedsec C.1(3-5): Access to Machine Operations
7488 @sp 1
7489 @cartouche
7490 The machine code or intrinsic support should allow access to all
7491 operations normally available to assembly language programmers for the
7492 target environment, including privileged instructions, if any.
7493 @end cartouche
7494 Followed.
7495
7496 @sp 1
7497 @cartouche
7498 The interfacing pragmas (see Annex B) should support interface to
7499 assembler; the default assembler should be associated with the
7500 convention identifier @code{Assembler}.
7501 @end cartouche
7502 Followed.
7503
7504 @sp 1
7505 @cartouche
7506 If an entity is exported to assembly language, then the implementation
7507 should allocate it at an addressable location, and should ensure that it
7508 is retained by the linking process, even if not otherwise referenced
7509 from the Ada code. The implementation should assume that any call to a
7510 machine code or assembler subprogram is allowed to read or update every
7511 object that is specified as exported.
7512 @end cartouche
7513 Followed.
7514
7515 @unnumberedsec C.1(10-16): Access to Machine Operations
7516 @sp 1
7517 @cartouche
7518 The implementation should ensure that little or no overhead is
7519 associated with calling intrinsic and machine-code subprograms.
7520 @end cartouche
7521 Followed for both intrinsics and machine-code subprograms.
7522
7523 @sp 1
7524 @cartouche
7525 It is recommended that intrinsic subprograms be provided for convenient
7526 access to any machine operations that provide special capabilities or
7527 efficiency and that are not otherwise available through the language
7528 constructs.
7529 @end cartouche
7530 Followed. A full set of machine operation intrinsic subprograms is provided.
7531
7532 @sp 1
7533 @cartouche
7534 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7535 swap, decrement and test, enqueue/dequeue.
7536 @end cartouche
7537 Followed on any target supporting such operations.
7538
7539 @sp 1
7540 @cartouche
7541 Standard numeric functions---e.g.@:, sin, log.
7542 @end cartouche
7543 Followed on any target supporting such operations.
7544
7545 @sp 1
7546 @cartouche
7547 String manipulation operations---e.g.@:, translate and test.
7548 @end cartouche
7549 Followed on any target supporting such operations.
7550
7551 @sp 1
7552 @cartouche
7553 Vector operations---e.g.@:, compare vector against thresholds.
7554 @end cartouche
7555 Followed on any target supporting such operations.
7556
7557 @sp 1
7558 @cartouche
7559 Direct operations on I/O ports.
7560 @end cartouche
7561 Followed on any target supporting such operations.
7562
7563 @cindex Interrupt support
7564 @unnumberedsec C.3(28): Interrupt Support
7565 @sp 1
7566 @cartouche
7567 If the @code{Ceiling_Locking} policy is not in effect, the
7568 implementation should provide means for the application to specify which
7569 interrupts are to be blocked during protected actions, if the underlying
7570 system allows for a finer-grain control of interrupt blocking.
7571 @end cartouche
7572 Followed. The underlying system does not allow for finer-grain control
7573 of interrupt blocking.
7574
7575 @cindex Protected procedure handlers
7576 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7577 @sp 1
7578 @cartouche
7579 Whenever possible, the implementation should allow interrupt handlers to
7580 be called directly by the hardware.
7581 @end cartouche
7582 @c SGI info:
7583 @ignore
7584 This is never possible under IRIX, so this is followed by default.
7585 @end ignore
7586 Followed on any target where the underlying operating system permits
7587 such direct calls.
7588
7589 @sp 1
7590 @cartouche
7591 Whenever practical, violations of any
7592 implementation-defined restrictions should be detected before run time.
7593 @end cartouche
7594 Followed. Compile time warnings are given when possible.
7595
7596 @cindex Package @code{Interrupts}
7597 @findex Interrupts
7598 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7599
7600 @sp 1
7601 @cartouche
7602 If implementation-defined forms of interrupt handler procedures are
7603 supported, such as protected procedures with parameters, then for each
7604 such form of a handler, a type analogous to @code{Parameterless_Handler}
7605 should be specified in a child package of @code{Interrupts}, with the
7606 same operations as in the predefined package Interrupts.
7607 @end cartouche
7608 Followed.
7609
7610 @cindex Pre-elaboration requirements
7611 @unnumberedsec C.4(14): Pre-elaboration Requirements
7612 @sp 1
7613 @cartouche
7614 It is recommended that pre-elaborated packages be implemented in such a
7615 way that there should be little or no code executed at run time for the
7616 elaboration of entities not already covered by the Implementation
7617 Requirements.
7618 @end cartouche
7619 Followed. Executable code is generated in some cases, e.g.@: loops
7620 to initialize large arrays.
7621
7622 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7623
7624 @sp 1
7625 @cartouche
7626 If the pragma applies to an entity, then the implementation should
7627 reduce the amount of storage used for storing names associated with that
7628 entity.
7629 @end cartouche
7630 Followed.
7631
7632 @cindex Package @code{Task_Attributes}
7633 @findex Task_Attributes
7634 @unnumberedsec C.7.2(30): The Package Task_Attributes
7635 @sp 1
7636 @cartouche
7637 Some implementations are targeted to domains in which memory use at run
7638 time must be completely deterministic. For such implementations, it is
7639 recommended that the storage for task attributes will be pre-allocated
7640 statically and not from the heap. This can be accomplished by either
7641 placing restrictions on the number and the size of the task's
7642 attributes, or by using the pre-allocated storage for the first @var{N}
7643 attribute objects, and the heap for the others. In the latter case,
7644 @var{N} should be documented.
7645 @end cartouche
7646 Not followed. This implementation is not targeted to such a domain.
7647
7648 @cindex Locking Policies
7649 @unnumberedsec D.3(17): Locking Policies
7650
7651 @sp 1
7652 @cartouche
7653 The implementation should use names that end with @samp{_Locking} for
7654 locking policies defined by the implementation.
7655 @end cartouche
7656 Followed. A single implementation-defined locking policy is defined,
7657 whose name (@code{Inheritance_Locking}) follows this suggestion.
7658
7659 @cindex Entry queuing policies
7660 @unnumberedsec D.4(16): Entry Queuing Policies
7661 @sp 1
7662 @cartouche
7663 Names that end with @samp{_Queuing} should be used
7664 for all implementation-defined queuing policies.
7665 @end cartouche
7666 Followed. No such implementation-defined queuing policies exist.
7667
7668 @cindex Preemptive abort
7669 @unnumberedsec D.6(9-10): Preemptive Abort
7670 @sp 1
7671 @cartouche
7672 Even though the @code{abort_statement} is included in the list of
7673 potentially blocking operations (see 9.5.1), it is recommended that this
7674 statement be implemented in a way that never requires the task executing
7675 the @code{abort_statement} to block.
7676 @end cartouche
7677 Followed.
7678
7679 @sp 1
7680 @cartouche
7681 On a multi-processor, the delay associated with aborting a task on
7682 another processor should be bounded; the implementation should use
7683 periodic polling, if necessary, to achieve this.
7684 @end cartouche
7685 Followed.
7686
7687 @cindex Tasking restrictions
7688 @unnumberedsec D.7(21): Tasking Restrictions
7689 @sp 1
7690 @cartouche
7691 When feasible, the implementation should take advantage of the specified
7692 restrictions to produce a more efficient implementation.
7693 @end cartouche
7694 GNAT currently takes advantage of these restrictions by providing an optimized
7695 run time when the Ravenscar profile and the GNAT restricted run time set
7696 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7697 pragma @code{Profile (Restricted)} for more details.
7698
7699 @cindex Time, monotonic
7700 @unnumberedsec D.8(47-49): Monotonic Time
7701 @sp 1
7702 @cartouche
7703 When appropriate, implementations should provide configuration
7704 mechanisms to change the value of @code{Tick}.
7705 @end cartouche
7706 Such configuration mechanisms are not appropriate to this implementation
7707 and are thus not supported.
7708
7709 @sp 1
7710 @cartouche
7711 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7712 be implemented as transformations of the same time base.
7713 @end cartouche
7714 Followed.
7715
7716 @sp 1
7717 @cartouche
7718 It is recommended that the @dfn{best} time base which exists in
7719 the underlying system be available to the application through
7720 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7721 @end cartouche
7722 Followed.
7723
7724 @cindex Partition communication subsystem
7725 @cindex PCS
7726 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7727 @sp 1
7728 @cartouche
7729 Whenever possible, the PCS on the called partition should allow for
7730 multiple tasks to call the RPC-receiver with different messages and
7731 should allow them to block until the corresponding subprogram body
7732 returns.
7733 @end cartouche
7734 Followed by GLADE, a separately supplied PCS that can be used with
7735 GNAT.
7736
7737 @sp 1
7738 @cartouche
7739 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7740 should raise @code{Storage_Error} if it runs out of space trying to
7741 write the @code{Item} into the stream.
7742 @end cartouche
7743 Followed by GLADE, a separately supplied PCS that can be used with
7744 GNAT@.
7745
7746 @cindex COBOL support
7747 @unnumberedsec F(7): COBOL Support
7748 @sp 1
7749 @cartouche
7750 If COBOL (respectively, C) is widely supported in the target
7751 environment, implementations supporting the Information Systems Annex
7752 should provide the child package @code{Interfaces.COBOL} (respectively,
7753 @code{Interfaces.C}) specified in Annex B and should support a
7754 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7755 pragmas (see Annex B), thus allowing Ada programs to interface with
7756 programs written in that language.
7757 @end cartouche
7758 Followed.
7759
7760 @cindex Decimal radix support
7761 @unnumberedsec F.1(2): Decimal Radix Support
7762 @sp 1
7763 @cartouche
7764 Packed decimal should be used as the internal representation for objects
7765 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7766 @end cartouche
7767 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7768 representations.
7769
7770 @cindex Numerics
7771 @unnumberedsec G: Numerics
7772 @sp 2
7773 @cartouche
7774 If Fortran (respectively, C) is widely supported in the target
7775 environment, implementations supporting the Numerics Annex
7776 should provide the child package @code{Interfaces.Fortran} (respectively,
7777 @code{Interfaces.C}) specified in Annex B and should support a
7778 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7779 pragmas (see Annex B), thus allowing Ada programs to interface with
7780 programs written in that language.
7781 @end cartouche
7782 Followed.
7783
7784 @cindex Complex types
7785 @unnumberedsec G.1.1(56-58): Complex Types
7786 @sp 2
7787 @cartouche
7788 Because the usual mathematical meaning of multiplication of a complex
7789 operand and a real operand is that of the scaling of both components of
7790 the former by the latter, an implementation should not perform this
7791 operation by first promoting the real operand to complex type and then
7792 performing a full complex multiplication. In systems that, in the
7793 future, support an Ada binding to IEC 559:1989, the latter technique
7794 will not generate the required result when one of the components of the
7795 complex operand is infinite. (Explicit multiplication of the infinite
7796 component by the zero component obtained during promotion yields a NaN
7797 that propagates into the final result.) Analogous advice applies in the
7798 case of multiplication of a complex operand and a pure-imaginary
7799 operand, and in the case of division of a complex operand by a real or
7800 pure-imaginary operand.
7801 @end cartouche
7802 Not followed.
7803
7804 @sp 1
7805 @cartouche
7806 Similarly, because the usual mathematical meaning of addition of a
7807 complex operand and a real operand is that the imaginary operand remains
7808 unchanged, an implementation should not perform this operation by first
7809 promoting the real operand to complex type and then performing a full
7810 complex addition. In implementations in which the @code{Signed_Zeros}
7811 attribute of the component type is @code{True} (and which therefore
7812 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7813 predefined arithmetic operations), the latter technique will not
7814 generate the required result when the imaginary component of the complex
7815 operand is a negatively signed zero. (Explicit addition of the negative
7816 zero to the zero obtained during promotion yields a positive zero.)
7817 Analogous advice applies in the case of addition of a complex operand
7818 and a pure-imaginary operand, and in the case of subtraction of a
7819 complex operand and a real or pure-imaginary operand.
7820 @end cartouche
7821 Not followed.
7822
7823 @sp 1
7824 @cartouche
7825 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7826 attempt to provide a rational treatment of the signs of zero results and
7827 result components. As one example, the result of the @code{Argument}
7828 function should have the sign of the imaginary component of the
7829 parameter @code{X} when the point represented by that parameter lies on
7830 the positive real axis; as another, the sign of the imaginary component
7831 of the @code{Compose_From_Polar} function should be the same as
7832 (respectively, the opposite of) that of the @code{Argument} parameter when that
7833 parameter has a value of zero and the @code{Modulus} parameter has a
7834 nonnegative (respectively, negative) value.
7835 @end cartouche
7836 Followed.
7837
7838 @cindex Complex elementary functions
7839 @unnumberedsec G.1.2(49): Complex Elementary Functions
7840 @sp 1
7841 @cartouche
7842 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7843 @code{True} should attempt to provide a rational treatment of the signs
7844 of zero results and result components. For example, many of the complex
7845 elementary functions have components that are odd functions of one of
7846 the parameter components; in these cases, the result component should
7847 have the sign of the parameter component at the origin. Other complex
7848 elementary functions have zero components whose sign is opposite that of
7849 a parameter component at the origin, or is always positive or always
7850 negative.
7851 @end cartouche
7852 Followed.
7853
7854 @cindex Accuracy requirements
7855 @unnumberedsec G.2.4(19): Accuracy Requirements
7856 @sp 1
7857 @cartouche
7858 The versions of the forward trigonometric functions without a
7859 @code{Cycle} parameter should not be implemented by calling the
7860 corresponding version with a @code{Cycle} parameter of
7861 @code{2.0*Numerics.Pi}, since this will not provide the required
7862 accuracy in some portions of the domain. For the same reason, the
7863 version of @code{Log} without a @code{Base} parameter should not be
7864 implemented by calling the corresponding version with a @code{Base}
7865 parameter of @code{Numerics.e}.
7866 @end cartouche
7867 Followed.
7868
7869 @cindex Complex arithmetic accuracy
7870 @cindex Accuracy, complex arithmetic
7871 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7872
7873 @sp 1
7874 @cartouche
7875 The version of the @code{Compose_From_Polar} function without a
7876 @code{Cycle} parameter should not be implemented by calling the
7877 corresponding version with a @code{Cycle} parameter of
7878 @code{2.0*Numerics.Pi}, since this will not provide the required
7879 accuracy in some portions of the domain.
7880 @end cartouche
7881 Followed.
7882
7883 @c -----------------------------------------
7884 @node Implementation Defined Characteristics
7885 @chapter Implementation Defined Characteristics
7886
7887 @noindent
7888 In addition to the implementation dependent pragmas and attributes, and
7889 the implementation advice, there are a number of other Ada features
7890 that are potentially implementation dependent. These are mentioned
7891 throughout the Ada Reference Manual, and are summarized in Annex M@.
7892
7893 A requirement for conforming Ada compilers is that they provide
7894 documentation describing how the implementation deals with each of these
7895 issues. In this chapter, you will find each point in Annex M listed
7896 followed by a description in italic font of how GNAT
7897 @c SGI info:
7898 @ignore
7899 in the ProDev Ada
7900 implementation on IRIX 5.3 operating system or greater
7901 @end ignore
7902 handles the implementation dependence.
7903
7904 You can use this chapter as a guide to minimizing implementation
7905 dependent features in your programs if portability to other compilers
7906 and other operating systems is an important consideration. The numbers
7907 in each section below correspond to the paragraph number in the Ada
7908 Reference Manual.
7909
7910 @sp 1
7911 @cartouche
7912 @noindent
7913 @strong{2}. Whether or not each recommendation given in Implementation
7914 Advice is followed. See 1.1.2(37).
7915 @end cartouche
7916 @noindent
7917 @xref{Implementation Advice}.
7918
7919 @sp 1
7920 @cartouche
7921 @noindent
7922 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7923 @end cartouche
7924 @noindent
7925 The complexity of programs that can be processed is limited only by the
7926 total amount of available virtual memory, and disk space for the
7927 generated object files.
7928
7929 @sp 1
7930 @cartouche
7931 @noindent
7932 @strong{4}. Variations from the standard that are impractical to avoid
7933 given the implementation's execution environment. See 1.1.3(6).
7934 @end cartouche
7935 @noindent
7936 There are no variations from the standard.
7937
7938 @sp 1
7939 @cartouche
7940 @noindent
7941 @strong{5}. Which @code{code_statement}s cause external
7942 interactions. See 1.1.3(10).
7943 @end cartouche
7944 @noindent
7945 Any @code{code_statement} can potentially cause external interactions.
7946
7947 @sp 1
7948 @cartouche
7949 @noindent
7950 @strong{6}. The coded representation for the text of an Ada
7951 program. See 2.1(4).
7952 @end cartouche
7953 @noindent
7954 See separate section on source representation.
7955
7956 @sp 1
7957 @cartouche
7958 @noindent
7959 @strong{7}. The control functions allowed in comments. See 2.1(14).
7960 @end cartouche
7961 @noindent
7962 See separate section on source representation.
7963
7964 @sp 1
7965 @cartouche
7966 @noindent
7967 @strong{8}. The representation for an end of line. See 2.2(2).
7968 @end cartouche
7969 @noindent
7970 See separate section on source representation.
7971
7972 @sp 1
7973 @cartouche
7974 @noindent
7975 @strong{9}. Maximum supported line length and lexical element
7976 length. See 2.2(15).
7977 @end cartouche
7978 @noindent
7979 The maximum line length is 255 characters and the maximum length of a
7980 lexical element is also 255 characters.
7981
7982 @sp 1
7983 @cartouche
7984 @noindent
7985 @strong{10}. Implementation defined pragmas. See 2.8(14).
7986 @end cartouche
7987 @noindent
7988
7989 @xref{Implementation Defined Pragmas}.
7990
7991 @sp 1
7992 @cartouche
7993 @noindent
7994 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7995 @end cartouche
7996 @noindent
7997 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7998 parameter, checks that the optimization flag is set, and aborts if it is
7999 not.
8000
8001 @sp 1
8002 @cartouche
8003 @noindent
8004 @strong{12}. The sequence of characters of the value returned by
8005 @code{@var{S}'Image} when some of the graphic characters of
8006 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8007 3.5(37).
8008 @end cartouche
8009 @noindent
8010 The sequence of characters is as defined by the wide character encoding
8011 method used for the source. See section on source representation for
8012 further details.
8013
8014 @sp 1
8015 @cartouche
8016 @noindent
8017 @strong{13}. The predefined integer types declared in
8018 @code{Standard}. See 3.5.4(25).
8019 @end cartouche
8020 @noindent
8021 @table @code
8022 @item Short_Short_Integer
8023 8 bit signed
8024 @item Short_Integer
8025 (Short) 16 bit signed
8026 @item Integer
8027 32 bit signed
8028 @item Long_Integer
8029 64 bit signed (Alpha OpenVMS only)
8030 32 bit signed (all other targets)
8031 @item Long_Long_Integer
8032 64 bit signed
8033 @end table
8034
8035 @sp 1
8036 @cartouche
8037 @noindent
8038 @strong{14}. Any nonstandard integer types and the operators defined
8039 for them. See 3.5.4(26).
8040 @end cartouche
8041 @noindent
8042 There are no nonstandard integer types.
8043
8044 @sp 1
8045 @cartouche
8046 @noindent
8047 @strong{15}. Any nonstandard real types and the operators defined for
8048 them. See 3.5.6(8).
8049 @end cartouche
8050 @noindent
8051 There are no nonstandard real types.
8052
8053 @sp 1
8054 @cartouche
8055 @noindent
8056 @strong{16}. What combinations of requested decimal precision and range
8057 are supported for floating point types. See 3.5.7(7).
8058 @end cartouche
8059 @noindent
8060 The precision and range is as defined by the IEEE standard.
8061
8062 @sp 1
8063 @cartouche
8064 @noindent
8065 @strong{17}. The predefined floating point types declared in
8066 @code{Standard}. See 3.5.7(16).
8067 @end cartouche
8068 @noindent
8069 @table @code
8070 @item Short_Float
8071 32 bit IEEE short
8072 @item Float
8073 (Short) 32 bit IEEE short
8074 @item Long_Float
8075 64 bit IEEE long
8076 @item Long_Long_Float
8077 64 bit IEEE long (80 bit IEEE long on x86 processors)
8078 @end table
8079
8080 @sp 1
8081 @cartouche
8082 @noindent
8083 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8084 @end cartouche
8085 @noindent
8086 @code{Fine_Delta} is 2**(@minus{}63)
8087
8088 @sp 1
8089 @cartouche
8090 @noindent
8091 @strong{19}. What combinations of small, range, and digits are
8092 supported for fixed point types. See 3.5.9(10).
8093 @end cartouche
8094 @noindent
8095 Any combinations are permitted that do not result in a small less than
8096 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8097 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8098 is 64 bits (true of all architectures except ia32), then the output from
8099 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8100 is because floating-point conversions are used to convert fixed point.
8101
8102 @sp 1
8103 @cartouche
8104 @noindent
8105 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8106 within an unnamed @code{block_statement}. See 3.9(10).
8107 @end cartouche
8108 @noindent
8109 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8110 decimal integer are allocated.
8111
8112 @sp 1
8113 @cartouche
8114 @noindent
8115 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8116 @end cartouche
8117 @noindent
8118 @xref{Implementation Defined Attributes}.
8119
8120 @sp 1
8121 @cartouche
8122 @noindent
8123 @strong{22}. Any implementation-defined time types. See 9.6(6).
8124 @end cartouche
8125 @noindent
8126 There are no implementation-defined time types.
8127
8128 @sp 1
8129 @cartouche
8130 @noindent
8131 @strong{23}. The time base associated with relative delays.
8132 @end cartouche
8133 @noindent
8134 See 9.6(20). The time base used is that provided by the C library
8135 function @code{gettimeofday}.
8136
8137 @sp 1
8138 @cartouche
8139 @noindent
8140 @strong{24}. The time base of the type @code{Calendar.Time}. See
8141 9.6(23).
8142 @end cartouche
8143 @noindent
8144 The time base used is that provided by the C library function
8145 @code{gettimeofday}.
8146
8147 @sp 1
8148 @cartouche
8149 @noindent
8150 @strong{25}. The time zone used for package @code{Calendar}
8151 operations. See 9.6(24).
8152 @end cartouche
8153 @noindent
8154 The time zone used by package @code{Calendar} is the current system time zone
8155 setting for local time, as accessed by the C library function
8156 @code{localtime}.
8157
8158 @sp 1
8159 @cartouche
8160 @noindent
8161 @strong{26}. Any limit on @code{delay_until_statements} of
8162 @code{select_statements}. See 9.6(29).
8163 @end cartouche
8164 @noindent
8165 There are no such limits.
8166
8167 @sp 1
8168 @cartouche
8169 @noindent
8170 @strong{27}. Whether or not two non-overlapping parts of a composite
8171 object are independently addressable, in the case where packing, record
8172 layout, or @code{Component_Size} is specified for the object. See
8173 9.10(1).
8174 @end cartouche
8175 @noindent
8176 Separate components are independently addressable if they do not share
8177 overlapping storage units.
8178
8179 @sp 1
8180 @cartouche
8181 @noindent
8182 @strong{28}. The representation for a compilation. See 10.1(2).
8183 @end cartouche
8184 @noindent
8185 A compilation is represented by a sequence of files presented to the
8186 compiler in a single invocation of the @command{gcc} command.
8187
8188 @sp 1
8189 @cartouche
8190 @noindent
8191 @strong{29}. Any restrictions on compilations that contain multiple
8192 compilation_units. See 10.1(4).
8193 @end cartouche
8194 @noindent
8195 No single file can contain more than one compilation unit, but any
8196 sequence of files can be presented to the compiler as a single
8197 compilation.
8198
8199 @sp 1
8200 @cartouche
8201 @noindent
8202 @strong{30}. The mechanisms for creating an environment and for adding
8203 and replacing compilation units. See 10.1.4(3).
8204 @end cartouche
8205 @noindent
8206 See separate section on compilation model.
8207
8208 @sp 1
8209 @cartouche
8210 @noindent
8211 @strong{31}. The manner of explicitly assigning library units to a
8212 partition. See 10.2(2).
8213 @end cartouche
8214 @noindent
8215 If a unit contains an Ada main program, then the Ada units for the partition
8216 are determined by recursive application of the rules in the Ada Reference
8217 Manual section 10.2(2-6). In other words, the Ada units will be those that
8218 are needed by the main program, and then this definition of need is applied
8219 recursively to those units, and the partition contains the transitive
8220 closure determined by this relationship. In short, all the necessary units
8221 are included, with no need to explicitly specify the list. If additional
8222 units are required, e.g.@: by foreign language units, then all units must be
8223 mentioned in the context clause of one of the needed Ada units.
8224
8225 If the partition contains no main program, or if the main program is in
8226 a language other than Ada, then GNAT
8227 provides the binder options @option{-z} and @option{-n} respectively, and in
8228 this case a list of units can be explicitly supplied to the binder for
8229 inclusion in the partition (all units needed by these units will also
8230 be included automatically). For full details on the use of these
8231 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8232 @value{EDITION} User's Guide}.
8233
8234 @sp 1
8235 @cartouche
8236 @noindent
8237 @strong{32}. The implementation-defined means, if any, of specifying
8238 which compilation units are needed by a given compilation unit. See
8239 10.2(2).
8240 @end cartouche
8241 @noindent
8242 The units needed by a given compilation unit are as defined in
8243 the Ada Reference Manual section 10.2(2-6). There are no
8244 implementation-defined pragmas or other implementation-defined
8245 means for specifying needed units.
8246
8247 @sp 1
8248 @cartouche
8249 @noindent
8250 @strong{33}. The manner of designating the main subprogram of a
8251 partition. See 10.2(7).
8252 @end cartouche
8253 @noindent
8254 The main program is designated by providing the name of the
8255 corresponding @file{ALI} file as the input parameter to the binder.
8256
8257 @sp 1
8258 @cartouche
8259 @noindent
8260 @strong{34}. The order of elaboration of @code{library_items}. See
8261 10.2(18).
8262 @end cartouche
8263 @noindent
8264 The first constraint on ordering is that it meets the requirements of
8265 Chapter 10 of the Ada Reference Manual. This still leaves some
8266 implementation dependent choices, which are resolved by first
8267 elaborating bodies as early as possible (i.e., in preference to specs
8268 where there is a choice), and second by evaluating the immediate with
8269 clauses of a unit to determine the probably best choice, and
8270 third by elaborating in alphabetical order of unit names
8271 where a choice still remains.
8272
8273 @sp 1
8274 @cartouche
8275 @noindent
8276 @strong{35}. Parameter passing and function return for the main
8277 subprogram. See 10.2(21).
8278 @end cartouche
8279 @noindent
8280 The main program has no parameters. It may be a procedure, or a function
8281 returning an integer type. In the latter case, the returned integer
8282 value is the return code of the program (overriding any value that
8283 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8284
8285 @sp 1
8286 @cartouche
8287 @noindent
8288 @strong{36}. The mechanisms for building and running partitions. See
8289 10.2(24).
8290 @end cartouche
8291 @noindent
8292 GNAT itself supports programs with only a single partition. The GNATDIST
8293 tool provided with the GLADE package (which also includes an implementation
8294 of the PCS) provides a completely flexible method for building and running
8295 programs consisting of multiple partitions. See the separate GLADE manual
8296 for details.
8297
8298 @sp 1
8299 @cartouche
8300 @noindent
8301 @strong{37}. The details of program execution, including program
8302 termination. See 10.2(25).
8303 @end cartouche
8304 @noindent
8305 See separate section on compilation model.
8306
8307 @sp 1
8308 @cartouche
8309 @noindent
8310 @strong{38}. The semantics of any non-active partitions supported by the
8311 implementation. See 10.2(28).
8312 @end cartouche
8313 @noindent
8314 Passive partitions are supported on targets where shared memory is
8315 provided by the operating system. See the GLADE reference manual for
8316 further details.
8317
8318 @sp 1
8319 @cartouche
8320 @noindent
8321 @strong{39}. The information returned by @code{Exception_Message}. See
8322 11.4.1(10).
8323 @end cartouche
8324 @noindent
8325 Exception message returns the null string unless a specific message has
8326 been passed by the program.
8327
8328 @sp 1
8329 @cartouche
8330 @noindent
8331 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8332 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8333 @end cartouche
8334 @noindent
8335 Blocks have implementation defined names of the form @code{B@var{nnn}}
8336 where @var{nnn} is an integer.
8337
8338 @sp 1
8339 @cartouche
8340 @noindent
8341 @strong{41}. The information returned by
8342 @code{Exception_Information}. See 11.4.1(13).
8343 @end cartouche
8344 @noindent
8345 @code{Exception_Information} returns a string in the following format:
8346
8347 @smallexample
8348 @emph{Exception_Name:} nnnnn
8349 @emph{Message:} mmmmm
8350 @emph{PID:} ppp
8351 @emph{Call stack traceback locations:}
8352 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8353 @end smallexample
8354
8355 @noindent
8356 where
8357
8358 @itemize @bullet
8359 @item
8360 @code{nnnn} is the fully qualified name of the exception in all upper
8361 case letters. This line is always present.
8362
8363 @item
8364 @code{mmmm} is the message (this line present only if message is non-null)
8365
8366 @item
8367 @code{ppp} is the Process Id value as a decimal integer (this line is
8368 present only if the Process Id is nonzero). Currently we are
8369 not making use of this field.
8370
8371 @item
8372 The Call stack traceback locations line and the following values
8373 are present only if at least one traceback location was recorded.
8374 The values are given in C style format, with lower case letters
8375 for a-f, and only as many digits present as are necessary.
8376 @end itemize
8377
8378 @noindent
8379 The line terminator sequence at the end of each line, including
8380 the last line is a single @code{LF} character (@code{16#0A#}).
8381
8382 @sp 1
8383 @cartouche
8384 @noindent
8385 @strong{42}. Implementation-defined check names. See 11.5(27).
8386 @end cartouche
8387 @noindent
8388 The implementation defined check name Alignment_Check controls checking of
8389 address clause values for proper alignment (that is, the address supplied
8390 must be consistent with the alignment of the type).
8391
8392 In addition, a user program can add implementation-defined check names
8393 by means of the pragma Check_Name.
8394
8395 @sp 1
8396 @cartouche
8397 @noindent
8398 @strong{43}. The interpretation of each aspect of representation. See
8399 13.1(20).
8400 @end cartouche
8401 @noindent
8402 See separate section on data representations.
8403
8404 @sp 1
8405 @cartouche
8406 @noindent
8407 @strong{44}. Any restrictions placed upon representation items. See
8408 13.1(20).
8409 @end cartouche
8410 @noindent
8411 See separate section on data representations.
8412
8413 @sp 1
8414 @cartouche
8415 @noindent
8416 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8417 13.3(48).
8418 @end cartouche
8419 @noindent
8420 Size for an indefinite subtype is the maximum possible size, except that
8421 for the case of a subprogram parameter, the size of the parameter object
8422 is the actual size.
8423
8424 @sp 1
8425 @cartouche
8426 @noindent
8427 @strong{46}. The default external representation for a type tag. See
8428 13.3(75).
8429 @end cartouche
8430 @noindent
8431 The default external representation for a type tag is the fully expanded
8432 name of the type in upper case letters.
8433
8434 @sp 1
8435 @cartouche
8436 @noindent
8437 @strong{47}. What determines whether a compilation unit is the same in
8438 two different partitions. See 13.3(76).
8439 @end cartouche
8440 @noindent
8441 A compilation unit is the same in two different partitions if and only
8442 if it derives from the same source file.
8443
8444 @sp 1
8445 @cartouche
8446 @noindent
8447 @strong{48}. Implementation-defined components. See 13.5.1(15).
8448 @end cartouche
8449 @noindent
8450 The only implementation defined component is the tag for a tagged type,
8451 which contains a pointer to the dispatching table.
8452
8453 @sp 1
8454 @cartouche
8455 @noindent
8456 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8457 ordering. See 13.5.3(5).
8458 @end cartouche
8459 @noindent
8460 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8461 implementation, so no non-default bit ordering is supported. The default
8462 bit ordering corresponds to the natural endianness of the target architecture.
8463
8464 @sp 1
8465 @cartouche
8466 @noindent
8467 @strong{50}. The contents of the visible part of package @code{System}
8468 and its language-defined children. See 13.7(2).
8469 @end cartouche
8470 @noindent
8471 See the definition of these packages in files @file{system.ads} and
8472 @file{s-stoele.ads}.
8473
8474 @sp 1
8475 @cartouche
8476 @noindent
8477 @strong{51}. The contents of the visible part of package
8478 @code{System.Machine_Code}, and the meaning of
8479 @code{code_statements}. See 13.8(7).
8480 @end cartouche
8481 @noindent
8482 See the definition and documentation in file @file{s-maccod.ads}.
8483
8484 @sp 1
8485 @cartouche
8486 @noindent
8487 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8488 @end cartouche
8489 @noindent
8490 Unchecked conversion between types of the same size
8491 results in an uninterpreted transmission of the bits from one type
8492 to the other. If the types are of unequal sizes, then in the case of
8493 discrete types, a shorter source is first zero or sign extended as
8494 necessary, and a shorter target is simply truncated on the left.
8495 For all non-discrete types, the source is first copied if necessary
8496 to ensure that the alignment requirements of the target are met, then
8497 a pointer is constructed to the source value, and the result is obtained
8498 by dereferencing this pointer after converting it to be a pointer to the
8499 target type. Unchecked conversions where the target subtype is an
8500 unconstrained array are not permitted. If the target alignment is
8501 greater than the source alignment, then a copy of the result is
8502 made with appropriate alignment
8503
8504 @sp 1
8505 @cartouche
8506 @noindent
8507 @strong{53}. The manner of choosing a storage pool for an access type
8508 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8509 @end cartouche
8510 @noindent
8511 There are 3 different standard pools used by the compiler when
8512 @code{Storage_Pool} is not specified depending whether the type is local
8513 to a subprogram or defined at the library level and whether
8514 @code{Storage_Size}is specified or not. See documentation in the runtime
8515 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8516 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8517 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8518 default pools used.
8519
8520 @sp 1
8521 @cartouche
8522 @noindent
8523 @strong{54}. Whether or not the implementation provides user-accessible
8524 names for the standard pool type(s). See 13.11(17).
8525 @end cartouche
8526 @noindent
8527
8528 See documentation in the sources of the run time mentioned in paragraph
8529 @strong{53} . All these pools are accessible by means of @code{with}'ing
8530 these units.
8531
8532 @sp 1
8533 @cartouche
8534 @noindent
8535 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8536 @end cartouche
8537 @noindent
8538 @code{Storage_Size} is measured in storage units, and refers to the
8539 total space available for an access type collection, or to the primary
8540 stack space for a task.
8541
8542 @sp 1
8543 @cartouche
8544 @noindent
8545 @strong{56}. Implementation-defined aspects of storage pools. See
8546 13.11(22).
8547 @end cartouche
8548 @noindent
8549 See documentation in the sources of the run time mentioned in paragraph
8550 @strong{53} for details on GNAT-defined aspects of storage pools.
8551
8552 @sp 1
8553 @cartouche
8554 @noindent
8555 @strong{57}. The set of restrictions allowed in a pragma
8556 @code{Restrictions}. See 13.12(7).
8557 @end cartouche
8558 @noindent
8559 All RM defined Restriction identifiers are implemented. The following
8560 additional restriction identifiers are provided. There are two separate
8561 lists of implementation dependent restriction identifiers. The first
8562 set requires consistency throughout a partition (in other words, if the
8563 restriction identifier is used for any compilation unit in the partition,
8564 then all compilation units in the partition must obey the restriction.
8565
8566 @table @code
8567
8568 @item Simple_Barriers
8569 @findex Simple_Barriers
8570 This restriction ensures at compile time that barriers in entry declarations
8571 for protected types are restricted to either static boolean expressions or
8572 references to simple boolean variables defined in the private part of the
8573 protected type. No other form of entry barriers is permitted. This is one
8574 of the restrictions of the Ravenscar profile for limited tasking (see also
8575 pragma @code{Profile (Ravenscar)}).
8576
8577 @item Max_Entry_Queue_Length => Expr
8578 @findex Max_Entry_Queue_Length
8579 This restriction is a declaration that any protected entry compiled in
8580 the scope of the restriction has at most the specified number of
8581 tasks waiting on the entry
8582 at any one time, and so no queue is required. This restriction is not
8583 checked at compile time. A program execution is erroneous if an attempt
8584 is made to queue more than the specified number of tasks on such an entry.
8585
8586 @item No_Calendar
8587 @findex No_Calendar
8588 This restriction ensures at compile time that there is no implicit or
8589 explicit dependence on the package @code{Ada.Calendar}.
8590
8591 @item No_Default_Initialization
8592 @findex No_Default_Initialization
8593
8594 This restriction prohibits any instance of default initialization of variables.
8595 The binder implements a consistency rule which prevents any unit compiled
8596 without the restriction from with'ing a unit with the restriction (this allows
8597 the generation of initialization procedures to be skipped, since you can be
8598 sure that no call is ever generated to an initialization procedure in a unit
8599 with the restriction active). If used in conjunction with Initialize_Scalars or
8600 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8601 without a specific initializer (including the case of OUT scalar parameters).
8602
8603 @item No_Direct_Boolean_Operators
8604 @findex No_Direct_Boolean_Operators
8605 This restriction ensures that no logical (and/or/xor) are used on
8606 operands of type Boolean (or any type derived
8607 from Boolean). This is intended for use in safety critical programs
8608 where the certification protocol requires the use of short-circuit
8609 (and then, or else) forms for all composite boolean operations.
8610
8611 @item No_Dispatching_Calls
8612 @findex No_Dispatching_Calls
8613 This restriction ensures at compile time that the code generated by the
8614 compiler involves no dispatching calls. The use of this restriction allows the
8615 safe use of record extensions, classwide membership tests and other classwide
8616 features not involving implicit dispatching. This restriction ensures that
8617 the code contains no indirect calls through a dispatching mechanism. Note that
8618 this includes internally-generated calls created by the compiler, for example
8619 in the implementation of class-wide objects assignments. The
8620 membership test is allowed in the presence of this restriction, because its
8621 implementation requires no dispatching.
8622 This restriction is comparable to the official Ada restriction
8623 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8624 all classwide constructs that do not imply dispatching.
8625 The following example indicates constructs that violate this restriction.
8626
8627 @smallexample
8628 package Pkg is
8629 type T is tagged record
8630 Data : Natural;
8631 end record;
8632 procedure P (X : T);
8633
8634 type DT is new T with record
8635 More_Data : Natural;
8636 end record;
8637 procedure Q (X : DT);
8638 end Pkg;
8639
8640 with Pkg; use Pkg;
8641 procedure Example is
8642 procedure Test (O : T'Class) is
8643 N : Natural := O'Size;-- Error: Dispatching call
8644 C : T'Class := O; -- Error: implicit Dispatching Call
8645 begin
8646 if O in DT'Class then -- OK : Membership test
8647 Q (DT (O)); -- OK : Type conversion plus direct call
8648 else
8649 P (O); -- Error: Dispatching call
8650 end if;
8651 end Test;
8652
8653 Obj : DT;
8654 begin
8655 P (Obj); -- OK : Direct call
8656 P (T (Obj)); -- OK : Type conversion plus direct call
8657 P (T'Class (Obj)); -- Error: Dispatching call
8658
8659 Test (Obj); -- OK : Type conversion
8660
8661 if Obj in T'Class then -- OK : Membership test
8662 null;
8663 end if;
8664 end Example;
8665 @end smallexample
8666
8667 @item No_Dynamic_Attachment
8668 @findex No_Dynamic_Attachment
8669 This restriction ensures that there is no call to any of the operations
8670 defined in package Ada.Interrupts.
8671
8672 @item No_Enumeration_Maps
8673 @findex No_Enumeration_Maps
8674 This restriction ensures at compile time that no operations requiring
8675 enumeration maps are used (that is Image and Value attributes applied
8676 to enumeration types).
8677
8678 @item No_Entry_Calls_In_Elaboration_Code
8679 @findex No_Entry_Calls_In_Elaboration_Code
8680 This restriction ensures at compile time that no task or protected entry
8681 calls are made during elaboration code. As a result of the use of this
8682 restriction, the compiler can assume that no code past an accept statement
8683 in a task can be executed at elaboration time.
8684
8685 @item No_Exception_Handlers
8686 @findex No_Exception_Handlers
8687 This restriction ensures at compile time that there are no explicit
8688 exception handlers. It also indicates that no exception propagation will
8689 be provided. In this mode, exceptions may be raised but will result in
8690 an immediate call to the last chance handler, a routine that the user
8691 must define with the following profile:
8692
8693 @smallexample @c ada
8694 procedure Last_Chance_Handler
8695 (Source_Location : System.Address; Line : Integer);
8696 pragma Export (C, Last_Chance_Handler,
8697 "__gnat_last_chance_handler");
8698 @end smallexample
8699
8700 The parameter is a C null-terminated string representing a message to be
8701 associated with the exception (typically the source location of the raise
8702 statement generated by the compiler). The Line parameter when nonzero
8703 represents the line number in the source program where the raise occurs.
8704
8705 @item No_Exception_Propagation
8706 @findex No_Exception_Propagation
8707 This restriction guarantees that exceptions are never propagated to an outer
8708 subprogram scope). The only case in which an exception may be raised is when
8709 the handler is statically in the same subprogram, so that the effect of a raise
8710 is essentially like a goto statement. Any other raise statement (implicit or
8711 explicit) will be considered unhandled. Exception handlers are allowed, but may
8712 not contain an exception occurrence identifier (exception choice). In addition
8713 use of the package GNAT.Current_Exception is not permitted, and reraise
8714 statements (raise with no operand) are not permitted.
8715
8716 @item No_Exception_Registration
8717 @findex No_Exception_Registration
8718 This restriction ensures at compile time that no stream operations for
8719 types Exception_Id or Exception_Occurrence are used. This also makes it
8720 impossible to pass exceptions to or from a partition with this restriction
8721 in a distributed environment. If this exception is active, then the generated
8722 code is simplified by omitting the otherwise-required global registration
8723 of exceptions when they are declared.
8724
8725 @item No_Implicit_Conditionals
8726 @findex No_Implicit_Conditionals
8727 This restriction ensures that the generated code does not contain any
8728 implicit conditionals, either by modifying the generated code where possible,
8729 or by rejecting any construct that would otherwise generate an implicit
8730 conditional. Note that this check does not include run time constraint
8731 checks, which on some targets may generate implicit conditionals as
8732 well. To control the latter, constraint checks can be suppressed in the
8733 normal manner. Constructs generating implicit conditionals include comparisons
8734 of composite objects and the Max/Min attributes.
8735
8736 @item No_Implicit_Dynamic_Code
8737 @findex No_Implicit_Dynamic_Code
8738 @cindex trampoline
8739 This restriction prevents the compiler from building ``trampolines''.
8740 This is a structure that is built on the stack and contains dynamic
8741 code to be executed at run time. On some targets, a trampoline is
8742 built for the following features: @code{Access},
8743 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8744 nested task bodies; primitive operations of nested tagged types.
8745 Trampolines do not work on machines that prevent execution of stack
8746 data. For example, on windows systems, enabling DEP (data execution
8747 protection) will cause trampolines to raise an exception.
8748 Trampolines are also quite slow at run time.
8749
8750 On many targets, trampolines have been largely eliminated. Look at the
8751 version of system.ads for your target --- if it has
8752 Always_Compatible_Rep equal to False, then trampolines are largely
8753 eliminated. In particular, a trampoline is built for the following
8754 features: @code{Address} of a nested subprogram;
8755 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8756 but only if pragma Favor_Top_Level applies, or the access type has a
8757 foreign-language convention; primitive operations of nested tagged
8758 types.
8759
8760 @item No_Implicit_Loops
8761 @findex No_Implicit_Loops
8762 This restriction ensures that the generated code does not contain any
8763 implicit @code{for} loops, either by modifying
8764 the generated code where possible,
8765 or by rejecting any construct that would otherwise generate an implicit
8766 @code{for} loop. If this restriction is active, it is possible to build
8767 large array aggregates with all static components without generating an
8768 intermediate temporary, and without generating a loop to initialize individual
8769 components. Otherwise, a loop is created for arrays larger than about 5000
8770 scalar components.
8771
8772 @item No_Initialize_Scalars
8773 @findex No_Initialize_Scalars
8774 This restriction ensures that no unit in the partition is compiled with
8775 pragma Initialize_Scalars. This allows the generation of more efficient
8776 code, and in particular eliminates dummy null initialization routines that
8777 are otherwise generated for some record and array types.
8778
8779 @item No_Local_Protected_Objects
8780 @findex No_Local_Protected_Objects
8781 This restriction ensures at compile time that protected objects are
8782 only declared at the library level.
8783
8784 @item No_Protected_Type_Allocators
8785 @findex No_Protected_Type_Allocators
8786 This restriction ensures at compile time that there are no allocator
8787 expressions that attempt to allocate protected objects.
8788
8789 @item No_Secondary_Stack
8790 @findex No_Secondary_Stack
8791 This restriction ensures at compile time that the generated code does not
8792 contain any reference to the secondary stack. The secondary stack is used
8793 to implement functions returning unconstrained objects (arrays or records)
8794 on some targets.
8795
8796 @item No_Select_Statements
8797 @findex No_Select_Statements
8798 This restriction ensures at compile time no select statements of any kind
8799 are permitted, that is the keyword @code{select} may not appear.
8800 This is one of the restrictions of the Ravenscar
8801 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8802
8803 @item No_Standard_Storage_Pools
8804 @findex No_Standard_Storage_Pools
8805 This restriction ensures at compile time that no access types
8806 use the standard default storage pool. Any access type declared must
8807 have an explicit Storage_Pool attribute defined specifying a
8808 user-defined storage pool.
8809
8810 @item No_Streams
8811 @findex No_Streams
8812 This restriction ensures at compile/bind time that there are no
8813 stream objects created and no use of stream attributes.
8814 This restriction does not forbid dependences on the package
8815 @code{Ada.Streams}. So it is permissible to with
8816 @code{Ada.Streams} (or another package that does so itself)
8817 as long as no actual stream objects are created and no
8818 stream attributes are used.
8819
8820 Note that the use of restriction allows optimization of tagged types,
8821 since they do not need to worry about dispatching stream operations.
8822 To take maximum advantage of this space-saving optimization, any
8823 unit declaring a tagged type should be compiled with the restriction,
8824 though this is not required.
8825
8826 @item No_Task_Attributes_Package
8827 @findex No_Task_Attributes_Package
8828 This restriction ensures at compile time that there are no implicit or
8829 explicit dependencies on the package @code{Ada.Task_Attributes}.
8830
8831 @item No_Task_Termination
8832 @findex No_Task_Termination
8833 This restriction ensures at compile time that no terminate alternatives
8834 appear in any task body.
8835
8836 @item No_Tasking
8837 @findex No_Tasking
8838 This restriction prevents the declaration of tasks or task types throughout
8839 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8840 except that violations are caught at compile time and cause an error message
8841 to be output either by the compiler or binder.
8842
8843 @item Static_Priorities
8844 @findex Static_Priorities
8845 This restriction ensures at compile time that all priority expressions
8846 are static, and that there are no dependencies on the package
8847 @code{Ada.Dynamic_Priorities}.
8848
8849 @item Static_Storage_Size
8850 @findex Static_Storage_Size
8851 This restriction ensures at compile time that any expression appearing
8852 in a Storage_Size pragma or attribute definition clause is static.
8853
8854 @end table
8855
8856 @noindent
8857 The second set of implementation dependent restriction identifiers
8858 does not require partition-wide consistency.
8859 The restriction may be enforced for a single
8860 compilation unit without any effect on any of the
8861 other compilation units in the partition.
8862
8863 @table @code
8864
8865 @item No_Elaboration_Code
8866 @findex No_Elaboration_Code
8867 This restriction ensures at compile time that no elaboration code is
8868 generated. Note that this is not the same condition as is enforced
8869 by pragma @code{Preelaborate}. There are cases in which pragma
8870 @code{Preelaborate} still permits code to be generated (e.g.@: code
8871 to initialize a large array to all zeroes), and there are cases of units
8872 which do not meet the requirements for pragma @code{Preelaborate},
8873 but for which no elaboration code is generated. Generally, it is
8874 the case that preelaborable units will meet the restrictions, with
8875 the exception of large aggregates initialized with an others_clause,
8876 and exception declarations (which generate calls to a run-time
8877 registry procedure). This restriction is enforced on
8878 a unit by unit basis, it need not be obeyed consistently
8879 throughout a partition.
8880
8881 In the case of aggregates with others, if the aggregate has a dynamic
8882 size, there is no way to eliminate the elaboration code (such dynamic
8883 bounds would be incompatible with @code{Preelaborate} in any case). If
8884 the bounds are static, then use of this restriction actually modifies
8885 the code choice of the compiler to avoid generating a loop, and instead
8886 generate the aggregate statically if possible, no matter how many times
8887 the data for the others clause must be repeatedly generated.
8888
8889 It is not possible to precisely document
8890 the constructs which are compatible with this restriction, since,
8891 unlike most other restrictions, this is not a restriction on the
8892 source code, but a restriction on the generated object code. For
8893 example, if the source contains a declaration:
8894
8895 @smallexample
8896 Val : constant Integer := X;
8897 @end smallexample
8898
8899 @noindent
8900 where X is not a static constant, it may be possible, depending
8901 on complex optimization circuitry, for the compiler to figure
8902 out the value of X at compile time, in which case this initialization
8903 can be done by the loader, and requires no initialization code. It
8904 is not possible to document the precise conditions under which the
8905 optimizer can figure this out.
8906
8907 Note that this the implementation of this restriction requires full
8908 code generation. If it is used in conjunction with "semantics only"
8909 checking, then some cases of violations may be missed.
8910
8911 @item No_Entry_Queue
8912 @findex No_Entry_Queue
8913 This restriction is a declaration that any protected entry compiled in
8914 the scope of the restriction has at most one task waiting on the entry
8915 at any one time, and so no queue is required. This restriction is not
8916 checked at compile time. A program execution is erroneous if an attempt
8917 is made to queue a second task on such an entry.
8918
8919 @item No_Implementation_Attributes
8920 @findex No_Implementation_Attributes
8921 This restriction checks at compile time that no GNAT-defined attributes
8922 are present. With this restriction, the only attributes that can be used
8923 are those defined in the Ada Reference Manual.
8924
8925 @item No_Implementation_Pragmas
8926 @findex No_Implementation_Pragmas
8927 This restriction checks at compile time that no GNAT-defined pragmas
8928 are present. With this restriction, the only pragmas that can be used
8929 are those defined in the Ada Reference Manual.
8930
8931 @item No_Implementation_Restrictions
8932 @findex No_Implementation_Restrictions
8933 This restriction checks at compile time that no GNAT-defined restriction
8934 identifiers (other than @code{No_Implementation_Restrictions} itself)
8935 are present. With this restriction, the only other restriction identifiers
8936 that can be used are those defined in the Ada Reference Manual.
8937
8938 @item No_Wide_Characters
8939 @findex No_Wide_Characters
8940 This restriction ensures at compile time that no uses of the types
8941 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8942 wide types
8943 appear, and that no wide or wide wide string or character literals
8944 appear in the program (that is literals representing characters not in
8945 type @code{Character}.
8946
8947 @end table
8948
8949 @sp 1
8950 @cartouche
8951 @noindent
8952 @strong{58}. The consequences of violating limitations on
8953 @code{Restrictions} pragmas. See 13.12(9).
8954 @end cartouche
8955 @noindent
8956 Restrictions that can be checked at compile time result in illegalities
8957 if violated. Currently there are no other consequences of violating
8958 restrictions.
8959
8960 @sp 1
8961 @cartouche
8962 @noindent
8963 @strong{59}. The representation used by the @code{Read} and
8964 @code{Write} attributes of elementary types in terms of stream
8965 elements. See 13.13.2(9).
8966 @end cartouche
8967 @noindent
8968 The representation is the in-memory representation of the base type of
8969 the type, using the number of bits corresponding to the
8970 @code{@var{type}'Size} value, and the natural ordering of the machine.
8971
8972 @sp 1
8973 @cartouche
8974 @noindent
8975 @strong{60}. The names and characteristics of the numeric subtypes
8976 declared in the visible part of package @code{Standard}. See A.1(3).
8977 @end cartouche
8978 @noindent
8979 See items describing the integer and floating-point types supported.
8980
8981 @sp 1
8982 @cartouche
8983 @noindent
8984 @strong{61}. The accuracy actually achieved by the elementary
8985 functions. See A.5.1(1).
8986 @end cartouche
8987 @noindent
8988 The elementary functions correspond to the functions available in the C
8989 library. Only fast math mode is implemented.
8990
8991 @sp 1
8992 @cartouche
8993 @noindent
8994 @strong{62}. The sign of a zero result from some of the operators or
8995 functions in @code{Numerics.Generic_Elementary_Functions}, when
8996 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8997 @end cartouche
8998 @noindent
8999 The sign of zeroes follows the requirements of the IEEE 754 standard on
9000 floating-point.
9001
9002 @sp 1
9003 @cartouche
9004 @noindent
9005 @strong{63}. The value of
9006 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9007 @end cartouche
9008 @noindent
9009 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9010
9011 @sp 1
9012 @cartouche
9013 @noindent
9014 @strong{64}. The value of
9015 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9016 @end cartouche
9017 @noindent
9018 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9019
9020 @sp 1
9021 @cartouche
9022 @noindent
9023 @strong{65}. The algorithms for random number generation. See
9024 A.5.2(32).
9025 @end cartouche
9026 @noindent
9027 The algorithm is the Mersenne Twister, as documented in the source file
9028 @file{s-rannum.adb}. This version of the algorithm has a period of
9029 2**19937-1.
9030
9031 @sp 1
9032 @cartouche
9033 @noindent
9034 @strong{66}. The string representation of a random number generator's
9035 state. See A.5.2(38).
9036 @end cartouche
9037 @noindent
9038 The value returned by the Image function is the concatenation of
9039 the fixed-width decimal representations of the 624 32-bit integers
9040 of the state vector.
9041
9042 @sp 1
9043 @cartouche
9044 @noindent
9045 @strong{67}. The minimum time interval between calls to the
9046 time-dependent Reset procedure that are guaranteed to initiate different
9047 random number sequences. See A.5.2(45).
9048 @end cartouche
9049 @noindent
9050 The minimum period between reset calls to guarantee distinct series of
9051 random numbers is one microsecond.
9052
9053 @sp 1
9054 @cartouche
9055 @noindent
9056 @strong{68}. The values of the @code{Model_Mantissa},
9057 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9058 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9059 Annex is not supported. See A.5.3(72).
9060 @end cartouche
9061 @noindent
9062 See the source file @file{ttypef.ads} for the values of all numeric
9063 attributes.
9064
9065 @sp 1
9066 @cartouche
9067 @noindent
9068 @strong{69}. Any implementation-defined characteristics of the
9069 input-output packages. See A.7(14).
9070 @end cartouche
9071 @noindent
9072 There are no special implementation defined characteristics for these
9073 packages.
9074
9075 @sp 1
9076 @cartouche
9077 @noindent
9078 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9079 A.9(10).
9080 @end cartouche
9081 @noindent
9082 All type representations are contiguous, and the @code{Buffer_Size} is
9083 the value of @code{@var{type}'Size} rounded up to the next storage unit
9084 boundary.
9085
9086 @sp 1
9087 @cartouche
9088 @noindent
9089 @strong{71}. External files for standard input, standard output, and
9090 standard error See A.10(5).
9091 @end cartouche
9092 @noindent
9093 These files are mapped onto the files provided by the C streams
9094 libraries. See source file @file{i-cstrea.ads} for further details.
9095
9096 @sp 1
9097 @cartouche
9098 @noindent
9099 @strong{72}. The accuracy of the value produced by @code{Put}. See
9100 A.10.9(36).
9101 @end cartouche
9102 @noindent
9103 If more digits are requested in the output than are represented by the
9104 precision of the value, zeroes are output in the corresponding least
9105 significant digit positions.
9106
9107 @sp 1
9108 @cartouche
9109 @noindent
9110 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9111 @code{Command_Name}. See A.15(1).
9112 @end cartouche
9113 @noindent
9114 These are mapped onto the @code{argv} and @code{argc} parameters of the
9115 main program in the natural manner.
9116
9117 @sp 1
9118 @cartouche
9119 @noindent
9120 @strong{74}. Implementation-defined convention names. See B.1(11).
9121 @end cartouche
9122 @noindent
9123 The following convention names are supported
9124
9125 @table @code
9126 @item Ada
9127 Ada
9128 @item Assembler
9129 Assembly language
9130 @item Asm
9131 Synonym for Assembler
9132 @item Assembly
9133 Synonym for Assembler
9134 @item C
9135 C
9136 @item C_Pass_By_Copy
9137 Allowed only for record types, like C, but also notes that record
9138 is to be passed by copy rather than reference.
9139 @item COBOL
9140 COBOL
9141 @item C_Plus_Plus (or CPP)
9142 C++
9143 @item Default
9144 Treated the same as C
9145 @item External
9146 Treated the same as C
9147 @item Fortran
9148 Fortran
9149 @item Intrinsic
9150 For support of pragma @code{Import} with convention Intrinsic, see
9151 separate section on Intrinsic Subprograms.
9152 @item Stdcall
9153 Stdcall (used for Windows implementations only). This convention correspond
9154 to the WINAPI (previously called Pascal convention) C/C++ convention under
9155 Windows. A function with this convention cleans the stack before exit.
9156 @item DLL
9157 Synonym for Stdcall
9158 @item Win32
9159 Synonym for Stdcall
9160 @item Stubbed
9161 Stubbed is a special convention used to indicate that the body of the
9162 subprogram will be entirely ignored. Any call to the subprogram
9163 is converted into a raise of the @code{Program_Error} exception. If a
9164 pragma @code{Import} specifies convention @code{stubbed} then no body need
9165 be present at all. This convention is useful during development for the
9166 inclusion of subprograms whose body has not yet been written.
9167
9168 @end table
9169 @noindent
9170 In addition, all otherwise unrecognized convention names are also
9171 treated as being synonymous with convention C@. In all implementations
9172 except for VMS, use of such other names results in a warning. In VMS
9173 implementations, these names are accepted silently.
9174
9175 @sp 1
9176 @cartouche
9177 @noindent
9178 @strong{75}. The meaning of link names. See B.1(36).
9179 @end cartouche
9180 @noindent
9181 Link names are the actual names used by the linker.
9182
9183 @sp 1
9184 @cartouche
9185 @noindent
9186 @strong{76}. The manner of choosing link names when neither the link
9187 name nor the address of an imported or exported entity is specified. See
9188 B.1(36).
9189 @end cartouche
9190 @noindent
9191 The default linker name is that which would be assigned by the relevant
9192 external language, interpreting the Ada name as being in all lower case
9193 letters.
9194
9195 @sp 1
9196 @cartouche
9197 @noindent
9198 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
9199 @end cartouche
9200 @noindent
9201 The string passed to @code{Linker_Options} is presented uninterpreted as
9202 an argument to the link command, unless it contains ASCII.NUL characters.
9203 NUL characters if they appear act as argument separators, so for example
9204
9205 @smallexample @c ada
9206 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9207 @end smallexample
9208
9209 @noindent
9210 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9211 linker. The order of linker options is preserved for a given unit. The final
9212 list of options passed to the linker is in reverse order of the elaboration
9213 order. For example, linker options for a body always appear before the options
9214 from the corresponding package spec.
9215
9216 @sp 1
9217 @cartouche
9218 @noindent
9219 @strong{78}. The contents of the visible part of package
9220 @code{Interfaces} and its language-defined descendants. See B.2(1).
9221 @end cartouche
9222 @noindent
9223 See files with prefix @file{i-} in the distributed library.
9224
9225 @sp 1
9226 @cartouche
9227 @noindent
9228 @strong{79}. Implementation-defined children of package
9229 @code{Interfaces}. The contents of the visible part of package
9230 @code{Interfaces}. See B.2(11).
9231 @end cartouche
9232 @noindent
9233 See files with prefix @file{i-} in the distributed library.
9234
9235 @sp 1
9236 @cartouche
9237 @noindent
9238 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9239 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9240 @code{COBOL_Character}; and the initialization of the variables
9241 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9242 @code{Interfaces.COBOL}. See B.4(50).
9243 @end cartouche
9244 @noindent
9245 @table @code
9246 @item Floating
9247 Float
9248 @item Long_Floating
9249 (Floating) Long_Float
9250 @item Binary
9251 Integer
9252 @item Long_Binary
9253 Long_Long_Integer
9254 @item Decimal_Element
9255 Character
9256 @item COBOL_Character
9257 Character
9258 @end table
9259
9260 @noindent
9261 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9262
9263 @sp 1
9264 @cartouche
9265 @noindent
9266 @strong{81}. Support for access to machine instructions. See C.1(1).
9267 @end cartouche
9268 @noindent
9269 See documentation in file @file{s-maccod.ads} in the distributed library.
9270
9271 @sp 1
9272 @cartouche
9273 @noindent
9274 @strong{82}. Implementation-defined aspects of access to machine
9275 operations. See C.1(9).
9276 @end cartouche
9277 @noindent
9278 See documentation in file @file{s-maccod.ads} in the distributed library.
9279
9280 @sp 1
9281 @cartouche
9282 @noindent
9283 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9284 @end cartouche
9285 @noindent
9286 Interrupts are mapped to signals or conditions as appropriate. See
9287 definition of unit
9288 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9289 on the interrupts supported on a particular target.
9290
9291 @sp 1
9292 @cartouche
9293 @noindent
9294 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9295 C.4(13).
9296 @end cartouche
9297 @noindent
9298 GNAT does not permit a partition to be restarted without reloading,
9299 except under control of the debugger.
9300
9301 @sp 1
9302 @cartouche
9303 @noindent
9304 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9305 @end cartouche
9306 @noindent
9307 Pragma @code{Discard_Names} causes names of enumeration literals to
9308 be suppressed. In the presence of this pragma, the Image attribute
9309 provides the image of the Pos of the literal, and Value accepts
9310 Pos values.
9311
9312 @sp 1
9313 @cartouche
9314 @noindent
9315 @strong{86}. The result of the @code{Task_Identification.Image}
9316 attribute. See C.7.1(7).
9317 @end cartouche
9318 @noindent
9319 The result of this attribute is a string that identifies
9320 the object or component that denotes a given task. If a variable @code{Var}
9321 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9322 where the suffix
9323 is the hexadecimal representation of the virtual address of the corresponding
9324 task control block. If the variable is an array of tasks, the image of each
9325 task will have the form of an indexed component indicating the position of a
9326 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9327 component of a record, the image of the task will have the form of a selected
9328 component. These rules are fully recursive, so that the image of a task that
9329 is a subcomponent of a composite object corresponds to the expression that
9330 designates this task.
9331 @noindent
9332 If a task is created by an allocator, its image depends on the context. If the
9333 allocator is part of an object declaration, the rules described above are used
9334 to construct its image, and this image is not affected by subsequent
9335 assignments. If the allocator appears within an expression, the image
9336 includes only the name of the task type.
9337 @noindent
9338 If the configuration pragma Discard_Names is present, or if the restriction
9339 No_Implicit_Heap_Allocation is in effect, the image reduces to
9340 the numeric suffix, that is to say the hexadecimal representation of the
9341 virtual address of the control block of the task.
9342 @sp 1
9343 @cartouche
9344 @noindent
9345 @strong{87}. The value of @code{Current_Task} when in a protected entry
9346 or interrupt handler. See C.7.1(17).
9347 @end cartouche
9348 @noindent
9349 Protected entries or interrupt handlers can be executed by any
9350 convenient thread, so the value of @code{Current_Task} is undefined.
9351
9352 @sp 1
9353 @cartouche
9354 @noindent
9355 @strong{88}. The effect of calling @code{Current_Task} from an entry
9356 body or interrupt handler. See C.7.1(19).
9357 @end cartouche
9358 @noindent
9359 The effect of calling @code{Current_Task} from an entry body or
9360 interrupt handler is to return the identification of the task currently
9361 executing the code.
9362
9363 @sp 1
9364 @cartouche
9365 @noindent
9366 @strong{89}. Implementation-defined aspects of
9367 @code{Task_Attributes}. See C.7.2(19).
9368 @end cartouche
9369 @noindent
9370 There are no implementation-defined aspects of @code{Task_Attributes}.
9371
9372 @sp 1
9373 @cartouche
9374 @noindent
9375 @strong{90}. Values of all @code{Metrics}. See D(2).
9376 @end cartouche
9377 @noindent
9378 The metrics information for GNAT depends on the performance of the
9379 underlying operating system. The sources of the run-time for tasking
9380 implementation, together with the output from @option{-gnatG} can be
9381 used to determine the exact sequence of operating systems calls made
9382 to implement various tasking constructs. Together with appropriate
9383 information on the performance of the underlying operating system,
9384 on the exact target in use, this information can be used to determine
9385 the required metrics.
9386
9387 @sp 1
9388 @cartouche
9389 @noindent
9390 @strong{91}. The declarations of @code{Any_Priority} and
9391 @code{Priority}. See D.1(11).
9392 @end cartouche
9393 @noindent
9394 See declarations in file @file{system.ads}.
9395
9396 @sp 1
9397 @cartouche
9398 @noindent
9399 @strong{92}. Implementation-defined execution resources. See D.1(15).
9400 @end cartouche
9401 @noindent
9402 There are no implementation-defined execution resources.
9403
9404 @sp 1
9405 @cartouche
9406 @noindent
9407 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9408 access to a protected object keeps its processor busy. See D.2.1(3).
9409 @end cartouche
9410 @noindent
9411 On a multi-processor, a task that is waiting for access to a protected
9412 object does not keep its processor busy.
9413
9414 @sp 1
9415 @cartouche
9416 @noindent
9417 @strong{94}. The affect of implementation defined execution resources
9418 on task dispatching. See D.2.1(9).
9419 @end cartouche
9420 @noindent
9421 @c SGI info
9422 @ignore
9423 Tasks map to IRIX threads, and the dispatching policy is as defined by
9424 the IRIX implementation of threads.
9425 @end ignore
9426 Tasks map to threads in the threads package used by GNAT@. Where possible
9427 and appropriate, these threads correspond to native threads of the
9428 underlying operating system.
9429
9430 @sp 1
9431 @cartouche
9432 @noindent
9433 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9434 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9435 @end cartouche
9436 @noindent
9437 There are no implementation-defined policy-identifiers allowed in this
9438 pragma.
9439
9440 @sp 1
9441 @cartouche
9442 @noindent
9443 @strong{96}. Implementation-defined aspects of priority inversion. See
9444 D.2.2(16).
9445 @end cartouche
9446 @noindent
9447 Execution of a task cannot be preempted by the implementation processing
9448 of delay expirations for lower priority tasks.
9449
9450 @sp 1
9451 @cartouche
9452 @noindent
9453 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9454 @end cartouche
9455 @noindent
9456 @c SGI info:
9457 @ignore
9458 Tasks map to IRIX threads, and the dispatching policy is as defined by
9459 the IRIX implementation of threads.
9460 @end ignore
9461 The policy is the same as that of the underlying threads implementation.
9462
9463 @sp 1
9464 @cartouche
9465 @noindent
9466 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9467 in a pragma @code{Locking_Policy}. See D.3(4).
9468 @end cartouche
9469 @noindent
9470 The only implementation defined policy permitted in GNAT is
9471 @code{Inheritance_Locking}. On targets that support this policy, locking
9472 is implemented by inheritance, i.e.@: the task owning the lock operates
9473 at a priority equal to the highest priority of any task currently
9474 requesting the lock.
9475
9476 @sp 1
9477 @cartouche
9478 @noindent
9479 @strong{99}. Default ceiling priorities. See D.3(10).
9480 @end cartouche
9481 @noindent
9482 The ceiling priority of protected objects of the type
9483 @code{System.Interrupt_Priority'Last} as described in the Ada
9484 Reference Manual D.3(10),
9485
9486 @sp 1
9487 @cartouche
9488 @noindent
9489 @strong{100}. The ceiling of any protected object used internally by
9490 the implementation. See D.3(16).
9491 @end cartouche
9492 @noindent
9493 The ceiling priority of internal protected objects is
9494 @code{System.Priority'Last}.
9495
9496 @sp 1
9497 @cartouche
9498 @noindent
9499 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9500 @end cartouche
9501 @noindent
9502 There are no implementation-defined queuing policies.
9503
9504 @sp 1
9505 @cartouche
9506 @noindent
9507 @strong{102}. On a multiprocessor, any conditions that cause the
9508 completion of an aborted construct to be delayed later than what is
9509 specified for a single processor. See D.6(3).
9510 @end cartouche
9511 @noindent
9512 The semantics for abort on a multi-processor is the same as on a single
9513 processor, there are no further delays.
9514
9515 @sp 1
9516 @cartouche
9517 @noindent
9518 @strong{103}. Any operations that implicitly require heap storage
9519 allocation. See D.7(8).
9520 @end cartouche
9521 @noindent
9522 The only operation that implicitly requires heap storage allocation is
9523 task creation.
9524
9525 @sp 1
9526 @cartouche
9527 @noindent
9528 @strong{104}. Implementation-defined aspects of pragma
9529 @code{Restrictions}. See D.7(20).
9530 @end cartouche
9531 @noindent
9532 There are no such implementation-defined aspects.
9533
9534 @sp 1
9535 @cartouche
9536 @noindent
9537 @strong{105}. Implementation-defined aspects of package
9538 @code{Real_Time}. See D.8(17).
9539 @end cartouche
9540 @noindent
9541 There are no implementation defined aspects of package @code{Real_Time}.
9542
9543 @sp 1
9544 @cartouche
9545 @noindent
9546 @strong{106}. Implementation-defined aspects of
9547 @code{delay_statements}. See D.9(8).
9548 @end cartouche
9549 @noindent
9550 Any difference greater than one microsecond will cause the task to be
9551 delayed (see D.9(7)).
9552
9553 @sp 1
9554 @cartouche
9555 @noindent
9556 @strong{107}. The upper bound on the duration of interrupt blocking
9557 caused by the implementation. See D.12(5).
9558 @end cartouche
9559 @noindent
9560 The upper bound is determined by the underlying operating system. In
9561 no cases is it more than 10 milliseconds.
9562
9563 @sp 1
9564 @cartouche
9565 @noindent
9566 @strong{108}. The means for creating and executing distributed
9567 programs. See E(5).
9568 @end cartouche
9569 @noindent
9570 The GLADE package provides a utility GNATDIST for creating and executing
9571 distributed programs. See the GLADE reference manual for further details.
9572
9573 @sp 1
9574 @cartouche
9575 @noindent
9576 @strong{109}. Any events that can result in a partition becoming
9577 inaccessible. See E.1(7).
9578 @end cartouche
9579 @noindent
9580 See the GLADE reference manual for full details on such events.
9581
9582 @sp 1
9583 @cartouche
9584 @noindent
9585 @strong{110}. The scheduling policies, treatment of priorities, and
9586 management of shared resources between partitions in certain cases. See
9587 E.1(11).
9588 @end cartouche
9589 @noindent
9590 See the GLADE reference manual for full details on these aspects of
9591 multi-partition execution.
9592
9593 @sp 1
9594 @cartouche
9595 @noindent
9596 @strong{111}. Events that cause the version of a compilation unit to
9597 change. See E.3(5).
9598 @end cartouche
9599 @noindent
9600 Editing the source file of a compilation unit, or the source files of
9601 any units on which it is dependent in a significant way cause the version
9602 to change. No other actions cause the version number to change. All changes
9603 are significant except those which affect only layout, capitalization or
9604 comments.
9605
9606 @sp 1
9607 @cartouche
9608 @noindent
9609 @strong{112}. Whether the execution of the remote subprogram is
9610 immediately aborted as a result of cancellation. See E.4(13).
9611 @end cartouche
9612 @noindent
9613 See the GLADE reference manual for details on the effect of abort in
9614 a distributed application.
9615
9616 @sp 1
9617 @cartouche
9618 @noindent
9619 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9620 @end cartouche
9621 @noindent
9622 See the GLADE reference manual for a full description of all implementation
9623 defined aspects of the PCS@.
9624
9625 @sp 1
9626 @cartouche
9627 @noindent
9628 @strong{114}. Implementation-defined interfaces in the PCS@. See
9629 E.5(26).
9630 @end cartouche
9631 @noindent
9632 See the GLADE reference manual for a full description of all
9633 implementation defined interfaces.
9634
9635 @sp 1
9636 @cartouche
9637 @noindent
9638 @strong{115}. The values of named numbers in the package
9639 @code{Decimal}. See F.2(7).
9640 @end cartouche
9641 @noindent
9642 @table @code
9643 @item Max_Scale
9644 +18
9645 @item Min_Scale
9646 -18
9647 @item Min_Delta
9648 1.0E-18
9649 @item Max_Delta
9650 1.0E+18
9651 @item Max_Decimal_Digits
9652 18
9653 @end table
9654
9655 @sp 1
9656 @cartouche
9657 @noindent
9658 @strong{116}. The value of @code{Max_Picture_Length} in the package
9659 @code{Text_IO.Editing}. See F.3.3(16).
9660 @end cartouche
9661 @noindent
9662 64
9663
9664 @sp 1
9665 @cartouche
9666 @noindent
9667 @strong{117}. The value of @code{Max_Picture_Length} in the package
9668 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9669 @end cartouche
9670 @noindent
9671 64
9672
9673 @sp 1
9674 @cartouche
9675 @noindent
9676 @strong{118}. The accuracy actually achieved by the complex elementary
9677 functions and by other complex arithmetic operations. See G.1(1).
9678 @end cartouche
9679 @noindent
9680 Standard library functions are used for the complex arithmetic
9681 operations. Only fast math mode is currently supported.
9682
9683 @sp 1
9684 @cartouche
9685 @noindent
9686 @strong{119}. The sign of a zero result (or a component thereof) from
9687 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9688 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9689 @end cartouche
9690 @noindent
9691 The signs of zero values are as recommended by the relevant
9692 implementation advice.
9693
9694 @sp 1
9695 @cartouche
9696 @noindent
9697 @strong{120}. The sign of a zero result (or a component thereof) from
9698 any operator or function in
9699 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9700 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9701 @end cartouche
9702 @noindent
9703 The signs of zero values are as recommended by the relevant
9704 implementation advice.
9705
9706 @sp 1
9707 @cartouche
9708 @noindent
9709 @strong{121}. Whether the strict mode or the relaxed mode is the
9710 default. See G.2(2).
9711 @end cartouche
9712 @noindent
9713 The strict mode is the default. There is no separate relaxed mode. GNAT
9714 provides a highly efficient implementation of strict mode.
9715
9716 @sp 1
9717 @cartouche
9718 @noindent
9719 @strong{122}. The result interval in certain cases of fixed-to-float
9720 conversion. See G.2.1(10).
9721 @end cartouche
9722 @noindent
9723 For cases where the result interval is implementation dependent, the
9724 accuracy is that provided by performing all operations in 64-bit IEEE
9725 floating-point format.
9726
9727 @sp 1
9728 @cartouche
9729 @noindent
9730 @strong{123}. The result of a floating point arithmetic operation in
9731 overflow situations, when the @code{Machine_Overflows} attribute of the
9732 result type is @code{False}. See G.2.1(13).
9733 @end cartouche
9734 @noindent
9735 Infinite and NaN values are produced as dictated by the IEEE
9736 floating-point standard.
9737
9738 Note that on machines that are not fully compliant with the IEEE
9739 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9740 must be used for achieving IEEE confirming behavior (although at the cost
9741 of a significant performance penalty), so infinite and NaN values are
9742 properly generated.
9743
9744 @sp 1
9745 @cartouche
9746 @noindent
9747 @strong{124}. The result interval for division (or exponentiation by a
9748 negative exponent), when the floating point hardware implements division
9749 as multiplication by a reciprocal. See G.2.1(16).
9750 @end cartouche
9751 @noindent
9752 Not relevant, division is IEEE exact.
9753
9754 @sp 1
9755 @cartouche
9756 @noindent
9757 @strong{125}. The definition of close result set, which determines the
9758 accuracy of certain fixed point multiplications and divisions. See
9759 G.2.3(5).
9760 @end cartouche
9761 @noindent
9762 Operations in the close result set are performed using IEEE long format
9763 floating-point arithmetic. The input operands are converted to
9764 floating-point, the operation is done in floating-point, and the result
9765 is converted to the target type.
9766
9767 @sp 1
9768 @cartouche
9769 @noindent
9770 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9771 point multiplication or division for which the result shall be in the
9772 perfect result set. See G.2.3(22).
9773 @end cartouche
9774 @noindent
9775 The result is only defined to be in the perfect result set if the result
9776 can be computed by a single scaling operation involving a scale factor
9777 representable in 64-bits.
9778
9779 @sp 1
9780 @cartouche
9781 @noindent
9782 @strong{127}. The result of a fixed point arithmetic operation in
9783 overflow situations, when the @code{Machine_Overflows} attribute of the
9784 result type is @code{False}. See G.2.3(27).
9785 @end cartouche
9786 @noindent
9787 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9788 types.
9789
9790 @sp 1
9791 @cartouche
9792 @noindent
9793 @strong{128}. The result of an elementary function reference in
9794 overflow situations, when the @code{Machine_Overflows} attribute of the
9795 result type is @code{False}. See G.2.4(4).
9796 @end cartouche
9797 @noindent
9798 IEEE infinite and Nan values are produced as appropriate.
9799
9800 @sp 1
9801 @cartouche
9802 @noindent
9803 @strong{129}. The value of the angle threshold, within which certain
9804 elementary functions, complex arithmetic operations, and complex
9805 elementary functions yield results conforming to a maximum relative
9806 error bound. See G.2.4(10).
9807 @end cartouche
9808 @noindent
9809 Information on this subject is not yet available.
9810
9811 @sp 1
9812 @cartouche
9813 @noindent
9814 @strong{130}. The accuracy of certain elementary functions for
9815 parameters beyond the angle threshold. See G.2.4(10).
9816 @end cartouche
9817 @noindent
9818 Information on this subject is not yet available.
9819
9820 @sp 1
9821 @cartouche
9822 @noindent
9823 @strong{131}. The result of a complex arithmetic operation or complex
9824 elementary function reference in overflow situations, when the
9825 @code{Machine_Overflows} attribute of the corresponding real type is
9826 @code{False}. See G.2.6(5).
9827 @end cartouche
9828 @noindent
9829 IEEE infinite and Nan values are produced as appropriate.
9830
9831 @sp 1
9832 @cartouche
9833 @noindent
9834 @strong{132}. The accuracy of certain complex arithmetic operations and
9835 certain complex elementary functions for parameters (or components
9836 thereof) beyond the angle threshold. See G.2.6(8).
9837 @end cartouche
9838 @noindent
9839 Information on those subjects is not yet available.
9840
9841 @sp 1
9842 @cartouche
9843 @noindent
9844 @strong{133}. Information regarding bounded errors and erroneous
9845 execution. See H.2(1).
9846 @end cartouche
9847 @noindent
9848 Information on this subject is not yet available.
9849
9850 @sp 1
9851 @cartouche
9852 @noindent
9853 @strong{134}. Implementation-defined aspects of pragma
9854 @code{Inspection_Point}. See H.3.2(8).
9855 @end cartouche
9856 @noindent
9857 Pragma @code{Inspection_Point} ensures that the variable is live and can
9858 be examined by the debugger at the inspection point.
9859
9860 @sp 1
9861 @cartouche
9862 @noindent
9863 @strong{135}. Implementation-defined aspects of pragma
9864 @code{Restrictions}. See H.4(25).
9865 @end cartouche
9866 @noindent
9867 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9868 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9869 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9870
9871 @sp 1
9872 @cartouche
9873 @noindent
9874 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9875 H.4(27).
9876 @end cartouche
9877 @noindent
9878 There are no restrictions on pragma @code{Restrictions}.
9879
9880 @node Intrinsic Subprograms
9881 @chapter Intrinsic Subprograms
9882 @cindex Intrinsic Subprograms
9883
9884 @menu
9885 * Intrinsic Operators::
9886 * Enclosing_Entity::
9887 * Exception_Information::
9888 * Exception_Message::
9889 * Exception_Name::
9890 * File::
9891 * Line::
9892 * Rotate_Left::
9893 * Rotate_Right::
9894 * Shift_Left::
9895 * Shift_Right::
9896 * Shift_Right_Arithmetic::
9897 * Source_Location::
9898 @end menu
9899
9900 @noindent
9901 GNAT allows a user application program to write the declaration:
9902
9903 @smallexample @c ada
9904 pragma Import (Intrinsic, name);
9905 @end smallexample
9906
9907 @noindent
9908 providing that the name corresponds to one of the implemented intrinsic
9909 subprograms in GNAT, and that the parameter profile of the referenced
9910 subprogram meets the requirements. This chapter describes the set of
9911 implemented intrinsic subprograms, and the requirements on parameter profiles.
9912 Note that no body is supplied; as with other uses of pragma Import, the
9913 body is supplied elsewhere (in this case by the compiler itself). Note
9914 that any use of this feature is potentially non-portable, since the
9915 Ada standard does not require Ada compilers to implement this feature.
9916
9917 @node Intrinsic Operators
9918 @section Intrinsic Operators
9919 @cindex Intrinsic operator
9920
9921 @noindent
9922 All the predefined numeric operators in package Standard
9923 in @code{pragma Import (Intrinsic,..)}
9924 declarations. In the binary operator case, the operands must have the same
9925 size. The operand or operands must also be appropriate for
9926 the operator. For example, for addition, the operands must
9927 both be floating-point or both be fixed-point, and the
9928 right operand for @code{"**"} must have a root type of
9929 @code{Standard.Integer'Base}.
9930 You can use an intrinsic operator declaration as in the following example:
9931
9932 @smallexample @c ada
9933 type Int1 is new Integer;
9934 type Int2 is new Integer;
9935
9936 function "+" (X1 : Int1; X2 : Int2) return Int1;
9937 function "+" (X1 : Int1; X2 : Int2) return Int2;
9938 pragma Import (Intrinsic, "+");
9939 @end smallexample
9940
9941 @noindent
9942 This declaration would permit ``mixed mode'' arithmetic on items
9943 of the differing types @code{Int1} and @code{Int2}.
9944 It is also possible to specify such operators for private types, if the
9945 full views are appropriate arithmetic types.
9946
9947 @node Enclosing_Entity
9948 @section Enclosing_Entity
9949 @cindex Enclosing_Entity
9950 @noindent
9951 This intrinsic subprogram is used in the implementation of the
9952 library routine @code{GNAT.Source_Info}. The only useful use of the
9953 intrinsic import in this case is the one in this unit, so an
9954 application program should simply call the function
9955 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9956 the current subprogram, package, task, entry, or protected subprogram.
9957
9958 @node Exception_Information
9959 @section Exception_Information
9960 @cindex Exception_Information'
9961 @noindent
9962 This intrinsic subprogram is used in the implementation of the
9963 library routine @code{GNAT.Current_Exception}. The only useful
9964 use of the intrinsic import in this case is the one in this unit,
9965 so an application program should simply call the function
9966 @code{GNAT.Current_Exception.Exception_Information} to obtain
9967 the exception information associated with the current exception.
9968
9969 @node Exception_Message
9970 @section Exception_Message
9971 @cindex Exception_Message
9972 @noindent
9973 This intrinsic subprogram is used in the implementation of the
9974 library routine @code{GNAT.Current_Exception}. The only useful
9975 use of the intrinsic import in this case is the one in this unit,
9976 so an application program should simply call the function
9977 @code{GNAT.Current_Exception.Exception_Message} to obtain
9978 the message associated with the current exception.
9979
9980 @node Exception_Name
9981 @section Exception_Name
9982 @cindex Exception_Name
9983 @noindent
9984 This intrinsic subprogram is used in the implementation of the
9985 library routine @code{GNAT.Current_Exception}. The only useful
9986 use of the intrinsic import in this case is the one in this unit,
9987 so an application program should simply call the function
9988 @code{GNAT.Current_Exception.Exception_Name} to obtain
9989 the name of the current exception.
9990
9991 @node File
9992 @section File
9993 @cindex File
9994 @noindent
9995 This intrinsic subprogram is used in the implementation of the
9996 library routine @code{GNAT.Source_Info}. The only useful use of the
9997 intrinsic import in this case is the one in this unit, so an
9998 application program should simply call the function
9999 @code{GNAT.Source_Info.File} to obtain the name of the current
10000 file.
10001
10002 @node Line
10003 @section Line
10004 @cindex Line
10005 @noindent
10006 This intrinsic subprogram is used in the implementation of the
10007 library routine @code{GNAT.Source_Info}. The only useful use of the
10008 intrinsic import in this case is the one in this unit, so an
10009 application program should simply call the function
10010 @code{GNAT.Source_Info.Line} to obtain the number of the current
10011 source line.
10012
10013 @node Rotate_Left
10014 @section Rotate_Left
10015 @cindex Rotate_Left
10016 @noindent
10017 In standard Ada, the @code{Rotate_Left} function is available only
10018 for the predefined modular types in package @code{Interfaces}. However, in
10019 GNAT it is possible to define a Rotate_Left function for a user
10020 defined modular type or any signed integer type as in this example:
10021
10022 @smallexample @c ada
10023 function Shift_Left
10024 (Value : My_Modular_Type;
10025 Amount : Natural)
10026 return My_Modular_Type;
10027 @end smallexample
10028
10029 @noindent
10030 The requirements are that the profile be exactly as in the example
10031 above. The only modifications allowed are in the formal parameter
10032 names, and in the type of @code{Value} and the return type, which
10033 must be the same, and must be either a signed integer type, or
10034 a modular integer type with a binary modulus, and the size must
10035 be 8. 16, 32 or 64 bits.
10036
10037 @node Rotate_Right
10038 @section Rotate_Right
10039 @cindex Rotate_Right
10040 @noindent
10041 A @code{Rotate_Right} function can be defined for any user defined
10042 binary modular integer type, or signed integer type, as described
10043 above for @code{Rotate_Left}.
10044
10045 @node Shift_Left
10046 @section Shift_Left
10047 @cindex Shift_Left
10048 @noindent
10049 A @code{Shift_Left} function can be defined for any user defined
10050 binary modular integer type, or signed integer type, as described
10051 above for @code{Rotate_Left}.
10052
10053 @node Shift_Right
10054 @section Shift_Right
10055 @cindex Shift_Right
10056 @noindent
10057 A @code{Shift_Right} function can be defined for any user defined
10058 binary modular integer type, or signed integer type, as described
10059 above for @code{Rotate_Left}.
10060
10061 @node Shift_Right_Arithmetic
10062 @section Shift_Right_Arithmetic
10063 @cindex Shift_Right_Arithmetic
10064 @noindent
10065 A @code{Shift_Right_Arithmetic} function can be defined for any user
10066 defined binary modular integer type, or signed integer type, as described
10067 above for @code{Rotate_Left}.
10068
10069 @node Source_Location
10070 @section Source_Location
10071 @cindex Source_Location
10072 @noindent
10073 This intrinsic subprogram is used in the implementation of the
10074 library routine @code{GNAT.Source_Info}. The only useful use of the
10075 intrinsic import in this case is the one in this unit, so an
10076 application program should simply call the function
10077 @code{GNAT.Source_Info.Source_Location} to obtain the current
10078 source file location.
10079
10080 @node Representation Clauses and Pragmas
10081 @chapter Representation Clauses and Pragmas
10082 @cindex Representation Clauses
10083
10084 @menu
10085 * Alignment Clauses::
10086 * Size Clauses::
10087 * Storage_Size Clauses::
10088 * Size of Variant Record Objects::
10089 * Biased Representation ::
10090 * Value_Size and Object_Size Clauses::
10091 * Component_Size Clauses::
10092 * Bit_Order Clauses::
10093 * Effect of Bit_Order on Byte Ordering::
10094 * Pragma Pack for Arrays::
10095 * Pragma Pack for Records::
10096 * Record Representation Clauses::
10097 * Enumeration Clauses::
10098 * Address Clauses::
10099 * Effect of Convention on Representation::
10100 * Determining the Representations chosen by GNAT::
10101 @end menu
10102
10103 @noindent
10104 @cindex Representation Clause
10105 @cindex Representation Pragma
10106 @cindex Pragma, representation
10107 This section describes the representation clauses accepted by GNAT, and
10108 their effect on the representation of corresponding data objects.
10109
10110 GNAT fully implements Annex C (Systems Programming). This means that all
10111 the implementation advice sections in chapter 13 are fully implemented.
10112 However, these sections only require a minimal level of support for
10113 representation clauses. GNAT provides much more extensive capabilities,
10114 and this section describes the additional capabilities provided.
10115
10116 @node Alignment Clauses
10117 @section Alignment Clauses
10118 @cindex Alignment Clause
10119
10120 @noindent
10121 GNAT requires that all alignment clauses specify a power of 2, and all
10122 default alignments are always a power of 2. The default alignment
10123 values are as follows:
10124
10125 @itemize @bullet
10126 @item @emph{Primitive Types}.
10127 For primitive types, the alignment is the minimum of the actual size of
10128 objects of the type divided by @code{Storage_Unit},
10129 and the maximum alignment supported by the target.
10130 (This maximum alignment is given by the GNAT-specific attribute
10131 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10132 @cindex @code{Maximum_Alignment} attribute
10133 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10134 default alignment will be 8 on any target that supports alignments
10135 this large, but on some targets, the maximum alignment may be smaller
10136 than 8, in which case objects of type @code{Long_Float} will be maximally
10137 aligned.
10138
10139 @item @emph{Arrays}.
10140 For arrays, the alignment is equal to the alignment of the component type
10141 for the normal case where no packing or component size is given. If the
10142 array is packed, and the packing is effective (see separate section on
10143 packed arrays), then the alignment will be one for long packed arrays,
10144 or arrays whose length is not known at compile time. For short packed
10145 arrays, which are handled internally as modular types, the alignment
10146 will be as described for primitive types, e.g.@: a packed array of length
10147 31 bits will have an object size of four bytes, and an alignment of 4.
10148
10149 @item @emph{Records}.
10150 For the normal non-packed case, the alignment of a record is equal to
10151 the maximum alignment of any of its components. For tagged records, this
10152 includes the implicit access type used for the tag. If a pragma @code{Pack}
10153 is used and all components are packable (see separate section on pragma
10154 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10155 record makes it profitable to increase it.
10156
10157 A special case is when:
10158 @itemize @bullet
10159 @item
10160 the size of the record is given explicitly, or a
10161 full record representation clause is given, and
10162 @item
10163 the size of the record is 2, 4, or 8 bytes.
10164 @end itemize
10165 @noindent
10166 In this case, an alignment is chosen to match the
10167 size of the record. For example, if we have:
10168
10169 @smallexample @c ada
10170 type Small is record
10171 A, B : Character;
10172 end record;
10173 for Small'Size use 16;
10174 @end smallexample
10175
10176 @noindent
10177 then the default alignment of the record type @code{Small} is 2, not 1. This
10178 leads to more efficient code when the record is treated as a unit, and also
10179 allows the type to specified as @code{Atomic} on architectures requiring
10180 strict alignment.
10181
10182 @end itemize
10183
10184 @noindent
10185 An alignment clause may specify a larger alignment than the default value
10186 up to some maximum value dependent on the target (obtainable by using the
10187 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10188 a smaller alignment than the default value for enumeration, integer and
10189 fixed point types, as well as for record types, for example
10190
10191 @smallexample @c ada
10192 type V is record
10193 A : Integer;
10194 end record;
10195
10196 for V'alignment use 1;
10197 @end smallexample
10198
10199 @noindent
10200 @cindex Alignment, default
10201 The default alignment for the type @code{V} is 4, as a result of the
10202 Integer field in the record, but it is permissible, as shown, to
10203 override the default alignment of the record with a smaller value.
10204
10205 @node Size Clauses
10206 @section Size Clauses
10207 @cindex Size Clause
10208
10209 @noindent
10210 The default size for a type @code{T} is obtainable through the
10211 language-defined attribute @code{T'Size} and also through the
10212 equivalent GNAT-defined attribute @code{T'Value_Size}.
10213 For objects of type @code{T}, GNAT will generally increase the type size
10214 so that the object size (obtainable through the GNAT-defined attribute
10215 @code{T'Object_Size})
10216 is a multiple of @code{T'Alignment * Storage_Unit}.
10217 For example
10218
10219 @smallexample @c ada
10220 type Smallint is range 1 .. 6;
10221
10222 type Rec is record
10223 Y1 : integer;
10224 Y2 : boolean;
10225 end record;
10226 @end smallexample
10227
10228 @noindent
10229 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10230 as specified by the RM rules,
10231 but objects of this type will have a size of 8
10232 (@code{Smallint'Object_Size} = 8),
10233 since objects by default occupy an integral number
10234 of storage units. On some targets, notably older
10235 versions of the Digital Alpha, the size of stand
10236 alone objects of this type may be 32, reflecting
10237 the inability of the hardware to do byte load/stores.
10238
10239 Similarly, the size of type @code{Rec} is 40 bits
10240 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10241 the alignment is 4, so objects of this type will have
10242 their size increased to 64 bits so that it is a multiple
10243 of the alignment (in bits). This decision is
10244 in accordance with the specific Implementation Advice in RM 13.3(43):
10245
10246 @quotation
10247 A @code{Size} clause should be supported for an object if the specified
10248 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10249 to a size in storage elements that is a multiple of the object's
10250 @code{Alignment} (if the @code{Alignment} is nonzero).
10251 @end quotation
10252
10253 @noindent
10254 An explicit size clause may be used to override the default size by
10255 increasing it. For example, if we have:
10256
10257 @smallexample @c ada
10258 type My_Boolean is new Boolean;
10259 for My_Boolean'Size use 32;
10260 @end smallexample
10261
10262 @noindent
10263 then values of this type will always be 32 bits long. In the case of
10264 discrete types, the size can be increased up to 64 bits, with the effect
10265 that the entire specified field is used to hold the value, sign- or
10266 zero-extended as appropriate. If more than 64 bits is specified, then
10267 padding space is allocated after the value, and a warning is issued that
10268 there are unused bits.
10269
10270 Similarly the size of records and arrays may be increased, and the effect
10271 is to add padding bits after the value. This also causes a warning message
10272 to be generated.
10273
10274 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10275 Size in bits, this corresponds to an object of size 256 megabytes (minus
10276 one). This limitation is true on all targets. The reason for this
10277 limitation is that it improves the quality of the code in many cases
10278 if it is known that a Size value can be accommodated in an object of
10279 type Integer.
10280
10281 @node Storage_Size Clauses
10282 @section Storage_Size Clauses
10283 @cindex Storage_Size Clause
10284
10285 @noindent
10286 For tasks, the @code{Storage_Size} clause specifies the amount of space
10287 to be allocated for the task stack. This cannot be extended, and if the
10288 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10289 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10290 or a @code{Storage_Size} pragma in the task definition to set the
10291 appropriate required size. A useful technique is to include in every
10292 task definition a pragma of the form:
10293
10294 @smallexample @c ada
10295 pragma Storage_Size (Default_Stack_Size);
10296 @end smallexample
10297
10298 @noindent
10299 Then @code{Default_Stack_Size} can be defined in a global package, and
10300 modified as required. Any tasks requiring stack sizes different from the
10301 default can have an appropriate alternative reference in the pragma.
10302
10303 You can also use the @option{-d} binder switch to modify the default stack
10304 size.
10305
10306 For access types, the @code{Storage_Size} clause specifies the maximum
10307 space available for allocation of objects of the type. If this space is
10308 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10309 In the case where the access type is declared local to a subprogram, the
10310 use of a @code{Storage_Size} clause triggers automatic use of a special
10311 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10312 space for the pool is automatically reclaimed on exit from the scope in
10313 which the type is declared.
10314
10315 A special case recognized by the compiler is the specification of a
10316 @code{Storage_Size} of zero for an access type. This means that no
10317 items can be allocated from the pool, and this is recognized at compile
10318 time, and all the overhead normally associated with maintaining a fixed
10319 size storage pool is eliminated. Consider the following example:
10320
10321 @smallexample @c ada
10322 procedure p is
10323 type R is array (Natural) of Character;
10324 type P is access all R;
10325 for P'Storage_Size use 0;
10326 -- Above access type intended only for interfacing purposes
10327
10328 y : P;
10329
10330 procedure g (m : P);
10331 pragma Import (C, g);
10332
10333 -- @dots{}
10334
10335 begin
10336 -- @dots{}
10337 y := new R;
10338 end;
10339 @end smallexample
10340
10341 @noindent
10342 As indicated in this example, these dummy storage pools are often useful in
10343 connection with interfacing where no object will ever be allocated. If you
10344 compile the above example, you get the warning:
10345
10346 @smallexample
10347 p.adb:16:09: warning: allocation from empty storage pool
10348 p.adb:16:09: warning: Storage_Error will be raised at run time
10349 @end smallexample
10350
10351 @noindent
10352 Of course in practice, there will not be any explicit allocators in the
10353 case of such an access declaration.
10354
10355 @node Size of Variant Record Objects
10356 @section Size of Variant Record Objects
10357 @cindex Size, variant record objects
10358 @cindex Variant record objects, size
10359
10360 @noindent
10361 In the case of variant record objects, there is a question whether Size gives
10362 information about a particular variant, or the maximum size required
10363 for any variant. Consider the following program
10364
10365 @smallexample @c ada
10366 with Text_IO; use Text_IO;
10367 procedure q is
10368 type R1 (A : Boolean := False) is record
10369 case A is
10370 when True => X : Character;
10371 when False => null;
10372 end case;
10373 end record;
10374
10375 V1 : R1 (False);
10376 V2 : R1;
10377
10378 begin
10379 Put_Line (Integer'Image (V1'Size));
10380 Put_Line (Integer'Image (V2'Size));
10381 end q;
10382 @end smallexample
10383
10384 @noindent
10385 Here we are dealing with a variant record, where the True variant
10386 requires 16 bits, and the False variant requires 8 bits.
10387 In the above example, both V1 and V2 contain the False variant,
10388 which is only 8 bits long. However, the result of running the
10389 program is:
10390
10391 @smallexample
10392 8
10393 16
10394 @end smallexample
10395
10396 @noindent
10397 The reason for the difference here is that the discriminant value of
10398 V1 is fixed, and will always be False. It is not possible to assign
10399 a True variant value to V1, therefore 8 bits is sufficient. On the
10400 other hand, in the case of V2, the initial discriminant value is
10401 False (from the default), but it is possible to assign a True
10402 variant value to V2, therefore 16 bits must be allocated for V2
10403 in the general case, even fewer bits may be needed at any particular
10404 point during the program execution.
10405
10406 As can be seen from the output of this program, the @code{'Size}
10407 attribute applied to such an object in GNAT gives the actual allocated
10408 size of the variable, which is the largest size of any of the variants.
10409 The Ada Reference Manual is not completely clear on what choice should
10410 be made here, but the GNAT behavior seems most consistent with the
10411 language in the RM@.
10412
10413 In some cases, it may be desirable to obtain the size of the current
10414 variant, rather than the size of the largest variant. This can be
10415 achieved in GNAT by making use of the fact that in the case of a
10416 subprogram parameter, GNAT does indeed return the size of the current
10417 variant (because a subprogram has no way of knowing how much space
10418 is actually allocated for the actual).
10419
10420 Consider the following modified version of the above program:
10421
10422 @smallexample @c ada
10423 with Text_IO; use Text_IO;
10424 procedure q is
10425 type R1 (A : Boolean := False) is record
10426 case A is
10427 when True => X : Character;
10428 when False => null;
10429 end case;
10430 end record;
10431
10432 V2 : R1;
10433
10434 function Size (V : R1) return Integer is
10435 begin
10436 return V'Size;
10437 end Size;
10438
10439 begin
10440 Put_Line (Integer'Image (V2'Size));
10441 Put_Line (Integer'IMage (Size (V2)));
10442 V2 := (True, 'x');
10443 Put_Line (Integer'Image (V2'Size));
10444 Put_Line (Integer'IMage (Size (V2)));
10445 end q;
10446 @end smallexample
10447
10448 @noindent
10449 The output from this program is
10450
10451 @smallexample
10452 16
10453 8
10454 16
10455 16
10456 @end smallexample
10457
10458 @noindent
10459 Here we see that while the @code{'Size} attribute always returns
10460 the maximum size, regardless of the current variant value, the
10461 @code{Size} function does indeed return the size of the current
10462 variant value.
10463
10464 @node Biased Representation
10465 @section Biased Representation
10466 @cindex Size for biased representation
10467 @cindex Biased representation
10468
10469 @noindent
10470 In the case of scalars with a range starting at other than zero, it is
10471 possible in some cases to specify a size smaller than the default minimum
10472 value, and in such cases, GNAT uses an unsigned biased representation,
10473 in which zero is used to represent the lower bound, and successive values
10474 represent successive values of the type.
10475
10476 For example, suppose we have the declaration:
10477
10478 @smallexample @c ada
10479 type Small is range -7 .. -4;
10480 for Small'Size use 2;
10481 @end smallexample
10482
10483 @noindent
10484 Although the default size of type @code{Small} is 4, the @code{Size}
10485 clause is accepted by GNAT and results in the following representation
10486 scheme:
10487
10488 @smallexample
10489 -7 is represented as 2#00#
10490 -6 is represented as 2#01#
10491 -5 is represented as 2#10#
10492 -4 is represented as 2#11#
10493 @end smallexample
10494
10495 @noindent
10496 Biased representation is only used if the specified @code{Size} clause
10497 cannot be accepted in any other manner. These reduced sizes that force
10498 biased representation can be used for all discrete types except for
10499 enumeration types for which a representation clause is given.
10500
10501 @node Value_Size and Object_Size Clauses
10502 @section Value_Size and Object_Size Clauses
10503 @findex Value_Size
10504 @findex Object_Size
10505 @cindex Size, of objects
10506
10507 @noindent
10508 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10509 number of bits required to hold values of type @code{T}.
10510 Although this interpretation was allowed in Ada 83, it was not required,
10511 and this requirement in practice can cause some significant difficulties.
10512 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10513 However, in Ada 95 and Ada 2005,
10514 @code{Natural'Size} is
10515 typically 31. This means that code may change in behavior when moving
10516 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10517
10518 @smallexample @c ada
10519 type Rec is record;
10520 A : Natural;
10521 B : Natural;
10522 end record;
10523
10524 for Rec use record
10525 at 0 range 0 .. Natural'Size - 1;
10526 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10527 end record;
10528 @end smallexample
10529
10530 @noindent
10531 In the above code, since the typical size of @code{Natural} objects
10532 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10533 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10534 there are cases where the fact that the object size can exceed the
10535 size of the type causes surprises.
10536
10537 To help get around this problem GNAT provides two implementation
10538 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10539 applied to a type, these attributes yield the size of the type
10540 (corresponding to the RM defined size attribute), and the size of
10541 objects of the type respectively.
10542
10543 The @code{Object_Size} is used for determining the default size of
10544 objects and components. This size value can be referred to using the
10545 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10546 the basis of the determination of the size. The backend is free to
10547 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10548 character might be stored in 32 bits on a machine with no efficient
10549 byte access instructions such as the Alpha.
10550
10551 The default rules for the value of @code{Object_Size} for
10552 discrete types are as follows:
10553
10554 @itemize @bullet
10555 @item
10556 The @code{Object_Size} for base subtypes reflect the natural hardware
10557 size in bits (run the compiler with @option{-gnatS} to find those values
10558 for numeric types). Enumeration types and fixed-point base subtypes have
10559 8, 16, 32 or 64 bits for this size, depending on the range of values
10560 to be stored.
10561
10562 @item
10563 The @code{Object_Size} of a subtype is the same as the
10564 @code{Object_Size} of
10565 the type from which it is obtained.
10566
10567 @item
10568 The @code{Object_Size} of a derived base type is copied from the parent
10569 base type, and the @code{Object_Size} of a derived first subtype is copied
10570 from the parent first subtype.
10571 @end itemize
10572
10573 @noindent
10574 The @code{Value_Size} attribute
10575 is the (minimum) number of bits required to store a value
10576 of the type.
10577 This value is used to determine how tightly to pack
10578 records or arrays with components of this type, and also affects
10579 the semantics of unchecked conversion (unchecked conversions where
10580 the @code{Value_Size} values differ generate a warning, and are potentially
10581 target dependent).
10582
10583 The default rules for the value of @code{Value_Size} are as follows:
10584
10585 @itemize @bullet
10586 @item
10587 The @code{Value_Size} for a base subtype is the minimum number of bits
10588 required to store all values of the type (including the sign bit
10589 only if negative values are possible).
10590
10591 @item
10592 If a subtype statically matches the first subtype of a given type, then it has
10593 by default the same @code{Value_Size} as the first subtype. This is a
10594 consequence of RM 13.1(14) (``if two subtypes statically match,
10595 then their subtype-specific aspects are the same''.)
10596
10597 @item
10598 All other subtypes have a @code{Value_Size} corresponding to the minimum
10599 number of bits required to store all values of the subtype. For
10600 dynamic bounds, it is assumed that the value can range down or up
10601 to the corresponding bound of the ancestor
10602 @end itemize
10603
10604 @noindent
10605 The RM defined attribute @code{Size} corresponds to the
10606 @code{Value_Size} attribute.
10607
10608 The @code{Size} attribute may be defined for a first-named subtype. This sets
10609 the @code{Value_Size} of
10610 the first-named subtype to the given value, and the
10611 @code{Object_Size} of this first-named subtype to the given value padded up
10612 to an appropriate boundary. It is a consequence of the default rules
10613 above that this @code{Object_Size} will apply to all further subtypes. On the
10614 other hand, @code{Value_Size} is affected only for the first subtype, any
10615 dynamic subtypes obtained from it directly, and any statically matching
10616 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10617
10618 @code{Value_Size} and
10619 @code{Object_Size} may be explicitly set for any subtype using
10620 an attribute definition clause. Note that the use of these attributes
10621 can cause the RM 13.1(14) rule to be violated. If two access types
10622 reference aliased objects whose subtypes have differing @code{Object_Size}
10623 values as a result of explicit attribute definition clauses, then it
10624 is erroneous to convert from one access subtype to the other.
10625
10626 At the implementation level, Esize stores the Object_Size and the
10627 RM_Size field stores the @code{Value_Size} (and hence the value of the
10628 @code{Size} attribute,
10629 which, as noted above, is equivalent to @code{Value_Size}).
10630
10631 To get a feel for the difference, consider the following examples (note
10632 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10633
10634 @smallexample
10635 Object_Size Value_Size
10636
10637 type x1 is range 0 .. 5; 8 3
10638
10639 type x2 is range 0 .. 5;
10640 for x2'size use 12; 16 12
10641
10642 subtype x3 is x2 range 0 .. 3; 16 2
10643
10644 subtype x4 is x2'base range 0 .. 10; 8 4
10645
10646 subtype x5 is x2 range 0 .. dynamic; 16 3*
10647
10648 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10649
10650 @end smallexample
10651
10652 @noindent
10653 Note: the entries marked ``3*'' are not actually specified by the Ada
10654 Reference Manual, but it seems in the spirit of the RM rules to allocate
10655 the minimum number of bits (here 3, given the range for @code{x2})
10656 known to be large enough to hold the given range of values.
10657
10658 So far, so good, but GNAT has to obey the RM rules, so the question is
10659 under what conditions must the RM @code{Size} be used.
10660 The following is a list
10661 of the occasions on which the RM @code{Size} must be used:
10662
10663 @itemize @bullet
10664 @item
10665 Component size for packed arrays or records
10666
10667 @item
10668 Value of the attribute @code{Size} for a type
10669
10670 @item
10671 Warning about sizes not matching for unchecked conversion
10672 @end itemize
10673
10674 @noindent
10675 For record types, the @code{Object_Size} is always a multiple of the
10676 alignment of the type (this is true for all types). In some cases the
10677 @code{Value_Size} can be smaller. Consider:
10678
10679 @smallexample
10680 type R is record
10681 X : Integer;
10682 Y : Character;
10683 end record;
10684 @end smallexample
10685
10686 @noindent
10687 On a typical 32-bit architecture, the X component will be four bytes, and
10688 require four-byte alignment, and the Y component will be one byte. In this
10689 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10690 required to store a value of this type, and for example, it is permissible
10691 to have a component of type R in an outer array whose component size is
10692 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10693 since it must be rounded up so that this value is a multiple of the
10694 alignment (4 bytes = 32 bits).
10695
10696 @noindent
10697 For all other types, the @code{Object_Size}
10698 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10699 Only @code{Size} may be specified for such types.
10700
10701 @node Component_Size Clauses
10702 @section Component_Size Clauses
10703 @cindex Component_Size Clause
10704
10705 @noindent
10706 Normally, the value specified in a component size clause must be consistent
10707 with the subtype of the array component with regard to size and alignment.
10708 In other words, the value specified must be at least equal to the size
10709 of this subtype, and must be a multiple of the alignment value.
10710
10711 In addition, component size clauses are allowed which cause the array
10712 to be packed, by specifying a smaller value. A first case is for
10713 component size values in the range 1 through 63. The value specified
10714 must not be smaller than the Size of the subtype. GNAT will accurately
10715 honor all packing requests in this range. For example, if we have:
10716
10717 @smallexample @c ada
10718 type r is array (1 .. 8) of Natural;
10719 for r'Component_Size use 31;
10720 @end smallexample
10721
10722 @noindent
10723 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10724 Of course access to the components of such an array is considerably
10725 less efficient than if the natural component size of 32 is used.
10726 A second case is when the subtype of the component is a record type
10727 padded because of its default alignment. For example, if we have:
10728
10729 @smallexample @c ada
10730 type r is record
10731 i : Integer;
10732 j : Integer;
10733 b : Boolean;
10734 end record;
10735
10736 type a is array (1 .. 8) of r;
10737 for a'Component_Size use 72;
10738 @end smallexample
10739
10740 @noindent
10741 then the resulting array has a length of 72 bytes, instead of 96 bytes
10742 if the alignment of the record (4) was obeyed.
10743
10744 Note that there is no point in giving both a component size clause
10745 and a pragma Pack for the same array type. if such duplicate
10746 clauses are given, the pragma Pack will be ignored.
10747
10748 @node Bit_Order Clauses
10749 @section Bit_Order Clauses
10750 @cindex Bit_Order Clause
10751 @cindex bit ordering
10752 @cindex ordering, of bits
10753
10754 @noindent
10755 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10756 attribute. The specification may either correspond to the default bit
10757 order for the target, in which case the specification has no effect and
10758 places no additional restrictions, or it may be for the non-standard
10759 setting (that is the opposite of the default).
10760
10761 In the case where the non-standard value is specified, the effect is
10762 to renumber bits within each byte, but the ordering of bytes is not
10763 affected. There are certain
10764 restrictions placed on component clauses as follows:
10765
10766 @itemize @bullet
10767
10768 @item Components fitting within a single storage unit.
10769 @noindent
10770 These are unrestricted, and the effect is merely to renumber bits. For
10771 example if we are on a little-endian machine with @code{Low_Order_First}
10772 being the default, then the following two declarations have exactly
10773 the same effect:
10774
10775 @smallexample @c ada
10776 type R1 is record
10777 A : Boolean;
10778 B : Integer range 1 .. 120;
10779 end record;
10780
10781 for R1 use record
10782 A at 0 range 0 .. 0;
10783 B at 0 range 1 .. 7;
10784 end record;
10785
10786 type R2 is record
10787 A : Boolean;
10788 B : Integer range 1 .. 120;
10789 end record;
10790
10791 for R2'Bit_Order use High_Order_First;
10792
10793 for R2 use record
10794 A at 0 range 7 .. 7;
10795 B at 0 range 0 .. 6;
10796 end record;
10797 @end smallexample
10798
10799 @noindent
10800 The useful application here is to write the second declaration with the
10801 @code{Bit_Order} attribute definition clause, and know that it will be treated
10802 the same, regardless of whether the target is little-endian or big-endian.
10803
10804 @item Components occupying an integral number of bytes.
10805 @noindent
10806 These are components that exactly fit in two or more bytes. Such component
10807 declarations are allowed, but have no effect, since it is important to realize
10808 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10809 In particular, the following attempt at getting an endian-independent integer
10810 does not work:
10811
10812 @smallexample @c ada
10813 type R2 is record
10814 A : Integer;
10815 end record;
10816
10817 for R2'Bit_Order use High_Order_First;
10818
10819 for R2 use record
10820 A at 0 range 0 .. 31;
10821 end record;
10822 @end smallexample
10823
10824 @noindent
10825 This declaration will result in a little-endian integer on a
10826 little-endian machine, and a big-endian integer on a big-endian machine.
10827 If byte flipping is required for interoperability between big- and
10828 little-endian machines, this must be explicitly programmed. This capability
10829 is not provided by @code{Bit_Order}.
10830
10831 @item Components that are positioned across byte boundaries
10832 @noindent
10833 but do not occupy an integral number of bytes. Given that bytes are not
10834 reordered, such fields would occupy a non-contiguous sequence of bits
10835 in memory, requiring non-trivial code to reassemble. They are for this
10836 reason not permitted, and any component clause specifying such a layout
10837 will be flagged as illegal by GNAT@.
10838
10839 @end itemize
10840
10841 @noindent
10842 Since the misconception that Bit_Order automatically deals with all
10843 endian-related incompatibilities is a common one, the specification of
10844 a component field that is an integral number of bytes will always
10845 generate a warning. This warning may be suppressed using @code{pragma
10846 Warnings (Off)} if desired. The following section contains additional
10847 details regarding the issue of byte ordering.
10848
10849 @node Effect of Bit_Order on Byte Ordering
10850 @section Effect of Bit_Order on Byte Ordering
10851 @cindex byte ordering
10852 @cindex ordering, of bytes
10853
10854 @noindent
10855 In this section we will review the effect of the @code{Bit_Order} attribute
10856 definition clause on byte ordering. Briefly, it has no effect at all, but
10857 a detailed example will be helpful. Before giving this
10858 example, let us review the precise
10859 definition of the effect of defining @code{Bit_Order}. The effect of a
10860 non-standard bit order is described in section 15.5.3 of the Ada
10861 Reference Manual:
10862
10863 @quotation
10864 2 A bit ordering is a method of interpreting the meaning of
10865 the storage place attributes.
10866 @end quotation
10867
10868 @noindent
10869 To understand the precise definition of storage place attributes in
10870 this context, we visit section 13.5.1 of the manual:
10871
10872 @quotation
10873 13 A record_representation_clause (without the mod_clause)
10874 specifies the layout. The storage place attributes (see 13.5.2)
10875 are taken from the values of the position, first_bit, and last_bit
10876 expressions after normalizing those values so that first_bit is
10877 less than Storage_Unit.
10878 @end quotation
10879
10880 @noindent
10881 The critical point here is that storage places are taken from
10882 the values after normalization, not before. So the @code{Bit_Order}
10883 interpretation applies to normalized values. The interpretation
10884 is described in the later part of the 15.5.3 paragraph:
10885
10886 @quotation
10887 2 A bit ordering is a method of interpreting the meaning of
10888 the storage place attributes. High_Order_First (known in the
10889 vernacular as ``big endian'') means that the first bit of a
10890 storage element (bit 0) is the most significant bit (interpreting
10891 the sequence of bits that represent a component as an unsigned
10892 integer value). Low_Order_First (known in the vernacular as
10893 ``little endian'') means the opposite: the first bit is the
10894 least significant.
10895 @end quotation
10896
10897 @noindent
10898 Note that the numbering is with respect to the bits of a storage
10899 unit. In other words, the specification affects only the numbering
10900 of bits within a single storage unit.
10901
10902 We can make the effect clearer by giving an example.
10903
10904 Suppose that we have an external device which presents two bytes, the first
10905 byte presented, which is the first (low addressed byte) of the two byte
10906 record is called Master, and the second byte is called Slave.
10907
10908 The left most (most significant bit is called Control for each byte, and
10909 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10910 (least significant) bit.
10911
10912 On a big-endian machine, we can write the following representation clause
10913
10914 @smallexample @c ada
10915 type Data is record
10916 Master_Control : Bit;
10917 Master_V1 : Bit;
10918 Master_V2 : Bit;
10919 Master_V3 : Bit;
10920 Master_V4 : Bit;
10921 Master_V5 : Bit;
10922 Master_V6 : Bit;
10923 Master_V7 : Bit;
10924 Slave_Control : Bit;
10925 Slave_V1 : Bit;
10926 Slave_V2 : Bit;
10927 Slave_V3 : Bit;
10928 Slave_V4 : Bit;
10929 Slave_V5 : Bit;
10930 Slave_V6 : Bit;
10931 Slave_V7 : Bit;
10932 end record;
10933
10934 for Data use record
10935 Master_Control at 0 range 0 .. 0;
10936 Master_V1 at 0 range 1 .. 1;
10937 Master_V2 at 0 range 2 .. 2;
10938 Master_V3 at 0 range 3 .. 3;
10939 Master_V4 at 0 range 4 .. 4;
10940 Master_V5 at 0 range 5 .. 5;
10941 Master_V6 at 0 range 6 .. 6;
10942 Master_V7 at 0 range 7 .. 7;
10943 Slave_Control at 1 range 0 .. 0;
10944 Slave_V1 at 1 range 1 .. 1;
10945 Slave_V2 at 1 range 2 .. 2;
10946 Slave_V3 at 1 range 3 .. 3;
10947 Slave_V4 at 1 range 4 .. 4;
10948 Slave_V5 at 1 range 5 .. 5;
10949 Slave_V6 at 1 range 6 .. 6;
10950 Slave_V7 at 1 range 7 .. 7;
10951 end record;
10952 @end smallexample
10953
10954 @noindent
10955 Now if we move this to a little endian machine, then the bit ordering within
10956 the byte is backwards, so we have to rewrite the record rep clause as:
10957
10958 @smallexample @c ada
10959 for Data use record
10960 Master_Control at 0 range 7 .. 7;
10961 Master_V1 at 0 range 6 .. 6;
10962 Master_V2 at 0 range 5 .. 5;
10963 Master_V3 at 0 range 4 .. 4;
10964 Master_V4 at 0 range 3 .. 3;
10965 Master_V5 at 0 range 2 .. 2;
10966 Master_V6 at 0 range 1 .. 1;
10967 Master_V7 at 0 range 0 .. 0;
10968 Slave_Control at 1 range 7 .. 7;
10969 Slave_V1 at 1 range 6 .. 6;
10970 Slave_V2 at 1 range 5 .. 5;
10971 Slave_V3 at 1 range 4 .. 4;
10972 Slave_V4 at 1 range 3 .. 3;
10973 Slave_V5 at 1 range 2 .. 2;
10974 Slave_V6 at 1 range 1 .. 1;
10975 Slave_V7 at 1 range 0 .. 0;
10976 end record;
10977 @end smallexample
10978
10979 @noindent
10980 It is a nuisance to have to rewrite the clause, especially if
10981 the code has to be maintained on both machines. However,
10982 this is a case that we can handle with the
10983 @code{Bit_Order} attribute if it is implemented.
10984 Note that the implementation is not required on byte addressed
10985 machines, but it is indeed implemented in GNAT.
10986 This means that we can simply use the
10987 first record clause, together with the declaration
10988
10989 @smallexample @c ada
10990 for Data'Bit_Order use High_Order_First;
10991 @end smallexample
10992
10993 @noindent
10994 and the effect is what is desired, namely the layout is exactly the same,
10995 independent of whether the code is compiled on a big-endian or little-endian
10996 machine.
10997
10998 The important point to understand is that byte ordering is not affected.
10999 A @code{Bit_Order} attribute definition never affects which byte a field
11000 ends up in, only where it ends up in that byte.
11001 To make this clear, let us rewrite the record rep clause of the previous
11002 example as:
11003
11004 @smallexample @c ada
11005 for Data'Bit_Order use High_Order_First;
11006 for Data use record
11007 Master_Control at 0 range 0 .. 0;
11008 Master_V1 at 0 range 1 .. 1;
11009 Master_V2 at 0 range 2 .. 2;
11010 Master_V3 at 0 range 3 .. 3;
11011 Master_V4 at 0 range 4 .. 4;
11012 Master_V5 at 0 range 5 .. 5;
11013 Master_V6 at 0 range 6 .. 6;
11014 Master_V7 at 0 range 7 .. 7;
11015 Slave_Control at 0 range 8 .. 8;
11016 Slave_V1 at 0 range 9 .. 9;
11017 Slave_V2 at 0 range 10 .. 10;
11018 Slave_V3 at 0 range 11 .. 11;
11019 Slave_V4 at 0 range 12 .. 12;
11020 Slave_V5 at 0 range 13 .. 13;
11021 Slave_V6 at 0 range 14 .. 14;
11022 Slave_V7 at 0 range 15 .. 15;
11023 end record;
11024 @end smallexample
11025
11026 @noindent
11027 This is exactly equivalent to saying (a repeat of the first example):
11028
11029 @smallexample @c ada
11030 for Data'Bit_Order use High_Order_First;
11031 for Data use record
11032 Master_Control at 0 range 0 .. 0;
11033 Master_V1 at 0 range 1 .. 1;
11034 Master_V2 at 0 range 2 .. 2;
11035 Master_V3 at 0 range 3 .. 3;
11036 Master_V4 at 0 range 4 .. 4;
11037 Master_V5 at 0 range 5 .. 5;
11038 Master_V6 at 0 range 6 .. 6;
11039 Master_V7 at 0 range 7 .. 7;
11040 Slave_Control at 1 range 0 .. 0;
11041 Slave_V1 at 1 range 1 .. 1;
11042 Slave_V2 at 1 range 2 .. 2;
11043 Slave_V3 at 1 range 3 .. 3;
11044 Slave_V4 at 1 range 4 .. 4;
11045 Slave_V5 at 1 range 5 .. 5;
11046 Slave_V6 at 1 range 6 .. 6;
11047 Slave_V7 at 1 range 7 .. 7;
11048 end record;
11049 @end smallexample
11050
11051 @noindent
11052 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11053 field. The storage place attributes are obtained by normalizing the
11054 values given so that the @code{First_Bit} value is less than 8. After
11055 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11056 we specified in the other case.
11057
11058 Now one might expect that the @code{Bit_Order} attribute might affect
11059 bit numbering within the entire record component (two bytes in this
11060 case, thus affecting which byte fields end up in), but that is not
11061 the way this feature is defined, it only affects numbering of bits,
11062 not which byte they end up in.
11063
11064 Consequently it never makes sense to specify a starting bit number
11065 greater than 7 (for a byte addressable field) if an attribute
11066 definition for @code{Bit_Order} has been given, and indeed it
11067 may be actively confusing to specify such a value, so the compiler
11068 generates a warning for such usage.
11069
11070 If you do need to control byte ordering then appropriate conditional
11071 values must be used. If in our example, the slave byte came first on
11072 some machines we might write:
11073
11074 @smallexample @c ada
11075 Master_Byte_First constant Boolean := @dots{};
11076
11077 Master_Byte : constant Natural :=
11078 1 - Boolean'Pos (Master_Byte_First);
11079 Slave_Byte : constant Natural :=
11080 Boolean'Pos (Master_Byte_First);
11081
11082 for Data'Bit_Order use High_Order_First;
11083 for Data use record
11084 Master_Control at Master_Byte range 0 .. 0;
11085 Master_V1 at Master_Byte range 1 .. 1;
11086 Master_V2 at Master_Byte range 2 .. 2;
11087 Master_V3 at Master_Byte range 3 .. 3;
11088 Master_V4 at Master_Byte range 4 .. 4;
11089 Master_V5 at Master_Byte range 5 .. 5;
11090 Master_V6 at Master_Byte range 6 .. 6;
11091 Master_V7 at Master_Byte range 7 .. 7;
11092 Slave_Control at Slave_Byte range 0 .. 0;
11093 Slave_V1 at Slave_Byte range 1 .. 1;
11094 Slave_V2 at Slave_Byte range 2 .. 2;
11095 Slave_V3 at Slave_Byte range 3 .. 3;
11096 Slave_V4 at Slave_Byte range 4 .. 4;
11097 Slave_V5 at Slave_Byte range 5 .. 5;
11098 Slave_V6 at Slave_Byte range 6 .. 6;
11099 Slave_V7 at Slave_Byte range 7 .. 7;
11100 end record;
11101 @end smallexample
11102
11103 @noindent
11104 Now to switch between machines, all that is necessary is
11105 to set the boolean constant @code{Master_Byte_First} in
11106 an appropriate manner.
11107
11108 @node Pragma Pack for Arrays
11109 @section Pragma Pack for Arrays
11110 @cindex Pragma Pack (for arrays)
11111
11112 @noindent
11113 Pragma @code{Pack} applied to an array has no effect unless the component type
11114 is packable. For a component type to be packable, it must be one of the
11115 following cases:
11116
11117 @itemize @bullet
11118 @item
11119 Any scalar type
11120 @item
11121 Any type whose size is specified with a size clause
11122 @item
11123 Any packed array type with a static size
11124 @item
11125 Any record type padded because of its default alignment
11126 @end itemize
11127
11128 @noindent
11129 For all these cases, if the component subtype size is in the range
11130 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11131 component size were specified giving the component subtype size.
11132 For example if we have:
11133
11134 @smallexample @c ada
11135 type r is range 0 .. 17;
11136
11137 type ar is array (1 .. 8) of r;
11138 pragma Pack (ar);
11139 @end smallexample
11140
11141 @noindent
11142 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11143 and the size of the array @code{ar} will be exactly 40 bits.
11144
11145 Note that in some cases this rather fierce approach to packing can produce
11146 unexpected effects. For example, in Ada 95 and Ada 2005,
11147 subtype @code{Natural} typically has a size of 31, meaning that if you
11148 pack an array of @code{Natural}, you get 31-bit
11149 close packing, which saves a few bits, but results in far less efficient
11150 access. Since many other Ada compilers will ignore such a packing request,
11151 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11152 might not be what is intended. You can easily remove this warning by
11153 using an explicit @code{Component_Size} setting instead, which never generates
11154 a warning, since the intention of the programmer is clear in this case.
11155
11156 GNAT treats packed arrays in one of two ways. If the size of the array is
11157 known at compile time and is less than 64 bits, then internally the array
11158 is represented as a single modular type, of exactly the appropriate number
11159 of bits. If the length is greater than 63 bits, or is not known at compile
11160 time, then the packed array is represented as an array of bytes, and the
11161 length is always a multiple of 8 bits.
11162
11163 Note that to represent a packed array as a modular type, the alignment must
11164 be suitable for the modular type involved. For example, on typical machines
11165 a 32-bit packed array will be represented by a 32-bit modular integer with
11166 an alignment of four bytes. If you explicitly override the default alignment
11167 with an alignment clause that is too small, the modular representation
11168 cannot be used. For example, consider the following set of declarations:
11169
11170 @smallexample @c ada
11171 type R is range 1 .. 3;
11172 type S is array (1 .. 31) of R;
11173 for S'Component_Size use 2;
11174 for S'Size use 62;
11175 for S'Alignment use 1;
11176 @end smallexample
11177
11178 @noindent
11179 If the alignment clause were not present, then a 62-bit modular
11180 representation would be chosen (typically with an alignment of 4 or 8
11181 bytes depending on the target). But the default alignment is overridden
11182 with the explicit alignment clause. This means that the modular
11183 representation cannot be used, and instead the array of bytes
11184 representation must be used, meaning that the length must be a multiple
11185 of 8. Thus the above set of declarations will result in a diagnostic
11186 rejecting the size clause and noting that the minimum size allowed is 64.
11187
11188 @cindex Pragma Pack (for type Natural)
11189 @cindex Pragma Pack warning
11190
11191 One special case that is worth noting occurs when the base type of the
11192 component size is 8/16/32 and the subtype is one bit less. Notably this
11193 occurs with subtype @code{Natural}. Consider:
11194
11195 @smallexample @c ada
11196 type Arr is array (1 .. 32) of Natural;
11197 pragma Pack (Arr);
11198 @end smallexample
11199
11200 @noindent
11201 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11202 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11203 Ada 83 compilers did not attempt 31 bit packing.
11204
11205 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11206 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11207 substantial unintended performance penalty when porting legacy Ada 83 code.
11208 To help prevent this, GNAT generates a warning in such cases. If you really
11209 want 31 bit packing in a case like this, you can set the component size
11210 explicitly:
11211
11212 @smallexample @c ada
11213 type Arr is array (1 .. 32) of Natural;
11214 for Arr'Component_Size use 31;
11215 @end smallexample
11216
11217 @noindent
11218 Here 31-bit packing is achieved as required, and no warning is generated,
11219 since in this case the programmer intention is clear.
11220
11221 @node Pragma Pack for Records
11222 @section Pragma Pack for Records
11223 @cindex Pragma Pack (for records)
11224
11225 @noindent
11226 Pragma @code{Pack} applied to a record will pack the components to reduce
11227 wasted space from alignment gaps and by reducing the amount of space
11228 taken by components. We distinguish between @emph{packable} components and
11229 @emph{non-packable} components.
11230 Components of the following types are considered packable:
11231 @itemize @bullet
11232 @item
11233 All primitive types are packable.
11234
11235 @item
11236 Small packed arrays, whose size does not exceed 64 bits, and where the
11237 size is statically known at compile time, are represented internally
11238 as modular integers, and so they are also packable.
11239
11240 @end itemize
11241
11242 @noindent
11243 All packable components occupy the exact number of bits corresponding to
11244 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11245 can start on an arbitrary bit boundary.
11246
11247 All other types are non-packable, they occupy an integral number of
11248 storage units, and
11249 are placed at a boundary corresponding to their alignment requirements.
11250
11251 For example, consider the record
11252
11253 @smallexample @c ada
11254 type Rb1 is array (1 .. 13) of Boolean;
11255 pragma Pack (rb1);
11256
11257 type Rb2 is array (1 .. 65) of Boolean;
11258 pragma Pack (rb2);
11259
11260 type x2 is record
11261 l1 : Boolean;
11262 l2 : Duration;
11263 l3 : Float;
11264 l4 : Boolean;
11265 l5 : Rb1;
11266 l6 : Rb2;
11267 end record;
11268 pragma Pack (x2);
11269 @end smallexample
11270
11271 @noindent
11272 The representation for the record x2 is as follows:
11273
11274 @smallexample @c ada
11275 for x2'Size use 224;
11276 for x2 use record
11277 l1 at 0 range 0 .. 0;
11278 l2 at 0 range 1 .. 64;
11279 l3 at 12 range 0 .. 31;
11280 l4 at 16 range 0 .. 0;
11281 l5 at 16 range 1 .. 13;
11282 l6 at 18 range 0 .. 71;
11283 end record;
11284 @end smallexample
11285
11286 @noindent
11287 Studying this example, we see that the packable fields @code{l1}
11288 and @code{l2} are
11289 of length equal to their sizes, and placed at specific bit boundaries (and
11290 not byte boundaries) to
11291 eliminate padding. But @code{l3} is of a non-packable float type, so
11292 it is on the next appropriate alignment boundary.
11293
11294 The next two fields are fully packable, so @code{l4} and @code{l5} are
11295 minimally packed with no gaps. However, type @code{Rb2} is a packed
11296 array that is longer than 64 bits, so it is itself non-packable. Thus
11297 the @code{l6} field is aligned to the next byte boundary, and takes an
11298 integral number of bytes, i.e.@: 72 bits.
11299
11300 @node Record Representation Clauses
11301 @section Record Representation Clauses
11302 @cindex Record Representation Clause
11303
11304 @noindent
11305 Record representation clauses may be given for all record types, including
11306 types obtained by record extension. Component clauses are allowed for any
11307 static component. The restrictions on component clauses depend on the type
11308 of the component.
11309
11310 @cindex Component Clause
11311 For all components of an elementary type, the only restriction on component
11312 clauses is that the size must be at least the 'Size value of the type
11313 (actually the Value_Size). There are no restrictions due to alignment,
11314 and such components may freely cross storage boundaries.
11315
11316 Packed arrays with a size up to and including 64 bits are represented
11317 internally using a modular type with the appropriate number of bits, and
11318 thus the same lack of restriction applies. For example, if you declare:
11319
11320 @smallexample @c ada
11321 type R is array (1 .. 49) of Boolean;
11322 pragma Pack (R);
11323 for R'Size use 49;
11324 @end smallexample
11325
11326 @noindent
11327 then a component clause for a component of type R may start on any
11328 specified bit boundary, and may specify a value of 49 bits or greater.
11329
11330 For packed bit arrays that are longer than 64 bits, there are two
11331 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11332 including the important case of single bits or boolean values, then
11333 there are no limitations on placement of such components, and they
11334 may start and end at arbitrary bit boundaries.
11335
11336 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11337 an array of this type longer than 64 bits must always be placed on
11338 on a storage unit (byte) boundary and occupy an integral number
11339 of storage units (bytes). Any component clause that does not
11340 meet this requirement will be rejected.
11341
11342 Any aliased component, or component of an aliased type, must
11343 have its normal alignment and size. A component clause that
11344 does not meet this requirement will be rejected.
11345
11346 The tag field of a tagged type always occupies an address sized field at
11347 the start of the record. No component clause may attempt to overlay this
11348 tag. When a tagged type appears as a component, the tag field must have
11349 proper alignment
11350
11351 In the case of a record extension T1, of a type T, no component clause applied
11352 to the type T1 can specify a storage location that would overlap the first
11353 T'Size bytes of the record.
11354
11355 For all other component types, including non-bit-packed arrays,
11356 the component can be placed at an arbitrary bit boundary,
11357 so for example, the following is permitted:
11358
11359 @smallexample @c ada
11360 type R is array (1 .. 10) of Boolean;
11361 for R'Size use 80;
11362
11363 type Q is record
11364 G, H : Boolean;
11365 L, M : R;
11366 end record;
11367
11368 for Q use record
11369 G at 0 range 0 .. 0;
11370 H at 0 range 1 .. 1;
11371 L at 0 range 2 .. 81;
11372 R at 0 range 82 .. 161;
11373 end record;
11374 @end smallexample
11375
11376 @noindent
11377 Note: the above rules apply to recent releases of GNAT 5.
11378 In GNAT 3, there are more severe restrictions on larger components.
11379 For non-primitive types, including packed arrays with a size greater than
11380 64 bits, component clauses must respect the alignment requirement of the
11381 type, in particular, always starting on a byte boundary, and the length
11382 must be a multiple of the storage unit.
11383
11384 @node Enumeration Clauses
11385 @section Enumeration Clauses
11386
11387 The only restriction on enumeration clauses is that the range of values
11388 must be representable. For the signed case, if one or more of the
11389 representation values are negative, all values must be in the range:
11390
11391 @smallexample @c ada
11392 System.Min_Int .. System.Max_Int
11393 @end smallexample
11394
11395 @noindent
11396 For the unsigned case, where all values are nonnegative, the values must
11397 be in the range:
11398
11399 @smallexample @c ada
11400 0 .. System.Max_Binary_Modulus;
11401 @end smallexample
11402
11403 @noindent
11404 A @emph{confirming} representation clause is one in which the values range
11405 from 0 in sequence, i.e.@: a clause that confirms the default representation
11406 for an enumeration type.
11407 Such a confirming representation
11408 is permitted by these rules, and is specially recognized by the compiler so
11409 that no extra overhead results from the use of such a clause.
11410
11411 If an array has an index type which is an enumeration type to which an
11412 enumeration clause has been applied, then the array is stored in a compact
11413 manner. Consider the declarations:
11414
11415 @smallexample @c ada
11416 type r is (A, B, C);
11417 for r use (A => 1, B => 5, C => 10);
11418 type t is array (r) of Character;
11419 @end smallexample
11420
11421 @noindent
11422 The array type t corresponds to a vector with exactly three elements and
11423 has a default size equal to @code{3*Character'Size}. This ensures efficient
11424 use of space, but means that accesses to elements of the array will incur
11425 the overhead of converting representation values to the corresponding
11426 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11427
11428 @node Address Clauses
11429 @section Address Clauses
11430 @cindex Address Clause
11431
11432 The reference manual allows a general restriction on representation clauses,
11433 as found in RM 13.1(22):
11434
11435 @quotation
11436 An implementation need not support representation
11437 items containing nonstatic expressions, except that
11438 an implementation should support a representation item
11439 for a given entity if each nonstatic expression in the
11440 representation item is a name that statically denotes
11441 a constant declared before the entity.
11442 @end quotation
11443
11444 @noindent
11445 In practice this is applicable only to address clauses, since this is the
11446 only case in which a non-static expression is permitted by the syntax. As
11447 the AARM notes in sections 13.1 (22.a-22.h):
11448
11449 @display
11450 22.a Reason: This is to avoid the following sort of thing:
11451
11452 22.b X : Integer := F(@dots{});
11453 Y : Address := G(@dots{});
11454 for X'Address use Y;
11455
11456 22.c In the above, we have to evaluate the
11457 initialization expression for X before we
11458 know where to put the result. This seems
11459 like an unreasonable implementation burden.
11460
11461 22.d The above code should instead be written
11462 like this:
11463
11464 22.e Y : constant Address := G(@dots{});
11465 X : Integer := F(@dots{});
11466 for X'Address use Y;
11467
11468 22.f This allows the expression ``Y'' to be safely
11469 evaluated before X is created.
11470
11471 22.g The constant could be a formal parameter of mode in.
11472
11473 22.h An implementation can support other nonstatic
11474 expressions if it wants to. Expressions of type
11475 Address are hardly ever static, but their value
11476 might be known at compile time anyway in many
11477 cases.
11478 @end display
11479
11480 @noindent
11481 GNAT does indeed permit many additional cases of non-static expressions. In
11482 particular, if the type involved is elementary there are no restrictions
11483 (since in this case, holding a temporary copy of the initialization value,
11484 if one is present, is inexpensive). In addition, if there is no implicit or
11485 explicit initialization, then there are no restrictions. GNAT will reject
11486 only the case where all three of these conditions hold:
11487
11488 @itemize @bullet
11489
11490 @item
11491 The type of the item is non-elementary (e.g.@: a record or array).
11492
11493 @item
11494 There is explicit or implicit initialization required for the object.
11495 Note that access values are always implicitly initialized, and also
11496 in GNAT, certain bit-packed arrays (those having a dynamic length or
11497 a length greater than 64) will also be implicitly initialized to zero.
11498
11499 @item
11500 The address value is non-static. Here GNAT is more permissive than the
11501 RM, and allows the address value to be the address of a previously declared
11502 stand-alone variable, as long as it does not itself have an address clause.
11503
11504 @smallexample @c ada
11505 Anchor : Some_Initialized_Type;
11506 Overlay : Some_Initialized_Type;
11507 for Overlay'Address use Anchor'Address;
11508 @end smallexample
11509
11510 @noindent
11511 However, the prefix of the address clause cannot be an array component, or
11512 a component of a discriminated record.
11513
11514 @end itemize
11515
11516 @noindent
11517 As noted above in section 22.h, address values are typically non-static. In
11518 particular the To_Address function, even if applied to a literal value, is
11519 a non-static function call. To avoid this minor annoyance, GNAT provides
11520 the implementation defined attribute 'To_Address. The following two
11521 expressions have identical values:
11522
11523 @findex Attribute
11524 @findex To_Address
11525 @smallexample @c ada
11526 To_Address (16#1234_0000#)
11527 System'To_Address (16#1234_0000#);
11528 @end smallexample
11529
11530 @noindent
11531 except that the second form is considered to be a static expression, and
11532 thus when used as an address clause value is always permitted.
11533
11534 @noindent
11535 Additionally, GNAT treats as static an address clause that is an
11536 unchecked_conversion of a static integer value. This simplifies the porting
11537 of legacy code, and provides a portable equivalent to the GNAT attribute
11538 @code{To_Address}.
11539
11540 Another issue with address clauses is the interaction with alignment
11541 requirements. When an address clause is given for an object, the address
11542 value must be consistent with the alignment of the object (which is usually
11543 the same as the alignment of the type of the object). If an address clause
11544 is given that specifies an inappropriately aligned address value, then the
11545 program execution is erroneous.
11546
11547 Since this source of erroneous behavior can have unfortunate effects, GNAT
11548 checks (at compile time if possible, generating a warning, or at execution
11549 time with a run-time check) that the alignment is appropriate. If the
11550 run-time check fails, then @code{Program_Error} is raised. This run-time
11551 check is suppressed if range checks are suppressed, or if the special GNAT
11552 check Alignment_Check is suppressed, or if
11553 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11554
11555 Finally, GNAT does not permit overlaying of objects of controlled types or
11556 composite types containing a controlled component. In most cases, the compiler
11557 can detect an attempt at such overlays and will generate a warning at compile
11558 time and a Program_Error exception at run time.
11559
11560 @findex Export
11561 An address clause cannot be given for an exported object. More
11562 understandably the real restriction is that objects with an address
11563 clause cannot be exported. This is because such variables are not
11564 defined by the Ada program, so there is no external object to export.
11565
11566 @findex Import
11567 It is permissible to give an address clause and a pragma Import for the
11568 same object. In this case, the variable is not really defined by the
11569 Ada program, so there is no external symbol to be linked. The link name
11570 and the external name are ignored in this case. The reason that we allow this
11571 combination is that it provides a useful idiom to avoid unwanted
11572 initializations on objects with address clauses.
11573
11574 When an address clause is given for an object that has implicit or
11575 explicit initialization, then by default initialization takes place. This
11576 means that the effect of the object declaration is to overwrite the
11577 memory at the specified address. This is almost always not what the
11578 programmer wants, so GNAT will output a warning:
11579
11580 @smallexample
11581 with System;
11582 package G is
11583 type R is record
11584 M : Integer := 0;
11585 end record;
11586
11587 Ext : R;
11588 for Ext'Address use System'To_Address (16#1234_1234#);
11589 |
11590 >>> warning: implicit initialization of "Ext" may
11591 modify overlaid storage
11592 >>> warning: use pragma Import for "Ext" to suppress
11593 initialization (RM B(24))
11594
11595 end G;
11596 @end smallexample
11597
11598 @noindent
11599 As indicated by the warning message, the solution is to use a (dummy) pragma
11600 Import to suppress this initialization. The pragma tell the compiler that the
11601 object is declared and initialized elsewhere. The following package compiles
11602 without warnings (and the initialization is suppressed):
11603
11604 @smallexample @c ada
11605 with System;
11606 package G is
11607 type R is record
11608 M : Integer := 0;
11609 end record;
11610
11611 Ext : R;
11612 for Ext'Address use System'To_Address (16#1234_1234#);
11613 pragma Import (Ada, Ext);
11614 end G;
11615 @end smallexample
11616
11617 @noindent
11618 A final issue with address clauses involves their use for overlaying
11619 variables, as in the following example:
11620 @cindex Overlaying of objects
11621
11622 @smallexample @c ada
11623 A : Integer;
11624 B : Integer;
11625 for B'Address use A'Address;
11626 @end smallexample
11627
11628 @noindent
11629 or alternatively, using the form recommended by the RM:
11630
11631 @smallexample @c ada
11632 A : Integer;
11633 Addr : constant Address := A'Address;
11634 B : Integer;
11635 for B'Address use Addr;
11636 @end smallexample
11637
11638 @noindent
11639 In both of these cases, @code{A}
11640 and @code{B} become aliased to one another via the
11641 address clause. This use of address clauses to overlay
11642 variables, achieving an effect similar to unchecked
11643 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11644 the effect is implementation defined. Furthermore, the
11645 Ada RM specifically recommends that in a situation
11646 like this, @code{B} should be subject to the following
11647 implementation advice (RM 13.3(19)):
11648
11649 @quotation
11650 19 If the Address of an object is specified, or it is imported
11651 or exported, then the implementation should not perform
11652 optimizations based on assumptions of no aliases.
11653 @end quotation
11654
11655 @noindent
11656 GNAT follows this recommendation, and goes further by also applying
11657 this recommendation to the overlaid variable (@code{A}
11658 in the above example) in this case. This means that the overlay
11659 works "as expected", in that a modification to one of the variables
11660 will affect the value of the other.
11661
11662 @node Effect of Convention on Representation
11663 @section Effect of Convention on Representation
11664 @cindex Convention, effect on representation
11665
11666 @noindent
11667 Normally the specification of a foreign language convention for a type or
11668 an object has no effect on the chosen representation. In particular, the
11669 representation chosen for data in GNAT generally meets the standard system
11670 conventions, and for example records are laid out in a manner that is
11671 consistent with C@. This means that specifying convention C (for example)
11672 has no effect.
11673
11674 There are four exceptions to this general rule:
11675
11676 @itemize @bullet
11677
11678 @item Convention Fortran and array subtypes
11679 If pragma Convention Fortran is specified for an array subtype, then in
11680 accordance with the implementation advice in section 3.6.2(11) of the
11681 Ada Reference Manual, the array will be stored in a Fortran-compatible
11682 column-major manner, instead of the normal default row-major order.
11683
11684 @item Convention C and enumeration types
11685 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11686 to accommodate all values of the type. For example, for the enumeration
11687 type declared by:
11688
11689 @smallexample @c ada
11690 type Color is (Red, Green, Blue);
11691 @end smallexample
11692
11693 @noindent
11694 8 bits is sufficient to store all values of the type, so by default, objects
11695 of type @code{Color} will be represented using 8 bits. However, normal C
11696 convention is to use 32 bits for all enum values in C, since enum values
11697 are essentially of type int. If pragma @code{Convention C} is specified for an
11698 Ada enumeration type, then the size is modified as necessary (usually to
11699 32 bits) to be consistent with the C convention for enum values.
11700
11701 Note that this treatment applies only to types. If Convention C is given for
11702 an enumeration object, where the enumeration type is not Convention C, then
11703 Object_Size bits are allocated. For example, for a normal enumeration type,
11704 with less than 256 elements, only 8 bits will be allocated for the object.
11705 Since this may be a surprise in terms of what C expects, GNAT will issue a
11706 warning in this situation. The warning can be suppressed by giving an explicit
11707 size clause specifying the desired size.
11708
11709 @item Convention C/Fortran and Boolean types
11710 In C, the usual convention for boolean values, that is values used for
11711 conditions, is that zero represents false, and nonzero values represent
11712 true. In Ada, the normal convention is that two specific values, typically
11713 0/1, are used to represent false/true respectively.
11714
11715 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11716 value represents true).
11717
11718 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11719 C or Fortran convention for a derived Boolean, as in the following example:
11720
11721 @smallexample @c ada
11722 type C_Switch is new Boolean;
11723 pragma Convention (C, C_Switch);
11724 @end smallexample
11725
11726 @noindent
11727 then the GNAT generated code will treat any nonzero value as true. For truth
11728 values generated by GNAT, the conventional value 1 will be used for True, but
11729 when one of these values is read, any nonzero value is treated as True.
11730
11731 @item Access types on OpenVMS
11732 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11733 arrays) are 64-bits long. An exception to this rule is for the case of
11734 C-convention access types where there is no explicit size clause present (or
11735 inherited for derived types). In this case, GNAT chooses to make these
11736 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11737 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11738
11739 @end itemize
11740
11741 @node Determining the Representations chosen by GNAT
11742 @section Determining the Representations chosen by GNAT
11743 @cindex Representation, determination of
11744 @cindex @option{-gnatR} switch
11745
11746 @noindent
11747 Although the descriptions in this section are intended to be complete, it is
11748 often easier to simply experiment to see what GNAT accepts and what the
11749 effect is on the layout of types and objects.
11750
11751 As required by the Ada RM, if a representation clause is not accepted, then
11752 it must be rejected as illegal by the compiler. However, when a
11753 representation clause or pragma is accepted, there can still be questions
11754 of what the compiler actually does. For example, if a partial record
11755 representation clause specifies the location of some components and not
11756 others, then where are the non-specified components placed? Or if pragma
11757 @code{Pack} is used on a record, then exactly where are the resulting
11758 fields placed? The section on pragma @code{Pack} in this chapter can be
11759 used to answer the second question, but it is often easier to just see
11760 what the compiler does.
11761
11762 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11763 with this option, then the compiler will output information on the actual
11764 representations chosen, in a format similar to source representation
11765 clauses. For example, if we compile the package:
11766
11767 @smallexample @c ada
11768 package q is
11769 type r (x : boolean) is tagged record
11770 case x is
11771 when True => S : String (1 .. 100);
11772 when False => null;
11773 end case;
11774 end record;
11775
11776 type r2 is new r (false) with record
11777 y2 : integer;
11778 end record;
11779
11780 for r2 use record
11781 y2 at 16 range 0 .. 31;
11782 end record;
11783
11784 type x is record
11785 y : character;
11786 end record;
11787
11788 type x1 is array (1 .. 10) of x;
11789 for x1'component_size use 11;
11790
11791 type ia is access integer;
11792
11793 type Rb1 is array (1 .. 13) of Boolean;
11794 pragma Pack (rb1);
11795
11796 type Rb2 is array (1 .. 65) of Boolean;
11797 pragma Pack (rb2);
11798
11799 type x2 is record
11800 l1 : Boolean;
11801 l2 : Duration;
11802 l3 : Float;
11803 l4 : Boolean;
11804 l5 : Rb1;
11805 l6 : Rb2;
11806 end record;
11807 pragma Pack (x2);
11808 end q;
11809 @end smallexample
11810
11811 @noindent
11812 using the switch @option{-gnatR} we obtain the following output:
11813
11814 @smallexample
11815 Representation information for unit q
11816 -------------------------------------
11817
11818 for r'Size use ??;
11819 for r'Alignment use 4;
11820 for r use record
11821 x at 4 range 0 .. 7;
11822 _tag at 0 range 0 .. 31;
11823 s at 5 range 0 .. 799;
11824 end record;
11825
11826 for r2'Size use 160;
11827 for r2'Alignment use 4;
11828 for r2 use record
11829 x at 4 range 0 .. 7;
11830 _tag at 0 range 0 .. 31;
11831 _parent at 0 range 0 .. 63;
11832 y2 at 16 range 0 .. 31;
11833 end record;
11834
11835 for x'Size use 8;
11836 for x'Alignment use 1;
11837 for x use record
11838 y at 0 range 0 .. 7;
11839 end record;
11840
11841 for x1'Size use 112;
11842 for x1'Alignment use 1;
11843 for x1'Component_Size use 11;
11844
11845 for rb1'Size use 13;
11846 for rb1'Alignment use 2;
11847 for rb1'Component_Size use 1;
11848
11849 for rb2'Size use 72;
11850 for rb2'Alignment use 1;
11851 for rb2'Component_Size use 1;
11852
11853 for x2'Size use 224;
11854 for x2'Alignment use 4;
11855 for x2 use record
11856 l1 at 0 range 0 .. 0;
11857 l2 at 0 range 1 .. 64;
11858 l3 at 12 range 0 .. 31;
11859 l4 at 16 range 0 .. 0;
11860 l5 at 16 range 1 .. 13;
11861 l6 at 18 range 0 .. 71;
11862 end record;
11863 @end smallexample
11864
11865 @noindent
11866 The Size values are actually the Object_Size, i.e.@: the default size that
11867 will be allocated for objects of the type.
11868 The ?? size for type r indicates that we have a variant record, and the
11869 actual size of objects will depend on the discriminant value.
11870
11871 The Alignment values show the actual alignment chosen by the compiler
11872 for each record or array type.
11873
11874 The record representation clause for type r shows where all fields
11875 are placed, including the compiler generated tag field (whose location
11876 cannot be controlled by the programmer).
11877
11878 The record representation clause for the type extension r2 shows all the
11879 fields present, including the parent field, which is a copy of the fields
11880 of the parent type of r2, i.e.@: r1.
11881
11882 The component size and size clauses for types rb1 and rb2 show
11883 the exact effect of pragma @code{Pack} on these arrays, and the record
11884 representation clause for type x2 shows how pragma @code{Pack} affects
11885 this record type.
11886
11887 In some cases, it may be useful to cut and paste the representation clauses
11888 generated by the compiler into the original source to fix and guarantee
11889 the actual representation to be used.
11890
11891 @node Standard Library Routines
11892 @chapter Standard Library Routines
11893
11894 @noindent
11895 The Ada Reference Manual contains in Annex A a full description of an
11896 extensive set of standard library routines that can be used in any Ada
11897 program, and which must be provided by all Ada compilers. They are
11898 analogous to the standard C library used by C programs.
11899
11900 GNAT implements all of the facilities described in annex A, and for most
11901 purposes the description in the Ada Reference Manual, or appropriate Ada
11902 text book, will be sufficient for making use of these facilities.
11903
11904 In the case of the input-output facilities,
11905 @xref{The Implementation of Standard I/O},
11906 gives details on exactly how GNAT interfaces to the
11907 file system. For the remaining packages, the Ada Reference Manual
11908 should be sufficient. The following is a list of the packages included,
11909 together with a brief description of the functionality that is provided.
11910
11911 For completeness, references are included to other predefined library
11912 routines defined in other sections of the Ada Reference Manual (these are
11913 cross-indexed from Annex A).
11914
11915 @table @code
11916 @item Ada (A.2)
11917 This is a parent package for all the standard library packages. It is
11918 usually included implicitly in your program, and itself contains no
11919 useful data or routines.
11920
11921 @item Ada.Calendar (9.6)
11922 @code{Calendar} provides time of day access, and routines for
11923 manipulating times and durations.
11924
11925 @item Ada.Characters (A.3.1)
11926 This is a dummy parent package that contains no useful entities
11927
11928 @item Ada.Characters.Handling (A.3.2)
11929 This package provides some basic character handling capabilities,
11930 including classification functions for classes of characters (e.g.@: test
11931 for letters, or digits).
11932
11933 @item Ada.Characters.Latin_1 (A.3.3)
11934 This package includes a complete set of definitions of the characters
11935 that appear in type CHARACTER@. It is useful for writing programs that
11936 will run in international environments. For example, if you want an
11937 upper case E with an acute accent in a string, it is often better to use
11938 the definition of @code{UC_E_Acute} in this package. Then your program
11939 will print in an understandable manner even if your environment does not
11940 support these extended characters.
11941
11942 @item Ada.Command_Line (A.15)
11943 This package provides access to the command line parameters and the name
11944 of the current program (analogous to the use of @code{argc} and @code{argv}
11945 in C), and also allows the exit status for the program to be set in a
11946 system-independent manner.
11947
11948 @item Ada.Decimal (F.2)
11949 This package provides constants describing the range of decimal numbers
11950 implemented, and also a decimal divide routine (analogous to the COBOL
11951 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11952
11953 @item Ada.Direct_IO (A.8.4)
11954 This package provides input-output using a model of a set of records of
11955 fixed-length, containing an arbitrary definite Ada type, indexed by an
11956 integer record number.
11957
11958 @item Ada.Dynamic_Priorities (D.5)
11959 This package allows the priorities of a task to be adjusted dynamically
11960 as the task is running.
11961
11962 @item Ada.Exceptions (11.4.1)
11963 This package provides additional information on exceptions, and also
11964 contains facilities for treating exceptions as data objects, and raising
11965 exceptions with associated messages.
11966
11967 @item Ada.Finalization (7.6)
11968 This package contains the declarations and subprograms to support the
11969 use of controlled types, providing for automatic initialization and
11970 finalization (analogous to the constructors and destructors of C++)
11971
11972 @item Ada.Interrupts (C.3.2)
11973 This package provides facilities for interfacing to interrupts, which
11974 includes the set of signals or conditions that can be raised and
11975 recognized as interrupts.
11976
11977 @item Ada.Interrupts.Names (C.3.2)
11978 This package provides the set of interrupt names (actually signal
11979 or condition names) that can be handled by GNAT@.
11980
11981 @item Ada.IO_Exceptions (A.13)
11982 This package defines the set of exceptions that can be raised by use of
11983 the standard IO packages.
11984
11985 @item Ada.Numerics
11986 This package contains some standard constants and exceptions used
11987 throughout the numerics packages. Note that the constants pi and e are
11988 defined here, and it is better to use these definitions than rolling
11989 your own.
11990
11991 @item Ada.Numerics.Complex_Elementary_Functions
11992 Provides the implementation of standard elementary functions (such as
11993 log and trigonometric functions) operating on complex numbers using the
11994 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11995 created by the package @code{Numerics.Complex_Types}.
11996
11997 @item Ada.Numerics.Complex_Types
11998 This is a predefined instantiation of
11999 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12000 build the type @code{Complex} and @code{Imaginary}.
12001
12002 @item Ada.Numerics.Discrete_Random
12003 This generic package provides a random number generator suitable for generating
12004 uniformly distributed values of a specified discrete subtype.
12005
12006 @item Ada.Numerics.Float_Random
12007 This package provides a random number generator suitable for generating
12008 uniformly distributed floating point values in the unit interval.
12009
12010 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12011 This is a generic version of the package that provides the
12012 implementation of standard elementary functions (such as log and
12013 trigonometric functions) for an arbitrary complex type.
12014
12015 The following predefined instantiations of this package are provided:
12016
12017 @table @code
12018 @item Short_Float
12019 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12020 @item Float
12021 @code{Ada.Numerics.Complex_Elementary_Functions}
12022 @item Long_Float
12023 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12024 @end table
12025
12026 @item Ada.Numerics.Generic_Complex_Types
12027 This is a generic package that allows the creation of complex types,
12028 with associated complex arithmetic operations.
12029
12030 The following predefined instantiations of this package exist
12031 @table @code
12032 @item Short_Float
12033 @code{Ada.Numerics.Short_Complex_Complex_Types}
12034 @item Float
12035 @code{Ada.Numerics.Complex_Complex_Types}
12036 @item Long_Float
12037 @code{Ada.Numerics.Long_Complex_Complex_Types}
12038 @end table
12039
12040 @item Ada.Numerics.Generic_Elementary_Functions
12041 This is a generic package that provides the implementation of standard
12042 elementary functions (such as log an trigonometric functions) for an
12043 arbitrary float type.
12044
12045 The following predefined instantiations of this package exist
12046
12047 @table @code
12048 @item Short_Float
12049 @code{Ada.Numerics.Short_Elementary_Functions}
12050 @item Float
12051 @code{Ada.Numerics.Elementary_Functions}
12052 @item Long_Float
12053 @code{Ada.Numerics.Long_Elementary_Functions}
12054 @end table
12055
12056 @item Ada.Real_Time (D.8)
12057 This package provides facilities similar to those of @code{Calendar}, but
12058 operating with a finer clock suitable for real time control. Note that
12059 annex D requires that there be no backward clock jumps, and GNAT generally
12060 guarantees this behavior, but of course if the external clock on which
12061 the GNAT runtime depends is deliberately reset by some external event,
12062 then such a backward jump may occur.
12063
12064 @item Ada.Sequential_IO (A.8.1)
12065 This package provides input-output facilities for sequential files,
12066 which can contain a sequence of values of a single type, which can be
12067 any Ada type, including indefinite (unconstrained) types.
12068
12069 @item Ada.Storage_IO (A.9)
12070 This package provides a facility for mapping arbitrary Ada types to and
12071 from a storage buffer. It is primarily intended for the creation of new
12072 IO packages.
12073
12074 @item Ada.Streams (13.13.1)
12075 This is a generic package that provides the basic support for the
12076 concept of streams as used by the stream attributes (@code{Input},
12077 @code{Output}, @code{Read} and @code{Write}).
12078
12079 @item Ada.Streams.Stream_IO (A.12.1)
12080 This package is a specialization of the type @code{Streams} defined in
12081 package @code{Streams} together with a set of operations providing
12082 Stream_IO capability. The Stream_IO model permits both random and
12083 sequential access to a file which can contain an arbitrary set of values
12084 of one or more Ada types.
12085
12086 @item Ada.Strings (A.4.1)
12087 This package provides some basic constants used by the string handling
12088 packages.
12089
12090 @item Ada.Strings.Bounded (A.4.4)
12091 This package provides facilities for handling variable length
12092 strings. The bounded model requires a maximum length. It is thus
12093 somewhat more limited than the unbounded model, but avoids the use of
12094 dynamic allocation or finalization.
12095
12096 @item Ada.Strings.Fixed (A.4.3)
12097 This package provides facilities for handling fixed length strings.
12098
12099 @item Ada.Strings.Maps (A.4.2)
12100 This package provides facilities for handling character mappings and
12101 arbitrarily defined subsets of characters. For instance it is useful in
12102 defining specialized translation tables.
12103
12104 @item Ada.Strings.Maps.Constants (A.4.6)
12105 This package provides a standard set of predefined mappings and
12106 predefined character sets. For example, the standard upper to lower case
12107 conversion table is found in this package. Note that upper to lower case
12108 conversion is non-trivial if you want to take the entire set of
12109 characters, including extended characters like E with an acute accent,
12110 into account. You should use the mappings in this package (rather than
12111 adding 32 yourself) to do case mappings.
12112
12113 @item Ada.Strings.Unbounded (A.4.5)
12114 This package provides facilities for handling variable length
12115 strings. The unbounded model allows arbitrary length strings, but
12116 requires the use of dynamic allocation and finalization.
12117
12118 @item Ada.Strings.Wide_Bounded (A.4.7)
12119 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12120 @itemx Ada.Strings.Wide_Maps (A.4.7)
12121 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12122 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12123 These packages provide analogous capabilities to the corresponding
12124 packages without @samp{Wide_} in the name, but operate with the types
12125 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12126 and @code{Character}.
12127
12128 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12129 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12130 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12131 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12132 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12133 These packages provide analogous capabilities to the corresponding
12134 packages without @samp{Wide_} in the name, but operate with the types
12135 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12136 of @code{String} and @code{Character}.
12137
12138 @item Ada.Synchronous_Task_Control (D.10)
12139 This package provides some standard facilities for controlling task
12140 communication in a synchronous manner.
12141
12142 @item Ada.Tags
12143 This package contains definitions for manipulation of the tags of tagged
12144 values.
12145
12146 @item Ada.Task_Attributes
12147 This package provides the capability of associating arbitrary
12148 task-specific data with separate tasks.
12149
12150 @item Ada.Text_IO
12151 This package provides basic text input-output capabilities for
12152 character, string and numeric data. The subpackages of this
12153 package are listed next.
12154
12155 @item Ada.Text_IO.Decimal_IO
12156 Provides input-output facilities for decimal fixed-point types
12157
12158 @item Ada.Text_IO.Enumeration_IO
12159 Provides input-output facilities for enumeration types.
12160
12161 @item Ada.Text_IO.Fixed_IO
12162 Provides input-output facilities for ordinary fixed-point types.
12163
12164 @item Ada.Text_IO.Float_IO
12165 Provides input-output facilities for float types. The following
12166 predefined instantiations of this generic package are available:
12167
12168 @table @code
12169 @item Short_Float
12170 @code{Short_Float_Text_IO}
12171 @item Float
12172 @code{Float_Text_IO}
12173 @item Long_Float
12174 @code{Long_Float_Text_IO}
12175 @end table
12176
12177 @item Ada.Text_IO.Integer_IO
12178 Provides input-output facilities for integer types. The following
12179 predefined instantiations of this generic package are available:
12180
12181 @table @code
12182 @item Short_Short_Integer
12183 @code{Ada.Short_Short_Integer_Text_IO}
12184 @item Short_Integer
12185 @code{Ada.Short_Integer_Text_IO}
12186 @item Integer
12187 @code{Ada.Integer_Text_IO}
12188 @item Long_Integer
12189 @code{Ada.Long_Integer_Text_IO}
12190 @item Long_Long_Integer
12191 @code{Ada.Long_Long_Integer_Text_IO}
12192 @end table
12193
12194 @item Ada.Text_IO.Modular_IO
12195 Provides input-output facilities for modular (unsigned) types
12196
12197 @item Ada.Text_IO.Complex_IO (G.1.3)
12198 This package provides basic text input-output capabilities for complex
12199 data.
12200
12201 @item Ada.Text_IO.Editing (F.3.3)
12202 This package contains routines for edited output, analogous to the use
12203 of pictures in COBOL@. The picture formats used by this package are a
12204 close copy of the facility in COBOL@.
12205
12206 @item Ada.Text_IO.Text_Streams (A.12.2)
12207 This package provides a facility that allows Text_IO files to be treated
12208 as streams, so that the stream attributes can be used for writing
12209 arbitrary data, including binary data, to Text_IO files.
12210
12211 @item Ada.Unchecked_Conversion (13.9)
12212 This generic package allows arbitrary conversion from one type to
12213 another of the same size, providing for breaking the type safety in
12214 special circumstances.
12215
12216 If the types have the same Size (more accurately the same Value_Size),
12217 then the effect is simply to transfer the bits from the source to the
12218 target type without any modification. This usage is well defined, and
12219 for simple types whose representation is typically the same across
12220 all implementations, gives a portable method of performing such
12221 conversions.
12222
12223 If the types do not have the same size, then the result is implementation
12224 defined, and thus may be non-portable. The following describes how GNAT
12225 handles such unchecked conversion cases.
12226
12227 If the types are of different sizes, and are both discrete types, then
12228 the effect is of a normal type conversion without any constraint checking.
12229 In particular if the result type has a larger size, the result will be
12230 zero or sign extended. If the result type has a smaller size, the result
12231 will be truncated by ignoring high order bits.
12232
12233 If the types are of different sizes, and are not both discrete types,
12234 then the conversion works as though pointers were created to the source
12235 and target, and the pointer value is converted. The effect is that bits
12236 are copied from successive low order storage units and bits of the source
12237 up to the length of the target type.
12238
12239 A warning is issued if the lengths differ, since the effect in this
12240 case is implementation dependent, and the above behavior may not match
12241 that of some other compiler.
12242
12243 A pointer to one type may be converted to a pointer to another type using
12244 unchecked conversion. The only case in which the effect is undefined is
12245 when one or both pointers are pointers to unconstrained array types. In
12246 this case, the bounds information may get incorrectly transferred, and in
12247 particular, GNAT uses double size pointers for such types, and it is
12248 meaningless to convert between such pointer types. GNAT will issue a
12249 warning if the alignment of the target designated type is more strict
12250 than the alignment of the source designated type (since the result may
12251 be unaligned in this case).
12252
12253 A pointer other than a pointer to an unconstrained array type may be
12254 converted to and from System.Address. Such usage is common in Ada 83
12255 programs, but note that Ada.Address_To_Access_Conversions is the
12256 preferred method of performing such conversions in Ada 95 and Ada 2005.
12257 Neither
12258 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12259 used in conjunction with pointers to unconstrained objects, since
12260 the bounds information cannot be handled correctly in this case.
12261
12262 @item Ada.Unchecked_Deallocation (13.11.2)
12263 This generic package allows explicit freeing of storage previously
12264 allocated by use of an allocator.
12265
12266 @item Ada.Wide_Text_IO (A.11)
12267 This package is similar to @code{Ada.Text_IO}, except that the external
12268 file supports wide character representations, and the internal types are
12269 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12270 and @code{String}. It contains generic subpackages listed next.
12271
12272 @item Ada.Wide_Text_IO.Decimal_IO
12273 Provides input-output facilities for decimal fixed-point types
12274
12275 @item Ada.Wide_Text_IO.Enumeration_IO
12276 Provides input-output facilities for enumeration types.
12277
12278 @item Ada.Wide_Text_IO.Fixed_IO
12279 Provides input-output facilities for ordinary fixed-point types.
12280
12281 @item Ada.Wide_Text_IO.Float_IO
12282 Provides input-output facilities for float types. The following
12283 predefined instantiations of this generic package are available:
12284
12285 @table @code
12286 @item Short_Float
12287 @code{Short_Float_Wide_Text_IO}
12288 @item Float
12289 @code{Float_Wide_Text_IO}
12290 @item Long_Float
12291 @code{Long_Float_Wide_Text_IO}
12292 @end table
12293
12294 @item Ada.Wide_Text_IO.Integer_IO
12295 Provides input-output facilities for integer types. The following
12296 predefined instantiations of this generic package are available:
12297
12298 @table @code
12299 @item Short_Short_Integer
12300 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12301 @item Short_Integer
12302 @code{Ada.Short_Integer_Wide_Text_IO}
12303 @item Integer
12304 @code{Ada.Integer_Wide_Text_IO}
12305 @item Long_Integer
12306 @code{Ada.Long_Integer_Wide_Text_IO}
12307 @item Long_Long_Integer
12308 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12309 @end table
12310
12311 @item Ada.Wide_Text_IO.Modular_IO
12312 Provides input-output facilities for modular (unsigned) types
12313
12314 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12315 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12316 external file supports wide character representations.
12317
12318 @item Ada.Wide_Text_IO.Editing (F.3.4)
12319 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12320 types are @code{Wide_Character} and @code{Wide_String} instead of
12321 @code{Character} and @code{String}.
12322
12323 @item Ada.Wide_Text_IO.Streams (A.12.3)
12324 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12325 types are @code{Wide_Character} and @code{Wide_String} instead of
12326 @code{Character} and @code{String}.
12327
12328 @item Ada.Wide_Wide_Text_IO (A.11)
12329 This package is similar to @code{Ada.Text_IO}, except that the external
12330 file supports wide character representations, and the internal types are
12331 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12332 and @code{String}. It contains generic subpackages listed next.
12333
12334 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12335 Provides input-output facilities for decimal fixed-point types
12336
12337 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12338 Provides input-output facilities for enumeration types.
12339
12340 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12341 Provides input-output facilities for ordinary fixed-point types.
12342
12343 @item Ada.Wide_Wide_Text_IO.Float_IO
12344 Provides input-output facilities for float types. The following
12345 predefined instantiations of this generic package are available:
12346
12347 @table @code
12348 @item Short_Float
12349 @code{Short_Float_Wide_Wide_Text_IO}
12350 @item Float
12351 @code{Float_Wide_Wide_Text_IO}
12352 @item Long_Float
12353 @code{Long_Float_Wide_Wide_Text_IO}
12354 @end table
12355
12356 @item Ada.Wide_Wide_Text_IO.Integer_IO
12357 Provides input-output facilities for integer types. The following
12358 predefined instantiations of this generic package are available:
12359
12360 @table @code
12361 @item Short_Short_Integer
12362 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12363 @item Short_Integer
12364 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12365 @item Integer
12366 @code{Ada.Integer_Wide_Wide_Text_IO}
12367 @item Long_Integer
12368 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12369 @item Long_Long_Integer
12370 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12371 @end table
12372
12373 @item Ada.Wide_Wide_Text_IO.Modular_IO
12374 Provides input-output facilities for modular (unsigned) types
12375
12376 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12377 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12378 external file supports wide character representations.
12379
12380 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12381 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12382 types are @code{Wide_Character} and @code{Wide_String} instead of
12383 @code{Character} and @code{String}.
12384
12385 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12386 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12387 types are @code{Wide_Character} and @code{Wide_String} instead of
12388 @code{Character} and @code{String}.
12389 @end table
12390
12391 @node The Implementation of Standard I/O
12392 @chapter The Implementation of Standard I/O
12393
12394 @noindent
12395 GNAT implements all the required input-output facilities described in
12396 A.6 through A.14. These sections of the Ada Reference Manual describe the
12397 required behavior of these packages from the Ada point of view, and if
12398 you are writing a portable Ada program that does not need to know the
12399 exact manner in which Ada maps to the outside world when it comes to
12400 reading or writing external files, then you do not need to read this
12401 chapter. As long as your files are all regular files (not pipes or
12402 devices), and as long as you write and read the files only from Ada, the
12403 description in the Ada Reference Manual is sufficient.
12404
12405 However, if you want to do input-output to pipes or other devices, such
12406 as the keyboard or screen, or if the files you are dealing with are
12407 either generated by some other language, or to be read by some other
12408 language, then you need to know more about the details of how the GNAT
12409 implementation of these input-output facilities behaves.
12410
12411 In this chapter we give a detailed description of exactly how GNAT
12412 interfaces to the file system. As always, the sources of the system are
12413 available to you for answering questions at an even more detailed level,
12414 but for most purposes the information in this chapter will suffice.
12415
12416 Another reason that you may need to know more about how input-output is
12417 implemented arises when you have a program written in mixed languages
12418 where, for example, files are shared between the C and Ada sections of
12419 the same program. GNAT provides some additional facilities, in the form
12420 of additional child library packages, that facilitate this sharing, and
12421 these additional facilities are also described in this chapter.
12422
12423 @menu
12424 * Standard I/O Packages::
12425 * FORM Strings::
12426 * Direct_IO::
12427 * Sequential_IO::
12428 * Text_IO::
12429 * Wide_Text_IO::
12430 * Wide_Wide_Text_IO::
12431 * Stream_IO::
12432 * Text Translation::
12433 * Shared Files::
12434 * Filenames encoding::
12435 * Open Modes::
12436 * Operations on C Streams::
12437 * Interfacing to C Streams::
12438 @end menu
12439
12440 @node Standard I/O Packages
12441 @section Standard I/O Packages
12442
12443 @noindent
12444 The Standard I/O packages described in Annex A for
12445
12446 @itemize @bullet
12447 @item
12448 Ada.Text_IO
12449 @item
12450 Ada.Text_IO.Complex_IO
12451 @item
12452 Ada.Text_IO.Text_Streams
12453 @item
12454 Ada.Wide_Text_IO
12455 @item
12456 Ada.Wide_Text_IO.Complex_IO
12457 @item
12458 Ada.Wide_Text_IO.Text_Streams
12459 @item
12460 Ada.Wide_Wide_Text_IO
12461 @item
12462 Ada.Wide_Wide_Text_IO.Complex_IO
12463 @item
12464 Ada.Wide_Wide_Text_IO.Text_Streams
12465 @item
12466 Ada.Stream_IO
12467 @item
12468 Ada.Sequential_IO
12469 @item
12470 Ada.Direct_IO
12471 @end itemize
12472
12473 @noindent
12474 are implemented using the C
12475 library streams facility; where
12476
12477 @itemize @bullet
12478 @item
12479 All files are opened using @code{fopen}.
12480 @item
12481 All input/output operations use @code{fread}/@code{fwrite}.
12482 @end itemize
12483
12484 @noindent
12485 There is no internal buffering of any kind at the Ada library level. The only
12486 buffering is that provided at the system level in the implementation of the
12487 library routines that support streams. This facilitates shared use of these
12488 streams by mixed language programs. Note though that system level buffering is
12489 explicitly enabled at elaboration of the standard I/O packages and that can
12490 have an impact on mixed language programs, in particular those using I/O before
12491 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12492 the Ada elaboration routine before performing any I/O or when impractical,
12493 flush the common I/O streams and in particular Standard_Output before
12494 elaborating the Ada code.
12495
12496 @node FORM Strings
12497 @section FORM Strings
12498
12499 @noindent
12500 The format of a FORM string in GNAT is:
12501
12502 @smallexample
12503 "keyword=value,keyword=value,@dots{},keyword=value"
12504 @end smallexample
12505
12506 @noindent
12507 where letters may be in upper or lower case, and there are no spaces
12508 between values. The order of the entries is not important. Currently
12509 the following keywords defined.
12510
12511 @smallexample
12512 TEXT_TRANSLATION=[YES|NO]
12513 SHARED=[YES|NO]
12514 WCEM=[n|h|u|s|e|8|b]
12515 ENCODING=[UTF8|8BITS]
12516 @end smallexample
12517
12518 @noindent
12519 The use of these parameters is described later in this section.
12520
12521 @node Direct_IO
12522 @section Direct_IO
12523
12524 @noindent
12525 Direct_IO can only be instantiated for definite types. This is a
12526 restriction of the Ada language, which means that the records are fixed
12527 length (the length being determined by @code{@var{type}'Size}, rounded
12528 up to the next storage unit boundary if necessary).
12529
12530 The records of a Direct_IO file are simply written to the file in index
12531 sequence, with the first record starting at offset zero, and subsequent
12532 records following. There is no control information of any kind. For
12533 example, if 32-bit integers are being written, each record takes
12534 4-bytes, so the record at index @var{K} starts at offset
12535 (@var{K}@minus{}1)*4.
12536
12537 There is no limit on the size of Direct_IO files, they are expanded as
12538 necessary to accommodate whatever records are written to the file.
12539
12540 @node Sequential_IO
12541 @section Sequential_IO
12542
12543 @noindent
12544 Sequential_IO may be instantiated with either a definite (constrained)
12545 or indefinite (unconstrained) type.
12546
12547 For the definite type case, the elements written to the file are simply
12548 the memory images of the data values with no control information of any
12549 kind. The resulting file should be read using the same type, no validity
12550 checking is performed on input.
12551
12552 For the indefinite type case, the elements written consist of two
12553 parts. First is the size of the data item, written as the memory image
12554 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12555 the data value. The resulting file can only be read using the same
12556 (unconstrained) type. Normal assignment checks are performed on these
12557 read operations, and if these checks fail, @code{Data_Error} is
12558 raised. In particular, in the array case, the lengths must match, and in
12559 the variant record case, if the variable for a particular read operation
12560 is constrained, the discriminants must match.
12561
12562 Note that it is not possible to use Sequential_IO to write variable
12563 length array items, and then read the data back into different length
12564 arrays. For example, the following will raise @code{Data_Error}:
12565
12566 @smallexample @c ada
12567 package IO is new Sequential_IO (String);
12568 F : IO.File_Type;
12569 S : String (1..4);
12570 @dots{}
12571 IO.Create (F)
12572 IO.Write (F, "hello!")
12573 IO.Reset (F, Mode=>In_File);
12574 IO.Read (F, S);
12575 Put_Line (S);
12576
12577 @end smallexample
12578
12579 @noindent
12580 On some Ada implementations, this will print @code{hell}, but the program is
12581 clearly incorrect, since there is only one element in the file, and that
12582 element is the string @code{hello!}.
12583
12584 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12585 using Stream_IO, and this is the preferred mechanism. In particular, the
12586 above program fragment rewritten to use Stream_IO will work correctly.
12587
12588 @node Text_IO
12589 @section Text_IO
12590
12591 @noindent
12592 Text_IO files consist of a stream of characters containing the following
12593 special control characters:
12594
12595 @smallexample
12596 LF (line feed, 16#0A#) Line Mark
12597 FF (form feed, 16#0C#) Page Mark
12598 @end smallexample
12599
12600 @noindent
12601 A canonical Text_IO file is defined as one in which the following
12602 conditions are met:
12603
12604 @itemize @bullet
12605 @item
12606 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12607 of the line.
12608
12609 @item
12610 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12611 end of a page and consequently can appear only immediately following a
12612 @code{LF} (line mark) character.
12613
12614 @item
12615 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12616 (line mark, page mark). In the former case, the page mark is implicitly
12617 assumed to be present.
12618 @end itemize
12619
12620 @noindent
12621 A file written using Text_IO will be in canonical form provided that no
12622 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12623 or @code{Put_Line}. There will be no @code{FF} character at the end of
12624 the file unless an explicit @code{New_Page} operation was performed
12625 before closing the file.
12626
12627 A canonical Text_IO file that is a regular file (i.e., not a device or a
12628 pipe) can be read using any of the routines in Text_IO@. The
12629 semantics in this case will be exactly as defined in the Ada Reference
12630 Manual, and all the routines in Text_IO are fully implemented.
12631
12632 A text file that does not meet the requirements for a canonical Text_IO
12633 file has one of the following:
12634
12635 @itemize @bullet
12636 @item
12637 The file contains @code{FF} characters not immediately following a
12638 @code{LF} character.
12639
12640 @item
12641 The file contains @code{LF} or @code{FF} characters written by
12642 @code{Put} or @code{Put_Line}, which are not logically considered to be
12643 line marks or page marks.
12644
12645 @item
12646 The file ends in a character other than @code{LF} or @code{FF},
12647 i.e.@: there is no explicit line mark or page mark at the end of the file.
12648 @end itemize
12649
12650 @noindent
12651 Text_IO can be used to read such non-standard text files but subprograms
12652 to do with line or page numbers do not have defined meanings. In
12653 particular, a @code{FF} character that does not follow a @code{LF}
12654 character may or may not be treated as a page mark from the point of
12655 view of page and line numbering. Every @code{LF} character is considered
12656 to end a line, and there is an implied @code{LF} character at the end of
12657 the file.
12658
12659 @menu
12660 * Text_IO Stream Pointer Positioning::
12661 * Text_IO Reading and Writing Non-Regular Files::
12662 * Get_Immediate::
12663 * Treating Text_IO Files as Streams::
12664 * Text_IO Extensions::
12665 * Text_IO Facilities for Unbounded Strings::
12666 @end menu
12667
12668 @node Text_IO Stream Pointer Positioning
12669 @subsection Stream Pointer Positioning
12670
12671 @noindent
12672 @code{Ada.Text_IO} has a definition of current position for a file that
12673 is being read. No internal buffering occurs in Text_IO, and usually the
12674 physical position in the stream used to implement the file corresponds
12675 to this logical position defined by Text_IO@. There are two exceptions:
12676
12677 @itemize @bullet
12678 @item
12679 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12680 is positioned past the @code{LF} (line mark) that precedes the page
12681 mark. Text_IO maintains an internal flag so that subsequent read
12682 operations properly handle the logical position which is unchanged by
12683 the @code{End_Of_Page} call.
12684
12685 @item
12686 After a call to @code{End_Of_File} that returns @code{True}, if the
12687 Text_IO file was positioned before the line mark at the end of file
12688 before the call, then the logical position is unchanged, but the stream
12689 is physically positioned right at the end of file (past the line mark,
12690 and past a possible page mark following the line mark. Again Text_IO
12691 maintains internal flags so that subsequent read operations properly
12692 handle the logical position.
12693 @end itemize
12694
12695 @noindent
12696 These discrepancies have no effect on the observable behavior of
12697 Text_IO, but if a single Ada stream is shared between a C program and
12698 Ada program, or shared (using @samp{shared=yes} in the form string)
12699 between two Ada files, then the difference may be observable in some
12700 situations.
12701
12702 @node Text_IO Reading and Writing Non-Regular Files
12703 @subsection Reading and Writing Non-Regular Files
12704
12705 @noindent
12706 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12707 can be used for reading and writing. Writing is not affected and the
12708 sequence of characters output is identical to the normal file case, but
12709 for reading, the behavior of Text_IO is modified to avoid undesirable
12710 look-ahead as follows:
12711
12712 An input file that is not a regular file is considered to have no page
12713 marks. Any @code{Ascii.FF} characters (the character normally used for a
12714 page mark) appearing in the file are considered to be data
12715 characters. In particular:
12716
12717 @itemize @bullet
12718 @item
12719 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12720 following a line mark. If a page mark appears, it will be treated as a
12721 data character.
12722
12723 @item
12724 This avoids the need to wait for an extra character to be typed or
12725 entered from the pipe to complete one of these operations.
12726
12727 @item
12728 @code{End_Of_Page} always returns @code{False}
12729
12730 @item
12731 @code{End_Of_File} will return @code{False} if there is a page mark at
12732 the end of the file.
12733 @end itemize
12734
12735 @noindent
12736 Output to non-regular files is the same as for regular files. Page marks
12737 may be written to non-regular files using @code{New_Page}, but as noted
12738 above they will not be treated as page marks on input if the output is
12739 piped to another Ada program.
12740
12741 Another important discrepancy when reading non-regular files is that the end
12742 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12743 pressing the @key{EOT} key,
12744 then end of file
12745 is signaled once (i.e.@: the test @code{End_Of_File}
12746 will yield @code{True}, or a read will
12747 raise @code{End_Error}), but then reading can resume
12748 to read data past that end of
12749 file indication, until another end of file indication is entered.
12750
12751 @node Get_Immediate
12752 @subsection Get_Immediate
12753 @cindex Get_Immediate
12754
12755 @noindent
12756 Get_Immediate returns the next character (including control characters)
12757 from the input file. In particular, Get_Immediate will return LF or FF
12758 characters used as line marks or page marks. Such operations leave the
12759 file positioned past the control character, and it is thus not treated
12760 as having its normal function. This means that page, line and column
12761 counts after this kind of Get_Immediate call are set as though the mark
12762 did not occur. In the case where a Get_Immediate leaves the file
12763 positioned between the line mark and page mark (which is not normally
12764 possible), it is undefined whether the FF character will be treated as a
12765 page mark.
12766
12767 @node Treating Text_IO Files as Streams
12768 @subsection Treating Text_IO Files as Streams
12769 @cindex Stream files
12770
12771 @noindent
12772 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12773 as a stream. Data written to a Text_IO file in this stream mode is
12774 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12775 16#0C# (@code{FF}), the resulting file may have non-standard
12776 format. Similarly if read operations are used to read from a Text_IO
12777 file treated as a stream, then @code{LF} and @code{FF} characters may be
12778 skipped and the effect is similar to that described above for
12779 @code{Get_Immediate}.
12780
12781 @node Text_IO Extensions
12782 @subsection Text_IO Extensions
12783 @cindex Text_IO extensions
12784
12785 @noindent
12786 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12787 to the standard @code{Text_IO} package:
12788
12789 @itemize @bullet
12790 @item function File_Exists (Name : String) return Boolean;
12791 Determines if a file of the given name exists.
12792
12793 @item function Get_Line return String;
12794 Reads a string from the standard input file. The value returned is exactly
12795 the length of the line that was read.
12796
12797 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12798 Similar, except that the parameter File specifies the file from which
12799 the string is to be read.
12800
12801 @end itemize
12802
12803 @node Text_IO Facilities for Unbounded Strings
12804 @subsection Text_IO Facilities for Unbounded Strings
12805 @cindex Text_IO for unbounded strings
12806 @cindex Unbounded_String, Text_IO operations
12807
12808 @noindent
12809 The package @code{Ada.Strings.Unbounded.Text_IO}
12810 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12811 subprograms useful for Text_IO operations on unbounded strings:
12812
12813 @itemize @bullet
12814
12815 @item function Get_Line (File : File_Type) return Unbounded_String;
12816 Reads a line from the specified file
12817 and returns the result as an unbounded string.
12818
12819 @item procedure Put (File : File_Type; U : Unbounded_String);
12820 Writes the value of the given unbounded string to the specified file
12821 Similar to the effect of
12822 @code{Put (To_String (U))} except that an extra copy is avoided.
12823
12824 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12825 Writes the value of the given unbounded string to the specified file,
12826 followed by a @code{New_Line}.
12827 Similar to the effect of @code{Put_Line (To_String (U))} except
12828 that an extra copy is avoided.
12829 @end itemize
12830
12831 @noindent
12832 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12833 and is optional. If the parameter is omitted, then the standard input or
12834 output file is referenced as appropriate.
12835
12836 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12837 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12838 @code{Wide_Text_IO} functionality for unbounded wide strings.
12839
12840 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12841 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12842 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12843
12844 @node Wide_Text_IO
12845 @section Wide_Text_IO
12846
12847 @noindent
12848 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12849 both input and output files may contain special sequences that represent
12850 wide character values. The encoding scheme for a given file may be
12851 specified using a FORM parameter:
12852
12853 @smallexample
12854 WCEM=@var{x}
12855 @end smallexample
12856
12857 @noindent
12858 as part of the FORM string (WCEM = wide character encoding method),
12859 where @var{x} is one of the following characters
12860
12861 @table @samp
12862 @item h
12863 Hex ESC encoding
12864 @item u
12865 Upper half encoding
12866 @item s
12867 Shift-JIS encoding
12868 @item e
12869 EUC Encoding
12870 @item 8
12871 UTF-8 encoding
12872 @item b
12873 Brackets encoding
12874 @end table
12875
12876 @noindent
12877 The encoding methods match those that
12878 can be used in a source
12879 program, but there is no requirement that the encoding method used for
12880 the source program be the same as the encoding method used for files,
12881 and different files may use different encoding methods.
12882
12883 The default encoding method for the standard files, and for opened files
12884 for which no WCEM parameter is given in the FORM string matches the
12885 wide character encoding specified for the main program (the default
12886 being brackets encoding if no coding method was specified with -gnatW).
12887
12888 @table @asis
12889 @item Hex Coding
12890 In this encoding, a wide character is represented by a five character
12891 sequence:
12892
12893 @smallexample
12894 ESC a b c d
12895 @end smallexample
12896
12897 @noindent
12898 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12899 characters (using upper case letters) of the wide character code. For
12900 example, ESC A345 is used to represent the wide character with code
12901 16#A345#. This scheme is compatible with use of the full
12902 @code{Wide_Character} set.
12903
12904 @item Upper Half Coding
12905 The wide character with encoding 16#abcd#, where the upper bit is on
12906 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12907 16#cd#. The second byte may never be a format control character, but is
12908 not required to be in the upper half. This method can be also used for
12909 shift-JIS or EUC where the internal coding matches the external coding.
12910
12911 @item Shift JIS Coding
12912 A wide character is represented by a two character sequence 16#ab# and
12913 16#cd#, with the restrictions described for upper half encoding as
12914 described above. The internal character code is the corresponding JIS
12915 character according to the standard algorithm for Shift-JIS
12916 conversion. Only characters defined in the JIS code set table can be
12917 used with this encoding method.
12918
12919 @item EUC Coding
12920 A wide character is represented by a two character sequence 16#ab# and
12921 16#cd#, with both characters being in the upper half. The internal
12922 character code is the corresponding JIS character according to the EUC
12923 encoding algorithm. Only characters defined in the JIS code set table
12924 can be used with this encoding method.
12925
12926 @item UTF-8 Coding
12927 A wide character is represented using
12928 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12929 10646-1/Am.2. Depending on the character value, the representation
12930 is a one, two, or three byte sequence:
12931
12932 @smallexample
12933 16#0000#-16#007f#: 2#0xxxxxxx#
12934 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12935 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12936 @end smallexample
12937
12938 @noindent
12939 where the @var{xxx} bits correspond to the left-padded bits of the
12940 16-bit character value. Note that all lower half ASCII characters
12941 are represented as ASCII bytes and all upper half characters and
12942 other wide characters are represented as sequences of upper-half
12943 (The full UTF-8 scheme allows for encoding 31-bit characters as
12944 6-byte sequences, but in this implementation, all UTF-8 sequences
12945 of four or more bytes length will raise a Constraint_Error, as
12946 will all invalid UTF-8 sequences.)
12947
12948 @item Brackets Coding
12949 In this encoding, a wide character is represented by the following eight
12950 character sequence:
12951
12952 @smallexample
12953 [ " a b c d " ]
12954 @end smallexample
12955
12956 @noindent
12957 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12958 characters (using uppercase letters) of the wide character code. For
12959 example, @code{["A345"]} is used to represent the wide character with code
12960 @code{16#A345#}.
12961 This scheme is compatible with use of the full Wide_Character set.
12962 On input, brackets coding can also be used for upper half characters,
12963 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12964 is only used for wide characters with a code greater than @code{16#FF#}.
12965
12966 Note that brackets coding is not normally used in the context of
12967 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12968 a portable way of encoding source files. In the context of Wide_Text_IO
12969 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12970 any instance of the left bracket character other than to encode wide
12971 character values using the brackets encoding method. In practice it is
12972 expected that some standard wide character encoding method such
12973 as UTF-8 will be used for text input output.
12974
12975 If brackets notation is used, then any occurrence of a left bracket
12976 in the input file which is not the start of a valid wide character
12977 sequence will cause Constraint_Error to be raised. It is possible to
12978 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12979 input will interpret this as a left bracket.
12980
12981 However, when a left bracket is output, it will be output as a left bracket
12982 and not as ["5B"]. We make this decision because for normal use of
12983 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12984 brackets. For example, if we write:
12985
12986 @smallexample
12987 Put_Line ("Start of output [first run]");
12988 @end smallexample
12989
12990 @noindent
12991 we really do not want to have the left bracket in this message clobbered so
12992 that the output reads:
12993
12994 @smallexample
12995 Start of output ["5B"]first run]
12996 @end smallexample
12997
12998 @noindent
12999 In practice brackets encoding is reasonably useful for normal Put_Line use
13000 since we won't get confused between left brackets and wide character
13001 sequences in the output. But for input, or when files are written out
13002 and read back in, it really makes better sense to use one of the standard
13003 encoding methods such as UTF-8.
13004
13005 @end table
13006
13007 @noindent
13008 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13009 not all wide character
13010 values can be represented. An attempt to output a character that cannot
13011 be represented using the encoding scheme for the file causes
13012 Constraint_Error to be raised. An invalid wide character sequence on
13013 input also causes Constraint_Error to be raised.
13014
13015 @menu
13016 * Wide_Text_IO Stream Pointer Positioning::
13017 * Wide_Text_IO Reading and Writing Non-Regular Files::
13018 @end menu
13019
13020 @node Wide_Text_IO Stream Pointer Positioning
13021 @subsection Stream Pointer Positioning
13022
13023 @noindent
13024 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13025 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13026 case:
13027
13028 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13029 normal lower ASCII set (i.e.@: a character in the range:
13030
13031 @smallexample @c ada
13032 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13033 @end smallexample
13034
13035 @noindent
13036 then although the logical position of the file pointer is unchanged by
13037 the @code{Look_Ahead} call, the stream is physically positioned past the
13038 wide character sequence. Again this is to avoid the need for buffering
13039 or backup, and all @code{Wide_Text_IO} routines check the internal
13040 indication that this situation has occurred so that this is not visible
13041 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13042 can be observed if the wide text file shares a stream with another file.
13043
13044 @node Wide_Text_IO Reading and Writing Non-Regular Files
13045 @subsection Reading and Writing Non-Regular Files
13046
13047 @noindent
13048 As in the case of Text_IO, when a non-regular file is read, it is
13049 assumed that the file contains no page marks (any form characters are
13050 treated as data characters), and @code{End_Of_Page} always returns
13051 @code{False}. Similarly, the end of file indication is not sticky, so
13052 it is possible to read beyond an end of file.
13053
13054 @node Wide_Wide_Text_IO
13055 @section Wide_Wide_Text_IO
13056
13057 @noindent
13058 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13059 both input and output files may contain special sequences that represent
13060 wide wide character values. The encoding scheme for a given file may be
13061 specified using a FORM parameter:
13062
13063 @smallexample
13064 WCEM=@var{x}
13065 @end smallexample
13066
13067 @noindent
13068 as part of the FORM string (WCEM = wide character encoding method),
13069 where @var{x} is one of the following characters
13070
13071 @table @samp
13072 @item h
13073 Hex ESC encoding
13074 @item u
13075 Upper half encoding
13076 @item s
13077 Shift-JIS encoding
13078 @item e
13079 EUC Encoding
13080 @item 8
13081 UTF-8 encoding
13082 @item b
13083 Brackets encoding
13084 @end table
13085
13086 @noindent
13087 The encoding methods match those that
13088 can be used in a source
13089 program, but there is no requirement that the encoding method used for
13090 the source program be the same as the encoding method used for files,
13091 and different files may use different encoding methods.
13092
13093 The default encoding method for the standard files, and for opened files
13094 for which no WCEM parameter is given in the FORM string matches the
13095 wide character encoding specified for the main program (the default
13096 being brackets encoding if no coding method was specified with -gnatW).
13097
13098 @table @asis
13099
13100 @item UTF-8 Coding
13101 A wide character is represented using
13102 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13103 10646-1/Am.2. Depending on the character value, the representation
13104 is a one, two, three, or four byte sequence:
13105
13106 @smallexample
13107 16#000000#-16#00007f#: 2#0xxxxxxx#
13108 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13109 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13110 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13111 @end smallexample
13112
13113 @noindent
13114 where the @var{xxx} bits correspond to the left-padded bits of the
13115 21-bit character value. Note that all lower half ASCII characters
13116 are represented as ASCII bytes and all upper half characters and
13117 other wide characters are represented as sequences of upper-half
13118 characters.
13119
13120 @item Brackets Coding
13121 In this encoding, a wide wide character is represented by the following eight
13122 character sequence if is in wide character range
13123
13124 @smallexample
13125 [ " a b c d " ]
13126 @end smallexample
13127
13128 and by the following ten character sequence if not
13129
13130 @smallexample
13131 [ " a b c d e f " ]
13132 @end smallexample
13133
13134 @noindent
13135 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13136 are the four or six hexadecimal
13137 characters (using uppercase letters) of the wide wide character code. For
13138 example, @code{["01A345"]} is used to represent the wide wide character
13139 with code @code{16#01A345#}.
13140
13141 This scheme is compatible with use of the full Wide_Wide_Character set.
13142 On input, brackets coding can also be used for upper half characters,
13143 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13144 is only used for wide characters with a code greater than @code{16#FF#}.
13145
13146 @end table
13147
13148 @noindent
13149 If is also possible to use the other Wide_Character encoding methods,
13150 such as Shift-JIS, but the other schemes cannot support the full range
13151 of wide wide characters.
13152 An attempt to output a character that cannot
13153 be represented using the encoding scheme for the file causes
13154 Constraint_Error to be raised. An invalid wide character sequence on
13155 input also causes Constraint_Error to be raised.
13156
13157 @menu
13158 * Wide_Wide_Text_IO Stream Pointer Positioning::
13159 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13160 @end menu
13161
13162 @node Wide_Wide_Text_IO Stream Pointer Positioning
13163 @subsection Stream Pointer Positioning
13164
13165 @noindent
13166 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13167 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13168 case:
13169
13170 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13171 normal lower ASCII set (i.e.@: a character in the range:
13172
13173 @smallexample @c ada
13174 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13175 @end smallexample
13176
13177 @noindent
13178 then although the logical position of the file pointer is unchanged by
13179 the @code{Look_Ahead} call, the stream is physically positioned past the
13180 wide character sequence. Again this is to avoid the need for buffering
13181 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13182 indication that this situation has occurred so that this is not visible
13183 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13184 can be observed if the wide text file shares a stream with another file.
13185
13186 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13187 @subsection Reading and Writing Non-Regular Files
13188
13189 @noindent
13190 As in the case of Text_IO, when a non-regular file is read, it is
13191 assumed that the file contains no page marks (any form characters are
13192 treated as data characters), and @code{End_Of_Page} always returns
13193 @code{False}. Similarly, the end of file indication is not sticky, so
13194 it is possible to read beyond an end of file.
13195
13196 @node Stream_IO
13197 @section Stream_IO
13198
13199 @noindent
13200 A stream file is a sequence of bytes, where individual elements are
13201 written to the file as described in the Ada Reference Manual. The type
13202 @code{Stream_Element} is simply a byte. There are two ways to read or
13203 write a stream file.
13204
13205 @itemize @bullet
13206 @item
13207 The operations @code{Read} and @code{Write} directly read or write a
13208 sequence of stream elements with no control information.
13209
13210 @item
13211 The stream attributes applied to a stream file transfer data in the
13212 manner described for stream attributes.
13213 @end itemize
13214
13215 @node Text Translation
13216 @section Text Translation
13217
13218 @noindent
13219 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13220 passed to Text_IO.Create and Text_IO.Open:
13221 @samp{Text_Translation=@var{Yes}} is the default, which means to
13222 translate LF to/from CR/LF on Windows systems.
13223 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13224 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13225 may be used to create Unix-style files on
13226 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13227 systems.
13228
13229 @node Shared Files
13230 @section Shared Files
13231
13232 @noindent
13233 Section A.14 of the Ada Reference Manual allows implementations to
13234 provide a wide variety of behavior if an attempt is made to access the
13235 same external file with two or more internal files.
13236
13237 To provide a full range of functionality, while at the same time
13238 minimizing the problems of portability caused by this implementation
13239 dependence, GNAT handles file sharing as follows:
13240
13241 @itemize @bullet
13242 @item
13243 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13244 to open two or more files with the same full name is considered an error
13245 and is not supported. The exception @code{Use_Error} will be
13246 raised. Note that a file that is not explicitly closed by the program
13247 remains open until the program terminates.
13248
13249 @item
13250 If the form parameter @samp{shared=no} appears in the form string, the
13251 file can be opened or created with its own separate stream identifier,
13252 regardless of whether other files sharing the same external file are
13253 opened. The exact effect depends on how the C stream routines handle
13254 multiple accesses to the same external files using separate streams.
13255
13256 @item
13257 If the form parameter @samp{shared=yes} appears in the form string for
13258 each of two or more files opened using the same full name, the same
13259 stream is shared between these files, and the semantics are as described
13260 in Ada Reference Manual, Section A.14.
13261 @end itemize
13262
13263 @noindent
13264 When a program that opens multiple files with the same name is ported
13265 from another Ada compiler to GNAT, the effect will be that
13266 @code{Use_Error} is raised.
13267
13268 The documentation of the original compiler and the documentation of the
13269 program should then be examined to determine if file sharing was
13270 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13271 and @code{Create} calls as required.
13272
13273 When a program is ported from GNAT to some other Ada compiler, no
13274 special attention is required unless the @samp{shared=@var{xxx}} form
13275 parameter is used in the program. In this case, you must examine the
13276 documentation of the new compiler to see if it supports the required
13277 file sharing semantics, and form strings modified appropriately. Of
13278 course it may be the case that the program cannot be ported if the
13279 target compiler does not support the required functionality. The best
13280 approach in writing portable code is to avoid file sharing (and hence
13281 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13282 completely.
13283
13284 One common use of file sharing in Ada 83 is the use of instantiations of
13285 Sequential_IO on the same file with different types, to achieve
13286 heterogeneous input-output. Although this approach will work in GNAT if
13287 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13288 for this purpose (using the stream attributes)
13289
13290 @node Filenames encoding
13291 @section Filenames encoding
13292
13293 @noindent
13294 An encoding form parameter can be used to specify the filename
13295 encoding @samp{encoding=@var{xxx}}.
13296
13297 @itemize @bullet
13298 @item
13299 If the form parameter @samp{encoding=utf8} appears in the form string, the
13300 filename must be encoded in UTF-8.
13301
13302 @item
13303 If the form parameter @samp{encoding=8bits} appears in the form
13304 string, the filename must be a standard 8bits string.
13305 @end itemize
13306
13307 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13308 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13309 variable. And if not set @samp{utf8} is assumed.
13310
13311 @table @samp
13312 @item CP_ACP
13313 The current system Windows ANSI code page.
13314 @item CP_UTF8
13315 UTF-8 encoding
13316 @end table
13317
13318 This encoding form parameter is only supported on the Windows
13319 platform. On the other Operating Systems the run-time is supporting
13320 UTF-8 natively.
13321
13322 @node Open Modes
13323 @section Open Modes
13324
13325 @noindent
13326 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13327 using the mode shown in the following table:
13328
13329 @sp 2
13330 @center @code{Open} and @code{Create} Call Modes
13331 @smallexample
13332 @b{OPEN } @b{CREATE}
13333 Append_File "r+" "w+"
13334 In_File "r" "w+"
13335 Out_File (Direct_IO) "r+" "w"
13336 Out_File (all other cases) "w" "w"
13337 Inout_File "r+" "w+"
13338 @end smallexample
13339
13340 @noindent
13341 If text file translation is required, then either @samp{b} or @samp{t}
13342 is added to the mode, depending on the setting of Text. Text file
13343 translation refers to the mapping of CR/LF sequences in an external file
13344 to LF characters internally. This mapping only occurs in DOS and
13345 DOS-like systems, and is not relevant to other systems.
13346
13347 A special case occurs with Stream_IO@. As shown in the above table, the
13348 file is initially opened in @samp{r} or @samp{w} mode for the
13349 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13350 subsequently requires switching from reading to writing or vice-versa,
13351 then the file is reopened in @samp{r+} mode to permit the required operation.
13352
13353 @node Operations on C Streams
13354 @section Operations on C Streams
13355 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13356 access to the C library functions for operations on C streams:
13357
13358 @smallexample @c adanocomment
13359 package Interfaces.C_Streams is
13360 -- Note: the reason we do not use the types that are in
13361 -- Interfaces.C is that we want to avoid dragging in the
13362 -- code in this unit if possible.
13363 subtype chars is System.Address;
13364 -- Pointer to null-terminated array of characters
13365 subtype FILEs is System.Address;
13366 -- Corresponds to the C type FILE*
13367 subtype voids is System.Address;
13368 -- Corresponds to the C type void*
13369 subtype int is Integer;
13370 subtype long is Long_Integer;
13371 -- Note: the above types are subtypes deliberately, and it
13372 -- is part of this spec that the above correspondences are
13373 -- guaranteed. This means that it is legitimate to, for
13374 -- example, use Integer instead of int. We provide these
13375 -- synonyms for clarity, but in some cases it may be
13376 -- convenient to use the underlying types (for example to
13377 -- avoid an unnecessary dependency of a spec on the spec
13378 -- of this unit).
13379 type size_t is mod 2 ** Standard'Address_Size;
13380 NULL_Stream : constant FILEs;
13381 -- Value returned (NULL in C) to indicate an
13382 -- fdopen/fopen/tmpfile error
13383 ----------------------------------
13384 -- Constants Defined in stdio.h --
13385 ----------------------------------
13386 EOF : constant int;
13387 -- Used by a number of routines to indicate error or
13388 -- end of file
13389 IOFBF : constant int;
13390 IOLBF : constant int;
13391 IONBF : constant int;
13392 -- Used to indicate buffering mode for setvbuf call
13393 SEEK_CUR : constant int;
13394 SEEK_END : constant int;
13395 SEEK_SET : constant int;
13396 -- Used to indicate origin for fseek call
13397 function stdin return FILEs;
13398 function stdout return FILEs;
13399 function stderr return FILEs;
13400 -- Streams associated with standard files
13401 --------------------------
13402 -- Standard C functions --
13403 --------------------------
13404 -- The functions selected below are ones that are
13405 -- available in UNIX (but not necessarily in ANSI C).
13406 -- These are very thin interfaces
13407 -- which copy exactly the C headers. For more
13408 -- documentation on these functions, see the Microsoft C
13409 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13410 -- ISBN 1-55615-225-6), which includes useful information
13411 -- on system compatibility.
13412 procedure clearerr (stream : FILEs);
13413 function fclose (stream : FILEs) return int;
13414 function fdopen (handle : int; mode : chars) return FILEs;
13415 function feof (stream : FILEs) return int;
13416 function ferror (stream : FILEs) return int;
13417 function fflush (stream : FILEs) return int;
13418 function fgetc (stream : FILEs) return int;
13419 function fgets (strng : chars; n : int; stream : FILEs)
13420 return chars;
13421 function fileno (stream : FILEs) return int;
13422 function fopen (filename : chars; Mode : chars)
13423 return FILEs;
13424 -- Note: to maintain target independence, use
13425 -- text_translation_required, a boolean variable defined in
13426 -- a-sysdep.c to deal with the target dependent text
13427 -- translation requirement. If this variable is set,
13428 -- then b/t should be appended to the standard mode
13429 -- argument to set the text translation mode off or on
13430 -- as required.
13431 function fputc (C : int; stream : FILEs) return int;
13432 function fputs (Strng : chars; Stream : FILEs) return int;
13433 function fread
13434 (buffer : voids;
13435 size : size_t;
13436 count : size_t;
13437 stream : FILEs)
13438 return size_t;
13439 function freopen
13440 (filename : chars;
13441 mode : chars;
13442 stream : FILEs)
13443 return FILEs;
13444 function fseek
13445 (stream : FILEs;
13446 offset : long;
13447 origin : int)
13448 return int;
13449 function ftell (stream : FILEs) return long;
13450 function fwrite
13451 (buffer : voids;
13452 size : size_t;
13453 count : size_t;
13454 stream : FILEs)
13455 return size_t;
13456 function isatty (handle : int) return int;
13457 procedure mktemp (template : chars);
13458 -- The return value (which is just a pointer to template)
13459 -- is discarded
13460 procedure rewind (stream : FILEs);
13461 function rmtmp return int;
13462 function setvbuf
13463 (stream : FILEs;
13464 buffer : chars;
13465 mode : int;
13466 size : size_t)
13467 return int;
13468
13469 function tmpfile return FILEs;
13470 function ungetc (c : int; stream : FILEs) return int;
13471 function unlink (filename : chars) return int;
13472 ---------------------
13473 -- Extra functions --
13474 ---------------------
13475 -- These functions supply slightly thicker bindings than
13476 -- those above. They are derived from functions in the
13477 -- C Run-Time Library, but may do a bit more work than
13478 -- just directly calling one of the Library functions.
13479 function is_regular_file (handle : int) return int;
13480 -- Tests if given handle is for a regular file (result 1)
13481 -- or for a non-regular file (pipe or device, result 0).
13482 ---------------------------------
13483 -- Control of Text/Binary Mode --
13484 ---------------------------------
13485 -- If text_translation_required is true, then the following
13486 -- functions may be used to dynamically switch a file from
13487 -- binary to text mode or vice versa. These functions have
13488 -- no effect if text_translation_required is false (i.e.@: in
13489 -- normal UNIX mode). Use fileno to get a stream handle.
13490 procedure set_binary_mode (handle : int);
13491 procedure set_text_mode (handle : int);
13492 ----------------------------
13493 -- Full Path Name support --
13494 ----------------------------
13495 procedure full_name (nam : chars; buffer : chars);
13496 -- Given a NUL terminated string representing a file
13497 -- name, returns in buffer a NUL terminated string
13498 -- representing the full path name for the file name.
13499 -- On systems where it is relevant the drive is also
13500 -- part of the full path name. It is the responsibility
13501 -- of the caller to pass an actual parameter for buffer
13502 -- that is big enough for any full path name. Use
13503 -- max_path_len given below as the size of buffer.
13504 max_path_len : integer;
13505 -- Maximum length of an allowable full path name on the
13506 -- system, including a terminating NUL character.
13507 end Interfaces.C_Streams;
13508 @end smallexample
13509
13510 @node Interfacing to C Streams
13511 @section Interfacing to C Streams
13512
13513 @noindent
13514 The packages in this section permit interfacing Ada files to C Stream
13515 operations.
13516
13517 @smallexample @c ada
13518 with Interfaces.C_Streams;
13519 package Ada.Sequential_IO.C_Streams is
13520 function C_Stream (F : File_Type)
13521 return Interfaces.C_Streams.FILEs;
13522 procedure Open
13523 (File : in out File_Type;
13524 Mode : in File_Mode;
13525 C_Stream : in Interfaces.C_Streams.FILEs;
13526 Form : in String := "");
13527 end Ada.Sequential_IO.C_Streams;
13528
13529 with Interfaces.C_Streams;
13530 package Ada.Direct_IO.C_Streams is
13531 function C_Stream (F : File_Type)
13532 return Interfaces.C_Streams.FILEs;
13533 procedure Open
13534 (File : in out File_Type;
13535 Mode : in File_Mode;
13536 C_Stream : in Interfaces.C_Streams.FILEs;
13537 Form : in String := "");
13538 end Ada.Direct_IO.C_Streams;
13539
13540 with Interfaces.C_Streams;
13541 package Ada.Text_IO.C_Streams is
13542 function C_Stream (F : File_Type)
13543 return Interfaces.C_Streams.FILEs;
13544 procedure Open
13545 (File : in out File_Type;
13546 Mode : in File_Mode;
13547 C_Stream : in Interfaces.C_Streams.FILEs;
13548 Form : in String := "");
13549 end Ada.Text_IO.C_Streams;
13550
13551 with Interfaces.C_Streams;
13552 package Ada.Wide_Text_IO.C_Streams is
13553 function C_Stream (F : File_Type)
13554 return Interfaces.C_Streams.FILEs;
13555 procedure Open
13556 (File : in out File_Type;
13557 Mode : in File_Mode;
13558 C_Stream : in Interfaces.C_Streams.FILEs;
13559 Form : in String := "");
13560 end Ada.Wide_Text_IO.C_Streams;
13561
13562 with Interfaces.C_Streams;
13563 package Ada.Wide_Wide_Text_IO.C_Streams is
13564 function C_Stream (F : File_Type)
13565 return Interfaces.C_Streams.FILEs;
13566 procedure Open
13567 (File : in out File_Type;
13568 Mode : in File_Mode;
13569 C_Stream : in Interfaces.C_Streams.FILEs;
13570 Form : in String := "");
13571 end Ada.Wide_Wide_Text_IO.C_Streams;
13572
13573 with Interfaces.C_Streams;
13574 package Ada.Stream_IO.C_Streams is
13575 function C_Stream (F : File_Type)
13576 return Interfaces.C_Streams.FILEs;
13577 procedure Open
13578 (File : in out File_Type;
13579 Mode : in File_Mode;
13580 C_Stream : in Interfaces.C_Streams.FILEs;
13581 Form : in String := "");
13582 end Ada.Stream_IO.C_Streams;
13583 @end smallexample
13584
13585 @noindent
13586 In each of these six packages, the @code{C_Stream} function obtains the
13587 @code{FILE} pointer from a currently opened Ada file. It is then
13588 possible to use the @code{Interfaces.C_Streams} package to operate on
13589 this stream, or the stream can be passed to a C program which can
13590 operate on it directly. Of course the program is responsible for
13591 ensuring that only appropriate sequences of operations are executed.
13592
13593 One particular use of relevance to an Ada program is that the
13594 @code{setvbuf} function can be used to control the buffering of the
13595 stream used by an Ada file. In the absence of such a call the standard
13596 default buffering is used.
13597
13598 The @code{Open} procedures in these packages open a file giving an
13599 existing C Stream instead of a file name. Typically this stream is
13600 imported from a C program, allowing an Ada file to operate on an
13601 existing C file.
13602
13603 @node The GNAT Library
13604 @chapter The GNAT Library
13605
13606 @noindent
13607 The GNAT library contains a number of general and special purpose packages.
13608 It represents functionality that the GNAT developers have found useful, and
13609 which is made available to GNAT users. The packages described here are fully
13610 supported, and upwards compatibility will be maintained in future releases,
13611 so you can use these facilities with the confidence that the same functionality
13612 will be available in future releases.
13613
13614 The chapter here simply gives a brief summary of the facilities available.
13615 The full documentation is found in the spec file for the package. The full
13616 sources of these library packages, including both spec and body, are provided
13617 with all GNAT releases. For example, to find out the full specifications of
13618 the SPITBOL pattern matching capability, including a full tutorial and
13619 extensive examples, look in the @file{g-spipat.ads} file in the library.
13620
13621 For each entry here, the package name (as it would appear in a @code{with}
13622 clause) is given, followed by the name of the corresponding spec file in
13623 parentheses. The packages are children in four hierarchies, @code{Ada},
13624 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13625 GNAT-specific hierarchy.
13626
13627 Note that an application program should only use packages in one of these
13628 four hierarchies if the package is defined in the Ada Reference Manual,
13629 or is listed in this section of the GNAT Programmers Reference Manual.
13630 All other units should be considered internal implementation units and
13631 should not be directly @code{with}'ed by application code. The use of
13632 a @code{with} statement that references one of these internal implementation
13633 units makes an application potentially dependent on changes in versions
13634 of GNAT, and will generate a warning message.
13635
13636 @menu
13637 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13638 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13639 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13640 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13641 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13642 * Ada.Command_Line.Environment (a-colien.ads)::
13643 * Ada.Command_Line.Remove (a-colire.ads)::
13644 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13645 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13646 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13647 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13648 * Ada.Exceptions.Traceback (a-exctra.ads)::
13649 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13650 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13651 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13652 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13653 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13654 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13655 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13656 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13657 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13658 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13659 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13660 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13661 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13662 * GNAT.Altivec (g-altive.ads)::
13663 * GNAT.Altivec.Conversions (g-altcon.ads)::
13664 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13665 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13666 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13667 * GNAT.Array_Split (g-arrspl.ads)::
13668 * GNAT.AWK (g-awk.ads)::
13669 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13670 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13671 * GNAT.Bubble_Sort (g-bubsor.ads)::
13672 * GNAT.Bubble_Sort_A (g-busora.ads)::
13673 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13674 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13675 * GNAT.Byte_Swapping (g-bytswa.ads)::
13676 * GNAT.Calendar (g-calend.ads)::
13677 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13678 * GNAT.Case_Util (g-casuti.ads)::
13679 * GNAT.CGI (g-cgi.ads)::
13680 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13681 * GNAT.CGI.Debug (g-cgideb.ads)::
13682 * GNAT.Command_Line (g-comlin.ads)::
13683 * GNAT.Compiler_Version (g-comver.ads)::
13684 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13685 * GNAT.CRC32 (g-crc32.ads)::
13686 * GNAT.Current_Exception (g-curexc.ads)::
13687 * GNAT.Debug_Pools (g-debpoo.ads)::
13688 * GNAT.Debug_Utilities (g-debuti.ads)::
13689 * GNAT.Decode_String (g-decstr.ads)::
13690 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13691 * GNAT.Directory_Operations (g-dirope.ads)::
13692 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13693 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13694 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13695 * GNAT.Encode_String (g-encstr.ads)::
13696 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13697 * GNAT.Exception_Actions (g-excact.ads)::
13698 * GNAT.Exception_Traces (g-exctra.ads)::
13699 * GNAT.Exceptions (g-except.ads)::
13700 * GNAT.Expect (g-expect.ads)::
13701 * GNAT.Float_Control (g-flocon.ads)::
13702 * GNAT.Heap_Sort (g-heasor.ads)::
13703 * GNAT.Heap_Sort_A (g-hesora.ads)::
13704 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13705 * GNAT.HTable (g-htable.ads)::
13706 * GNAT.IO (g-io.ads)::
13707 * GNAT.IO_Aux (g-io_aux.ads)::
13708 * GNAT.Lock_Files (g-locfil.ads)::
13709 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
13710 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
13711 * GNAT.MD5 (g-md5.ads)::
13712 * GNAT.Memory_Dump (g-memdum.ads)::
13713 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13714 * GNAT.OS_Lib (g-os_lib.ads)::
13715 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13716 * GNAT.Random_Numbers (g-rannum.ads)::
13717 * GNAT.Regexp (g-regexp.ads)::
13718 * GNAT.Registry (g-regist.ads)::
13719 * GNAT.Regpat (g-regpat.ads)::
13720 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13721 * GNAT.Semaphores (g-semaph.ads)::
13722 * GNAT.Serial_Communications (g-sercom.ads)::
13723 * GNAT.SHA1 (g-sha1.ads)::
13724 * GNAT.SHA224 (g-sha224.ads)::
13725 * GNAT.SHA256 (g-sha256.ads)::
13726 * GNAT.SHA384 (g-sha384.ads)::
13727 * GNAT.SHA512 (g-sha512.ads)::
13728 * GNAT.Signals (g-signal.ads)::
13729 * GNAT.Sockets (g-socket.ads)::
13730 * GNAT.Source_Info (g-souinf.ads)::
13731 * GNAT.Spelling_Checker (g-speche.ads)::
13732 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13733 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13734 * GNAT.Spitbol (g-spitbo.ads)::
13735 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13736 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13737 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13738 * GNAT.SSE (g-sse.ads)::
13739 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13740 * GNAT.Strings (g-string.ads)::
13741 * GNAT.String_Split (g-strspl.ads)::
13742 * GNAT.Table (g-table.ads)::
13743 * GNAT.Task_Lock (g-tasloc.ads)::
13744 * GNAT.Threads (g-thread.ads)::
13745 * GNAT.Time_Stamp (g-timsta.ads)::
13746 * GNAT.Traceback (g-traceb.ads)::
13747 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13748 * GNAT.UTF_32 (g-utf_32.ads)::
13749 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13750 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13751 * GNAT.Wide_String_Split (g-wistsp.ads)::
13752 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13753 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13754 * Interfaces.C.Extensions (i-cexten.ads)::
13755 * Interfaces.C.Streams (i-cstrea.ads)::
13756 * Interfaces.CPP (i-cpp.ads)::
13757 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13758 * Interfaces.VxWorks (i-vxwork.ads)::
13759 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13760 * System.Address_Image (s-addima.ads)::
13761 * System.Assertions (s-assert.ads)::
13762 * System.Memory (s-memory.ads)::
13763 * System.Partition_Interface (s-parint.ads)::
13764 * System.Pool_Global (s-pooglo.ads)::
13765 * System.Pool_Local (s-pooloc.ads)::
13766 * System.Restrictions (s-restri.ads)::
13767 * System.Rident (s-rident.ads)::
13768 * System.Strings.Stream_Ops (s-ststop.ads)::
13769 * System.Task_Info (s-tasinf.ads)::
13770 * System.Wch_Cnv (s-wchcnv.ads)::
13771 * System.Wch_Con (s-wchcon.ads)::
13772 @end menu
13773
13774 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13775 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13776 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13777 @cindex Latin_9 constants for Character
13778
13779 @noindent
13780 This child of @code{Ada.Characters}
13781 provides a set of definitions corresponding to those in the
13782 RM-defined package @code{Ada.Characters.Latin_1} but with the
13783 few modifications required for @code{Latin-9}
13784 The provision of such a package
13785 is specifically authorized by the Ada Reference Manual
13786 (RM A.3.3(27)).
13787
13788 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13789 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13790 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13791 @cindex Latin_1 constants for Wide_Character
13792
13793 @noindent
13794 This child of @code{Ada.Characters}
13795 provides a set of definitions corresponding to those in the
13796 RM-defined package @code{Ada.Characters.Latin_1} but with the
13797 types of the constants being @code{Wide_Character}
13798 instead of @code{Character}. The provision of such a package
13799 is specifically authorized by the Ada Reference Manual
13800 (RM A.3.3(27)).
13801
13802 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13803 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13804 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13805 @cindex Latin_9 constants for Wide_Character
13806
13807 @noindent
13808 This child of @code{Ada.Characters}
13809 provides a set of definitions corresponding to those in the
13810 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13811 types of the constants being @code{Wide_Character}
13812 instead of @code{Character}. The provision of such a package
13813 is specifically authorized by the Ada Reference Manual
13814 (RM A.3.3(27)).
13815
13816 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13817 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13818 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13819 @cindex Latin_1 constants for Wide_Wide_Character
13820
13821 @noindent
13822 This child of @code{Ada.Characters}
13823 provides a set of definitions corresponding to those in the
13824 RM-defined package @code{Ada.Characters.Latin_1} but with the
13825 types of the constants being @code{Wide_Wide_Character}
13826 instead of @code{Character}. The provision of such a package
13827 is specifically authorized by the Ada Reference Manual
13828 (RM A.3.3(27)).
13829
13830 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13831 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13832 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13833 @cindex Latin_9 constants for Wide_Wide_Character
13834
13835 @noindent
13836 This child of @code{Ada.Characters}
13837 provides a set of definitions corresponding to those in the
13838 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13839 types of the constants being @code{Wide_Wide_Character}
13840 instead of @code{Character}. The provision of such a package
13841 is specifically authorized by the Ada Reference Manual
13842 (RM A.3.3(27)).
13843
13844 @node Ada.Command_Line.Environment (a-colien.ads)
13845 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13846 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13847 @cindex Environment entries
13848
13849 @noindent
13850 This child of @code{Ada.Command_Line}
13851 provides a mechanism for obtaining environment values on systems
13852 where this concept makes sense.
13853
13854 @node Ada.Command_Line.Remove (a-colire.ads)
13855 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13856 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13857 @cindex Removing command line arguments
13858 @cindex Command line, argument removal
13859
13860 @noindent
13861 This child of @code{Ada.Command_Line}
13862 provides a mechanism for logically removing
13863 arguments from the argument list. Once removed, an argument is not visible
13864 to further calls on the subprograms in @code{Ada.Command_Line} will not
13865 see the removed argument.
13866
13867 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13868 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13869 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13870 @cindex Response file for command line
13871 @cindex Command line, response file
13872 @cindex Command line, handling long command lines
13873
13874 @noindent
13875 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13876 getting command line arguments from a text file, called a "response file".
13877 Using a response file allow passing a set of arguments to an executable longer
13878 than the maximum allowed by the system on the command line.
13879
13880 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13881 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13882 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13883 @cindex C Streams, Interfacing with Direct_IO
13884
13885 @noindent
13886 This package provides subprograms that allow interfacing between
13887 C streams and @code{Direct_IO}. The stream identifier can be
13888 extracted from a file opened on the Ada side, and an Ada file
13889 can be constructed from a stream opened on the C side.
13890
13891 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13892 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13893 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13894 @cindex Null_Occurrence, testing for
13895
13896 @noindent
13897 This child subprogram provides a way of testing for the null
13898 exception occurrence (@code{Null_Occurrence}) without raising
13899 an exception.
13900
13901 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13902 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13903 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13904 @cindex Null_Occurrence, testing for
13905
13906 @noindent
13907 This child subprogram is used for handling otherwise unhandled
13908 exceptions (hence the name last chance), and perform clean ups before
13909 terminating the program. Note that this subprogram never returns.
13910
13911 @node Ada.Exceptions.Traceback (a-exctra.ads)
13912 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13913 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13914 @cindex Traceback for Exception Occurrence
13915
13916 @noindent
13917 This child package provides the subprogram (@code{Tracebacks}) to
13918 give a traceback array of addresses based on an exception
13919 occurrence.
13920
13921 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13922 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13923 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13924 @cindex C Streams, Interfacing with Sequential_IO
13925
13926 @noindent
13927 This package provides subprograms that allow interfacing between
13928 C streams and @code{Sequential_IO}. The stream identifier can be
13929 extracted from a file opened on the Ada side, and an Ada file
13930 can be constructed from a stream opened on the C side.
13931
13932 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13933 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13934 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13935 @cindex C Streams, Interfacing with Stream_IO
13936
13937 @noindent
13938 This package provides subprograms that allow interfacing between
13939 C streams and @code{Stream_IO}. The stream identifier can be
13940 extracted from a file opened on the Ada side, and an Ada file
13941 can be constructed from a stream opened on the C side.
13942
13943 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13944 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13945 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13946 @cindex @code{Unbounded_String}, IO support
13947 @cindex @code{Text_IO}, extensions for unbounded strings
13948
13949 @noindent
13950 This package provides subprograms for Text_IO for unbounded
13951 strings, avoiding the necessity for an intermediate operation
13952 with ordinary strings.
13953
13954 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13955 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13956 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13957 @cindex @code{Unbounded_Wide_String}, IO support
13958 @cindex @code{Text_IO}, extensions for unbounded wide strings
13959
13960 @noindent
13961 This package provides subprograms for Text_IO for unbounded
13962 wide strings, avoiding the necessity for an intermediate operation
13963 with ordinary wide strings.
13964
13965 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13966 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13967 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13968 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13969 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13970
13971 @noindent
13972 This package provides subprograms for Text_IO for unbounded
13973 wide wide strings, avoiding the necessity for an intermediate operation
13974 with ordinary wide wide strings.
13975
13976 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13977 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13978 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13979 @cindex C Streams, Interfacing with @code{Text_IO}
13980
13981 @noindent
13982 This package provides subprograms that allow interfacing between
13983 C streams and @code{Text_IO}. The stream identifier can be
13984 extracted from a file opened on the Ada side, and an Ada file
13985 can be constructed from a stream opened on the C side.
13986
13987 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
13988 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13989 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13990 @cindex @code{Text_IO} resetting standard files
13991
13992 @noindent
13993 This procedure is used to reset the status of the standard files used
13994 by Ada.Text_IO. This is useful in a situation (such as a restart in an
13995 embedded application) where the status of the files may change during
13996 execution (for example a standard input file may be redefined to be
13997 interactive).
13998
13999 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14000 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14001 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14002 @cindex Unicode categorization, Wide_Character
14003
14004 @noindent
14005 This package provides subprograms that allow categorization of
14006 Wide_Character values according to Unicode categories.
14007
14008 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14009 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14010 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14011 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14012
14013 @noindent
14014 This package provides subprograms that allow interfacing between
14015 C streams and @code{Wide_Text_IO}. The stream identifier can be
14016 extracted from a file opened on the Ada side, and an Ada file
14017 can be constructed from a stream opened on the C side.
14018
14019 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14020 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14021 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14022 @cindex @code{Wide_Text_IO} resetting standard files
14023
14024 @noindent
14025 This procedure is used to reset the status of the standard files used
14026 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14027 embedded application) where the status of the files may change during
14028 execution (for example a standard input file may be redefined to be
14029 interactive).
14030
14031 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14032 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14033 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14034 @cindex Unicode categorization, Wide_Wide_Character
14035
14036 @noindent
14037 This package provides subprograms that allow categorization of
14038 Wide_Wide_Character values according to Unicode categories.
14039
14040 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14041 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14042 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14043 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14044
14045 @noindent
14046 This package provides subprograms that allow interfacing between
14047 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14048 extracted from a file opened on the Ada side, and an Ada file
14049 can be constructed from a stream opened on the C side.
14050
14051 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14052 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14053 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14054 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14055
14056 @noindent
14057 This procedure is used to reset the status of the standard files used
14058 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14059 restart in an embedded application) where the status of the files may
14060 change during execution (for example a standard input file may be
14061 redefined to be interactive).
14062
14063 @node GNAT.Altivec (g-altive.ads)
14064 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14065 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14066 @cindex AltiVec
14067
14068 @noindent
14069 This is the root package of the GNAT AltiVec binding. It provides
14070 definitions of constants and types common to all the versions of the
14071 binding.
14072
14073 @node GNAT.Altivec.Conversions (g-altcon.ads)
14074 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14075 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14076 @cindex AltiVec
14077
14078 @noindent
14079 This package provides the Vector/View conversion routines.
14080
14081 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14082 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14083 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14084 @cindex AltiVec
14085
14086 @noindent
14087 This package exposes the Ada interface to the AltiVec operations on
14088 vector objects. A soft emulation is included by default in the GNAT
14089 library. The hard binding is provided as a separate package. This unit
14090 is common to both bindings.
14091
14092 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14093 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14094 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14095 @cindex AltiVec
14096
14097 @noindent
14098 This package exposes the various vector types part of the Ada binding
14099 to AltiVec facilities.
14100
14101 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14102 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14103 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14104 @cindex AltiVec
14105
14106 @noindent
14107 This package provides public 'View' data types from/to which private
14108 vector representations can be converted via
14109 GNAT.Altivec.Conversions. This allows convenient access to individual
14110 vector elements and provides a simple way to initialize vector
14111 objects.
14112
14113 @node GNAT.Array_Split (g-arrspl.ads)
14114 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14115 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14116 @cindex Array splitter
14117
14118 @noindent
14119 Useful array-manipulation routines: given a set of separators, split
14120 an array wherever the separators appear, and provide direct access
14121 to the resulting slices.
14122
14123 @node GNAT.AWK (g-awk.ads)
14124 @section @code{GNAT.AWK} (@file{g-awk.ads})
14125 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14126 @cindex Parsing
14127 @cindex AWK
14128
14129 @noindent
14130 Provides AWK-like parsing functions, with an easy interface for parsing one
14131 or more files containing formatted data. The file is viewed as a database
14132 where each record is a line and a field is a data element in this line.
14133
14134 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14135 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14136 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14137 @cindex Parsing
14138 @cindex Bounded Buffers
14139
14140 @noindent
14141 Provides a concurrent generic bounded buffer abstraction. Instances are
14142 useful directly or as parts of the implementations of other abstractions,
14143 such as mailboxes.
14144
14145 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14146 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14147 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14148 @cindex Parsing
14149 @cindex Mailboxes
14150
14151 @noindent
14152 Provides a thread-safe asynchronous intertask mailbox communication facility.
14153
14154 @node GNAT.Bubble_Sort (g-bubsor.ads)
14155 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14156 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14157 @cindex Sorting
14158 @cindex Bubble sort
14159
14160 @noindent
14161 Provides a general implementation of bubble sort usable for sorting arbitrary
14162 data items. Exchange and comparison procedures are provided by passing
14163 access-to-procedure values.
14164
14165 @node GNAT.Bubble_Sort_A (g-busora.ads)
14166 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14167 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14168 @cindex Sorting
14169 @cindex Bubble sort
14170
14171 @noindent
14172 Provides a general implementation of bubble sort usable for sorting arbitrary
14173 data items. Move and comparison procedures are provided by passing
14174 access-to-procedure values. This is an older version, retained for
14175 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14176
14177 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14178 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14179 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14180 @cindex Sorting
14181 @cindex Bubble sort
14182
14183 @noindent
14184 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14185 are provided as generic parameters, this improves efficiency, especially
14186 if the procedures can be inlined, at the expense of duplicating code for
14187 multiple instantiations.
14188
14189 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14190 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14191 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14192 @cindex UTF-8 representation
14193 @cindex Wide characte representations
14194
14195 @noindent
14196 Provides a routine which given a string, reads the start of the string to
14197 see whether it is one of the standard byte order marks (BOM's) which signal
14198 the encoding of the string. The routine includes detection of special XML
14199 sequences for various UCS input formats.
14200
14201 @node GNAT.Byte_Swapping (g-bytswa.ads)
14202 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14203 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14204 @cindex Byte swapping
14205 @cindex Endian
14206
14207 @noindent
14208 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14209 Machine-specific implementations are available in some cases.
14210
14211 @node GNAT.Calendar (g-calend.ads)
14212 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14213 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14214 @cindex @code{Calendar}
14215
14216 @noindent
14217 Extends the facilities provided by @code{Ada.Calendar} to include handling
14218 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14219 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14220 C @code{timeval} format.
14221
14222 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14223 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14224 @cindex @code{Calendar}
14225 @cindex Time
14226 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14227
14228 @node GNAT.CRC32 (g-crc32.ads)
14229 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14230 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14231 @cindex CRC32
14232 @cindex Cyclic Redundancy Check
14233
14234 @noindent
14235 This package implements the CRC-32 algorithm. For a full description
14236 of this algorithm see
14237 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14238 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14239 Aug.@: 1988. Sarwate, D.V@.
14240
14241 @node GNAT.Case_Util (g-casuti.ads)
14242 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14243 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14244 @cindex Casing utilities
14245 @cindex Character handling (@code{GNAT.Case_Util})
14246
14247 @noindent
14248 A set of simple routines for handling upper and lower casing of strings
14249 without the overhead of the full casing tables
14250 in @code{Ada.Characters.Handling}.
14251
14252 @node GNAT.CGI (g-cgi.ads)
14253 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14254 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14255 @cindex CGI (Common Gateway Interface)
14256
14257 @noindent
14258 This is a package for interfacing a GNAT program with a Web server via the
14259 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14260 parameters, which are a set of key/value pairs sent by the Web server. It
14261 builds a table whose index is the key and provides some services to deal
14262 with this table.
14263
14264 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14265 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14266 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14267 @cindex CGI (Common Gateway Interface) cookie support
14268 @cindex Cookie support in CGI
14269
14270 @noindent
14271 This is a package to interface a GNAT program with a Web server via the
14272 Common Gateway Interface (CGI). It exports services to deal with Web
14273 cookies (piece of information kept in the Web client software).
14274
14275 @node GNAT.CGI.Debug (g-cgideb.ads)
14276 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14277 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14278 @cindex CGI (Common Gateway Interface) debugging
14279
14280 @noindent
14281 This is a package to help debugging CGI (Common Gateway Interface)
14282 programs written in Ada.
14283
14284 @node GNAT.Command_Line (g-comlin.ads)
14285 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14286 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14287 @cindex Command line
14288
14289 @noindent
14290 Provides a high level interface to @code{Ada.Command_Line} facilities,
14291 including the ability to scan for named switches with optional parameters
14292 and expand file names using wild card notations.
14293
14294 @node GNAT.Compiler_Version (g-comver.ads)
14295 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14296 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14297 @cindex Compiler Version
14298 @cindex Version, of compiler
14299
14300 @noindent
14301 Provides a routine for obtaining the version of the compiler used to
14302 compile the program. More accurately this is the version of the binder
14303 used to bind the program (this will normally be the same as the version
14304 of the compiler if a consistent tool set is used to compile all units
14305 of a partition).
14306
14307 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14308 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14309 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14310 @cindex Interrupt
14311
14312 @noindent
14313 Provides a simple interface to handle Ctrl-C keyboard events.
14314
14315 @node GNAT.Current_Exception (g-curexc.ads)
14316 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14317 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14318 @cindex Current exception
14319 @cindex Exception retrieval
14320
14321 @noindent
14322 Provides access to information on the current exception that has been raised
14323 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14324 specification syntax.
14325 This is particularly useful in simulating typical facilities for
14326 obtaining information about exceptions provided by Ada 83 compilers.
14327
14328 @node GNAT.Debug_Pools (g-debpoo.ads)
14329 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14330 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14331 @cindex Debugging
14332 @cindex Debug pools
14333 @cindex Memory corruption debugging
14334
14335 @noindent
14336 Provide a debugging storage pools that helps tracking memory corruption
14337 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14338 @value{EDITION} User's Guide}.
14339
14340 @node GNAT.Debug_Utilities (g-debuti.ads)
14341 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14342 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14343 @cindex Debugging
14344
14345 @noindent
14346 Provides a few useful utilities for debugging purposes, including conversion
14347 to and from string images of address values. Supports both C and Ada formats
14348 for hexadecimal literals.
14349
14350 @node GNAT.Decode_String (g-decstr.ads)
14351 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14352 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14353 @cindex Decoding strings
14354 @cindex String decoding
14355 @cindex Wide character encoding
14356 @cindex UTF-8
14357 @cindex Unicode
14358
14359 @noindent
14360 A generic package providing routines for decoding wide character and wide wide
14361 character strings encoded as sequences of 8-bit characters using a specified
14362 encoding method. Includes validation routines, and also routines for stepping
14363 to next or previous encoded character in an encoded string.
14364 Useful in conjunction with Unicode character coding. Note there is a
14365 preinstantiation for UTF-8. See next entry.
14366
14367 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14368 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14369 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14370 @cindex Decoding strings
14371 @cindex Decoding UTF-8 strings
14372 @cindex UTF-8 string decoding
14373 @cindex Wide character decoding
14374 @cindex UTF-8
14375 @cindex Unicode
14376
14377 @noindent
14378 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14379
14380 @node GNAT.Directory_Operations (g-dirope.ads)
14381 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14382 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14383 @cindex Directory operations
14384
14385 @noindent
14386 Provides a set of routines for manipulating directories, including changing
14387 the current directory, making new directories, and scanning the files in a
14388 directory.
14389
14390 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14391 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14392 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14393 @cindex Directory operations iteration
14394
14395 @noindent
14396 A child unit of GNAT.Directory_Operations providing additional operations
14397 for iterating through directories.
14398
14399 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14400 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14401 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14402 @cindex Hash tables
14403
14404 @noindent
14405 A generic implementation of hash tables that can be used to hash arbitrary
14406 data. Provided in two forms, a simple form with built in hash functions,
14407 and a more complex form in which the hash function is supplied.
14408
14409 @noindent
14410 This package provides a facility similar to that of @code{GNAT.HTable},
14411 except that this package declares a type that can be used to define
14412 dynamic instances of the hash table, while an instantiation of
14413 @code{GNAT.HTable} creates a single instance of the hash table.
14414
14415 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14416 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14417 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14418 @cindex Table implementation
14419 @cindex Arrays, extendable
14420
14421 @noindent
14422 A generic package providing a single dimension array abstraction where the
14423 length of the array can be dynamically modified.
14424
14425 @noindent
14426 This package provides a facility similar to that of @code{GNAT.Table},
14427 except that this package declares a type that can be used to define
14428 dynamic instances of the table, while an instantiation of
14429 @code{GNAT.Table} creates a single instance of the table type.
14430
14431 @node GNAT.Encode_String (g-encstr.ads)
14432 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14433 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14434 @cindex Encoding strings
14435 @cindex String encoding
14436 @cindex Wide character encoding
14437 @cindex UTF-8
14438 @cindex Unicode
14439
14440 @noindent
14441 A generic package providing routines for encoding wide character and wide
14442 wide character strings as sequences of 8-bit characters using a specified
14443 encoding method. Useful in conjunction with Unicode character coding.
14444 Note there is a preinstantiation for UTF-8. See next entry.
14445
14446 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14447 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14448 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14449 @cindex Encoding strings
14450 @cindex Encoding UTF-8 strings
14451 @cindex UTF-8 string encoding
14452 @cindex Wide character encoding
14453 @cindex UTF-8
14454 @cindex Unicode
14455
14456 @noindent
14457 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14458
14459 @node GNAT.Exception_Actions (g-excact.ads)
14460 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14461 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14462 @cindex Exception actions
14463
14464 @noindent
14465 Provides callbacks when an exception is raised. Callbacks can be registered
14466 for specific exceptions, or when any exception is raised. This
14467 can be used for instance to force a core dump to ease debugging.
14468
14469 @node GNAT.Exception_Traces (g-exctra.ads)
14470 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14471 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14472 @cindex Exception traces
14473 @cindex Debugging
14474
14475 @noindent
14476 Provides an interface allowing to control automatic output upon exception
14477 occurrences.
14478
14479 @node GNAT.Exceptions (g-except.ads)
14480 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14481 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14482 @cindex Exceptions, Pure
14483 @cindex Pure packages, exceptions
14484
14485 @noindent
14486 Normally it is not possible to raise an exception with
14487 a message from a subprogram in a pure package, since the
14488 necessary types and subprograms are in @code{Ada.Exceptions}
14489 which is not a pure unit. @code{GNAT.Exceptions} provides a
14490 facility for getting around this limitation for a few
14491 predefined exceptions, and for example allow raising
14492 @code{Constraint_Error} with a message from a pure subprogram.
14493
14494 @node GNAT.Expect (g-expect.ads)
14495 @section @code{GNAT.Expect} (@file{g-expect.ads})
14496 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14497
14498 @noindent
14499 Provides a set of subprograms similar to what is available
14500 with the standard Tcl Expect tool.
14501 It allows you to easily spawn and communicate with an external process.
14502 You can send commands or inputs to the process, and compare the output
14503 with some expected regular expression. Currently @code{GNAT.Expect}
14504 is implemented on all native GNAT ports except for OpenVMS@.
14505 It is not implemented for cross ports, and in particular is not
14506 implemented for VxWorks or LynxOS@.
14507
14508 @node GNAT.Float_Control (g-flocon.ads)
14509 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14510 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14511 @cindex Floating-Point Processor
14512
14513 @noindent
14514 Provides an interface for resetting the floating-point processor into the
14515 mode required for correct semantic operation in Ada. Some third party
14516 library calls may cause this mode to be modified, and the Reset procedure
14517 in this package can be used to reestablish the required mode.
14518
14519 @node GNAT.Heap_Sort (g-heasor.ads)
14520 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14521 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14522 @cindex Sorting
14523
14524 @noindent
14525 Provides a general implementation of heap sort usable for sorting arbitrary
14526 data items. Exchange and comparison procedures are provided by passing
14527 access-to-procedure values. The algorithm used is a modified heap sort
14528 that performs approximately N*log(N) comparisons in the worst case.
14529
14530 @node GNAT.Heap_Sort_A (g-hesora.ads)
14531 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14532 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14533 @cindex Sorting
14534
14535 @noindent
14536 Provides a general implementation of heap sort usable for sorting arbitrary
14537 data items. Move and comparison procedures are provided by passing
14538 access-to-procedure values. The algorithm used is a modified heap sort
14539 that performs approximately N*log(N) comparisons in the worst case.
14540 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14541 interface, but may be slightly more efficient.
14542
14543 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14544 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14545 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14546 @cindex Sorting
14547
14548 @noindent
14549 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14550 are provided as generic parameters, this improves efficiency, especially
14551 if the procedures can be inlined, at the expense of duplicating code for
14552 multiple instantiations.
14553
14554 @node GNAT.HTable (g-htable.ads)
14555 @section @code{GNAT.HTable} (@file{g-htable.ads})
14556 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14557 @cindex Hash tables
14558
14559 @noindent
14560 A generic implementation of hash tables that can be used to hash arbitrary
14561 data. Provides two approaches, one a simple static approach, and the other
14562 allowing arbitrary dynamic hash tables.
14563
14564 @node GNAT.IO (g-io.ads)
14565 @section @code{GNAT.IO} (@file{g-io.ads})
14566 @cindex @code{GNAT.IO} (@file{g-io.ads})
14567 @cindex Simple I/O
14568 @cindex Input/Output facilities
14569
14570 @noindent
14571 A simple preelaborable input-output package that provides a subset of
14572 simple Text_IO functions for reading characters and strings from
14573 Standard_Input, and writing characters, strings and integers to either
14574 Standard_Output or Standard_Error.
14575
14576 @node GNAT.IO_Aux (g-io_aux.ads)
14577 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14578 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14579 @cindex Text_IO
14580 @cindex Input/Output facilities
14581
14582 Provides some auxiliary functions for use with Text_IO, including a test
14583 for whether a file exists, and functions for reading a line of text.
14584
14585 @node GNAT.Lock_Files (g-locfil.ads)
14586 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14587 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14588 @cindex File locking
14589 @cindex Locking using files
14590
14591 @noindent
14592 Provides a general interface for using files as locks. Can be used for
14593 providing program level synchronization.
14594
14595 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
14596 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14597 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14598 @cindex Random number generation
14599
14600 @noindent
14601 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
14602 a modified version of the Blum-Blum-Shub generator.
14603
14604 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
14605 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14606 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14607 @cindex Random number generation
14608
14609 @noindent
14610 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
14611 a modified version of the Blum-Blum-Shub generator.
14612
14613 @node GNAT.MD5 (g-md5.ads)
14614 @section @code{GNAT.MD5} (@file{g-md5.ads})
14615 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14616 @cindex Message Digest MD5
14617
14618 @noindent
14619 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14620
14621 @node GNAT.Memory_Dump (g-memdum.ads)
14622 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14623 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14624 @cindex Dump Memory
14625
14626 @noindent
14627 Provides a convenient routine for dumping raw memory to either the
14628 standard output or standard error files. Uses GNAT.IO for actual
14629 output.
14630
14631 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14632 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14633 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14634 @cindex Exception, obtaining most recent
14635
14636 @noindent
14637 Provides access to the most recently raised exception. Can be used for
14638 various logging purposes, including duplicating functionality of some
14639 Ada 83 implementation dependent extensions.
14640
14641 @node GNAT.OS_Lib (g-os_lib.ads)
14642 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14643 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14644 @cindex Operating System interface
14645 @cindex Spawn capability
14646
14647 @noindent
14648 Provides a range of target independent operating system interface functions,
14649 including time/date management, file operations, subprocess management,
14650 including a portable spawn procedure, and access to environment variables
14651 and error return codes.
14652
14653 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14654 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14655 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14656 @cindex Hash functions
14657
14658 @noindent
14659 Provides a generator of static minimal perfect hash functions. No
14660 collisions occur and each item can be retrieved from the table in one
14661 probe (perfect property). The hash table size corresponds to the exact
14662 size of the key set and no larger (minimal property). The key set has to
14663 be know in advance (static property). The hash functions are also order
14664 preserving. If w2 is inserted after w1 in the generator, their
14665 hashcode are in the same order. These hashing functions are very
14666 convenient for use with realtime applications.
14667
14668 @node GNAT.Random_Numbers (g-rannum.ads)
14669 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14670 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14671 @cindex Random number generation
14672
14673 @noindent
14674 Provides random number capabilities which extend those available in the
14675 standard Ada library and are more convenient to use.
14676
14677 @node GNAT.Regexp (g-regexp.ads)
14678 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14679 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14680 @cindex Regular expressions
14681 @cindex Pattern matching
14682
14683 @noindent
14684 A simple implementation of regular expressions, using a subset of regular
14685 expression syntax copied from familiar Unix style utilities. This is the
14686 simples of the three pattern matching packages provided, and is particularly
14687 suitable for ``file globbing'' applications.
14688
14689 @node GNAT.Registry (g-regist.ads)
14690 @section @code{GNAT.Registry} (@file{g-regist.ads})
14691 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14692 @cindex Windows Registry
14693
14694 @noindent
14695 This is a high level binding to the Windows registry. It is possible to
14696 do simple things like reading a key value, creating a new key. For full
14697 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14698 package provided with the Win32Ada binding
14699
14700 @node GNAT.Regpat (g-regpat.ads)
14701 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14702 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14703 @cindex Regular expressions
14704 @cindex Pattern matching
14705
14706 @noindent
14707 A complete implementation of Unix-style regular expression matching, copied
14708 from the original V7 style regular expression library written in C by
14709 Henry Spencer (and binary compatible with this C library).
14710
14711 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14712 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14713 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14714 @cindex Secondary Stack Info
14715
14716 @noindent
14717 Provide the capability to query the high water mark of the current task's
14718 secondary stack.
14719
14720 @node GNAT.Semaphores (g-semaph.ads)
14721 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14722 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14723 @cindex Semaphores
14724
14725 @noindent
14726 Provides classic counting and binary semaphores using protected types.
14727
14728 @node GNAT.Serial_Communications (g-sercom.ads)
14729 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14730 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14731 @cindex Serial_Communications
14732
14733 @noindent
14734 Provides a simple interface to send and receive data over a serial
14735 port. This is only supported on GNU/Linux and Windows.
14736
14737 @node GNAT.SHA1 (g-sha1.ads)
14738 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14739 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14740 @cindex Secure Hash Algorithm SHA-1
14741
14742 @noindent
14743 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14744 and RFC 3174.
14745
14746 @node GNAT.SHA224 (g-sha224.ads)
14747 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14748 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14749 @cindex Secure Hash Algorithm SHA-224
14750
14751 @noindent
14752 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14753
14754 @node GNAT.SHA256 (g-sha256.ads)
14755 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14756 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14757 @cindex Secure Hash Algorithm SHA-256
14758
14759 @noindent
14760 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14761
14762 @node GNAT.SHA384 (g-sha384.ads)
14763 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14764 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14765 @cindex Secure Hash Algorithm SHA-384
14766
14767 @noindent
14768 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14769
14770 @node GNAT.SHA512 (g-sha512.ads)
14771 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14772 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14773 @cindex Secure Hash Algorithm SHA-512
14774
14775 @noindent
14776 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14777
14778 @node GNAT.Signals (g-signal.ads)
14779 @section @code{GNAT.Signals} (@file{g-signal.ads})
14780 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14781 @cindex Signals
14782
14783 @noindent
14784 Provides the ability to manipulate the blocked status of signals on supported
14785 targets.
14786
14787 @node GNAT.Sockets (g-socket.ads)
14788 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14789 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14790 @cindex Sockets
14791
14792 @noindent
14793 A high level and portable interface to develop sockets based applications.
14794 This package is based on the sockets thin binding found in
14795 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14796 on all native GNAT ports except for OpenVMS@. It is not implemented
14797 for the LynxOS@ cross port.
14798
14799 @node GNAT.Source_Info (g-souinf.ads)
14800 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14801 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14802 @cindex Source Information
14803
14804 @noindent
14805 Provides subprograms that give access to source code information known at
14806 compile time, such as the current file name and line number.
14807
14808 @node GNAT.Spelling_Checker (g-speche.ads)
14809 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14810 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14811 @cindex Spell checking
14812
14813 @noindent
14814 Provides a function for determining whether one string is a plausible
14815 near misspelling of another string.
14816
14817 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14818 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14819 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14820 @cindex Spell checking
14821
14822 @noindent
14823 Provides a generic function that can be instantiated with a string type for
14824 determining whether one string is a plausible near misspelling of another
14825 string.
14826
14827 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14828 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14829 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14830 @cindex SPITBOL pattern matching
14831 @cindex Pattern matching
14832
14833 @noindent
14834 A complete implementation of SNOBOL4 style pattern matching. This is the
14835 most elaborate of the pattern matching packages provided. It fully duplicates
14836 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14837 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14838
14839 @node GNAT.Spitbol (g-spitbo.ads)
14840 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14841 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14842 @cindex SPITBOL interface
14843
14844 @noindent
14845 The top level package of the collection of SPITBOL-style functionality, this
14846 package provides basic SNOBOL4 string manipulation functions, such as
14847 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14848 useful for constructing arbitrary mappings from strings in the style of
14849 the SNOBOL4 TABLE function.
14850
14851 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14852 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14853 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14854 @cindex Sets of strings
14855 @cindex SPITBOL Tables
14856
14857 @noindent
14858 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14859 for type @code{Standard.Boolean}, giving an implementation of sets of
14860 string values.
14861
14862 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14863 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14864 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14865 @cindex Integer maps
14866 @cindex Maps
14867 @cindex SPITBOL Tables
14868
14869 @noindent
14870 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14871 for type @code{Standard.Integer}, giving an implementation of maps
14872 from string to integer values.
14873
14874 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14875 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14876 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14877 @cindex String maps
14878 @cindex Maps
14879 @cindex SPITBOL Tables
14880
14881 @noindent
14882 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14883 a variable length string type, giving an implementation of general
14884 maps from strings to strings.
14885
14886 @node GNAT.SSE (g-sse.ads)
14887 @section @code{GNAT.SSE} (@file{g-sse.ads})
14888 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14889
14890 @noindent
14891 Root of a set of units aimed at offering Ada bindings to a subset of
14892 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14893 targets. It exposes vector component types together with a general
14894 introduction to the binding contents and use.
14895
14896 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14897 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14898 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14899
14900 @noindent
14901 SSE vector types for use with SSE related intrinsics.
14902
14903 @node GNAT.Strings (g-string.ads)
14904 @section @code{GNAT.Strings} (@file{g-string.ads})
14905 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14906
14907 @noindent
14908 Common String access types and related subprograms. Basically it
14909 defines a string access and an array of string access types.
14910
14911 @node GNAT.String_Split (g-strspl.ads)
14912 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14913 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14914 @cindex String splitter
14915
14916 @noindent
14917 Useful string manipulation routines: given a set of separators, split
14918 a string wherever the separators appear, and provide direct access
14919 to the resulting slices. This package is instantiated from
14920 @code{GNAT.Array_Split}.
14921
14922 @node GNAT.Table (g-table.ads)
14923 @section @code{GNAT.Table} (@file{g-table.ads})
14924 @cindex @code{GNAT.Table} (@file{g-table.ads})
14925 @cindex Table implementation
14926 @cindex Arrays, extendable
14927
14928 @noindent
14929 A generic package providing a single dimension array abstraction where the
14930 length of the array can be dynamically modified.
14931
14932 @noindent
14933 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14934 except that this package declares a single instance of the table type,
14935 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14936 used to define dynamic instances of the table.
14937
14938 @node GNAT.Task_Lock (g-tasloc.ads)
14939 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14940 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14941 @cindex Task synchronization
14942 @cindex Task locking
14943 @cindex Locking
14944
14945 @noindent
14946 A very simple facility for locking and unlocking sections of code using a
14947 single global task lock. Appropriate for use in situations where contention
14948 between tasks is very rarely expected.
14949
14950 @node GNAT.Time_Stamp (g-timsta.ads)
14951 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14952 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14953 @cindex Time stamp
14954 @cindex Current time
14955
14956 @noindent
14957 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14958 represents the current date and time in ISO 8601 format. This is a very simple
14959 routine with minimal code and there are no dependencies on any other unit.
14960
14961 @node GNAT.Threads (g-thread.ads)
14962 @section @code{GNAT.Threads} (@file{g-thread.ads})
14963 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14964 @cindex Foreign threads
14965 @cindex Threads, foreign
14966
14967 @noindent
14968 Provides facilities for dealing with foreign threads which need to be known
14969 by the GNAT run-time system. Consult the documentation of this package for
14970 further details if your program has threads that are created by a non-Ada
14971 environment which then accesses Ada code.
14972
14973 @node GNAT.Traceback (g-traceb.ads)
14974 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14975 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14976 @cindex Trace back facilities
14977
14978 @noindent
14979 Provides a facility for obtaining non-symbolic traceback information, useful
14980 in various debugging situations.
14981
14982 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14983 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14984 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14985 @cindex Trace back facilities
14986
14987 @node GNAT.UTF_32 (g-utf_32.ads)
14988 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14989 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14990 @cindex Wide character codes
14991
14992 @noindent
14993 This is a package intended to be used in conjunction with the
14994 @code{Wide_Character} type in Ada 95 and the
14995 @code{Wide_Wide_Character} type in Ada 2005 (available
14996 in @code{GNAT} in Ada 2005 mode). This package contains
14997 Unicode categorization routines, as well as lexical
14998 categorization routines corresponding to the Ada 2005
14999 lexical rules for identifiers and strings, and also a
15000 lower case to upper case fold routine corresponding to
15001 the Ada 2005 rules for identifier equivalence.
15002
15003 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15004 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15005 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15006 @cindex Spell checking
15007
15008 @noindent
15009 Provides a function for determining whether one wide wide string is a plausible
15010 near misspelling of another wide wide string, where the strings are represented
15011 using the UTF_32_String type defined in System.Wch_Cnv.
15012
15013 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15014 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15015 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15016 @cindex Spell checking
15017
15018 @noindent
15019 Provides a function for determining whether one wide string is a plausible
15020 near misspelling of another wide string.
15021
15022 @node GNAT.Wide_String_Split (g-wistsp.ads)
15023 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15024 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15025 @cindex Wide_String splitter
15026
15027 @noindent
15028 Useful wide string manipulation routines: given a set of separators, split
15029 a wide string wherever the separators appear, and provide direct access
15030 to the resulting slices. This package is instantiated from
15031 @code{GNAT.Array_Split}.
15032
15033 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15034 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15035 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15036 @cindex Spell checking
15037
15038 @noindent
15039 Provides a function for determining whether one wide wide string is a plausible
15040 near misspelling of another wide wide string.
15041
15042 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15043 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15044 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15045 @cindex Wide_Wide_String splitter
15046
15047 @noindent
15048 Useful wide wide string manipulation routines: given a set of separators, split
15049 a wide wide string wherever the separators appear, and provide direct access
15050 to the resulting slices. This package is instantiated from
15051 @code{GNAT.Array_Split}.
15052
15053 @node Interfaces.C.Extensions (i-cexten.ads)
15054 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15055 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15056
15057 @noindent
15058 This package contains additional C-related definitions, intended
15059 for use with either manually or automatically generated bindings
15060 to C libraries.
15061
15062 @node Interfaces.C.Streams (i-cstrea.ads)
15063 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15064 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15065 @cindex C streams, interfacing
15066
15067 @noindent
15068 This package is a binding for the most commonly used operations
15069 on C streams.
15070
15071 @node Interfaces.CPP (i-cpp.ads)
15072 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15073 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15074 @cindex C++ interfacing
15075 @cindex Interfacing, to C++
15076
15077 @noindent
15078 This package provides facilities for use in interfacing to C++. It
15079 is primarily intended to be used in connection with automated tools
15080 for the generation of C++ interfaces.
15081
15082 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15083 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15084 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15085 @cindex IBM Packed Format
15086 @cindex Packed Decimal
15087
15088 @noindent
15089 This package provides a set of routines for conversions to and
15090 from a packed decimal format compatible with that used on IBM
15091 mainframes.
15092
15093 @node Interfaces.VxWorks (i-vxwork.ads)
15094 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15095 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15096 @cindex Interfacing to VxWorks
15097 @cindex VxWorks, interfacing
15098
15099 @noindent
15100 This package provides a limited binding to the VxWorks API.
15101 In particular, it interfaces with the
15102 VxWorks hardware interrupt facilities.
15103
15104 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15105 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15106 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15107 @cindex Interfacing to VxWorks' I/O
15108 @cindex VxWorks, I/O interfacing
15109 @cindex VxWorks, Get_Immediate
15110 @cindex Get_Immediate, VxWorks
15111
15112 @noindent
15113 This package provides a binding to the ioctl (IO/Control)
15114 function of VxWorks, defining a set of option values and
15115 function codes. A particular use of this package is
15116 to enable the use of Get_Immediate under VxWorks.
15117
15118 @node System.Address_Image (s-addima.ads)
15119 @section @code{System.Address_Image} (@file{s-addima.ads})
15120 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15121 @cindex Address image
15122 @cindex Image, of an address
15123
15124 @noindent
15125 This function provides a useful debugging
15126 function that gives an (implementation dependent)
15127 string which identifies an address.
15128
15129 @node System.Assertions (s-assert.ads)
15130 @section @code{System.Assertions} (@file{s-assert.ads})
15131 @cindex @code{System.Assertions} (@file{s-assert.ads})
15132 @cindex Assertions
15133 @cindex Assert_Failure, exception
15134
15135 @noindent
15136 This package provides the declaration of the exception raised
15137 by an run-time assertion failure, as well as the routine that
15138 is used internally to raise this assertion.
15139
15140 @node System.Memory (s-memory.ads)
15141 @section @code{System.Memory} (@file{s-memory.ads})
15142 @cindex @code{System.Memory} (@file{s-memory.ads})
15143 @cindex Memory allocation
15144
15145 @noindent
15146 This package provides the interface to the low level routines used
15147 by the generated code for allocation and freeing storage for the
15148 default storage pool (analogous to the C routines malloc and free.
15149 It also provides a reallocation interface analogous to the C routine
15150 realloc. The body of this unit may be modified to provide alternative
15151 allocation mechanisms for the default pool, and in addition, direct
15152 calls to this unit may be made for low level allocation uses (for
15153 example see the body of @code{GNAT.Tables}).
15154
15155 @node System.Partition_Interface (s-parint.ads)
15156 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15157 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15158 @cindex Partition interfacing functions
15159
15160 @noindent
15161 This package provides facilities for partition interfacing. It
15162 is used primarily in a distribution context when using Annex E
15163 with @code{GLADE}.
15164
15165 @node System.Pool_Global (s-pooglo.ads)
15166 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15167 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15168 @cindex Storage pool, global
15169 @cindex Global storage pool
15170
15171 @noindent
15172 This package provides a storage pool that is equivalent to the default
15173 storage pool used for access types for which no pool is specifically
15174 declared. It uses malloc/free to allocate/free and does not attempt to
15175 do any automatic reclamation.
15176
15177 @node System.Pool_Local (s-pooloc.ads)
15178 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15179 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15180 @cindex Storage pool, local
15181 @cindex Local storage pool
15182
15183 @noindent
15184 This package provides a storage pool that is intended for use with locally
15185 defined access types. It uses malloc/free for allocate/free, and maintains
15186 a list of allocated blocks, so that all storage allocated for the pool can
15187 be freed automatically when the pool is finalized.
15188
15189 @node System.Restrictions (s-restri.ads)
15190 @section @code{System.Restrictions} (@file{s-restri.ads})
15191 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15192 @cindex Run-time restrictions access
15193
15194 @noindent
15195 This package provides facilities for accessing at run time
15196 the status of restrictions specified at compile time for
15197 the partition. Information is available both with regard
15198 to actual restrictions specified, and with regard to
15199 compiler determined information on which restrictions
15200 are violated by one or more packages in the partition.
15201
15202 @node System.Rident (s-rident.ads)
15203 @section @code{System.Rident} (@file{s-rident.ads})
15204 @cindex @code{System.Rident} (@file{s-rident.ads})
15205 @cindex Restrictions definitions
15206
15207 @noindent
15208 This package provides definitions of the restrictions
15209 identifiers supported by GNAT, and also the format of
15210 the restrictions provided in package System.Restrictions.
15211 It is not normally necessary to @code{with} this generic package
15212 since the necessary instantiation is included in
15213 package System.Restrictions.
15214
15215 @node System.Strings.Stream_Ops (s-ststop.ads)
15216 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15217 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15218 @cindex Stream operations
15219 @cindex String stream operations
15220
15221 @noindent
15222 This package provides a set of stream subprograms for standard string types.
15223 It is intended primarily to support implicit use of such subprograms when
15224 stream attributes are applied to string types, but the subprograms in this
15225 package can be used directly by application programs.
15226
15227 @node System.Task_Info (s-tasinf.ads)
15228 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15229 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15230 @cindex Task_Info pragma
15231
15232 @noindent
15233 This package provides target dependent functionality that is used
15234 to support the @code{Task_Info} pragma
15235
15236 @node System.Wch_Cnv (s-wchcnv.ads)
15237 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15238 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15239 @cindex Wide Character, Representation
15240 @cindex Wide String, Conversion
15241 @cindex Representation of wide characters
15242
15243 @noindent
15244 This package provides routines for converting between
15245 wide and wide wide characters and a representation as a value of type
15246 @code{Standard.String}, using a specified wide character
15247 encoding method. It uses definitions in
15248 package @code{System.Wch_Con}.
15249
15250 @node System.Wch_Con (s-wchcon.ads)
15251 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15252 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15253
15254 @noindent
15255 This package provides definitions and descriptions of
15256 the various methods used for encoding wide characters
15257 in ordinary strings. These definitions are used by
15258 the package @code{System.Wch_Cnv}.
15259
15260 @node Interfacing to Other Languages
15261 @chapter Interfacing to Other Languages
15262 @noindent
15263 The facilities in annex B of the Ada Reference Manual are fully
15264 implemented in GNAT, and in addition, a full interface to C++ is
15265 provided.
15266
15267 @menu
15268 * Interfacing to C::
15269 * Interfacing to C++::
15270 * Interfacing to COBOL::
15271 * Interfacing to Fortran::
15272 * Interfacing to non-GNAT Ada code::
15273 @end menu
15274
15275 @node Interfacing to C
15276 @section Interfacing to C
15277
15278 @noindent
15279 Interfacing to C with GNAT can use one of two approaches:
15280
15281 @itemize @bullet
15282 @item
15283 The types in the package @code{Interfaces.C} may be used.
15284 @item
15285 Standard Ada types may be used directly. This may be less portable to
15286 other compilers, but will work on all GNAT compilers, which guarantee
15287 correspondence between the C and Ada types.
15288 @end itemize
15289
15290 @noindent
15291 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15292 effect, since this is the default. The following table shows the
15293 correspondence between Ada scalar types and the corresponding C types.
15294
15295 @table @code
15296 @item Integer
15297 @code{int}
15298 @item Short_Integer
15299 @code{short}
15300 @item Short_Short_Integer
15301 @code{signed char}
15302 @item Long_Integer
15303 @code{long}
15304 @item Long_Long_Integer
15305 @code{long long}
15306 @item Short_Float
15307 @code{float}
15308 @item Float
15309 @code{float}
15310 @item Long_Float
15311 @code{double}
15312 @item Long_Long_Float
15313 This is the longest floating-point type supported by the hardware.
15314 @end table
15315
15316 @noindent
15317 Additionally, there are the following general correspondences between Ada
15318 and C types:
15319 @itemize @bullet
15320 @item
15321 Ada enumeration types map to C enumeration types directly if pragma
15322 @code{Convention C} is specified, which causes them to have int
15323 length. Without pragma @code{Convention C}, Ada enumeration types map to
15324 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15325 @code{int}, respectively) depending on the number of values passed.
15326 This is the only case in which pragma @code{Convention C} affects the
15327 representation of an Ada type.
15328
15329 @item
15330 Ada access types map to C pointers, except for the case of pointers to
15331 unconstrained types in Ada, which have no direct C equivalent.
15332
15333 @item
15334 Ada arrays map directly to C arrays.
15335
15336 @item
15337 Ada records map directly to C structures.
15338
15339 @item
15340 Packed Ada records map to C structures where all members are bit fields
15341 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15342 @end itemize
15343
15344 @node Interfacing to C++
15345 @section Interfacing to C++
15346
15347 @noindent
15348 The interface to C++ makes use of the following pragmas, which are
15349 primarily intended to be constructed automatically using a binding generator
15350 tool, although it is possible to construct them by hand. No suitable binding
15351 generator tool is supplied with GNAT though.
15352
15353 Using these pragmas it is possible to achieve complete
15354 inter-operability between Ada tagged types and C++ class definitions.
15355 See @ref{Implementation Defined Pragmas}, for more details.
15356
15357 @table @code
15358 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15359 The argument denotes an entity in the current declarative region that is
15360 declared as a tagged or untagged record type. It indicates that the type
15361 corresponds to an externally declared C++ class type, and is to be laid
15362 out the same way that C++ would lay out the type.
15363
15364 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15365 for backward compatibility but its functionality is available
15366 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15367
15368 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15369 This pragma identifies an imported function (imported in the usual way
15370 with pragma @code{Import}) as corresponding to a C++ constructor.
15371 @end table
15372
15373 @node Interfacing to COBOL
15374 @section Interfacing to COBOL
15375
15376 @noindent
15377 Interfacing to COBOL is achieved as described in section B.4 of
15378 the Ada Reference Manual.
15379
15380 @node Interfacing to Fortran
15381 @section Interfacing to Fortran
15382
15383 @noindent
15384 Interfacing to Fortran is achieved as described in section B.5 of the
15385 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15386 multi-dimensional array causes the array to be stored in column-major
15387 order as required for convenient interface to Fortran.
15388
15389 @node Interfacing to non-GNAT Ada code
15390 @section Interfacing to non-GNAT Ada code
15391
15392 It is possible to specify the convention @code{Ada} in a pragma
15393 @code{Import} or pragma @code{Export}. However this refers to
15394 the calling conventions used by GNAT, which may or may not be
15395 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15396 compiler to allow interoperation.
15397
15398 If arguments types are kept simple, and if the foreign compiler generally
15399 follows system calling conventions, then it may be possible to integrate
15400 files compiled by other Ada compilers, provided that the elaboration
15401 issues are adequately addressed (for example by eliminating the
15402 need for any load time elaboration).
15403
15404 In particular, GNAT running on VMS is designed to
15405 be highly compatible with the DEC Ada 83 compiler, so this is one
15406 case in which it is possible to import foreign units of this type,
15407 provided that the data items passed are restricted to simple scalar
15408 values or simple record types without variants, or simple array
15409 types with fixed bounds.
15410
15411 @node Specialized Needs Annexes
15412 @chapter Specialized Needs Annexes
15413
15414 @noindent
15415 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15416 required in all implementations. However, as described in this chapter,
15417 GNAT implements all of these annexes:
15418
15419 @table @asis
15420 @item Systems Programming (Annex C)
15421 The Systems Programming Annex is fully implemented.
15422
15423 @item Real-Time Systems (Annex D)
15424 The Real-Time Systems Annex is fully implemented.
15425
15426 @item Distributed Systems (Annex E)
15427 Stub generation is fully implemented in the GNAT compiler. In addition,
15428 a complete compatible PCS is available as part of the GLADE system,
15429 a separate product. When the two
15430 products are used in conjunction, this annex is fully implemented.
15431
15432 @item Information Systems (Annex F)
15433 The Information Systems annex is fully implemented.
15434
15435 @item Numerics (Annex G)
15436 The Numerics Annex is fully implemented.
15437
15438 @item Safety and Security / High-Integrity Systems (Annex H)
15439 The Safety and Security Annex (termed the High-Integrity Systems Annex
15440 in Ada 2005) is fully implemented.
15441 @end table
15442
15443 @node Implementation of Specific Ada Features
15444 @chapter Implementation of Specific Ada Features
15445
15446 @noindent
15447 This chapter describes the GNAT implementation of several Ada language
15448 facilities.
15449
15450 @menu
15451 * Machine Code Insertions::
15452 * GNAT Implementation of Tasking::
15453 * GNAT Implementation of Shared Passive Packages::
15454 * Code Generation for Array Aggregates::
15455 * The Size of Discriminated Records with Default Discriminants::
15456 * Strict Conformance to the Ada Reference Manual::
15457 @end menu
15458
15459 @node Machine Code Insertions
15460 @section Machine Code Insertions
15461 @cindex Machine Code insertions
15462
15463 @noindent
15464 Package @code{Machine_Code} provides machine code support as described
15465 in the Ada Reference Manual in two separate forms:
15466 @itemize @bullet
15467 @item
15468 Machine code statements, consisting of qualified expressions that
15469 fit the requirements of RM section 13.8.
15470 @item
15471 An intrinsic callable procedure, providing an alternative mechanism of
15472 including machine instructions in a subprogram.
15473 @end itemize
15474
15475 @noindent
15476 The two features are similar, and both are closely related to the mechanism
15477 provided by the asm instruction in the GNU C compiler. Full understanding
15478 and use of the facilities in this package requires understanding the asm
15479 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15480 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15481
15482 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15483 semantic restrictions and effects as described below. Both are provided so
15484 that the procedure call can be used as a statement, and the function call
15485 can be used to form a code_statement.
15486
15487 The first example given in the GCC documentation is the C @code{asm}
15488 instruction:
15489 @smallexample
15490 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15491 @end smallexample
15492
15493 @noindent
15494 The equivalent can be written for GNAT as:
15495
15496 @smallexample @c ada
15497 Asm ("fsinx %1 %0",
15498 My_Float'Asm_Output ("=f", result),
15499 My_Float'Asm_Input ("f", angle));
15500 @end smallexample
15501
15502 @noindent
15503 The first argument to @code{Asm} is the assembler template, and is
15504 identical to what is used in GNU C@. This string must be a static
15505 expression. The second argument is the output operand list. It is
15506 either a single @code{Asm_Output} attribute reference, or a list of such
15507 references enclosed in parentheses (technically an array aggregate of
15508 such references).
15509
15510 The @code{Asm_Output} attribute denotes a function that takes two
15511 parameters. The first is a string, the second is the name of a variable
15512 of the type designated by the attribute prefix. The first (string)
15513 argument is required to be a static expression and designates the
15514 constraint for the parameter (e.g.@: what kind of register is
15515 required). The second argument is the variable to be updated with the
15516 result. The possible values for constraint are the same as those used in
15517 the RTL, and are dependent on the configuration file used to build the
15518 GCC back end. If there are no output operands, then this argument may
15519 either be omitted, or explicitly given as @code{No_Output_Operands}.
15520
15521 The second argument of @code{@var{my_float}'Asm_Output} functions as
15522 though it were an @code{out} parameter, which is a little curious, but
15523 all names have the form of expressions, so there is no syntactic
15524 irregularity, even though normally functions would not be permitted
15525 @code{out} parameters. The third argument is the list of input
15526 operands. It is either a single @code{Asm_Input} attribute reference, or
15527 a list of such references enclosed in parentheses (technically an array
15528 aggregate of such references).
15529
15530 The @code{Asm_Input} attribute denotes a function that takes two
15531 parameters. The first is a string, the second is an expression of the
15532 type designated by the prefix. The first (string) argument is required
15533 to be a static expression, and is the constraint for the parameter,
15534 (e.g.@: what kind of register is required). The second argument is the
15535 value to be used as the input argument. The possible values for the
15536 constant are the same as those used in the RTL, and are dependent on
15537 the configuration file used to built the GCC back end.
15538
15539 If there are no input operands, this argument may either be omitted, or
15540 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15541 present in the above example, is a list of register names, called the
15542 @dfn{clobber} argument. This argument, if given, must be a static string
15543 expression, and is a space or comma separated list of names of registers
15544 that must be considered destroyed as a result of the @code{Asm} call. If
15545 this argument is the null string (the default value), then the code
15546 generator assumes that no additional registers are destroyed.
15547
15548 The fifth argument, not present in the above example, called the
15549 @dfn{volatile} argument, is by default @code{False}. It can be set to
15550 the literal value @code{True} to indicate to the code generator that all
15551 optimizations with respect to the instruction specified should be
15552 suppressed, and that in particular, for an instruction that has outputs,
15553 the instruction will still be generated, even if none of the outputs are
15554 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15555 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15556 Generally it is strongly advisable to use Volatile for any ASM statement
15557 that is missing either input or output operands, or when two or more ASM
15558 statements appear in sequence, to avoid unwanted optimizations. A warning
15559 is generated if this advice is not followed.
15560
15561 The @code{Asm} subprograms may be used in two ways. First the procedure
15562 forms can be used anywhere a procedure call would be valid, and
15563 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15564 be used to intersperse machine instructions with other Ada statements.
15565 Second, the function forms, which return a dummy value of the limited
15566 private type @code{Asm_Insn}, can be used in code statements, and indeed
15567 this is the only context where such calls are allowed. Code statements
15568 appear as aggregates of the form:
15569
15570 @smallexample @c ada
15571 Asm_Insn'(Asm (@dots{}));
15572 Asm_Insn'(Asm_Volatile (@dots{}));
15573 @end smallexample
15574
15575 @noindent
15576 In accordance with RM rules, such code statements are allowed only
15577 within subprograms whose entire body consists of such statements. It is
15578 not permissible to intermix such statements with other Ada statements.
15579
15580 Typically the form using intrinsic procedure calls is more convenient
15581 and more flexible. The code statement form is provided to meet the RM
15582 suggestion that such a facility should be made available. The following
15583 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15584 is used, the arguments may be given in arbitrary order, following the
15585 normal rules for use of positional and named arguments)
15586
15587 @smallexample
15588 ASM_CALL ::= Asm (
15589 [Template =>] static_string_EXPRESSION
15590 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15591 [,[Inputs =>] INPUT_OPERAND_LIST ]
15592 [,[Clobber =>] static_string_EXPRESSION ]
15593 [,[Volatile =>] static_boolean_EXPRESSION] )
15594
15595 OUTPUT_OPERAND_LIST ::=
15596 [PREFIX.]No_Output_Operands
15597 | OUTPUT_OPERAND_ATTRIBUTE
15598 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15599
15600 OUTPUT_OPERAND_ATTRIBUTE ::=
15601 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15602
15603 INPUT_OPERAND_LIST ::=
15604 [PREFIX.]No_Input_Operands
15605 | INPUT_OPERAND_ATTRIBUTE
15606 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15607
15608 INPUT_OPERAND_ATTRIBUTE ::=
15609 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15610 @end smallexample
15611
15612 @noindent
15613 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15614 are declared in the package @code{Machine_Code} and must be referenced
15615 according to normal visibility rules. In particular if there is no
15616 @code{use} clause for this package, then appropriate package name
15617 qualification is required.
15618
15619 @node GNAT Implementation of Tasking
15620 @section GNAT Implementation of Tasking
15621
15622 @noindent
15623 This chapter outlines the basic GNAT approach to tasking (in particular,
15624 a multi-layered library for portability) and discusses issues related
15625 to compliance with the Real-Time Systems Annex.
15626
15627 @menu
15628 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15629 * Ensuring Compliance with the Real-Time Annex::
15630 @end menu
15631
15632 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15633 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15634
15635 @noindent
15636 GNAT's run-time support comprises two layers:
15637
15638 @itemize @bullet
15639 @item GNARL (GNAT Run-time Layer)
15640 @item GNULL (GNAT Low-level Library)
15641 @end itemize
15642
15643 @noindent
15644 In GNAT, Ada's tasking services rely on a platform and OS independent
15645 layer known as GNARL@. This code is responsible for implementing the
15646 correct semantics of Ada's task creation, rendezvous, protected
15647 operations etc.
15648
15649 GNARL decomposes Ada's tasking semantics into simpler lower level
15650 operations such as create a thread, set the priority of a thread,
15651 yield, create a lock, lock/unlock, etc. The spec for these low-level
15652 operations constitutes GNULLI, the GNULL Interface. This interface is
15653 directly inspired from the POSIX real-time API@.
15654
15655 If the underlying executive or OS implements the POSIX standard
15656 faithfully, the GNULL Interface maps as is to the services offered by
15657 the underlying kernel. Otherwise, some target dependent glue code maps
15658 the services offered by the underlying kernel to the semantics expected
15659 by GNARL@.
15660
15661 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
15662 key point is that each Ada task is mapped on a thread in the underlying
15663 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15664
15665 In addition Ada task priorities map onto the underlying thread priorities.
15666 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15667
15668 @itemize @bullet
15669 @item
15670 The underlying scheduler is used to schedule the Ada tasks. This
15671 makes Ada tasks as efficient as kernel threads from a scheduling
15672 standpoint.
15673
15674 @item
15675 Interaction with code written in C containing threads is eased
15676 since at the lowest level Ada tasks and C threads map onto the same
15677 underlying kernel concept.
15678
15679 @item
15680 When an Ada task is blocked during I/O the remaining Ada tasks are
15681 able to proceed.
15682
15683 @item
15684 On multiprocessor systems Ada tasks can execute in parallel.
15685 @end itemize
15686
15687 @noindent
15688 Some threads libraries offer a mechanism to fork a new process, with the
15689 child process duplicating the threads from the parent.
15690 GNAT does not
15691 support this functionality when the parent contains more than one task.
15692 @cindex Forking a new process
15693
15694 @node Ensuring Compliance with the Real-Time Annex
15695 @subsection Ensuring Compliance with the Real-Time Annex
15696 @cindex Real-Time Systems Annex compliance
15697
15698 @noindent
15699 Although mapping Ada tasks onto
15700 the underlying threads has significant advantages, it does create some
15701 complications when it comes to respecting the scheduling semantics
15702 specified in the real-time annex (Annex D).
15703
15704 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15705 scheduling policy states:
15706
15707 @quotation
15708 @emph{When the active priority of a ready task that is not running
15709 changes, or the setting of its base priority takes effect, the
15710 task is removed from the ready queue for its old active priority
15711 and is added at the tail of the ready queue for its new active
15712 priority, except in the case where the active priority is lowered
15713 due to the loss of inherited priority, in which case the task is
15714 added at the head of the ready queue for its new active priority.}
15715 @end quotation
15716
15717 @noindent
15718 While most kernels do put tasks at the end of the priority queue when
15719 a task changes its priority, (which respects the main
15720 FIFO_Within_Priorities requirement), almost none keep a thread at the
15721 beginning of its priority queue when its priority drops from the loss
15722 of inherited priority.
15723
15724 As a result most vendors have provided incomplete Annex D implementations.
15725
15726 The GNAT run-time, has a nice cooperative solution to this problem
15727 which ensures that accurate FIFO_Within_Priorities semantics are
15728 respected.
15729
15730 The principle is as follows. When an Ada task T is about to start
15731 running, it checks whether some other Ada task R with the same
15732 priority as T has been suspended due to the loss of priority
15733 inheritance. If this is the case, T yields and is placed at the end of
15734 its priority queue. When R arrives at the front of the queue it
15735 executes.
15736
15737 Note that this simple scheme preserves the relative order of the tasks
15738 that were ready to execute in the priority queue where R has been
15739 placed at the end.
15740
15741 @node GNAT Implementation of Shared Passive Packages
15742 @section GNAT Implementation of Shared Passive Packages
15743 @cindex Shared passive packages
15744
15745 @noindent
15746 GNAT fully implements the pragma @code{Shared_Passive} for
15747 @cindex pragma @code{Shared_Passive}
15748 the purpose of designating shared passive packages.
15749 This allows the use of passive partitions in the
15750 context described in the Ada Reference Manual; i.e., for communication
15751 between separate partitions of a distributed application using the
15752 features in Annex E.
15753 @cindex Annex E
15754 @cindex Distribution Systems Annex
15755
15756 However, the implementation approach used by GNAT provides for more
15757 extensive usage as follows:
15758
15759 @table @emph
15760 @item Communication between separate programs
15761
15762 This allows separate programs to access the data in passive
15763 partitions, using protected objects for synchronization where
15764 needed. The only requirement is that the two programs have a
15765 common shared file system. It is even possible for programs
15766 running on different machines with different architectures
15767 (e.g.@: different endianness) to communicate via the data in
15768 a passive partition.
15769
15770 @item Persistence between program runs
15771
15772 The data in a passive package can persist from one run of a
15773 program to another, so that a later program sees the final
15774 values stored by a previous run of the same program.
15775
15776 @end table
15777
15778 @noindent
15779 The implementation approach used is to store the data in files. A
15780 separate stream file is created for each object in the package, and
15781 an access to an object causes the corresponding file to be read or
15782 written.
15783
15784 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15785 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15786 set to the directory to be used for these files.
15787 The files in this directory
15788 have names that correspond to their fully qualified names. For
15789 example, if we have the package
15790
15791 @smallexample @c ada
15792 package X is
15793 pragma Shared_Passive (X);
15794 Y : Integer;
15795 Z : Float;
15796 end X;
15797 @end smallexample
15798
15799 @noindent
15800 and the environment variable is set to @code{/stemp/}, then the files created
15801 will have the names:
15802
15803 @smallexample
15804 /stemp/x.y
15805 /stemp/x.z
15806 @end smallexample
15807
15808 @noindent
15809 These files are created when a value is initially written to the object, and
15810 the files are retained until manually deleted. This provides the persistence
15811 semantics. If no file exists, it means that no partition has assigned a value
15812 to the variable; in this case the initial value declared in the package
15813 will be used. This model ensures that there are no issues in synchronizing
15814 the elaboration process, since elaboration of passive packages elaborates the
15815 initial values, but does not create the files.
15816
15817 The files are written using normal @code{Stream_IO} access.
15818 If you want to be able
15819 to communicate between programs or partitions running on different
15820 architectures, then you should use the XDR versions of the stream attribute
15821 routines, since these are architecture independent.
15822
15823 If active synchronization is required for access to the variables in the
15824 shared passive package, then as described in the Ada Reference Manual, the
15825 package may contain protected objects used for this purpose. In this case
15826 a lock file (whose name is @file{___lock} (three underscores)
15827 is created in the shared memory directory.
15828 @cindex @file{___lock} file (for shared passive packages)
15829 This is used to provide the required locking
15830 semantics for proper protected object synchronization.
15831
15832 As of January 2003, GNAT supports shared passive packages on all platforms
15833 except for OpenVMS.
15834
15835 @node Code Generation for Array Aggregates
15836 @section Code Generation for Array Aggregates
15837
15838 @menu
15839 * Static constant aggregates with static bounds::
15840 * Constant aggregates with unconstrained nominal types::
15841 * Aggregates with static bounds::
15842 * Aggregates with non-static bounds::
15843 * Aggregates in assignment statements::
15844 @end menu
15845
15846 @noindent
15847 Aggregates have a rich syntax and allow the user to specify the values of
15848 complex data structures by means of a single construct. As a result, the
15849 code generated for aggregates can be quite complex and involve loops, case
15850 statements and multiple assignments. In the simplest cases, however, the
15851 compiler will recognize aggregates whose components and constraints are
15852 fully static, and in those cases the compiler will generate little or no
15853 executable code. The following is an outline of the code that GNAT generates
15854 for various aggregate constructs. For further details, you will find it
15855 useful to examine the output produced by the -gnatG flag to see the expanded
15856 source that is input to the code generator. You may also want to examine
15857 the assembly code generated at various levels of optimization.
15858
15859 The code generated for aggregates depends on the context, the component values,
15860 and the type. In the context of an object declaration the code generated is
15861 generally simpler than in the case of an assignment. As a general rule, static
15862 component values and static subtypes also lead to simpler code.
15863
15864 @node Static constant aggregates with static bounds
15865 @subsection Static constant aggregates with static bounds
15866
15867 @noindent
15868 For the declarations:
15869 @smallexample @c ada
15870 type One_Dim is array (1..10) of integer;
15871 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15872 @end smallexample
15873
15874 @noindent
15875 GNAT generates no executable code: the constant ar0 is placed in static memory.
15876 The same is true for constant aggregates with named associations:
15877
15878 @smallexample @c ada
15879 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15880 Cr3 : constant One_Dim := (others => 7777);
15881 @end smallexample
15882
15883 @noindent
15884 The same is true for multidimensional constant arrays such as:
15885
15886 @smallexample @c ada
15887 type two_dim is array (1..3, 1..3) of integer;
15888 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15889 @end smallexample
15890
15891 @noindent
15892 The same is true for arrays of one-dimensional arrays: the following are
15893 static:
15894
15895 @smallexample @c ada
15896 type ar1b is array (1..3) of boolean;
15897 type ar_ar is array (1..3) of ar1b;
15898 None : constant ar1b := (others => false); -- fully static
15899 None2 : constant ar_ar := (1..3 => None); -- fully static
15900 @end smallexample
15901
15902 @noindent
15903 However, for multidimensional aggregates with named associations, GNAT will
15904 generate assignments and loops, even if all associations are static. The
15905 following two declarations generate a loop for the first dimension, and
15906 individual component assignments for the second dimension:
15907
15908 @smallexample @c ada
15909 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15910 Zero2: constant two_dim := (others => (others => 0));
15911 @end smallexample
15912
15913 @node Constant aggregates with unconstrained nominal types
15914 @subsection Constant aggregates with unconstrained nominal types
15915
15916 @noindent
15917 In such cases the aggregate itself establishes the subtype, so that
15918 associations with @code{others} cannot be used. GNAT determines the
15919 bounds for the actual subtype of the aggregate, and allocates the
15920 aggregate statically as well. No code is generated for the following:
15921
15922 @smallexample @c ada
15923 type One_Unc is array (natural range <>) of integer;
15924 Cr_Unc : constant One_Unc := (12,24,36);
15925 @end smallexample
15926
15927 @node Aggregates with static bounds
15928 @subsection Aggregates with static bounds
15929
15930 @noindent
15931 In all previous examples the aggregate was the initial (and immutable) value
15932 of a constant. If the aggregate initializes a variable, then code is generated
15933 for it as a combination of individual assignments and loops over the target
15934 object. The declarations
15935
15936 @smallexample @c ada
15937 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15938 Cr_Var2 : One_Dim := (others > -1);
15939 @end smallexample
15940
15941 @noindent
15942 generate the equivalent of
15943
15944 @smallexample @c ada
15945 Cr_Var1 (1) := 2;
15946 Cr_Var1 (2) := 3;
15947 Cr_Var1 (3) := 5;
15948 Cr_Var1 (4) := 11;
15949
15950 for I in Cr_Var2'range loop
15951 Cr_Var2 (I) := -1;
15952 end loop;
15953 @end smallexample
15954
15955 @node Aggregates with non-static bounds
15956 @subsection Aggregates with non-static bounds
15957
15958 @noindent
15959 If the bounds of the aggregate are not statically compatible with the bounds
15960 of the nominal subtype of the target, then constraint checks have to be
15961 generated on the bounds. For a multidimensional array, constraint checks may
15962 have to be applied to sub-arrays individually, if they do not have statically
15963 compatible subtypes.
15964
15965 @node Aggregates in assignment statements
15966 @subsection Aggregates in assignment statements
15967
15968 @noindent
15969 In general, aggregate assignment requires the construction of a temporary,
15970 and a copy from the temporary to the target of the assignment. This is because
15971 it is not always possible to convert the assignment into a series of individual
15972 component assignments. For example, consider the simple case:
15973
15974 @smallexample @c ada
15975 A := (A(2), A(1));
15976 @end smallexample
15977
15978 @noindent
15979 This cannot be converted into:
15980
15981 @smallexample @c ada
15982 A(1) := A(2);
15983 A(2) := A(1);
15984 @end smallexample
15985
15986 @noindent
15987 So the aggregate has to be built first in a separate location, and then
15988 copied into the target. GNAT recognizes simple cases where this intermediate
15989 step is not required, and the assignments can be performed in place, directly
15990 into the target. The following sufficient criteria are applied:
15991
15992 @itemize @bullet
15993 @item
15994 The bounds of the aggregate are static, and the associations are static.
15995 @item
15996 The components of the aggregate are static constants, names of
15997 simple variables that are not renamings, or expressions not involving
15998 indexed components whose operands obey these rules.
15999 @end itemize
16000
16001 @noindent
16002 If any of these conditions are violated, the aggregate will be built in
16003 a temporary (created either by the front-end or the code generator) and then
16004 that temporary will be copied onto the target.
16005
16006 @node The Size of Discriminated Records with Default Discriminants
16007 @section The Size of Discriminated Records with Default Discriminants
16008
16009 @noindent
16010 If a discriminated type @code{T} has discriminants with default values, it is
16011 possible to declare an object of this type without providing an explicit
16012 constraint:
16013
16014 @smallexample @c ada
16015 @group
16016 type Size is range 1..100;
16017
16018 type Rec (D : Size := 15) is record
16019 Name : String (1..D);
16020 end T;
16021
16022 Word : Rec;
16023 @end group
16024 @end smallexample
16025
16026 @noindent
16027 Such an object is said to be @emph{unconstrained}.
16028 The discriminant of the object
16029 can be modified by a full assignment to the object, as long as it preserves the
16030 relation between the value of the discriminant, and the value of the components
16031 that depend on it:
16032
16033 @smallexample @c ada
16034 @group
16035 Word := (3, "yes");
16036
16037 Word := (5, "maybe");
16038
16039 Word := (5, "no"); -- raises Constraint_Error
16040 @end group
16041 @end smallexample
16042
16043 @noindent
16044 In order to support this behavior efficiently, an unconstrained object is
16045 given the maximum size that any value of the type requires. In the case
16046 above, @code{Word} has storage for the discriminant and for
16047 a @code{String} of length 100.
16048 It is important to note that unconstrained objects do not require dynamic
16049 allocation. It would be an improper implementation to place on the heap those
16050 components whose size depends on discriminants. (This improper implementation
16051 was used by some Ada83 compilers, where the @code{Name} component above
16052 would have
16053 been stored as a pointer to a dynamic string). Following the principle that
16054 dynamic storage management should never be introduced implicitly,
16055 an Ada compiler should reserve the full size for an unconstrained declared
16056 object, and place it on the stack.
16057
16058 This maximum size approach
16059 has been a source of surprise to some users, who expect the default
16060 values of the discriminants to determine the size reserved for an
16061 unconstrained object: ``If the default is 15, why should the object occupy
16062 a larger size?''
16063 The answer, of course, is that the discriminant may be later modified,
16064 and its full range of values must be taken into account. This is why the
16065 declaration:
16066
16067 @smallexample
16068 @group
16069 type Rec (D : Positive := 15) is record
16070 Name : String (1..D);
16071 end record;
16072
16073 Too_Large : Rec;
16074 @end group
16075 @end smallexample
16076
16077 @noindent
16078 is flagged by the compiler with a warning:
16079 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16080 because the required size includes @code{Positive'Last}
16081 bytes. As the first example indicates, the proper approach is to declare an
16082 index type of ``reasonable'' range so that unconstrained objects are not too
16083 large.
16084
16085 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16086 created in the heap by means of an allocator, then it is @emph{not}
16087 unconstrained:
16088 it is constrained by the default values of the discriminants, and those values
16089 cannot be modified by full assignment. This is because in the presence of
16090 aliasing all views of the object (which may be manipulated by different tasks,
16091 say) must be consistent, so it is imperative that the object, once created,
16092 remain invariant.
16093
16094 @node Strict Conformance to the Ada Reference Manual
16095 @section Strict Conformance to the Ada Reference Manual
16096
16097 @noindent
16098 The dynamic semantics defined by the Ada Reference Manual impose a set of
16099 run-time checks to be generated. By default, the GNAT compiler will insert many
16100 run-time checks into the compiled code, including most of those required by the
16101 Ada Reference Manual. However, there are three checks that are not enabled
16102 in the default mode for efficiency reasons: arithmetic overflow checking for
16103 integer operations (including division by zero), checks for access before
16104 elaboration on subprogram calls, and stack overflow checking (most operating
16105 systems do not perform this check by default).
16106
16107 Strict conformance to the Ada Reference Manual can be achieved by adding
16108 three compiler options for overflow checking for integer operations
16109 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16110 calls and generic instantiations (@option{-gnatE}), and stack overflow
16111 checking (@option{-fstack-check}).
16112
16113 Note that the result of a floating point arithmetic operation in overflow and
16114 invalid situations, when the @code{Machine_Overflows} attribute of the result
16115 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16116 case for machines compliant with the IEEE floating-point standard, but on
16117 machines that are not fully compliant with this standard, such as Alpha, the
16118 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16119 behavior (although at the cost of a significant performance penalty), so
16120 infinite and and NaN values are properly generated.
16121
16122 @node Obsolescent Features
16123 @chapter Obsolescent Features
16124
16125 @noindent
16126 This chapter describes features that are provided by GNAT, but are
16127 considered obsolescent since there are preferred ways of achieving
16128 the same effect. These features are provided solely for historical
16129 compatibility purposes.
16130
16131 @menu
16132 * pragma No_Run_Time::
16133 * pragma Ravenscar::
16134 * pragma Restricted_Run_Time::
16135 @end menu
16136
16137 @node pragma No_Run_Time
16138 @section pragma No_Run_Time
16139
16140 The pragma @code{No_Run_Time} is used to achieve an affect similar
16141 to the use of the "Zero Foot Print" configurable run time, but without
16142 requiring a specially configured run time. The result of using this
16143 pragma, which must be used for all units in a partition, is to restrict
16144 the use of any language features requiring run-time support code. The
16145 preferred usage is to use an appropriately configured run-time that
16146 includes just those features that are to be made accessible.
16147
16148 @node pragma Ravenscar
16149 @section pragma Ravenscar
16150
16151 The pragma @code{Ravenscar} has exactly the same effect as pragma
16152 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16153 is part of the new Ada 2005 standard.
16154
16155 @node pragma Restricted_Run_Time
16156 @section pragma Restricted_Run_Time
16157
16158 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16159 pragma @code{Profile (Restricted)}. The latter usage is
16160 preferred since the Ada 2005 pragma @code{Profile} is intended for
16161 this kind of implementation dependent addition.
16162
16163 @include fdl.texi
16164 @c GNU Free Documentation License
16165
16166 @node Index,,GNU Free Documentation License, Top
16167 @unnumbered Index
16168
16169 @printindex cp
16170
16171 @contents
16172
16173 @bye