OSDN Git Service

2005-06-10 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.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              Copyright (C) 1995-2005 Free Software Foundation              o
12 @c                                                                            o
13 @c                                                                            o
14 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
15 @c                                                                            o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
17
18 @setfilename gnat_rm.info
19
20 @set FSFEDITION
21
22 @settitle GNAT Reference Manual
23
24 @setchapternewpage odd
25 @syncodeindex fn cp
26
27 @include gcc-common.texi
28
29 @dircategory GNU Ada tools
30 @direntry
31 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
32 @end direntry
33
34 @copying
35 Copyright @copyright{} 1995-2004, Free Software Foundation
36
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
44 @end copying
45
46 @titlepage
47
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author Ada Core Technologies, Inc.
52
53 @page
54 @vskip 0pt plus 1filll
55
56 @insertcopying
57
58 @end titlepage
59
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
63
64 @noindent
65 GNAT Reference Manual
66
67 @noindent
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
70
71 @noindent
72 Ada Core Technologies, Inc.
73
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
92
93  --- The Detailed Node Listing ---
94
95 About This Guide
96
97 * What This Reference Manual Contains::
98 * Related Information::
99
100 Implementation Defined Pragmas
101
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Ada_05::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Ast_Entry::
109 * Pragma C_Pass_By_Copy::
110 * Pragma Comment::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Warning::
113 * Pragma Complex_Representation::
114 * Pragma Component_Alignment::
115 * Pragma Convention_Identifier::
116 * Pragma CPP_Class::
117 * Pragma CPP_Constructor::
118 * Pragma CPP_Virtual::
119 * Pragma CPP_Vtable::
120 * Pragma Debug::
121 * Pragma Detect_Blocking::
122 * Pragma Elaboration_Checks::
123 * Pragma Eliminate::
124 * Pragma Export_Exception::
125 * Pragma Export_Function::
126 * Pragma Export_Object::
127 * Pragma Export_Procedure::
128 * Pragma Export_Value::
129 * Pragma Export_Valued_Procedure::
130 * Pragma Extend_System::
131 * Pragma External::
132 * Pragma External_Name_Casing::
133 * Pragma Finalize_Storage_Only::
134 * Pragma Float_Representation::
135 * Pragma Ident::
136 * Pragma Import_Exception::
137 * Pragma Import_Function::
138 * Pragma Import_Object::
139 * Pragma Import_Procedure::
140 * Pragma Import_Valued_Procedure::
141 * Pragma Initialize_Scalars::
142 * Pragma Inline_Always::
143 * Pragma Inline_Generic::
144 * Pragma Interface::
145 * Pragma Interface_Name::
146 * Pragma Interrupt_Handler::
147 * Pragma Interrupt_State::
148 * Pragma Keep_Names::
149 * Pragma License::
150 * Pragma Link_With::
151 * Pragma Linker_Alias::
152 * Pragma Linker_Section::
153 * Pragma Long_Float::
154 * Pragma Machine_Attribute::
155 * Pragma Main_Storage::
156 * Pragma No_Return::
157 * Pragma Normalize_Scalars::
158 * Pragma Obsolescent::
159 * Pragma Passive::
160 * Pragma Persistent_BSS::
161 * Pragma Polling::
162 * Pragma Profile (Ravenscar)::
163 * Pragma Profile (Restricted)::
164 * Pragma Propagate_Exceptions::
165 * Pragma Psect_Object::
166 * Pragma Pure_Function::
167 * Pragma Restriction_Warnings::
168 * Pragma Source_File_Name::
169 * Pragma Source_File_Name_Project::
170 * Pragma Source_Reference::
171 * Pragma Stream_Convert::
172 * Pragma Style_Checks::
173 * Pragma Subtitle::
174 * Pragma Suppress_All::
175 * Pragma Suppress_Exception_Locations::
176 * Pragma Suppress_Initialization::
177 * Pragma Task_Info::
178 * Pragma Task_Name::
179 * Pragma Task_Storage::
180 * Pragma Thread_Body::
181 * Pragma Time_Slice::
182 * Pragma Title::
183 * Pragma Unchecked_Union::
184 * Pragma Unimplemented_Unit::
185 * Pragma Universal_Data::
186 * Pragma Unreferenced::
187 * Pragma Unreserve_All_Interrupts::
188 * Pragma Unsuppress::
189 * Pragma Use_VADS_Size::
190 * Pragma Validity_Checks::
191 * Pragma Volatile::
192 * Pragma Warnings::
193 * Pragma Weak_External::
194
195 Implementation Defined Attributes
196
197 * Abort_Signal::
198 * Address_Size::
199 * Asm_Input::
200 * Asm_Output::
201 * AST_Entry::
202 * Bit::
203 * Bit_Position::
204 * Code_Address::
205 * Default_Bit_Order::
206 * Elaborated::
207 * Elab_Body::
208 * Elab_Spec::
209 * Emax::
210 * Enum_Rep::
211 * Epsilon::
212 * Fixed_Value::
213 * Has_Access_Values::
214 * Has_Discriminants::
215 * Img::
216 * Integer_Value::
217 * Large::
218 * Machine_Size::
219 * Mantissa::
220 * Max_Interrupt_Priority::
221 * Max_Priority::
222 * Maximum_Alignment::
223 * Mechanism_Code::
224 * Null_Parameter::
225 * Object_Size::
226 * Passed_By_Reference::
227 * Range_Length::
228 * Safe_Emax::
229 * Safe_Large::
230 * Small::
231 * Storage_Unit::
232 * Target_Name::
233 * Tick::
234 * To_Address::
235 * Type_Class::
236 * UET_Address::
237 * Unconstrained_Array::
238 * Universal_Literal_String::
239 * Unrestricted_Access::
240 * VADS_Size::
241 * Value_Size::
242 * Wchar_T_Size::
243 * Word_Size::
244
245 The Implementation of Standard I/O
246
247 * Standard I/O Packages::
248 * FORM Strings::
249 * Direct_IO::
250 * Sequential_IO::
251 * Text_IO::
252 * Wide_Text_IO::
253 * Wide_Wide_Text_IO::
254 * Stream_IO::
255 * Shared Files::
256 * Open Modes::
257 * Operations on C Streams::
258 * Interfacing to C Streams::
259
260 The GNAT Library
261
262 * Ada.Characters.Latin_9 (a-chlat9.ads)::
263 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
264 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
265 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
266 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
267 * Ada.Command_Line.Remove (a-colire.ads)::
268 * Ada.Command_Line.Environment (a-colien.ads)::
269 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
270 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
271 * Ada.Exceptions.Traceback (a-exctra.ads)::
272 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
273 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
274 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
275 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
276 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
277 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
278 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
279 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
280 * GNAT.Array_Split (g-arrspl.ads)::
281 * GNAT.AWK (g-awk.ads)::
282 * GNAT.Bounded_Buffers (g-boubuf.ads)::
283 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
284 * GNAT.Bubble_Sort (g-bubsor.ads)::
285 * GNAT.Bubble_Sort_A (g-busora.ads)::
286 * GNAT.Bubble_Sort_G (g-busorg.ads)::
287 * GNAT.Calendar (g-calend.ads)::
288 * GNAT.Calendar.Time_IO (g-catiio.ads)::
289 * GNAT.Case_Util (g-casuti.ads)::
290 * GNAT.CGI (g-cgi.ads)::
291 * GNAT.CGI.Cookie (g-cgicoo.ads)::
292 * GNAT.CGI.Debug (g-cgideb.ads)::
293 * GNAT.Command_Line (g-comlin.ads)::
294 * GNAT.Compiler_Version (g-comver.ads)::
295 * GNAT.Ctrl_C (g-ctrl_c.ads)::
296 * GNAT.CRC32 (g-crc32.ads)::
297 * GNAT.Current_Exception (g-curexc.ads)::
298 * GNAT.Debug_Pools (g-debpoo.ads)::
299 * GNAT.Debug_Utilities (g-debuti.ads)::
300 * GNAT.Directory_Operations (g-dirope.ads)::
301 * GNAT.Dynamic_HTables (g-dynhta.ads)::
302 * GNAT.Dynamic_Tables (g-dyntab.ads)::
303 * GNAT.Exception_Actions (g-excact.ads)::
304 * GNAT.Exception_Traces (g-exctra.ads)::
305 * GNAT.Exceptions (g-except.ads)::
306 * GNAT.Expect (g-expect.ads)::
307 * GNAT.Float_Control (g-flocon.ads)::
308 * GNAT.Heap_Sort (g-heasor.ads)::
309 * GNAT.Heap_Sort_A (g-hesora.ads)::
310 * GNAT.Heap_Sort_G (g-hesorg.ads)::
311 * GNAT.HTable (g-htable.ads)::
312 * GNAT.IO (g-io.ads)::
313 * GNAT.IO_Aux (g-io_aux.ads)::
314 * GNAT.Lock_Files (g-locfil.ads)::
315 * GNAT.MD5 (g-md5.ads)::
316 * GNAT.Memory_Dump (g-memdum.ads)::
317 * GNAT.Most_Recent_Exception (g-moreex.ads)::
318 * GNAT.OS_Lib (g-os_lib.ads)::
319 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
320 * GNAT.Regexp (g-regexp.ads)::
321 * GNAT.Registry (g-regist.ads)::
322 * GNAT.Regpat (g-regpat.ads)::
323 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
324 * GNAT.Semaphores (g-semaph.ads)::
325 * GNAT.Signals (g-signal.ads)::
326 * GNAT.Sockets (g-socket.ads)::
327 * GNAT.Source_Info (g-souinf.ads)::
328 * GNAT.Spell_Checker (g-speche.ads)::
329 * GNAT.Spitbol.Patterns (g-spipat.ads)::
330 * GNAT.Spitbol (g-spitbo.ads)::
331 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
332 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
333 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
334 * GNAT.Strings (g-string.ads)::
335 * GNAT.String_Split (g-strspl.ads)::
336 * GNAT.Table (g-table.ads)::
337 * GNAT.Task_Lock (g-tasloc.ads)::
338 * GNAT.Threads (g-thread.ads)::
339 * GNAT.Traceback (g-traceb.ads)::
340 * GNAT.Traceback.Symbolic (g-trasym.ads)::
341 * GNAT.Wide_String_Split (g-wistsp.ads)::
342 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
343 * Interfaces.C.Extensions (i-cexten.ads)::
344 * Interfaces.C.Streams (i-cstrea.ads)::
345 * Interfaces.CPP (i-cpp.ads)::
346 * Interfaces.Os2lib (i-os2lib.ads)::
347 * Interfaces.Os2lib.Errors (i-os2err.ads)::
348 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
349 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
350 * Interfaces.Packed_Decimal (i-pacdec.ads)::
351 * Interfaces.VxWorks (i-vxwork.ads)::
352 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
353 * System.Address_Image (s-addima.ads)::
354 * System.Assertions (s-assert.ads)::
355 * System.Memory (s-memory.ads)::
356 * System.Partition_Interface (s-parint.ads)::
357 * System.Restrictions (s-restri.ads)::
358 * System.Rident (s-rident.ads)::
359 * System.Task_Info (s-tasinf.ads)::
360 * System.Wch_Cnv (s-wchcnv.ads)::
361 * System.Wch_Con (s-wchcon.ads)::
362
363 Text_IO
364
365 * Text_IO Stream Pointer Positioning::
366 * Text_IO Reading and Writing Non-Regular Files::
367 * Get_Immediate::
368 * Treating Text_IO Files as Streams::
369 * Text_IO Extensions::
370 * Text_IO Facilities for Unbounded Strings::
371
372 Wide_Text_IO
373
374 * Wide_Text_IO Stream Pointer Positioning::
375 * Wide_Text_IO Reading and Writing Non-Regular Files::
376
377 Wide_Wide_Text_IO
378
379 * Wide_Wide_Text_IO Stream Pointer Positioning::
380 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
381
382 Interfacing to Other Languages
383
384 * Interfacing to C::
385 * Interfacing to C++::
386 * Interfacing to COBOL::
387 * Interfacing to Fortran::
388 * Interfacing to non-GNAT Ada code::
389
390 Specialized Needs Annexes
391
392 Implementation of Specific Ada Features
393 * Machine Code Insertions::
394 * GNAT Implementation of Tasking::
395 * GNAT Implementation of Shared Passive Packages::
396 * Code Generation for Array Aggregates::
397 * The Size of Discriminated Records with Default Discriminants::
398
399 Project File Reference
400
401 Obsolescent Features
402
403 GNU Free Documentation License
404
405 Index
406 @end menu
407
408 @end ifnottex
409
410 @node About This Guide
411 @unnumbered About This Guide
412
413 @ifclear PROEDITION
414 @noindent
415 This manual contains useful information in writing programs using the
416 GNAT compiler.  It includes information on implementation dependent
417 characteristics of GNAT, including all the information required by Annex
418 M of the standard.
419 @end ifclear
420
421 @ifset PROEDITION
422 @noindent
423 This manual contains useful information in writing programs using the
424 GNAT Pro compiler.  It includes information on implementation dependent
425 characteristics of GNAT Pro, including all the information required by Annex
426 M of the standard.
427 @end ifset
428
429 Ada 95 is designed to be highly portable.
430 In general, a program will have the same effect even when compiled by
431 different compilers on different platforms.
432 However, since Ada 95 is designed to be used in a
433 wide variety of applications, it also contains a number of system
434 dependent features to be used in interfacing to the external world.
435 @cindex Implementation-dependent features
436 @cindex Portability
437
438 Note: Any program that makes use of implementation-dependent features
439 may be non-portable.  You should follow good programming practice and
440 isolate and clearly document any sections of your program that make use
441 of these features in a non-portable manner.
442
443 @ifset PROEDITION
444 For ease of exposition, ``GNAT Pro'' will be referred to simply as
445 ``GNAT'' in the remainder of this document.
446 @end ifset
447
448 @menu
449 * What This Reference Manual Contains::
450 * Conventions::
451 * Related Information::
452 @end menu
453
454 @node What This Reference Manual Contains
455 @unnumberedsec What This Reference Manual Contains
456
457 @noindent
458 This reference manual contains the following chapters:
459
460 @itemize @bullet
461 @item
462 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
463 pragmas, which can be used to extend and enhance the functionality of the
464 compiler.
465
466 @item
467 @ref{Implementation Defined Attributes}, lists GNAT
468 implementation-dependent attributes which can be used to extend and
469 enhance the functionality of the compiler.
470
471 @item
472 @ref{Implementation Advice}, provides information on generally
473 desirable behavior which are not requirements that all compilers must
474 follow since it cannot be provided on all systems, or which may be
475 undesirable on some systems.
476
477 @item
478 @ref{Implementation Defined Characteristics}, provides a guide to
479 minimizing implementation dependent features.
480
481 @item
482 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
483 implemented by GNAT, and how they can be imported into user
484 application programs.
485
486 @item
487 @ref{Representation Clauses and Pragmas}, describes in detail the
488 way that GNAT represents data, and in particular the exact set
489 of representation clauses and pragmas that is accepted.
490
491 @item
492 @ref{Standard Library Routines}, provides a listing of packages and a
493 brief description of the functionality that is provided by Ada's
494 extensive set of standard library routines as implemented by GNAT@.
495
496 @item
497 @ref{The Implementation of Standard I/O}, details how the GNAT
498 implementation of the input-output facilities.
499
500 @item
501 @ref{The GNAT Library}, is a catalog of packages that complement
502 the Ada predefined library.
503
504 @item
505 @ref{Interfacing to Other Languages}, describes how programs
506 written in Ada using GNAT can be interfaced to other programming
507 languages.
508
509 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
510 of the specialized needs annexes.
511
512 @item
513 @ref{Implementation of Specific Ada Features}, discusses issues related
514 to GNAT's implementation of machine code insertions, tasking, and several
515 other features.
516
517 @item
518 @ref{Project File Reference}, presents the syntax and semantics
519 of project files.
520
521 @item
522 @ref{Obsolescent Features} documents implementation dependent features,
523 including pragmas and attributes, which are considered obsolescent, since
524 there are other preferred ways of achieving the same results. These
525 obsolescent forms are retained for backwards compatibility.
526
527 @end itemize
528
529 @cindex Ada 95 ISO/ANSI Standard
530 @noindent
531 This reference manual assumes that you are familiar with Ada 95
532 language, as described in the International Standard
533 ANSI/ISO/IEC-8652:1995, Jan 1995.
534
535 @node Conventions
536 @unnumberedsec Conventions
537 @cindex Conventions, typographical
538 @cindex Typographical conventions
539
540 @noindent
541 Following are examples of the typographical and graphic conventions used
542 in this guide:
543
544 @itemize @bullet
545 @item
546 @code{Functions}, @code{utility program names}, @code{standard names},
547 and @code{classes}.
548
549 @item
550 @code{Option flags}
551
552 @item
553 @file{File Names}, @samp{button names}, and @samp{field names}.
554
555 @item
556 @code{Variables}.
557
558 @item
559 @emph{Emphasis}.
560
561 @item
562 [optional information or parameters]
563
564 @item
565 Examples are described by text
566 @smallexample
567 and then shown this way.
568 @end smallexample
569 @end itemize
570
571 @noindent
572 Commands that are entered by the user are preceded in this manual by the
573 characters @samp{$ } (dollar sign followed by space).  If your system uses this
574 sequence as a prompt, then the commands will appear exactly as you see them
575 in the manual.  If your system uses some other prompt, then the command will
576 appear with the @samp{$} replaced by whatever prompt character you are using.
577
578 @node Related Information
579 @unnumberedsec Related Information
580 @noindent
581 See the following documents for further information on GNAT:
582
583 @itemize @bullet
584 @item
585 @cite{GNAT User's Guide}, which provides information on how to use
586 the GNAT compiler system.
587
588 @item
589 @cite{Ada 95 Reference Manual}, which contains all reference
590 material for the Ada 95 programming language.
591
592 @item
593 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
594 of the standard reference manual cited above.  The annotations describe
595 detailed aspects of the design decision, and in particular contain useful
596 sections on Ada 83 compatibility.
597
598 @item
599 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
600 which contains specific information on compatibility between GNAT and
601 DEC Ada 83 systems.
602
603 @item
604 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
605 describes in detail the pragmas and attributes provided by the DEC Ada 83
606 compiler system.
607
608 @end itemize
609
610 @node Implementation Defined Pragmas
611 @chapter Implementation Defined Pragmas
612
613 @noindent
614 Ada 95 defines a set of pragmas that can be used to supply additional
615 information to the compiler.  These language defined pragmas are
616 implemented in GNAT and work as described in the Ada 95 Reference
617 Manual.
618
619 In addition, Ada 95 allows implementations to define additional pragmas
620 whose meaning is defined by the implementation.  GNAT provides a number
621 of these implementation-dependent pragmas which can be used to extend
622 and enhance the functionality of the compiler.  This section of the GNAT
623 Reference Manual describes these additional pragmas.
624
625 Note that any program using these pragmas may not be portable to other
626 compilers (although GNAT implements this set of pragmas on all
627 platforms).  Therefore if portability to other compilers is an important
628 consideration, the use of these pragmas should be minimized.
629
630 @menu
631 * Pragma Abort_Defer::
632 * Pragma Ada_83::
633 * Pragma Ada_95::
634 * Pragma Ada_05::
635 * Pragma Annotate::
636 * Pragma Assert::
637 * Pragma Ast_Entry::
638 * Pragma C_Pass_By_Copy::
639 * Pragma Comment::
640 * Pragma Common_Object::
641 * Pragma Compile_Time_Warning::
642 * Pragma Complex_Representation::
643 * Pragma Component_Alignment::
644 * Pragma Convention_Identifier::
645 * Pragma CPP_Class::
646 * Pragma CPP_Constructor::
647 * Pragma CPP_Virtual::
648 * Pragma CPP_Vtable::
649 * Pragma Debug::
650 * Pragma Detect_Blocking::
651 * Pragma Elaboration_Checks::
652 * Pragma Eliminate::
653 * Pragma Export_Exception::
654 * Pragma Export_Function::
655 * Pragma Export_Object::
656 * Pragma Export_Procedure::
657 * Pragma Export_Value::
658 * Pragma Export_Valued_Procedure::
659 * Pragma Extend_System::
660 * Pragma External::
661 * Pragma External_Name_Casing::
662 * Pragma Finalize_Storage_Only::
663 * Pragma Float_Representation::
664 * Pragma Ident::
665 * Pragma Import_Exception::
666 * Pragma Import_Function::
667 * Pragma Import_Object::
668 * Pragma Import_Procedure::
669 * Pragma Import_Valued_Procedure::
670 * Pragma Initialize_Scalars::
671 * Pragma Inline_Always::
672 * Pragma Inline_Generic::
673 * Pragma Interface::
674 * Pragma Interface_Name::
675 * Pragma Interrupt_Handler::
676 * Pragma Interrupt_State::
677 * Pragma Keep_Names::
678 * Pragma License::
679 * Pragma Link_With::
680 * Pragma Linker_Alias::
681 * Pragma Linker_Section::
682 * Pragma Long_Float::
683 * Pragma Machine_Attribute::
684 * Pragma Main_Storage::
685 * Pragma No_Return::
686 * Pragma Normalize_Scalars::
687 * Pragma Obsolescent::
688 * Pragma Passive::
689 * Pragma Persistent_BSS::
690 * Pragma Polling::
691 * Pragma Profile (Ravenscar)::
692 * Pragma Profile (Restricted)::
693 * Pragma Propagate_Exceptions::
694 * Pragma Psect_Object::
695 * Pragma Pure_Function::
696 * Pragma Restriction_Warnings::
697 * Pragma Source_File_Name::
698 * Pragma Source_File_Name_Project::
699 * Pragma Source_Reference::
700 * Pragma Stream_Convert::
701 * Pragma Style_Checks::
702 * Pragma Subtitle::
703 * Pragma Suppress_All::
704 * Pragma Suppress_Exception_Locations::
705 * Pragma Suppress_Initialization::
706 * Pragma Task_Info::
707 * Pragma Task_Name::
708 * Pragma Task_Storage::
709 * Pragma Thread_Body::
710 * Pragma Time_Slice::
711 * Pragma Title::
712 * Pragma Unchecked_Union::
713 * Pragma Unimplemented_Unit::
714 * Pragma Universal_Data::
715 * Pragma Unreferenced::
716 * Pragma Unreserve_All_Interrupts::
717 * Pragma Unsuppress::
718 * Pragma Use_VADS_Size::
719 * Pragma Validity_Checks::
720 * Pragma Volatile::
721 * Pragma Warnings::
722 * Pragma Weak_External::
723 @end menu
724
725 @node Pragma Abort_Defer
726 @unnumberedsec Pragma Abort_Defer
727 @findex Abort_Defer
728 @cindex Deferring aborts
729 @noindent
730 Syntax:
731 @smallexample
732 pragma Abort_Defer;
733 @end smallexample
734
735 @noindent
736 This pragma must appear at the start of the statement sequence of a
737 handled sequence of statements (right after the @code{begin}).  It has
738 the effect of deferring aborts for the sequence of statements (but not
739 for the declarations or handlers, if any, associated with this statement
740 sequence).
741
742 @node Pragma Ada_83
743 @unnumberedsec Pragma Ada_83
744 @findex Ada_83
745 @noindent
746 Syntax:
747 @smallexample @c ada
748 pragma Ada_83;
749 @end smallexample
750
751 @noindent
752 A configuration pragma that establishes Ada 83 mode for the unit to
753 which it applies, regardless of the mode set by the command line
754 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
755 the syntax and semantics of Ada 83, as defined in the original Ada
756 83 Reference Manual as possible.  In particular, the new Ada 95
757 keywords are not recognized, optional package bodies are allowed,
758 and generics may name types with unknown discriminants without using
759 the @code{(<>)} notation.  In addition, some but not all of the additional
760 restrictions of Ada 83 are enforced.
761
762 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
763 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
764 Secondly, it aids in keeping code backwards compatible with Ada 83.
765 However, there is no guarantee that code that is processed correctly
766 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
767 83 compiler, since GNAT does not enforce all the additional checks
768 required by Ada 83.
769
770 @node Pragma Ada_95
771 @unnumberedsec Pragma Ada_95
772 @findex Ada_95
773 @noindent
774 Syntax:
775 @smallexample @c ada
776 pragma Ada_95;
777 @end smallexample
778
779 @noindent
780 A configuration pragma that establishes Ada 95 mode for the unit to which
781 it applies, regardless of the mode set by the command line switches.
782 This mode is set automatically for the @code{Ada} and @code{System}
783 packages and their children, so you need not specify it in these
784 contexts.  This pragma is useful when writing a reusable component that
785 itself uses Ada 95 features, but which is intended to be usable from
786 either Ada 83 or Ada 95 programs.
787
788 @node Pragma Ada_05
789 @unnumberedsec Pragma Ada_05
790 @findex Ada_05
791 @noindent
792 Syntax:
793 @smallexample @c ada
794 pragma Ada_05;
795 @end smallexample
796
797 @noindent
798 A configuration pragma that establishes Ada 2005 mode for the unit to which
799 it applies, regardless of the mode set by the command line switches.
800 This mode is set automatically for the @code{Ada} and @code{System}
801 packages and their children, so you need not specify it in these
802 contexts.  This pragma is useful when writing a reusable component that
803 itself uses Ada 2005 features, but which is intended to be usable from
804 either Ada 83 or Ada 95 programs.
805
806 @node Pragma Annotate
807 @unnumberedsec Pragma Annotate
808 @findex Annotate
809 @noindent
810 Syntax:
811 @smallexample @c ada
812 pragma Annotate (IDENTIFIER @{, ARG@});
813
814 ARG ::= NAME | EXPRESSION
815 @end smallexample
816
817 @noindent
818 This pragma is used to annotate programs.  @var{identifier} identifies
819 the type of annotation.  GNAT verifies this is an identifier, but does
820 not otherwise analyze it.  The @var{arg} argument
821 can be either a string literal or an
822 expression.  String literals are assumed to be of type
823 @code{Standard.String}.  Names of entities are simply analyzed as entity
824 names.  All other expressions are analyzed as expressions, and must be
825 unambiguous.
826
827 The analyzed pragma is retained in the tree, but not otherwise processed
828 by any part of the GNAT compiler.  This pragma is intended for use by
829 external tools, including ASIS@.
830
831 @node Pragma Assert
832 @unnumberedsec Pragma Assert
833 @findex Assert
834 @noindent
835 Syntax:
836 @smallexample @c ada
837 pragma Assert (
838   boolean_EXPRESSION
839   [, static_string_EXPRESSION]);
840 @end smallexample
841
842 @noindent
843 The effect of this pragma depends on whether the corresponding command
844 line switch is set to activate assertions.  The pragma expands into code
845 equivalent to the following:
846
847 @smallexample @c ada
848 if assertions-enabled then
849    if not boolean_EXPRESSION then
850       System.Assertions.Raise_Assert_Failure
851         (string_EXPRESSION);
852    end if;
853 end if;
854 @end smallexample
855
856 @noindent
857 The string argument, if given, is the message that will be associated
858 with the exception occurrence if the exception is raised.  If no second
859 argument is given, the default message is @samp{@var{file}:@var{nnn}},
860 where @var{file} is the name of the source file containing the assert,
861 and @var{nnn} is the line number of the assert.  A pragma is not a
862 statement, so if a statement sequence contains nothing but a pragma
863 assert, then a null statement is required in addition, as in:
864
865 @smallexample @c ada
866 @dots{}
867 if J > 3 then
868    pragma Assert (K > 3, "Bad value for K");
869    null;
870 end if;
871 @end smallexample
872
873 @noindent
874 Note that, as with the @code{if} statement to which it is equivalent, the
875 type of the expression is either @code{Standard.Boolean}, or any type derived
876 from this standard type.
877
878 If assertions are disabled (switch @code{-gnata} not used), then there
879 is no effect (and in particular, any side effects from the expression
880 are suppressed).  More precisely it is not quite true that the pragma
881 has no effect, since the expression is analyzed, and may cause types
882 to be frozen if they are mentioned here for the first time.
883
884 If assertions are enabled, then the given expression is tested, and if
885 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
886 which results in the raising of @code{Assert_Failure} with the given message.
887
888 If the boolean expression has side effects, these side effects will turn
889 on and off with the setting of the assertions mode, resulting in
890 assertions that have an effect on the program.  You should generally
891 avoid side effects in the expression arguments of this pragma.  However,
892 the expressions are analyzed for semantic correctness whether or not
893 assertions are enabled, so turning assertions on and off cannot affect
894 the legality of a program.
895
896 @node Pragma Ast_Entry
897 @unnumberedsec Pragma Ast_Entry
898 @cindex OpenVMS
899 @findex Ast_Entry
900 @noindent
901 Syntax:
902 @smallexample @c ada
903 pragma AST_Entry (entry_IDENTIFIER);
904 @end smallexample
905
906 @noindent
907 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
908 argument is the simple name of a single entry; at most one @code{AST_Entry}
909 pragma is allowed for any given entry.  This pragma must be used in
910 conjunction with the @code{AST_Entry} attribute, and is only allowed after
911 the entry declaration and in the same task type specification or single task
912 as the entry to which it applies.  This pragma specifies that the given entry
913 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
914 resulting from an OpenVMS system service call.  The pragma does not affect
915 normal use of the entry.  For further details on this pragma, see the
916 DEC Ada Language Reference Manual, section 9.12a.
917
918 @node Pragma C_Pass_By_Copy
919 @unnumberedsec Pragma C_Pass_By_Copy
920 @cindex Passing by copy
921 @findex C_Pass_By_Copy
922 @noindent
923 Syntax:
924 @smallexample @c ada
925 pragma C_Pass_By_Copy
926   ([Max_Size =>] static_integer_EXPRESSION);
927 @end smallexample
928
929 @noindent
930 Normally the default mechanism for passing C convention records to C
931 convention subprograms is to pass them by reference, as suggested by RM
932 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
933 this default, by requiring that record formal parameters be passed by
934 copy if all of the following conditions are met:
935
936 @itemize @bullet
937 @item
938 The size of the record type does not exceed@*@var{static_integer_expression}.
939 @item
940 The record type has @code{Convention C}.
941 @item
942 The formal parameter has this record type, and the subprogram has a
943 foreign (non-Ada) convention.
944 @end itemize
945
946 @noindent
947 If these conditions are met the argument is passed by copy, i.e.@: in a
948 manner consistent with what C expects if the corresponding formal in the
949 C prototype is a struct (rather than a pointer to a struct).
950
951 You can also pass records by copy by specifying the convention
952 @code{C_Pass_By_Copy} for the record type, or by using the extended
953 @code{Import} and @code{Export} pragmas, which allow specification of
954 passing mechanisms on a parameter by parameter basis.
955
956 @node Pragma Comment
957 @unnumberedsec Pragma Comment
958 @findex Comment
959 @noindent
960 Syntax:
961
962 @smallexample @c ada
963 pragma Comment (static_string_EXPRESSION);
964 @end smallexample
965
966 @noindent
967 This is almost identical in effect to pragma @code{Ident}.  It allows the
968 placement of a comment into the object file and hence into the
969 executable file if the operating system permits such usage.  The
970 difference is that @code{Comment}, unlike @code{Ident}, has
971 no limitations on placement of the pragma (it can be placed
972 anywhere in the main source unit), and if more than one pragma
973 is used, all comments are retained.
974
975 @node Pragma Common_Object
976 @unnumberedsec Pragma Common_Object
977 @findex Common_Object
978 @noindent
979 Syntax:
980
981 @smallexample @c ada
982 pragma Common_Object (
983      [Internal =>] local_NAME,
984   [, [External =>] EXTERNAL_SYMBOL]
985   [, [Size     =>] EXTERNAL_SYMBOL] );
986
987 EXTERNAL_SYMBOL ::=
988   IDENTIFIER
989 | static_string_EXPRESSION
990 @end smallexample
991
992 @noindent
993 This pragma enables the shared use of variables stored in overlaid
994 linker areas corresponding to the use of @code{COMMON}
995 in Fortran.  The single
996 object @var{local_NAME} is assigned to the area designated by
997 the @var{External} argument.
998 You may define a record to correspond to a series
999 of fields.  The @var{size} argument
1000 is syntax checked in GNAT, but otherwise ignored.
1001
1002 @code{Common_Object} is not supported on all platforms.  If no
1003 support is available, then the code generator will issue a message
1004 indicating that the necessary attribute for implementation of this
1005 pragma is not available.
1006
1007 @node Pragma Compile_Time_Warning
1008 @unnumberedsec Pragma Compile_Time_Warning
1009 @findex Compile_Time_Warning
1010 @noindent
1011 Syntax:
1012
1013 @smallexample @c ada
1014 pragma Compile_Time_Warning
1015          (boolean_EXPRESSION, static_string_EXPRESSION);
1016 @end smallexample
1017
1018 @noindent
1019 This pragma can be used to generate additional compile time warnings. It
1020 is particularly useful in generics, where warnings can be issued for
1021 specific problematic instantiations. The first parameter is a boolean
1022 expression. The pragma is effective only if the value of this expression
1023 is known at compile time, and has the value True. The set of expressions
1024 whose values are known at compile time includes all static boolean
1025 expressions, and also other values which the compiler can determine
1026 at compile time (e.g. the size of a record type set by an explicit
1027 size representation clause, or the value of a variable which was
1028 initialized to a constant and is known not to have been modified).
1029 If these conditions are met, a warning message is generated using
1030 the value given as the second argument. This string value may contain
1031 embedded ASCII.LF characters to break the message into multiple lines.
1032
1033 @node Pragma Complex_Representation
1034 @unnumberedsec Pragma Complex_Representation
1035 @findex Complex_Representation
1036 @noindent
1037 Syntax:
1038
1039 @smallexample @c ada
1040 pragma Complex_Representation
1041         ([Entity =>] local_NAME);
1042 @end smallexample
1043
1044 @noindent
1045 The @var{Entity} argument must be the name of a record type which has
1046 two fields of the same floating-point type.  The effect of this pragma is
1047 to force gcc to use the special internal complex representation form for
1048 this record, which may be more efficient.  Note that this may result in
1049 the code for this type not conforming to standard ABI (application
1050 binary interface) requirements for the handling of record types.  For
1051 example, in some environments, there is a requirement for passing
1052 records by pointer, and the use of this pragma may result in passing
1053 this type in floating-point registers.
1054
1055 @node Pragma Component_Alignment
1056 @unnumberedsec Pragma Component_Alignment
1057 @cindex Alignments of components
1058 @findex Component_Alignment
1059 @noindent
1060 Syntax:
1061
1062 @smallexample @c ada
1063 pragma Component_Alignment (
1064      [Form =>] ALIGNMENT_CHOICE
1065   [, [Name =>] type_local_NAME]);
1066
1067 ALIGNMENT_CHOICE ::=
1068   Component_Size
1069 | Component_Size_4
1070 | Storage_Unit
1071 | Default
1072 @end smallexample
1073
1074 @noindent
1075 Specifies the alignment of components in array or record types.
1076 The meaning of the @var{Form} argument is as follows:
1077
1078 @table @code
1079 @findex Component_Size
1080 @item Component_Size
1081 Aligns scalar components and subcomponents of the array or record type
1082 on boundaries appropriate to their inherent size (naturally
1083 aligned).  For example, 1-byte components are aligned on byte boundaries,
1084 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1085 integer components are aligned on 4-byte boundaries and so on.  These
1086 alignment rules correspond to the normal rules for C compilers on all
1087 machines except the VAX@.
1088
1089 @findex Component_Size_4
1090 @item Component_Size_4
1091 Naturally aligns components with a size of four or fewer
1092 bytes.  Components that are larger than 4 bytes are placed on the next
1093 4-byte boundary.
1094
1095 @findex Storage_Unit
1096 @item Storage_Unit
1097 Specifies that array or record components are byte aligned, i.e.@:
1098 aligned on boundaries determined by the value of the constant
1099 @code{System.Storage_Unit}.
1100
1101 @cindex OpenVMS
1102 @item Default
1103 Specifies that array or record components are aligned on default
1104 boundaries, appropriate to the underlying hardware or operating system or
1105 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1106 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1107 the @code{Default} choice is the same as @code{Component_Size} (natural
1108 alignment).
1109 @end table
1110
1111 @noindent
1112 If the @code{Name} parameter is present, @var{type_local_NAME} must
1113 refer to a local record or array type, and the specified alignment
1114 choice applies to the specified type.  The use of
1115 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1116 @code{Component_Alignment} pragma to be ignored.  The use of
1117 @code{Component_Alignment} together with a record representation clause
1118 is only effective for fields not specified by the representation clause.
1119
1120 If the @code{Name} parameter is absent, the pragma can be used as either
1121 a configuration pragma, in which case it applies to one or more units in
1122 accordance with the normal rules for configuration pragmas, or it can be
1123 used within a declarative part, in which case it applies to types that
1124 are declared within this declarative part, or within any nested scope
1125 within this declarative part.  In either case it specifies the alignment
1126 to be applied to any record or array type which has otherwise standard
1127 representation.
1128
1129 If the alignment for a record or array type is not specified (using
1130 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1131 clause), the GNAT uses the default alignment as described previously.
1132
1133 @node Pragma Convention_Identifier
1134 @unnumberedsec Pragma Convention_Identifier
1135 @findex Convention_Identifier
1136 @cindex Conventions, synonyms
1137 @noindent
1138 Syntax:
1139
1140 @smallexample @c ada
1141 pragma Convention_Identifier (
1142          [Name =>]       IDENTIFIER,
1143          [Convention =>] convention_IDENTIFIER);
1144 @end smallexample
1145
1146 @noindent
1147 This pragma provides a mechanism for supplying synonyms for existing
1148 convention identifiers. The @code{Name} identifier can subsequently
1149 be used as a synonym for the given convention in other pragmas (including
1150 for example pragma @code{Import} or another @code{Convention_Identifier}
1151 pragma). As an example of the use of this, suppose you had legacy code
1152 which used Fortran77 as the identifier for Fortran. Then the pragma:
1153
1154 @smallexample @c ada
1155 pragma Convention_Identifier (Fortran77, Fortran);
1156 @end smallexample
1157
1158 @noindent
1159 would allow the use of the convention identifier @code{Fortran77} in
1160 subsequent code, avoiding the need to modify the sources. As another
1161 example, you could use this to parametrize convention requirements
1162 according to systems. Suppose you needed to use @code{Stdcall} on
1163 windows systems, and @code{C} on some other system, then you could
1164 define a convention identifier @code{Library} and use a single
1165 @code{Convention_Identifier} pragma to specify which convention
1166 would be used system-wide.
1167
1168 @node Pragma CPP_Class
1169 @unnumberedsec Pragma CPP_Class
1170 @findex CPP_Class
1171 @cindex Interfacing with C++
1172 @noindent
1173 Syntax:
1174
1175 @smallexample @c ada
1176 pragma CPP_Class ([Entity =>] local_NAME);
1177 @end smallexample
1178
1179 @noindent
1180 The argument denotes an entity in the current declarative region
1181 that is declared as a tagged or untagged record type.  It indicates that
1182 the type corresponds to an externally declared C++ class type, and is to
1183 be laid out the same way that C++ would lay out the type.
1184
1185 If (and only if) the type is tagged, at least one component in the
1186 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1187 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1188 for dispatching.
1189
1190 Types for which @code{CPP_Class} is specified do not have assignment or
1191 equality operators defined (such operations can be imported or declared
1192 as subprograms as required).  Initialization is allowed only by
1193 constructor functions (see pragma @code{CPP_Constructor}).
1194
1195 Pragma @code{CPP_Class} is intended primarily for automatic generation
1196 using an automatic binding generator tool.
1197 See @ref{Interfacing to C++} for related information.
1198
1199 @node Pragma CPP_Constructor
1200 @unnumberedsec Pragma CPP_Constructor
1201 @cindex Interfacing with C++
1202 @findex CPP_Constructor
1203 @noindent
1204 Syntax:
1205
1206 @smallexample @c ada
1207 pragma CPP_Constructor ([Entity =>] local_NAME);
1208 @end smallexample
1209
1210 @noindent
1211 This pragma identifies an imported function (imported in the usual way
1212 with pragma @code{Import}) as corresponding to a C++
1213 constructor.  The argument is a name that must have been
1214 previously mentioned in a pragma @code{Import}
1215 with @code{Convention} = @code{CPP}, and must be of one of the following
1216 forms:
1217
1218 @itemize @bullet
1219 @item
1220 @code{function @var{Fname} return @var{T}'Class}
1221
1222 @item
1223 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1224 @end itemize
1225
1226 @noindent
1227 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1228
1229 The first form is the default constructor, used when an object of type
1230 @var{T} is created on the Ada side with no explicit constructor.  Other
1231 constructors (including the copy constructor, which is simply a special
1232 case of the second form in which the one and only argument is of type
1233 @var{T}), can only appear in two contexts:
1234
1235 @itemize @bullet
1236 @item
1237 On the right side of an initialization of an object of type @var{T}.
1238 @item
1239 In an extension aggregate for an object of a type derived from @var{T}.
1240 @end itemize
1241
1242 @noindent
1243 Although the constructor is described as a function that returns a value
1244 on the Ada side, it is typically a procedure with an extra implicit
1245 argument (the object being initialized) at the implementation
1246 level.  GNAT issues the appropriate call, whatever it is, to get the
1247 object properly initialized.
1248
1249 In the case of derived objects, you may use one of two possible forms
1250 for declaring and creating an object:
1251
1252 @itemize @bullet
1253 @item @code{New_Object : Derived_T}
1254 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1255 @end itemize
1256
1257 @noindent
1258 In the first case the default constructor is called and extension fields
1259 if any are initialized according to the default initialization
1260 expressions in the Ada declaration.  In the second case, the given
1261 constructor is called and the extension aggregate indicates the explicit
1262 values of the extension fields.
1263
1264 If no constructors are imported, it is impossible to create any objects
1265 on the Ada side.  If no default constructor is imported, only the
1266 initialization forms using an explicit call to a constructor are
1267 permitted.
1268
1269 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1270 using an automatic binding generator tool.
1271 See @ref{Interfacing to C++} for more related information.
1272
1273 @node Pragma CPP_Virtual
1274 @unnumberedsec Pragma CPP_Virtual
1275 @cindex Interfacing to C++
1276 @findex CPP_Virtual
1277 @noindent
1278 Syntax:
1279
1280 @smallexample @c ada
1281 pragma CPP_Virtual
1282      [Entity     =>] ENTITY,
1283   [, [Vtable_Ptr =>] vtable_ENTITY,]
1284   [, [Position   =>] static_integer_EXPRESSION]);
1285 @end smallexample
1286
1287 @noindent
1288 This pragma serves the same function as pragma @code{Import} in that
1289 case of a virtual function imported from C++.  The @var{Entity} argument
1290 must be a
1291 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1292 applies.  The @var{Vtable_Ptr} argument specifies
1293 the Vtable_Ptr component which contains the
1294 entry for this virtual function.  The @var{Position} argument
1295 is the sequential number
1296 counting virtual functions for this Vtable starting at 1.
1297
1298 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1299 there is one Vtable_Ptr present (single inheritance case) and all
1300 virtual functions are imported.  In that case the compiler can deduce both
1301 these values.
1302
1303 No @code{External_Name} or @code{Link_Name} arguments are required for a
1304 virtual function, since it is always accessed indirectly via the
1305 appropriate Vtable entry.
1306
1307 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1308 using an automatic binding generator tool.
1309 See @ref{Interfacing to C++} for related information.
1310
1311 @node Pragma CPP_Vtable
1312 @unnumberedsec Pragma CPP_Vtable
1313 @cindex Interfacing with C++
1314 @findex CPP_Vtable
1315 @noindent
1316 Syntax:
1317
1318 @smallexample @c ada
1319 pragma CPP_Vtable (
1320   [Entity      =>] ENTITY,
1321   [Vtable_Ptr  =>] vtable_ENTITY,
1322   [Entry_Count =>] static_integer_EXPRESSION);
1323 @end smallexample
1324
1325 @noindent
1326 Given a record to which the pragma @code{CPP_Class} applies,
1327 this pragma can be specified for each component of type
1328 @code{CPP.Interfaces.Vtable_Ptr}.
1329 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1330 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1331 the number of virtual functions on the C++ side.  Not all of these
1332 functions need to be imported on the Ada side.
1333
1334 You may omit the @code{CPP_Vtable} pragma if there is only one
1335 @code{Vtable_Ptr} component in the record and all virtual functions are
1336 imported on the Ada side (the default value for the entry count in this
1337 case is simply the total number of virtual functions).
1338
1339 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1340 using an automatic binding generator tool.
1341 See @ref{Interfacing to C++} for related information.
1342
1343 @node Pragma Debug
1344 @unnumberedsec Pragma Debug
1345 @findex Debug
1346 @noindent
1347 Syntax:
1348
1349 @smallexample @c ada
1350 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1351
1352 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1353   PROCEDURE_NAME
1354 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1355 @end smallexample
1356
1357 @noindent
1358 The argument has the syntactic form of an expression, meeting the
1359 syntactic requirements for pragmas.
1360
1361 If assertions are not enabled on the command line, this pragma has no
1362 effect.  If asserts are enabled, the semantics of the pragma is exactly
1363 equivalent to the procedure call statement corresponding to the argument
1364 with a terminating semicolon.  Pragmas are permitted in sequences of
1365 declarations, so you can use pragma @code{Debug} to intersperse calls to
1366 debug procedures in the middle of declarations.
1367
1368 @node Pragma Detect_Blocking
1369 @unnumberedsec Pragma Detect_Blocking
1370 @findex Detect_Blocking
1371 @noindent
1372 Syntax:
1373
1374 @smallexample @c ada
1375 pragma Detect_Blocking;
1376 @end smallexample
1377
1378 @noindent
1379 This is a configuration pragma that forces the detection of potentially
1380 blocking operations within a protected operation, and to raise Program_Error
1381 if that happens.
1382
1383 @node Pragma Elaboration_Checks
1384 @unnumberedsec Pragma Elaboration_Checks
1385 @cindex Elaboration control
1386 @findex Elaboration_Checks
1387 @noindent
1388 Syntax:
1389
1390 @smallexample @c ada
1391 pragma Elaboration_Checks (Dynamic | Static);
1392 @end smallexample
1393
1394 @noindent
1395 This is a configuration pragma that provides control over the
1396 elaboration model used by the compilation affected by the
1397 pragma.  If the parameter is @code{Dynamic},
1398 then the dynamic elaboration
1399 model described in the Ada Reference Manual is used, as though
1400 the @code{-gnatE} switch had been specified on the command
1401 line.  If the parameter is @code{Static}, then the default GNAT static
1402 model is used.  This configuration pragma overrides the setting
1403 of the command line.  For full details on the elaboration models
1404 used by the GNAT compiler, see section ``Elaboration Order
1405 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1406
1407 @node Pragma Eliminate
1408 @unnumberedsec Pragma Eliminate
1409 @cindex Elimination of unused subprograms
1410 @findex Eliminate
1411 @noindent
1412 Syntax:
1413
1414 @smallexample @c ada
1415 pragma Eliminate (
1416     [Unit_Name =>] IDENTIFIER |
1417                    SELECTED_COMPONENT);
1418
1419 pragma Eliminate (
1420     [Unit_Name       =>]  IDENTIFIER |
1421                           SELECTED_COMPONENT,
1422     [Entity          =>]  IDENTIFIER |
1423                           SELECTED_COMPONENT |
1424                           STRING_LITERAL
1425     [,OVERLOADING_RESOLUTION]);
1426
1427 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1428                            SOURCE_LOCATION
1429
1430 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1431                                       FUNCTION_PROFILE
1432
1433 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1434
1435 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1436                       Result_Type => result_SUBTYPE_NAME]
1437
1438 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1439 SUBTYPE_NAME    ::= STRING_VALUE
1440
1441 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1442 SOURCE_TRACE    ::= STRING_VALUE
1443
1444 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1445 @end smallexample
1446
1447 @noindent
1448 This pragma indicates that the given entity is not used outside the
1449 compilation unit it is defined in. The entity must be an explicitly declared
1450 subprogram; this includes  generic subprogram instances and
1451 subprograms declared in generic package instances.
1452
1453 If the entity to be eliminated is a library level subprogram, then
1454 the first form of pragma @code{Eliminate} is used with only a single argument.
1455 In this form, the @code{Unit_Name} argument specifies the name of the
1456 library  level unit to be eliminated.
1457
1458 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1459 are required. If item is an entity of a library package, then the first
1460 argument specifies the unit name, and the second argument specifies
1461 the particular entity.  If the second argument is in string form, it must
1462 correspond to the internal manner in which GNAT stores entity names (see
1463 compilation unit Namet in the compiler sources for details).
1464
1465 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1466 to distinguish between overloaded subprograms. If a pragma does not contain
1467 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1468 subprograms denoted by the first two parameters.
1469
1470 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1471 to be eliminated in a manner similar to that used for the extended
1472 @code{Import} and @code{Export} pragmas, except that the subtype names are
1473 always given as strings. At the moment, this form of distinguishing
1474 overloaded subprograms is implemented only partially, so we do not recommend
1475 using it for practical subprogram elimination.
1476
1477 Note, that in case of a parameterless procedure its profile is represented
1478 as @code{Parameter_Types => ("")}
1479
1480 Alternatively, the @code{Source_Location} parameter is used to specify
1481 which overloaded alternative is to be eliminated by pointing to the
1482 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1483 source text. The string literal (or concatenation of string literals)
1484 given as SOURCE_TRACE must have the following format:
1485
1486 @smallexample @c ada
1487 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1488
1489 LBRACKET ::= [
1490 RBRACKET ::= ]
1491
1492 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1493 FILE_NAME       ::= STRING_LITERAL
1494 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1495 @end smallexample
1496
1497 SOURCE_TRACE should be the short name of the source file (with no directory
1498 information), and LINE_NUMBER is supposed to point to the line where the
1499 defining name of the subprogram is located.
1500
1501 For the subprograms that are not a part of generic instantiations, only one
1502 SOURCE_LOCATION is used. If a subprogram is declared in a package
1503 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1504 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1505 second one denotes the declaration of the corresponding subprogram in the
1506 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1507 in case of nested instantiations.
1508
1509 The effect of the pragma is to allow the compiler to eliminate
1510 the code or data associated with the named entity.  Any reference to
1511 an eliminated entity outside the compilation unit it is defined in,
1512 causes a compile time or link time error.
1513
1514 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1515 in a system independent manner, with unused entities eliminated, without
1516 the requirement of modifying the source text.  Normally the required set
1517 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1518 tool. Elimination of unused entities local to a compilation unit is
1519 automatic, without requiring the use of pragma @code{Eliminate}.
1520
1521 Note that the reason this pragma takes string literals where names might
1522 be expected is that a pragma @code{Eliminate} can appear in a context where the
1523 relevant names are not visible.
1524
1525 Note that any change in the source files that includes removing, splitting of
1526 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1527 parameter illegal.
1528
1529 @node Pragma Export_Exception
1530 @unnumberedsec Pragma Export_Exception
1531 @cindex OpenVMS
1532 @findex Export_Exception
1533 @noindent
1534 Syntax:
1535
1536 @smallexample @c ada
1537 pragma Export_Exception (
1538      [Internal =>] local_NAME,
1539   [, [External =>] EXTERNAL_SYMBOL,]
1540   [, [Form     =>] Ada | VMS]
1541   [, [Code     =>] static_integer_EXPRESSION]);
1542
1543 EXTERNAL_SYMBOL ::=
1544   IDENTIFIER
1545 | static_string_EXPRESSION
1546 @end smallexample
1547
1548 @noindent
1549 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1550 causes the specified exception to be propagated outside of the Ada program,
1551 so that it can be handled by programs written in other OpenVMS languages.
1552 This pragma establishes an external name for an Ada exception and makes the
1553 name available to the OpenVMS Linker as a global symbol.  For further details
1554 on this pragma, see the
1555 DEC Ada Language Reference Manual, section 13.9a3.2.
1556
1557 @node Pragma Export_Function
1558 @unnumberedsec Pragma Export_Function
1559 @cindex Argument passing mechanisms
1560 @findex Export_Function
1561
1562 @noindent
1563 Syntax:
1564
1565 @smallexample @c ada
1566 pragma Export_Function (
1567      [Internal         =>] local_NAME,
1568   [, [External         =>] EXTERNAL_SYMBOL]
1569   [, [Parameter_Types  =>] PARAMETER_TYPES]
1570   [, [Result_Type      =>] result_SUBTYPE_MARK]
1571   [, [Mechanism        =>] MECHANISM]
1572   [, [Result_Mechanism =>] MECHANISM_NAME]);
1573
1574 EXTERNAL_SYMBOL ::=
1575   IDENTIFIER
1576 | static_string_EXPRESSION
1577 | ""
1578
1579 PARAMETER_TYPES ::=
1580   null
1581 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1582
1583 TYPE_DESIGNATOR ::=
1584   subtype_NAME
1585 | subtype_Name ' Access
1586
1587 MECHANISM ::=
1588   MECHANISM_NAME
1589 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1590
1591 MECHANISM_ASSOCIATION ::=
1592   [formal_parameter_NAME =>] MECHANISM_NAME
1593
1594 MECHANISM_NAME ::=
1595   Value
1596 | Reference
1597 @end smallexample
1598
1599 @noindent
1600 Use this pragma to make a function externally callable and optionally
1601 provide information on mechanisms to be used for passing parameter and
1602 result values.  We recommend, for the purposes of improving portability,
1603 this pragma always be used in conjunction with a separate pragma
1604 @code{Export}, which must precede the pragma @code{Export_Function}.
1605 GNAT does not require a separate pragma @code{Export}, but if none is
1606 present, @code{Convention Ada} is assumed, which is usually
1607 not what is wanted, so it is usually appropriate to use this
1608 pragma in conjunction with a @code{Export} or @code{Convention}
1609 pragma that specifies the desired foreign convention.
1610 Pragma @code{Export_Function}
1611 (and @code{Export}, if present) must appear in the same declarative
1612 region as the function to which they apply.
1613
1614 @var{internal_name} must uniquely designate the function to which the
1615 pragma applies.  If more than one function name exists of this name in
1616 the declarative part you must use the @code{Parameter_Types} and
1617 @code{Result_Type} parameters is mandatory to achieve the required
1618 unique designation.  @var{subtype_ mark}s in these parameters must
1619 exactly match the subtypes in the corresponding function specification,
1620 using positional notation to match parameters with subtype marks.
1621 The form with an @code{'Access} attribute can be used to match an
1622 anonymous access parameter.
1623
1624 @cindex OpenVMS
1625 @cindex Passing by descriptor
1626 Note that passing by descriptor is not supported, even on the OpenVMS
1627 ports of GNAT@.
1628
1629 @cindex Suppressing external name
1630 Special treatment is given if the EXTERNAL is an explicit null
1631 string or a static string expressions that evaluates to the null
1632 string. In this case, no external name is generated. This form
1633 still allows the specification of parameter mechanisms.
1634
1635 @node Pragma Export_Object
1636 @unnumberedsec Pragma Export_Object
1637 @findex Export_Object
1638 @noindent
1639 Syntax:
1640
1641 @smallexample @c ada
1642 pragma Export_Object
1643       [Internal =>] local_NAME,
1644    [, [External =>] EXTERNAL_SYMBOL]
1645    [, [Size     =>] EXTERNAL_SYMBOL]
1646
1647 EXTERNAL_SYMBOL ::=
1648   IDENTIFIER
1649 | static_string_EXPRESSION
1650 @end smallexample
1651
1652 @noindent
1653 This pragma designates an object as exported, and apart from the
1654 extended rules for external symbols, is identical in effect to the use of
1655 the normal @code{Export} pragma applied to an object.  You may use a
1656 separate Export pragma (and you probably should from the point of view
1657 of portability), but it is not required.  @var{Size} is syntax checked,
1658 but otherwise ignored by GNAT@.
1659
1660 @node Pragma Export_Procedure
1661 @unnumberedsec Pragma Export_Procedure
1662 @findex Export_Procedure
1663 @noindent
1664 Syntax:
1665
1666 @smallexample @c ada
1667 pragma Export_Procedure (
1668      [Internal        =>] local_NAME
1669   [, [External        =>] EXTERNAL_SYMBOL]
1670   [, [Parameter_Types =>] PARAMETER_TYPES]
1671   [, [Mechanism       =>] MECHANISM]);
1672
1673 EXTERNAL_SYMBOL ::=
1674   IDENTIFIER
1675 | static_string_EXPRESSION
1676 | ""
1677
1678 PARAMETER_TYPES ::=
1679   null
1680 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1681
1682 TYPE_DESIGNATOR ::=
1683   subtype_NAME
1684 | subtype_Name ' Access
1685
1686 MECHANISM ::=
1687   MECHANISM_NAME
1688 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1689
1690 MECHANISM_ASSOCIATION ::=
1691   [formal_parameter_NAME =>] MECHANISM_NAME
1692
1693 MECHANISM_NAME ::=
1694   Value
1695 | Reference
1696 @end smallexample
1697
1698 @noindent
1699 This pragma is identical to @code{Export_Function} except that it
1700 applies to a procedure rather than a function and the parameters
1701 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1702 GNAT does not require a separate pragma @code{Export}, but if none is
1703 present, @code{Convention Ada} is assumed, which is usually
1704 not what is wanted, so it is usually appropriate to use this
1705 pragma in conjunction with a @code{Export} or @code{Convention}
1706 pragma that specifies the desired foreign convention.
1707
1708 @cindex OpenVMS
1709 @cindex Passing by descriptor
1710 Note that passing by descriptor is not supported, even on the OpenVMS
1711 ports of GNAT@.
1712
1713 @cindex Suppressing external name
1714 Special treatment is given if the EXTERNAL is an explicit null
1715 string or a static string expressions that evaluates to the null
1716 string. In this case, no external name is generated. This form
1717 still allows the specification of parameter mechanisms.
1718
1719 @node Pragma Export_Value
1720 @unnumberedsec Pragma Export_Value
1721 @findex Export_Value
1722 @noindent
1723 Syntax:
1724
1725 @smallexample @c ada
1726 pragma Export_Value (
1727   [Value     =>] static_integer_EXPRESSION,
1728   [Link_Name =>] static_string_EXPRESSION);
1729 @end smallexample
1730
1731 @noindent
1732 This pragma serves to export a static integer value for external use.
1733 The first argument specifies the value to be exported. The Link_Name
1734 argument specifies the symbolic name to be associated with the integer
1735 value. This pragma is useful for defining a named static value in Ada
1736 that can be referenced in assembly language units to be linked with
1737 the application. This pragma is currently supported only for the
1738 AAMP target and is ignored for other targets.
1739
1740 @node Pragma Export_Valued_Procedure
1741 @unnumberedsec Pragma Export_Valued_Procedure
1742 @findex Export_Valued_Procedure
1743 @noindent
1744 Syntax:
1745
1746 @smallexample @c ada
1747 pragma Export_Valued_Procedure (
1748      [Internal        =>] local_NAME
1749   [, [External        =>] EXTERNAL_SYMBOL]
1750   [, [Parameter_Types =>] PARAMETER_TYPES]
1751   [, [Mechanism       =>] MECHANISM]);
1752
1753 EXTERNAL_SYMBOL ::=
1754   IDENTIFIER
1755 | static_string_EXPRESSION
1756 | ""
1757
1758 PARAMETER_TYPES ::=
1759   null
1760 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1761
1762 TYPE_DESIGNATOR ::=
1763   subtype_NAME
1764 | subtype_Name ' Access
1765
1766 MECHANISM ::=
1767   MECHANISM_NAME
1768 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1769
1770 MECHANISM_ASSOCIATION ::=
1771   [formal_parameter_NAME =>] MECHANISM_NAME
1772
1773 MECHANISM_NAME ::=
1774   Value
1775 | Reference
1776 @end smallexample
1777
1778 @noindent
1779 This pragma is identical to @code{Export_Procedure} except that the
1780 first parameter of @var{local_NAME}, which must be present, must be of
1781 mode @code{OUT}, and externally the subprogram is treated as a function
1782 with this parameter as the result of the function.  GNAT provides for
1783 this capability to allow the use of @code{OUT} and @code{IN OUT}
1784 parameters in interfacing to external functions (which are not permitted
1785 in Ada functions).
1786 GNAT does not require a separate pragma @code{Export}, but if none is
1787 present, @code{Convention Ada} is assumed, which is almost certainly
1788 not what is wanted since the whole point of this pragma is to interface
1789 with foreign language functions, so it is usually appropriate to use this
1790 pragma in conjunction with a @code{Export} or @code{Convention}
1791 pragma that specifies the desired foreign convention.
1792
1793 @cindex OpenVMS
1794 @cindex Passing by descriptor
1795 Note that passing by descriptor is not supported, even on the OpenVMS
1796 ports of GNAT@.
1797
1798 @cindex Suppressing external name
1799 Special treatment is given if the EXTERNAL is an explicit null
1800 string or a static string expressions that evaluates to the null
1801 string. In this case, no external name is generated. This form
1802 still allows the specification of parameter mechanisms.
1803
1804 @node Pragma Extend_System
1805 @unnumberedsec Pragma Extend_System
1806 @cindex @code{system}, extending
1807 @cindex Dec Ada 83
1808 @findex Extend_System
1809 @noindent
1810 Syntax:
1811
1812 @smallexample @c ada
1813 pragma Extend_System ([Name =>] IDENTIFIER);
1814 @end smallexample
1815
1816 @noindent
1817 This pragma is used to provide backwards compatibility with other
1818 implementations that extend the facilities of package @code{System}.  In
1819 GNAT, @code{System} contains only the definitions that are present in
1820 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1821 implementation, provide many extensions to package @code{System}.
1822
1823 For each such implementation accommodated by this pragma, GNAT provides a
1824 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1825 implementation, which provides the required additional definitions.  You
1826 can use this package in two ways.  You can @code{with} it in the normal
1827 way and access entities either by selection or using a @code{use}
1828 clause.  In this case no special processing is required.
1829
1830 However, if existing code contains references such as
1831 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1832 definitions provided in package @code{System}, you may use this pragma
1833 to extend visibility in @code{System} in a non-standard way that
1834 provides greater compatibility with the existing code.  Pragma
1835 @code{Extend_System} is a configuration pragma whose single argument is
1836 the name of the package containing the extended definition
1837 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1838 control of this pragma will be processed using special visibility
1839 processing that looks in package @code{System.Aux_@var{xxx}} where
1840 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1841 package @code{System}, but not found in package @code{System}.
1842
1843 You can use this pragma either to access a predefined @code{System}
1844 extension supplied with the compiler, for example @code{Aux_DEC} or
1845 you can construct your own extension unit following the above
1846 definition.  Note that such a package is a child of @code{System}
1847 and thus is considered part of the implementation.  To compile
1848 it you will have to use the appropriate switch for compiling
1849 system units.  See the GNAT User's Guide for details.
1850
1851 @node Pragma External
1852 @unnumberedsec Pragma External
1853 @findex External
1854 @noindent
1855 Syntax:
1856
1857 @smallexample @c ada
1858 pragma External (
1859   [   Convention    =>] convention_IDENTIFIER,
1860   [   Entity        =>] local_NAME
1861   [, [External_Name =>] static_string_EXPRESSION ]
1862   [, [Link_Name     =>] static_string_EXPRESSION ]);
1863 @end smallexample
1864
1865 @noindent
1866 This pragma is identical in syntax and semantics to pragma
1867 @code{Export} as defined in the Ada Reference Manual.  It is
1868 provided for compatibility with some Ada 83 compilers that
1869 used this pragma for exactly the same purposes as pragma
1870 @code{Export} before the latter was standardized.
1871
1872 @node Pragma External_Name_Casing
1873 @unnumberedsec Pragma External_Name_Casing
1874 @cindex Dec Ada 83 casing compatibility
1875 @cindex External Names, casing
1876 @cindex Casing of External names
1877 @findex External_Name_Casing
1878 @noindent
1879 Syntax:
1880
1881 @smallexample @c ada
1882 pragma External_Name_Casing (
1883   Uppercase | Lowercase
1884   [, Uppercase | Lowercase | As_Is]);
1885 @end smallexample
1886
1887 @noindent
1888 This pragma provides control over the casing of external names associated
1889 with Import and Export pragmas.  There are two cases to consider:
1890
1891 @table @asis
1892 @item Implicit external names
1893 Implicit external names are derived from identifiers.  The most common case
1894 arises when a standard Ada 95 Import or Export pragma is used with only two
1895 arguments, as in:
1896
1897 @smallexample @c ada
1898    pragma Import (C, C_Routine);
1899 @end smallexample
1900
1901 @noindent
1902 Since Ada is a case insensitive language, the spelling of the identifier in
1903 the Ada source program does not provide any information on the desired
1904 casing of the external name, and so a convention is needed.  In GNAT the
1905 default treatment is that such names are converted to all lower case
1906 letters.  This corresponds to the normal C style in many environments.
1907 The first argument of pragma @code{External_Name_Casing} can be used to
1908 control this treatment.  If @code{Uppercase} is specified, then the name
1909 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1910 then the normal default of all lower case letters will be used.
1911
1912 This same implicit treatment is also used in the case of extended DEC Ada 83
1913 compatible Import and Export pragmas where an external name is explicitly
1914 specified using an identifier rather than a string.
1915
1916 @item Explicit external names
1917 Explicit external names are given as string literals.  The most common case
1918 arises when a standard Ada 95 Import or Export pragma is used with three
1919 arguments, as in:
1920
1921 @smallexample @c ada
1922 pragma Import (C, C_Routine, "C_routine");
1923 @end smallexample
1924
1925 @noindent
1926 In this case, the string literal normally provides the exact casing required
1927 for the external name.  The second argument of pragma
1928 @code{External_Name_Casing} may be used to modify this behavior.
1929 If @code{Uppercase} is specified, then the name
1930 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1931 then the name will be forced to all lowercase letters.  A specification of
1932 @code{As_Is} provides the normal default behavior in which the casing is
1933 taken from the string provided.
1934 @end table
1935
1936 @noindent
1937 This pragma may appear anywhere that a pragma is valid.  In particular, it
1938 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1939 case it applies to all subsequent compilations, or it can be used as a program
1940 unit pragma, in which case it only applies to the current unit, or it can
1941 be used more locally to control individual Import/Export pragmas.
1942
1943 It is primarily intended for use with OpenVMS systems, where many
1944 compilers convert all symbols to upper case by default.  For interfacing to
1945 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1946 the pragma:
1947
1948 @smallexample @c ada
1949 pragma External_Name_Casing (Uppercase, Uppercase);
1950 @end smallexample
1951
1952 @noindent
1953 to enforce the upper casing of all external symbols.
1954
1955 @node Pragma Finalize_Storage_Only
1956 @unnumberedsec Pragma Finalize_Storage_Only
1957 @findex Finalize_Storage_Only
1958 @noindent
1959 Syntax:
1960
1961 @smallexample @c ada
1962 pragma Finalize_Storage_Only (first_subtype_local_NAME);
1963 @end smallexample
1964
1965 @noindent
1966 This pragma allows the compiler not to emit a Finalize call for objects
1967 defined at the library level.  This is mostly useful for types where
1968 finalization is only used to deal with storage reclamation since in most
1969 environments it is not necessary to reclaim memory just before terminating
1970 execution, hence the name.
1971
1972 @node Pragma Float_Representation
1973 @unnumberedsec Pragma Float_Representation
1974 @cindex OpenVMS
1975 @findex Float_Representation
1976 @noindent
1977 Syntax:
1978
1979 @smallexample @c ada
1980 pragma Float_Representation (FLOAT_REP);
1981
1982 FLOAT_REP ::= VAX_Float | IEEE_Float
1983 @end smallexample
1984
1985 @noindent
1986 This pragma
1987 allows control over the internal representation chosen for the predefined
1988 floating point types declared in the packages @code{Standard} and
1989 @code{System}. On all systems other than OpenVMS, the argument must
1990 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1991 argument may be @code{VAX_Float} to specify the use of the VAX float
1992 format for the floating-point types in Standard. This requires that
1993 the standard runtime libraries be recompiled. See the
1994 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1995 of the GNAT Users Guide for details on the use of this command.
1996
1997 @node Pragma Ident
1998 @unnumberedsec Pragma Ident
1999 @findex Ident
2000 @noindent
2001 Syntax:
2002
2003 @smallexample @c ada
2004 pragma Ident (static_string_EXPRESSION);
2005 @end smallexample
2006
2007 @noindent
2008 This pragma provides a string identification in the generated object file,
2009 if the system supports the concept of this kind of identification string.
2010 This pragma is allowed only in the outermost declarative part or
2011 declarative items of a compilation unit. If more than one @code{Ident}
2012 pragma is given, only the last one processed is effective.
2013 @cindex OpenVMS
2014 On OpenVMS systems, the effect of the pragma is identical to the effect of
2015 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2016 maximum allowed length is 31 characters, so if it is important to
2017 maintain compatibility with this compiler, you should obey this length
2018 limit.
2019
2020 @node Pragma Import_Exception
2021 @unnumberedsec Pragma Import_Exception
2022 @cindex OpenVMS
2023 @findex Import_Exception
2024 @noindent
2025 Syntax:
2026
2027 @smallexample @c ada
2028 pragma Import_Exception (
2029      [Internal =>] local_NAME,
2030   [, [External =>] EXTERNAL_SYMBOL,]
2031   [, [Form     =>] Ada | VMS]
2032   [, [Code     =>] static_integer_EXPRESSION]);
2033
2034 EXTERNAL_SYMBOL ::=
2035   IDENTIFIER
2036 | static_string_EXPRESSION
2037 @end smallexample
2038
2039 @noindent
2040 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2041 It allows OpenVMS conditions (for example, from OpenVMS system services or
2042 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2043 The pragma specifies that the exception associated with an exception
2044 declaration in an Ada program be defined externally (in non-Ada code).
2045 For further details on this pragma, see the
2046 DEC Ada Language Reference Manual, section 13.9a.3.1.
2047
2048 @node Pragma Import_Function
2049 @unnumberedsec Pragma Import_Function
2050 @findex Import_Function
2051 @noindent
2052 Syntax:
2053
2054 @smallexample @c ada
2055 pragma Import_Function (
2056      [Internal                 =>] local_NAME,
2057   [, [External                 =>] EXTERNAL_SYMBOL]
2058   [, [Parameter_Types          =>] PARAMETER_TYPES]
2059   [, [Result_Type              =>] SUBTYPE_MARK]
2060   [, [Mechanism                =>] MECHANISM]
2061   [, [Result_Mechanism         =>] MECHANISM_NAME]
2062   [, [First_Optional_Parameter =>] IDENTIFIER]);
2063
2064 EXTERNAL_SYMBOL ::=
2065   IDENTIFIER
2066 | static_string_EXPRESSION
2067
2068 PARAMETER_TYPES ::=
2069   null
2070 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2071
2072 TYPE_DESIGNATOR ::=
2073   subtype_NAME
2074 | subtype_Name ' Access
2075
2076 MECHANISM ::=
2077   MECHANISM_NAME
2078 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2079
2080 MECHANISM_ASSOCIATION ::=
2081   [formal_parameter_NAME =>] MECHANISM_NAME
2082
2083 MECHANISM_NAME ::=
2084   Value
2085 | Reference
2086 | Descriptor [([Class =>] CLASS_NAME)]
2087
2088 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2089 @end smallexample
2090
2091 @noindent
2092 This pragma is used in conjunction with a pragma @code{Import} to
2093 specify additional information for an imported function.  The pragma
2094 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2095 @code{Import_Function} pragma and both must appear in the same
2096 declarative part as the function specification.
2097
2098 The @var{Internal} argument must uniquely designate
2099 the function to which the
2100 pragma applies.  If more than one function name exists of this name in
2101 the declarative part you must use the @code{Parameter_Types} and
2102 @var{Result_Type} parameters to achieve the required unique
2103 designation.  Subtype marks in these parameters must exactly match the
2104 subtypes in the corresponding function specification, using positional
2105 notation to match parameters with subtype marks.
2106 The form with an @code{'Access} attribute can be used to match an
2107 anonymous access parameter.
2108
2109 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2110 parameters to specify passing mechanisms for the
2111 parameters and result.  If you specify a single mechanism name, it
2112 applies to all parameters.  Otherwise you may specify a mechanism on a
2113 parameter by parameter basis using either positional or named
2114 notation.  If the mechanism is not specified, the default mechanism
2115 is used.
2116
2117 @cindex OpenVMS
2118 @cindex Passing by descriptor
2119 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2120
2121 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2122 It specifies that the designated parameter and all following parameters
2123 are optional, meaning that they are not passed at the generated code
2124 level (this is distinct from the notion of optional parameters in Ada
2125 where the parameters are passed anyway with the designated optional
2126 parameters).  All optional parameters must be of mode @code{IN} and have
2127 default parameter values that are either known at compile time
2128 expressions, or uses of the @code{'Null_Parameter} attribute.
2129
2130 @node Pragma Import_Object
2131 @unnumberedsec Pragma Import_Object
2132 @findex Import_Object
2133 @noindent
2134 Syntax:
2135
2136 @smallexample @c ada
2137 pragma Import_Object
2138      [Internal =>] local_NAME,
2139   [, [External =>] EXTERNAL_SYMBOL],
2140   [, [Size     =>] EXTERNAL_SYMBOL]);
2141
2142 EXTERNAL_SYMBOL ::=
2143   IDENTIFIER
2144 | static_string_EXPRESSION
2145 @end smallexample
2146
2147 @noindent
2148 This pragma designates an object as imported, and apart from the
2149 extended rules for external symbols, is identical in effect to the use of
2150 the normal @code{Import} pragma applied to an object.  Unlike the
2151 subprogram case, you need not use a separate @code{Import} pragma,
2152 although you may do so (and probably should do so from a portability
2153 point of view).  @var{size} is syntax checked, but otherwise ignored by
2154 GNAT@.
2155
2156 @node Pragma Import_Procedure
2157 @unnumberedsec Pragma Import_Procedure
2158 @findex Import_Procedure
2159 @noindent
2160 Syntax:
2161
2162 @smallexample @c ada
2163 pragma Import_Procedure (
2164      [Internal                 =>] local_NAME,
2165   [, [External                 =>] EXTERNAL_SYMBOL]
2166   [, [Parameter_Types          =>] PARAMETER_TYPES]
2167   [, [Mechanism                =>] MECHANISM]
2168   [, [First_Optional_Parameter =>] IDENTIFIER]);
2169
2170 EXTERNAL_SYMBOL ::=
2171   IDENTIFIER
2172 | static_string_EXPRESSION
2173
2174 PARAMETER_TYPES ::=
2175   null
2176 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2177
2178 TYPE_DESIGNATOR ::=
2179   subtype_NAME
2180 | subtype_Name ' Access
2181
2182 MECHANISM ::=
2183   MECHANISM_NAME
2184 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2185
2186 MECHANISM_ASSOCIATION ::=
2187   [formal_parameter_NAME =>] MECHANISM_NAME
2188
2189 MECHANISM_NAME ::=
2190   Value
2191 | Reference
2192 | Descriptor [([Class =>] CLASS_NAME)]
2193
2194 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2195 @end smallexample
2196
2197 @noindent
2198 This pragma is identical to @code{Import_Function} except that it
2199 applies to a procedure rather than a function and the parameters
2200 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2201
2202 @node Pragma Import_Valued_Procedure
2203 @unnumberedsec Pragma Import_Valued_Procedure
2204 @findex Import_Valued_Procedure
2205 @noindent
2206 Syntax:
2207
2208 @smallexample @c ada
2209 pragma Import_Valued_Procedure (
2210      [Internal                 =>] local_NAME,
2211   [, [External                 =>] EXTERNAL_SYMBOL]
2212   [, [Parameter_Types          =>] PARAMETER_TYPES]
2213   [, [Mechanism                =>] MECHANISM]
2214   [, [First_Optional_Parameter =>] IDENTIFIER]);
2215
2216 EXTERNAL_SYMBOL ::=
2217   IDENTIFIER
2218 | static_string_EXPRESSION
2219
2220 PARAMETER_TYPES ::=
2221   null
2222 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2223
2224 TYPE_DESIGNATOR ::=
2225   subtype_NAME
2226 | subtype_Name ' Access
2227
2228 MECHANISM ::=
2229   MECHANISM_NAME
2230 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2231
2232 MECHANISM_ASSOCIATION ::=
2233   [formal_parameter_NAME =>] MECHANISM_NAME
2234
2235 MECHANISM_NAME ::=
2236   Value
2237 | Reference
2238 | Descriptor [([Class =>] CLASS_NAME)]
2239
2240 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2241 @end smallexample
2242
2243 @noindent
2244 This pragma is identical to @code{Import_Procedure} except that the
2245 first parameter of @var{local_NAME}, which must be present, must be of
2246 mode @code{OUT}, and externally the subprogram is treated as a function
2247 with this parameter as the result of the function.  The purpose of this
2248 capability is to allow the use of @code{OUT} and @code{IN OUT}
2249 parameters in interfacing to external functions (which are not permitted
2250 in Ada functions).  You may optionally use the @code{Mechanism}
2251 parameters to specify passing mechanisms for the parameters.
2252 If you specify a single mechanism name, it applies to all parameters.
2253 Otherwise you may specify a mechanism on a parameter by parameter
2254 basis using either positional or named notation.  If the mechanism is not
2255 specified, the default mechanism is used.
2256
2257 Note that it is important to use this pragma in conjunction with a separate
2258 pragma Import that specifies the desired convention, since otherwise the
2259 default convention is Ada, which is almost certainly not what is required.
2260
2261 @node Pragma Initialize_Scalars
2262 @unnumberedsec Pragma Initialize_Scalars
2263 @findex Initialize_Scalars
2264 @cindex debugging with Initialize_Scalars
2265 @noindent
2266 Syntax:
2267
2268 @smallexample @c ada
2269 pragma Initialize_Scalars;
2270 @end smallexample
2271
2272 @noindent
2273 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2274 two important differences.  First, there is no requirement for the pragma
2275 to be used uniformly in all units of a partition, in particular, it is fine
2276 to use this just for some or all of the application units of a partition,
2277 without needing to recompile the run-time library.
2278
2279 In the case where some units are compiled with the pragma, and some without,
2280 then a declaration of a variable where the type is defined in package
2281 Standard or is locally declared will always be subject to initialization,
2282 as will any declaration of a scalar variable.  For composite variables,
2283 whether the variable is initialized may also depend on whether the package
2284 in which the type of the variable is declared is compiled with the pragma.
2285
2286 The other important difference is that you can control the value used
2287 for initializing scalar objects.  At bind time, you can select several
2288 options for initialization. You can
2289 initialize with invalid values (similar to Normalize_Scalars, though for
2290 Initialize_Scalars it is not always possible to determine the invalid
2291 values in complex cases like signed component fields with non-standard
2292 sizes). You can also initialize with high or
2293 low values, or with a specified bit pattern.  See the users guide for binder
2294 options for specifying these cases.
2295
2296 This means that you can compile a program, and then without having to
2297 recompile the program, you can run it with different values being used
2298 for initializing otherwise uninitialized values, to test if your program
2299 behavior depends on the choice.  Of course the behavior should not change,
2300 and if it does, then most likely you have an erroneous reference to an
2301 uninitialized value.
2302
2303 It is even possible to change the value at execution time eliminating even
2304 the need to rebind with a different switch using an environment variable.
2305 See the GNAT users guide for details.
2306
2307 Note that pragma @code{Initialize_Scalars} is particularly useful in
2308 conjunction with the enhanced validity checking that is now provided
2309 in GNAT, which checks for invalid values under more conditions.
2310 Using this feature (see description of the @code{-gnatV} flag in the
2311 users guide) in conjunction with pragma @code{Initialize_Scalars}
2312 provides a powerful new tool to assist in the detection of problems
2313 caused by uninitialized variables.
2314
2315 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2316 effect on the generated code. This may cause your code to be
2317 substantially larger. It may also cause an increase in the amount
2318 of stack required, so it is probably a good idea to turn on stack
2319 checking (see description of stack checking in the GNAT users guide)
2320 when using this pragma.
2321
2322 @node Pragma Inline_Always
2323 @unnumberedsec Pragma Inline_Always
2324 @findex Inline_Always
2325 @noindent
2326 Syntax:
2327
2328 @smallexample @c ada
2329 pragma Inline_Always (NAME [, NAME]);
2330 @end smallexample
2331
2332 @noindent
2333 Similar to pragma @code{Inline} except that inlining is not subject to
2334 the use of option @code{-gnatn} and the inlining happens regardless of
2335 whether this option is used.
2336
2337 @node Pragma Inline_Generic
2338 @unnumberedsec Pragma Inline_Generic
2339 @findex Inline_Generic
2340 @noindent
2341 Syntax:
2342
2343 @smallexample @c ada
2344 pragma Inline_Generic (generic_package_NAME);
2345 @end smallexample
2346
2347 @noindent
2348 This is implemented for compatibility with DEC Ada 83 and is recognized,
2349 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2350 by default when using GNAT@.
2351
2352 @node Pragma Interface
2353 @unnumberedsec Pragma Interface
2354 @findex Interface
2355 @noindent
2356 Syntax:
2357
2358 @smallexample @c ada
2359 pragma Interface (
2360      [Convention    =>] convention_identifier,
2361      [Entity =>] local_NAME
2362   [, [External_Name =>] static_string_expression],
2363   [, [Link_Name     =>] static_string_expression]);
2364 @end smallexample
2365
2366 @noindent
2367 This pragma is identical in syntax and semantics to
2368 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2369 with Ada 83.  The definition is upwards compatible both with pragma
2370 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2371 with some extended implementations of this pragma in certain Ada 83
2372 implementations.
2373
2374 @node Pragma Interface_Name
2375 @unnumberedsec Pragma Interface_Name
2376 @findex Interface_Name
2377 @noindent
2378 Syntax:
2379
2380 @smallexample @c ada
2381 pragma Interface_Name (
2382      [Entity        =>] local_NAME
2383   [, [External_Name =>] static_string_EXPRESSION]
2384   [, [Link_Name     =>] static_string_EXPRESSION]);
2385 @end smallexample
2386
2387 @noindent
2388 This pragma provides an alternative way of specifying the interface name
2389 for an interfaced subprogram, and is provided for compatibility with Ada
2390 83 compilers that use the pragma for this purpose.  You must provide at
2391 least one of @var{External_Name} or @var{Link_Name}.
2392
2393 @node Pragma Interrupt_Handler
2394 @unnumberedsec Pragma Interrupt_Handler
2395 @findex Interrupt_Handler
2396 @noindent
2397 Syntax:
2398
2399 @smallexample @c ada
2400 pragma Interrupt_Handler (procedure_local_NAME);
2401 @end smallexample
2402
2403 @noindent
2404 This program unit pragma is supported for parameterless protected procedures
2405 as described in Annex C of the Ada Reference Manual. On the AAMP target
2406 the pragma can also be specified for nonprotected parameterless procedures
2407 that are declared at the library level (which includes procedures
2408 declared at the top level of a library package). In the case of AAMP,
2409 when this pragma is applied to a nonprotected procedure, the instruction
2410 @code{IERET} is generated for returns from the procedure, enabling
2411 maskable interrupts, in place of the normal return instruction.
2412
2413 @node Pragma Interrupt_State
2414 @unnumberedsec Pragma Interrupt_State
2415 @findex Interrupt_State
2416 @noindent
2417 Syntax:
2418
2419 @smallexample @c ada
2420 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2421 @end smallexample
2422
2423 @noindent
2424 Normally certain interrupts are reserved to the implementation.  Any attempt
2425 to attach an interrupt causes Program_Error to be raised, as described in
2426 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2427 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2428 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2429 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2430 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2431 Ada exceptions, or used to implement run-time functions such as the
2432 @code{abort} statement and stack overflow checking.
2433
2434 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2435 such uses of interrupts.  It subsumes the functionality of pragma
2436 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2437 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2438 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2439 and may be used to mark interrupts required by the board support package
2440 as reserved.
2441
2442 Interrupts can be in one of three states:
2443 @itemize @bullet
2444 @item System
2445
2446 The interrupt is reserved (no Ada handler can be installed), and the
2447 Ada run-time may not install a handler. As a result you are guaranteed
2448 standard system default action if this interrupt is raised.
2449
2450 @item Runtime
2451
2452 The interrupt is reserved (no Ada handler can be installed). The run time
2453 is allowed to install a handler for internal control purposes, but is
2454 not required to do so.
2455
2456 @item User
2457
2458 The interrupt is unreserved.  The user may install a handler to provide
2459 some other action.
2460 @end itemize
2461
2462 @noindent
2463 These states are the allowed values of the @code{State} parameter of the
2464 pragma.  The @code{Name} parameter is a value of the type
2465 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2466 @code{Ada.Interrupts.Names}.
2467
2468 This is a configuration pragma, and the binder will check that there
2469 are no inconsistencies between different units in a partition in how a
2470 given interrupt is specified. It may appear anywhere a pragma is legal.
2471
2472 The effect is to move the interrupt to the specified state.
2473
2474 By declaring interrupts to be SYSTEM, you guarantee the standard system
2475 action, such as a core dump.
2476
2477 By declaring interrupts to be USER, you guarantee that you can install
2478 a handler.
2479
2480 Note that certain signals on many operating systems cannot be caught and
2481 handled by applications.  In such cases, the pragma is ignored.  See the
2482 operating system documentation, or the value of the array @code{Reserved}
2483 declared in the specification of package @code{System.OS_Interface}.
2484
2485 Overriding the default state of signals used by the Ada runtime may interfere
2486 with an application's runtime behavior in the cases of the synchronous signals,
2487 and in the case of the signal used to implement the @code{abort} statement.
2488
2489 @node Pragma Keep_Names
2490 @unnumberedsec Pragma Keep_Names
2491 @findex Keep_Names
2492 @noindent
2493 Syntax:
2494
2495 @smallexample @c ada
2496 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2497 @end smallexample
2498
2499 @noindent
2500 The @var{local_NAME} argument
2501 must refer to an enumeration first subtype
2502 in the current declarative part. The effect is to retain the enumeration
2503 literal names for use by @code{Image} and @code{Value} even if a global
2504 @code{Discard_Names} pragma applies. This is useful when you want to
2505 generally suppress enumeration literal names and for example you therefore
2506 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2507 want to retain the names for specific enumeration types.
2508
2509 @node Pragma License
2510 @unnumberedsec Pragma License
2511 @findex License
2512 @cindex License checking
2513 @noindent
2514 Syntax:
2515
2516 @smallexample @c ada
2517 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2518 @end smallexample
2519
2520 @noindent
2521 This pragma is provided to allow automated checking for appropriate license
2522 conditions with respect to the standard and modified GPL@.  A pragma
2523 @code{License}, which is a configuration pragma that typically appears at
2524 the start of a source file or in a separate @file{gnat.adc} file, specifies
2525 the licensing conditions of a unit as follows:
2526
2527 @itemize @bullet
2528 @item Unrestricted
2529 This is used for a unit that can be freely used with no license restrictions.
2530 Examples of such units are public domain units, and units from the Ada
2531 Reference Manual.
2532
2533 @item GPL
2534 This is used for a unit that is licensed under the unmodified GPL, and which
2535 therefore cannot be @code{with}'ed by a restricted unit.
2536
2537 @item Modified_GPL
2538 This is used for a unit licensed under the GNAT modified GPL that includes
2539 a special exception paragraph that specifically permits the inclusion of
2540 the unit in programs without requiring the entire program to be released
2541 under the GPL@.  This is the license used for the GNAT run-time which ensures
2542 that the run-time can be used freely in any program without GPL concerns.
2543
2544 @item Restricted
2545 This is used for a unit that is restricted in that it is not permitted to
2546 depend on units that are licensed under the GPL@.  Typical examples are
2547 proprietary code that is to be released under more restrictive license
2548 conditions.  Note that restricted units are permitted to @code{with} units
2549 which are licensed under the modified GPL (this is the whole point of the
2550 modified GPL).
2551
2552 @end itemize
2553
2554 @noindent
2555 Normally a unit with no @code{License} pragma is considered to have an
2556 unknown license, and no checking is done.  However, standard GNAT headers
2557 are recognized, and license information is derived from them as follows.
2558
2559 @itemize @bullet
2560
2561 A GNAT license header starts with a line containing 78 hyphens.  The following
2562 comment text is searched for the appearance of any of the following strings.
2563
2564 If the string ``GNU General Public License'' is found, then the unit is assumed
2565 to have GPL license, unless the string ``As a special exception'' follows, in
2566 which case the license is assumed to be modified GPL@.
2567
2568 If one of the strings
2569 ``This specification is adapted from the Ada Semantic Interface'' or
2570 ``This specification is derived from the Ada Reference Manual'' is found
2571 then the unit is assumed to be unrestricted.
2572 @end itemize
2573
2574 @noindent
2575 These default actions means that a program with a restricted license pragma
2576 will automatically get warnings if a GPL unit is inappropriately
2577 @code{with}'ed.  For example, the program:
2578
2579 @smallexample @c ada
2580 with Sem_Ch3;
2581 with GNAT.Sockets;
2582 procedure Secret_Stuff is
2583   @dots{}
2584 end Secret_Stuff
2585 @end smallexample
2586
2587 @noindent
2588 if compiled with pragma @code{License} (@code{Restricted}) in a
2589 @file{gnat.adc} file will generate the warning:
2590
2591 @smallexample
2592 1.  with Sem_Ch3;
2593         |
2594    >>> license of withed unit "Sem_Ch3" is incompatible
2595
2596 2.  with GNAT.Sockets;
2597 3.  procedure Secret_Stuff is
2598 @end smallexample
2599
2600 @noindent
2601 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2602 compiler and is licensed under the
2603 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2604 run time, and is therefore licensed under the modified GPL@.
2605
2606 @node Pragma Link_With
2607 @unnumberedsec Pragma Link_With
2608 @findex Link_With
2609 @noindent
2610 Syntax:
2611
2612 @smallexample @c ada
2613 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2614 @end smallexample
2615
2616 @noindent
2617 This pragma is provided for compatibility with certain Ada 83 compilers.
2618 It has exactly the same effect as pragma @code{Linker_Options} except
2619 that spaces occurring within one of the string expressions are treated
2620 as separators. For example, in the following case:
2621
2622 @smallexample @c ada
2623 pragma Link_With ("-labc -ldef");
2624 @end smallexample
2625
2626 @noindent
2627 results in passing the strings @code{-labc} and @code{-ldef} as two
2628 separate arguments to the linker. In addition pragma Link_With allows
2629 multiple arguments, with the same effect as successive pragmas.
2630
2631 @node Pragma Linker_Alias
2632 @unnumberedsec Pragma Linker_Alias
2633 @findex Linker_Alias
2634 @noindent
2635 Syntax:
2636
2637 @smallexample @c ada
2638 pragma Linker_Alias (
2639   [Entity =>] local_NAME
2640   [Alias  =>] static_string_EXPRESSION);
2641 @end smallexample
2642
2643 @noindent
2644 This pragma establishes a linker alias for the given named entity.  For
2645 further details on the exact effect, consult the GCC manual.
2646
2647 @node Pragma Linker_Section
2648 @unnumberedsec Pragma Linker_Section
2649 @findex Linker_Section
2650 @noindent
2651 Syntax:
2652
2653 @smallexample @c ada
2654 pragma Linker_Section (
2655   [Entity  =>] local_NAME
2656   [Section =>] static_string_EXPRESSION);
2657 @end smallexample
2658
2659 @noindent
2660 This pragma specifies the name of the linker section for the given entity.
2661 For further details on the exact effect, consult the GCC manual.
2662
2663 @node Pragma Long_Float
2664 @unnumberedsec Pragma Long_Float
2665 @cindex OpenVMS
2666 @findex Long_Float
2667 @noindent
2668 Syntax:
2669
2670 @smallexample @c ada
2671 pragma Long_Float (FLOAT_FORMAT);
2672
2673 FLOAT_FORMAT ::= D_Float | G_Float
2674 @end smallexample
2675
2676 @noindent
2677 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2678 It allows control over the internal representation chosen for the predefined
2679 type @code{Long_Float} and for floating point type representations with
2680 @code{digits} specified in the range 7 through 15.
2681 For further details on this pragma, see the
2682 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2683 this pragma, the standard runtime libraries must be recompiled.  See the
2684 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2685 of the GNAT User's Guide for details on the use of this command.
2686
2687 @node Pragma Machine_Attribute
2688 @unnumberedsec Pragma Machine_Attribute
2689 @findex Machine_Attribute
2690 @noindent
2691 Syntax:
2692
2693 @smallexample @c ada
2694 pragma Machine_Attribute (
2695   [Attribute_Name =>] string_EXPRESSION,
2696   [Entity         =>] local_NAME);
2697 @end smallexample
2698
2699 @noindent
2700 Machine-dependent attributes can be specified for types and/or
2701 declarations.  This pragma is semantically equivalent to
2702 @code{__attribute__((@var{string_expression}))} in GNU C,
2703 where @code{@var{string_expression}} is
2704 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2705 defined for each machine.  See the GCC manual for further information.
2706 It is not possible to specify attributes defined by other languages,
2707 only attributes defined by the machine the code is intended to run on.
2708
2709 @node Pragma Main_Storage
2710 @unnumberedsec Pragma Main_Storage
2711 @cindex OpenVMS
2712 @findex Main_Storage
2713 @noindent
2714 Syntax:
2715
2716 @smallexample @c ada
2717 pragma Main_Storage
2718   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2719
2720 MAIN_STORAGE_OPTION ::=
2721   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2722 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2723
2724 @end smallexample
2725
2726 @noindent
2727 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2728 no effect in GNAT, other than being syntax checked.  Note that the pragma
2729 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2730
2731 @node Pragma No_Return
2732 @unnumberedsec Pragma No_Return
2733 @findex No_Return
2734 @noindent
2735 Syntax:
2736
2737 @smallexample @c ada
2738 pragma No_Return (procedure_local_NAME);
2739 @end smallexample
2740
2741 @noindent
2742 @var{procedure_local_NAME} must refer to one or more procedure
2743 declarations in the current declarative part.  A procedure to which this
2744 pragma is applied may not contain any explicit @code{return} statements,
2745 and also may not contain any implicit return statements from falling off
2746 the end of a statement sequence.  One use of this pragma is to identify
2747 procedures whose only purpose is to raise an exception.
2748
2749 Another use of this pragma is to suppress incorrect warnings about
2750 missing returns in functions, where the last statement of a function
2751 statement sequence is a call to such a procedure.
2752
2753 @node Pragma Normalize_Scalars
2754 @unnumberedsec Pragma Normalize_Scalars
2755 @findex Normalize_Scalars
2756 @noindent
2757 Syntax:
2758
2759 @smallexample @c ada
2760 pragma Normalize_Scalars;
2761 @end smallexample
2762
2763 @noindent
2764 This is a language defined pragma which is fully implemented in GNAT@.  The
2765 effect is to cause all scalar objects that are not otherwise initialized
2766 to be initialized.  The initial values are implementation dependent and
2767 are as follows:
2768
2769 @table @code
2770 @item Standard.Character
2771 @noindent
2772 Objects whose root type is Standard.Character are initialized to
2773 Character'Last unless the subtype range excludes NUL (in which case
2774 NUL is used). This choice will always generate an invalid value if
2775 one exists.
2776
2777 @item Standard.Wide_Character
2778 @noindent
2779 Objects whose root type is Standard.Wide_Character are initialized to
2780 Wide_Character'Last unless the subtype range excludes NUL (in which case
2781 NUL is used). This choice will always generate an invalid value if
2782 one exists.
2783
2784 @item Standard.Wide_Wide_Character
2785 @noindent
2786 Objects whose root type is Standard.Wide_Wide_Character are initialized to
2787 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
2788 which case NUL is used). This choice will always generate an invalid value if
2789 one exists.
2790
2791 @item Integer types
2792 @noindent
2793 Objects of an integer type are treated differently depending on whether
2794 negative values are present in the subtype. If no negative values are
2795 present, then all one bits is used as the initial value except in the
2796 special case where zero is excluded from the subtype, in which case
2797 all zero bits are used. This choice will always generate an invalid
2798 value if one exists.
2799
2800 For subtypes with negative values present, the largest negative number
2801 is used, except in the unusual case where this largest negative number
2802 is in the subtype, and the largest positive number is not, in which case
2803 the largest positive value is used. This choice will always generate
2804 an invalid value if one exists.
2805
2806 @item Floating-Point Types
2807 Objects of all floating-point types are initialized to all 1-bits. For
2808 standard IEEE format, this corresponds to a NaN (not a number) which is
2809 indeed an invalid value.
2810
2811 @item Fixed-Point Types
2812 Objects of all fixed-point types are treated as described above for integers,
2813 with the rules applying to the underlying integer value used to represent
2814 the fixed-point value.
2815
2816 @item Modular types
2817 Objects of a modular type are initialized to all one bits, except in
2818 the special case where zero is excluded from the subtype, in which
2819 case all zero bits are used. This choice will always generate an
2820 invalid value if one exists.
2821
2822 @item Enumeration types
2823 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2824 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
2825 whose Pos value is zero, in which case a code of zero is used. This choice
2826 will always generate an invalid value if one exists.
2827
2828 @end table
2829
2830 @node Pragma Obsolescent
2831 @unnumberedsec Pragma Obsolescent
2832 @findex Obsolescent
2833 @noindent
2834 Syntax:
2835
2836 @smallexample @c ada
2837 pragma Obsolescent [(static_string_EXPRESSION [,Ada_05])];
2838 @end smallexample
2839
2840 @noindent
2841 This pragma must occur immediately following a subprogram
2842 declaration. It indicates that the associated function or procedure
2843 is considered obsolescent and should not be used. Typically this is
2844 used when an API must be modified by eventually removing or modifying
2845 existing subprograms. The pragma can be used at an intermediate stage
2846 when the subprogram is still present, but will be removed later.
2847
2848 The effect of this pragma is to output a warning message that the
2849 subprogram is obsolescent if the appropriate warning option in the
2850 compiler is activated. If a parameter is present, then a second
2851 warning message is given containing this text.
2852
2853 In addition, a call to such a program is considered a violation of
2854 pragma Restrictions (No_Obsolescent_Features).
2855
2856 If the optional second parameter is present (which must be exactly
2857 the identifier Ada_05, no other argument is allowed), then the
2858 indication of obsolescence applies only when compiling in Ada 2005
2859 mode. This is primarily intended for dealing with the situations
2860 in the predefined library where subprograms have become defined
2861 as obsolescent in Ada 2005 (e.g. in Ada.Characters.Handling), but
2862 may be used anywhere.
2863
2864 @node Pragma Passive
2865 @unnumberedsec Pragma Passive
2866 @findex Passive
2867 @noindent
2868 Syntax:
2869
2870 @smallexample @c ada
2871 pragma Passive ([Semaphore | No]);
2872 @end smallexample
2873
2874 @noindent
2875 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2876 compatibility with DEC Ada 83 implementations, where it is used within a
2877 task definition to request that a task be made passive.  If the argument
2878 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2879 treats the pragma as an assertion that the containing task is passive
2880 and that optimization of context switch with this task is permitted and
2881 desired.  If the argument @code{No} is present, the task must not be
2882 optimized.  GNAT does not attempt to optimize any tasks in this manner
2883 (since protected objects are available in place of passive tasks).
2884
2885 @node Pragma Persistent_BSS
2886 @unnumberedsec Pragma Persistent_BSS
2887 @findex Persistent_BSS
2888 @noindent
2889 Syntax:
2890
2891 @smallexample @c ada
2892 pragma Persistent_BSS [local_NAME]
2893 @end smallexample
2894
2895 @noindent
2896 This pragma allows selected objects to be placed in the @code{.persistent_bss}
2897 section. On some targets the linker and loader provide for special
2898 treatment of this section, allowing a program to be reloaded without
2899 affecting the contents of this data (hence the name persistent).
2900
2901 There are two forms of usage. If an argument is given, it must be the
2902 local name of a library level object, with no explicit initialization
2903 and whose type is potentially persistent. If no argument is given, then
2904 the pragma is a configuration pragma, and applies to all library level
2905 objects with no explicit initialization of potentially persistent types.
2906
2907 A potentially persistent type is a scalar type, or a non-tagged,
2908 non-discriminated record, all of whose components have no explicit
2909 initialization and are themselves of a potentially persistent type,
2910 or an array, all of whose constraints are static, and whose component
2911 type is potentially persistent.
2912
2913 If this pragma is used on a target where this feature is not supported,
2914 then the pragma will be ignored. See also @code{pragma Linker_Section}.
2915
2916 @node Pragma Polling
2917 @unnumberedsec Pragma Polling
2918 @findex Polling
2919 @noindent
2920 Syntax:
2921
2922 @smallexample @c ada
2923 pragma Polling (ON | OFF);
2924 @end smallexample
2925
2926 @noindent
2927 This pragma controls the generation of polling code.  This is normally off.
2928 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2929 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2930 runtime library, and can be found in file @file{a-excpol.adb}.
2931
2932 Pragma @code{Polling} can appear as a configuration pragma (for example it
2933 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2934 can be used in the statement or declaration sequence to control polling
2935 more locally.
2936
2937 A call to the polling routine is generated at the start of every loop and
2938 at the start of every subprogram call.  This guarantees that the @code{Poll}
2939 routine is called frequently, and places an upper bound (determined by
2940 the complexity of the code) on the period between two @code{Poll} calls.
2941
2942 The primary purpose of the polling interface is to enable asynchronous
2943 aborts on targets that cannot otherwise support it (for example Windows
2944 NT), but it may be used for any other purpose requiring periodic polling.
2945 The standard version is null, and can be replaced by a user program.  This
2946 will require re-compilation of the @code{Ada.Exceptions} package that can
2947 be found in files @file{a-except.ads} and @file{a-except.adb}.
2948
2949 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2950 distribution) is used to enable the asynchronous abort capability on
2951 targets that do not normally support the capability.  The version of
2952 @code{Poll} in this file makes a call to the appropriate runtime routine
2953 to test for an abort condition.
2954
2955 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2956 the @cite{GNAT User's Guide} for details.
2957
2958 @node Pragma Profile (Ravenscar)
2959 @unnumberedsec Pragma Profile (Ravenscar)
2960 @findex Ravenscar
2961 @noindent
2962 Syntax:
2963
2964 @smallexample @c ada
2965 pragma Profile (Ravenscar);
2966 @end smallexample
2967
2968 @noindent
2969 A configuration pragma that establishes the following set of configuration
2970 pragmas:
2971
2972 @table @code
2973 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2974 [RM D.2.2] Tasks are dispatched following a preemptive
2975 priority-ordered scheduling policy.
2976
2977 @item Locking_Policy (Ceiling_Locking)
2978 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2979 the ceiling priority of the corresponding protected object.
2980 @c
2981 @c @item Detect_Blocking
2982 @c This pragma forces the detection of potentially blocking operations within a
2983 @c protected operation, and to raise Program_Error if that happens.
2984 @end table
2985 @noindent
2986
2987 plus the following set of restrictions:
2988
2989 @table @code
2990 @item Max_Entry_Queue_Length = 1
2991 Defines the maximum number of calls that are queued on a (protected) entry.
2992 Note that this restrictions is checked at run time. Violation of this
2993 restriction results in the raising of Program_Error exception at the point of
2994 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2995 always 1 and hence no task can be queued on a protected entry.
2996
2997 @item Max_Protected_Entries = 1
2998 [RM D.7] Specifies the maximum number of entries per protected type. The
2999 bounds of every entry family of a protected unit shall be static, or shall be
3000 defined by a discriminant of a subtype whose corresponding bound is static.
3001 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3002
3003 @item Max_Task_Entries = 0
3004 [RM D.7] Specifies the maximum number of entries
3005 per task.  The bounds of every entry family
3006 of a task unit shall be static, or shall be
3007 defined by a discriminant of a subtype whose
3008 corresponding bound is static.  A value of zero
3009 indicates that no rendezvous are possible.  For
3010 the Profile (Ravenscar), the value of Max_Task_Entries is always
3011 0 (zero).
3012
3013 @item No_Abort_Statements
3014 [RM D.7] There are no abort_statements, and there are
3015 no calls to Task_Identification.Abort_Task.
3016
3017 @item No_Asynchronous_Control
3018 [RM D.7] There are no semantic dependences on the package
3019 Asynchronous_Task_Control.
3020
3021 @item No_Calendar
3022 There are no semantic dependencies on the package Ada.Calendar.
3023
3024 @item No_Dynamic_Attachment
3025 There is no call to any of the operations defined in package Ada.Interrupts
3026 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3027 Detach_Handler, and Reference).
3028
3029 @item No_Dynamic_Priorities
3030 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3031
3032 @item No_Implicit_Heap_Allocations
3033 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3034
3035 @item No_Local_Protected_Objects
3036 Protected objects and access types that designate
3037 such objects shall be declared only at library level.
3038
3039 @item No_Protected_Type_Allocators
3040 There are no allocators for protected types or
3041 types containing protected subcomponents.
3042
3043 @item No_Relative_Delay
3044 There are no delay_relative statements.
3045
3046 @item No_Requeue_Statements
3047 Requeue statements are not allowed.
3048
3049 @item No_Select_Statements
3050 There are no select_statements.
3051
3052 @item No_Task_Allocators
3053 [RM D.7] There are no allocators for task types
3054 or types containing task subcomponents.
3055
3056 @item No_Task_Attributes_Package
3057 There are no semantic dependencies on the Ada.Task_Attributes package.
3058
3059 @item No_Task_Hierarchy
3060 [RM D.7] All (non-environment) tasks depend
3061 directly on the environment task of the partition.
3062
3063 @item No_Task_Termination
3064 Tasks which terminate are erroneous.
3065
3066 @item Simple_Barriers
3067 Entry barrier condition expressions shall be either static
3068 boolean expressions or boolean objects which are declared in
3069 the protected type which contains the entry.
3070 @end table
3071
3072 @noindent
3073 This set of configuration pragmas and restrictions correspond to the
3074 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3075 published by the @cite{International Real-Time Ada Workshop}, 1997,
3076 and whose most recent description is available at
3077 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3078
3079 The original definition of the profile was revised at subsequent IRTAW
3080 meetings. It has been included in the ISO
3081 @cite{Guide for the Use of the Ada Programming Language in High
3082 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3083 the next revision of the standard. The formal definition given by
3084 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3085 AI-305) available at
3086 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3087 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3088 respectively.
3089
3090 The above set is a superset of the restrictions provided by pragma
3091 @code{Profile (Restricted)}, it includes six additional restrictions
3092 (@code{Simple_Barriers}, @code{No_Select_Statements},
3093 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3094 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3095 that pragma @code{Profile (Ravenscar)}, like the pragma
3096 @code{Profile (Restricted)},
3097 automatically causes the use of a simplified,
3098 more efficient version of the tasking run-time system.
3099
3100 @node Pragma Profile (Restricted)
3101 @unnumberedsec Pragma Profile (Restricted)
3102 @findex Restricted Run Time
3103 @noindent
3104 Syntax:
3105
3106 @smallexample @c ada
3107 pragma Profile (Restricted);
3108 @end smallexample
3109
3110 @noindent
3111 A configuration pragma that establishes the following set of restrictions:
3112
3113 @itemize @bullet
3114 @item No_Abort_Statements
3115 @item No_Entry_Queue
3116 @item No_Task_Hierarchy
3117 @item No_Task_Allocators
3118 @item No_Dynamic_Priorities
3119 @item No_Terminate_Alternatives
3120 @item No_Dynamic_Attachment
3121 @item No_Protected_Type_Allocators
3122 @item No_Local_Protected_Objects
3123 @item No_Requeue_Statements
3124 @item No_Task_Attributes_Package
3125 @item Max_Asynchronous_Select_Nesting =  0
3126 @item Max_Task_Entries =  0
3127 @item Max_Protected_Entries = 1
3128 @item Max_Select_Alternatives = 0
3129 @end itemize
3130
3131 @noindent
3132 This set of restrictions causes the automatic selection of a simplified
3133 version of the run time that provides improved performance for the
3134 limited set of tasking functionality permitted by this set of restrictions.
3135
3136 @node Pragma Propagate_Exceptions
3137 @unnumberedsec Pragma Propagate_Exceptions
3138 @findex Propagate_Exceptions
3139 @cindex Zero Cost Exceptions
3140 @noindent
3141 Syntax:
3142
3143 @smallexample @c ada
3144 pragma Propagate_Exceptions (subprogram_local_NAME);
3145 @end smallexample
3146
3147 @noindent
3148 This pragma indicates that the given entity, which is the name of an
3149 imported foreign-language subprogram may receive an Ada exception,
3150 and that the exception should be propagated.  It is relevant only if
3151 zero cost exception handling is in use, and is thus never needed if
3152 the alternative @code{longjmp} / @code{setjmp} implementation of
3153 exceptions is used (although it is harmless to use it in such cases).
3154
3155 The implementation of fast exceptions always properly propagates
3156 exceptions through Ada code, as described in the Ada Reference Manual.
3157 However, this manual is silent about the propagation of exceptions
3158 through foreign code.  For example, consider the
3159 situation where @code{P1} calls
3160 @code{P2}, and @code{P2} calls @code{P3}, where
3161 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3162 @code{P3} raises an Ada exception.  The question is whether or not
3163 it will be propagated through @code{P2} and can be handled in
3164 @code{P1}.
3165
3166 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3167 the answer is always yes.  For some targets on which zero cost exception
3168 handling is implemented, the answer is also always yes.  However, there
3169 are some targets, notably in the current version all x86 architecture
3170 targets, in which the answer is that such propagation does not
3171 happen automatically.  If such propagation is required on these
3172 targets, it is mandatory to use @code{Propagate_Exceptions} to
3173 name all foreign language routines through which Ada exceptions
3174 may be propagated.
3175
3176 @node Pragma Psect_Object
3177 @unnumberedsec Pragma Psect_Object
3178 @findex Psect_Object
3179 @noindent
3180 Syntax:
3181
3182 @smallexample @c ada
3183 pragma Psect_Object (
3184      [Internal =>] local_NAME,
3185   [, [External =>] EXTERNAL_SYMBOL]
3186   [, [Size     =>] EXTERNAL_SYMBOL]);
3187
3188 EXTERNAL_SYMBOL ::=
3189   IDENTIFIER
3190 | static_string_EXPRESSION
3191 @end smallexample
3192
3193 @noindent
3194 This pragma is identical in effect to pragma @code{Common_Object}.
3195
3196 @node Pragma Pure_Function
3197 @unnumberedsec Pragma Pure_Function
3198 @findex Pure_Function
3199 @noindent
3200 Syntax:
3201
3202 @smallexample @c ada
3203 pragma Pure_Function ([Entity =>] function_local_NAME);
3204 @end smallexample
3205
3206 @noindent
3207 This pragma appears in the same declarative part as a function
3208 declaration (or a set of function declarations if more than one
3209 overloaded declaration exists, in which case the pragma applies
3210 to all entities).  It specifies that the function @code{Entity} is
3211 to be considered pure for the purposes of code generation.  This means
3212 that the compiler can assume that there are no side effects, and
3213 in particular that two calls with identical arguments produce the
3214 same result.  It also means that the function can be used in an
3215 address clause.
3216
3217 Note that, quite deliberately, there are no static checks to try
3218 to ensure that this promise is met, so @code{Pure_Function} can be used
3219 with functions that are conceptually pure, even if they do modify
3220 global variables.  For example, a square root function that is
3221 instrumented to count the number of times it is called is still
3222 conceptually pure, and can still be optimized, even though it
3223 modifies a global variable (the count).  Memo functions are another
3224 example (where a table of previous calls is kept and consulted to
3225 avoid re-computation).
3226
3227 @findex Pure
3228 Note: Most functions in a @code{Pure} package are automatically pure, and
3229 there is no need to use pragma @code{Pure_Function} for such functions.  One
3230 exception is any function that has at least one formal of type
3231 @code{System.Address} or a type derived from it.  Such functions are not
3232 considered pure by default, since the compiler assumes that the
3233 @code{Address} parameter may be functioning as a pointer and that the
3234 referenced data may change even if the address value does not.
3235 Similarly, imported functions are not considered to be pure by default,
3236 since there is no way of checking that they are in fact pure.  The use
3237 of pragma @code{Pure_Function} for such a function will override these default
3238 assumption, and cause the compiler to treat a designated subprogram as pure
3239 in these cases.
3240
3241 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3242 applies to the underlying renamed function.  This can be used to
3243 disambiguate cases of overloading where some but not all functions
3244 in a set of overloaded functions are to be designated as pure.
3245
3246 @node Pragma Restriction_Warnings
3247 @unnumberedsec Pragma Restriction_Warnings
3248 @findex Restriction_Warnings
3249 @noindent
3250 Syntax:
3251
3252 @smallexample @c ada
3253 pragma Restriction_Warnings
3254   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3255 @end smallexample
3256
3257 @noindent
3258 This pragma allows a series of restriction identifiers to be
3259 specified (the list of allowed identifiers is the same as for
3260 pragma @code{Restrictions}). For each of these identifiers
3261 the compiler checks for violations of the restriction, but
3262 generates a warning message rather than an error message
3263 if the restriction is violated.
3264
3265 @node Pragma Source_File_Name
3266 @unnumberedsec Pragma Source_File_Name
3267 @findex Source_File_Name
3268 @noindent
3269 Syntax:
3270
3271 @smallexample @c ada
3272 pragma Source_File_Name (
3273   [Unit_Name   =>] unit_NAME,
3274   Spec_File_Name =>  STRING_LITERAL);
3275
3276 pragma Source_File_Name (
3277   [Unit_Name   =>] unit_NAME,
3278   Body_File_Name =>  STRING_LITERAL);
3279 @end smallexample
3280
3281 @noindent
3282 Use this to override the normal naming convention.  It is a configuration
3283 pragma, and so has the usual applicability of configuration pragmas
3284 (i.e.@: it applies to either an entire partition, or to all units in a
3285 compilation, or to a single unit, depending on how it is used.
3286 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3287 the second argument is required, and indicates whether this is the file
3288 name for the spec or for the body.
3289
3290 Another form of the @code{Source_File_Name} pragma allows
3291 the specification of patterns defining alternative file naming schemes
3292 to apply to all files.
3293
3294 @smallexample @c ada
3295 pragma Source_File_Name
3296   (Spec_File_Name => STRING_LITERAL
3297    [,Casing => CASING_SPEC]
3298    [,Dot_Replacement => STRING_LITERAL]);
3299
3300 pragma Source_File_Name
3301   (Body_File_Name => STRING_LITERAL
3302    [,Casing => CASING_SPEC]
3303    [,Dot_Replacement => STRING_LITERAL]);
3304
3305 pragma Source_File_Name
3306   (Subunit_File_Name => STRING_LITERAL
3307    [,Casing => CASING_SPEC]
3308    [,Dot_Replacement => STRING_LITERAL]);
3309
3310 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3311 @end smallexample
3312
3313 @noindent
3314 The first argument is a pattern that contains a single asterisk indicating
3315 the point at which the unit name is to be inserted in the pattern string
3316 to form the file name.  The second argument is optional.  If present it
3317 specifies the casing of the unit name in the resulting file name string.
3318 The default is lower case.  Finally the third argument allows for systematic
3319 replacement of any dots in the unit name by the specified string literal.
3320
3321 A pragma Source_File_Name cannot appear after a
3322 @ref{Pragma Source_File_Name_Project}.
3323
3324 For more details on the use of the @code{Source_File_Name} pragma,
3325 see the sections ``Using Other File Names'' and
3326 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3327
3328 @node Pragma Source_File_Name_Project
3329 @unnumberedsec Pragma Source_File_Name_Project
3330 @findex Source_File_Name_Project
3331 @noindent
3332
3333 This pragma has the same syntax and semantics as pragma Source_File_Name.
3334 It is only allowed as a stand alone configuration pragma.
3335 It cannot appear after a @ref{Pragma Source_File_Name}, and
3336 most importantly, once pragma Source_File_Name_Project appears,
3337 no further Source_File_Name pragmas are allowed.
3338
3339 The intention is that Source_File_Name_Project pragmas are always
3340 generated by the Project Manager in a manner consistent with the naming
3341 specified in a project file, and when naming is controlled in this manner,
3342 it is not permissible to attempt to modify this naming scheme using
3343 Source_File_Name pragmas (which would not be known to the project manager).
3344
3345 @node Pragma Source_Reference
3346 @unnumberedsec Pragma Source_Reference
3347 @findex Source_Reference
3348 @noindent
3349 Syntax:
3350
3351 @smallexample @c ada
3352 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3353 @end smallexample
3354
3355 @noindent
3356 This pragma must appear as the first line of a source file.
3357 @var{integer_literal} is the logical line number of the line following
3358 the pragma line (for use in error messages and debugging
3359 information).  @var{string_literal} is a static string constant that
3360 specifies the file name to be used in error messages and debugging
3361 information.  This is most notably used for the output of @code{gnatchop}
3362 with the @code{-r} switch, to make sure that the original unchopped
3363 source file is the one referred to.
3364
3365 The second argument must be a string literal, it cannot be a static
3366 string expression other than a string literal.  This is because its value
3367 is needed for error messages issued by all phases of the compiler.
3368
3369 @node Pragma Stream_Convert
3370 @unnumberedsec Pragma Stream_Convert
3371 @findex Stream_Convert
3372 @noindent
3373 Syntax:
3374
3375 @smallexample @c ada
3376 pragma Stream_Convert (
3377   [Entity =>] type_local_NAME,
3378   [Read   =>] function_NAME,
3379   [Write  =>] function_NAME);
3380 @end smallexample
3381
3382 @noindent
3383 This pragma provides an efficient way of providing stream functions for
3384 types defined in packages.  Not only is it simpler to use than declaring
3385 the necessary functions with attribute representation clauses, but more
3386 significantly, it allows the declaration to made in such a way that the
3387 stream packages are not loaded unless they are needed.  The use of
3388 the Stream_Convert pragma adds no overhead at all, unless the stream
3389 attributes are actually used on the designated type.
3390
3391 The first argument specifies the type for which stream functions are
3392 provided.  The second parameter provides a function used to read values
3393 of this type.  It must name a function whose argument type may be any
3394 subtype, and whose returned type must be the type given as the first
3395 argument to the pragma.
3396
3397 The meaning of the @var{Read}
3398 parameter is that if a stream attribute directly
3399 or indirectly specifies reading of the type given as the first parameter,
3400 then a value of the type given as the argument to the Read function is
3401 read from the stream, and then the Read function is used to convert this
3402 to the required target type.
3403
3404 Similarly the @var{Write} parameter specifies how to treat write attributes
3405 that directly or indirectly apply to the type given as the first parameter.
3406 It must have an input parameter of the type specified by the first parameter,
3407 and the return type must be the same as the input type of the Read function.
3408 The effect is to first call the Write function to convert to the given stream
3409 type, and then write the result type to the stream.
3410
3411 The Read and Write functions must not be overloaded subprograms.  If necessary
3412 renamings can be supplied to meet this requirement.
3413 The usage of this attribute is best illustrated by a simple example, taken
3414 from the GNAT implementation of package Ada.Strings.Unbounded:
3415
3416 @smallexample @c ada
3417 function To_Unbounded (S : String)
3418            return Unbounded_String
3419   renames To_Unbounded_String;
3420
3421 pragma Stream_Convert
3422   (Unbounded_String, To_Unbounded, To_String);
3423 @end smallexample
3424
3425 @noindent
3426 The specifications of the referenced functions, as given in the Ada 95
3427 Reference Manual are:
3428
3429 @smallexample @c ada
3430 function To_Unbounded_String (Source : String)
3431   return Unbounded_String;
3432
3433 function To_String (Source : Unbounded_String)
3434   return String;
3435 @end smallexample
3436
3437 @noindent
3438 The effect is that if the value of an unbounded string is written to a
3439 stream, then the representation of the item in the stream is in the same
3440 format used for @code{Standard.String}, and this same representation is
3441 expected when a value of this type is read from the stream.
3442
3443 @node Pragma Style_Checks
3444 @unnumberedsec Pragma Style_Checks
3445 @findex Style_Checks
3446 @noindent
3447 Syntax:
3448
3449 @smallexample @c ada
3450 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3451                      On | Off [, local_NAME]);
3452 @end smallexample
3453
3454 @noindent
3455 This pragma is used in conjunction with compiler switches to control the
3456 built in style checking provided by GNAT@.  The compiler switches, if set,
3457 provide an initial setting for the switches, and this pragma may be used
3458 to modify these settings, or the settings may be provided entirely by
3459 the use of the pragma.  This pragma can be used anywhere that a pragma
3460 is legal, including use as a configuration pragma (including use in
3461 the @file{gnat.adc} file).
3462
3463 The form with a string literal specifies which style options are to be
3464 activated.  These are additive, so they apply in addition to any previously
3465 set style check options.  The codes for the options are the same as those
3466 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3467 For example the following two methods can be used to enable
3468 layout checking:
3469
3470 @itemize @bullet
3471 @item
3472 @smallexample @c ada
3473 pragma Style_Checks ("l");
3474 @end smallexample
3475
3476 @item
3477 @smallexample
3478 gcc -c -gnatyl @dots{}
3479 @end smallexample
3480 @end itemize
3481
3482 @noindent
3483 The form ALL_CHECKS activates all standard checks (its use is equivalent
3484 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3485 Guide for details.
3486
3487 The forms with @code{Off} and @code{On}
3488 can be used to temporarily disable style checks
3489 as shown in the following example:
3490
3491 @smallexample @c ada
3492 @iftex
3493 @leftskip=0cm
3494 @end iftex
3495 pragma Style_Checks ("k"); -- requires keywords in lower case
3496 pragma Style_Checks (Off); -- turn off style checks
3497 NULL;                      -- this will not generate an error message
3498 pragma Style_Checks (On);  -- turn style checks back on
3499 NULL;                      -- this will generate an error message
3500 @end smallexample
3501
3502 @noindent
3503 Finally the two argument form is allowed only if the first argument is
3504 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3505 for the specified entity, as shown in the following example:
3506
3507 @smallexample @c ada
3508 @iftex
3509 @leftskip=0cm
3510 @end iftex
3511 pragma Style_Checks ("r"); -- require consistency of identifier casing
3512 Arg : Integer;
3513 Rf1 : Integer := ARG;      -- incorrect, wrong case
3514 pragma Style_Checks (Off, Arg);
3515 Rf2 : Integer := ARG;      -- OK, no error
3516 @end smallexample
3517
3518 @node Pragma Subtitle
3519 @unnumberedsec Pragma Subtitle
3520 @findex Subtitle
3521 @noindent
3522 Syntax:
3523
3524 @smallexample @c ada
3525 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3526 @end smallexample
3527
3528 @noindent
3529 This pragma is recognized for compatibility with other Ada compilers
3530 but is ignored by GNAT@.
3531
3532 @node Pragma Suppress_All
3533 @unnumberedsec Pragma Suppress_All
3534 @findex Suppress_All
3535 @noindent
3536 Syntax:
3537
3538 @smallexample @c ada
3539 pragma Suppress_All;
3540 @end smallexample
3541
3542 @noindent
3543 This pragma can only appear immediately following a compilation
3544 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3545 which it follows.  This pragma is implemented for compatibility with DEC
3546 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3547 configuration pragma is the preferred usage in GNAT@.
3548
3549 @node Pragma Suppress_Exception_Locations
3550 @unnumberedsec Pragma Suppress_Exception_Locations
3551 @findex Suppress_Exception_Locations
3552 @noindent
3553 Syntax:
3554
3555 @smallexample @c ada
3556 pragma Suppress_Exception_Locations;
3557 @end smallexample
3558
3559 @noindent
3560 In normal mode, a raise statement for an exception by default generates
3561 an exception message giving the file name and line number for the location
3562 of the raise. This is useful for debugging and logging purposes, but this
3563 entails extra space for the strings for the messages. The configuration
3564 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3565 generation of these strings, with the result that space is saved, but the
3566 exception message for such raises is null. This configuration pragma may
3567 appear in a global configuration pragma file, or in a specific unit as
3568 usual. It is not required that this pragma be used consistently within
3569 a partition, so it is fine to have some units within a partition compiled
3570 with this pragma and others compiled in normal mode without it.
3571
3572 @node Pragma Suppress_Initialization
3573 @unnumberedsec Pragma Suppress_Initialization
3574 @findex Suppress_Initialization
3575 @cindex Suppressing initialization
3576 @cindex Initialization, suppression of
3577 @noindent
3578 Syntax:
3579
3580 @smallexample @c ada
3581 pragma Suppress_Initialization ([Entity =>] type_Name);
3582 @end smallexample
3583
3584 @noindent
3585 This pragma suppresses any implicit or explicit initialization
3586 associated with the given type name for all variables of this type.
3587
3588 @node Pragma Task_Info
3589 @unnumberedsec Pragma Task_Info
3590 @findex Task_Info
3591 @noindent
3592 Syntax
3593
3594 @smallexample @c ada
3595 pragma Task_Info (EXPRESSION);
3596 @end smallexample
3597
3598 @noindent
3599 This pragma appears within a task definition (like pragma
3600 @code{Priority}) and applies to the task in which it appears.  The
3601 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3602 The @code{Task_Info} pragma provides system dependent control over
3603 aspects of tasking implementation, for example, the ability to map
3604 tasks to specific processors.  For details on the facilities available
3605 for the version of GNAT that you are using, see the documentation
3606 in the specification of package System.Task_Info in the runtime
3607 library.
3608
3609 @node Pragma Task_Name
3610 @unnumberedsec Pragma Task_Name
3611 @findex Task_Name
3612 @noindent
3613 Syntax
3614
3615 @smallexample @c ada
3616 pragma Task_Name (string_EXPRESSION);
3617 @end smallexample
3618
3619 @noindent
3620 This pragma appears within a task definition (like pragma
3621 @code{Priority}) and applies to the task in which it appears.  The
3622 argument must be of type String, and provides a name to be used for
3623 the task instance when the task is created.  Note that this expression
3624 is not required to be static, and in particular, it can contain
3625 references to task discriminants.  This facility can be used to
3626 provide different names for different tasks as they are created,
3627 as illustrated in the example below.
3628
3629 The task name is recorded internally in the run-time structures
3630 and is accessible to tools like the debugger.  In addition the
3631 routine @code{Ada.Task_Identification.Image} will return this
3632 string, with a unique task address appended.
3633
3634 @smallexample @c ada
3635 --  Example of the use of pragma Task_Name
3636
3637 with Ada.Task_Identification;
3638 use Ada.Task_Identification;
3639 with Text_IO; use Text_IO;
3640 procedure t3 is
3641
3642    type Astring is access String;
3643
3644    task type Task_Typ (Name : access String) is
3645       pragma Task_Name (Name.all);
3646    end Task_Typ;
3647
3648    task body Task_Typ is
3649       Nam : constant String := Image (Current_Task);
3650    begin
3651       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3652    end Task_Typ;
3653
3654    type Ptr_Task is access Task_Typ;
3655    Task_Var : Ptr_Task;
3656
3657 begin
3658    Task_Var :=
3659      new Task_Typ (new String'("This is task 1"));
3660    Task_Var :=
3661      new Task_Typ (new String'("This is task 2"));
3662 end;
3663 @end smallexample
3664
3665 @node Pragma Task_Storage
3666 @unnumberedsec Pragma Task_Storage
3667 @findex Task_Storage
3668 Syntax:
3669
3670 @smallexample @c ada
3671 pragma Task_Storage (
3672   [Task_Type =>] local_NAME,
3673   [Top_Guard =>] static_integer_EXPRESSION);
3674 @end smallexample
3675
3676 @noindent
3677 This pragma specifies the length of the guard area for tasks.  The guard
3678 area is an additional storage area allocated to a task.  A value of zero
3679 means that either no guard area is created or a minimal guard area is
3680 created, depending on the target.  This pragma can appear anywhere a
3681 @code{Storage_Size} attribute definition clause is allowed for a task
3682 type.
3683
3684 @node Pragma Thread_Body
3685 @unnumberedsec Pragma Thread_Body
3686 @findex Thread_Body
3687 Syntax:
3688
3689 @smallexample @c ada
3690 pragma Thread_Body (
3691   [Entity =>] local_NAME,
3692  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3693 @end smallexample
3694
3695 @noindent
3696 This pragma specifies that the subprogram whose name is given as the
3697 @code{Entity} argument is a thread body, which will be activated
3698 by being called via its Address from foreign code. The purpose is
3699 to allow execution and registration of the foreign thread within the
3700 Ada run-time system.
3701
3702 See the library unit @code{System.Threads} for details on the expansion of
3703 a thread body subprogram, including the calls made to subprograms
3704 within System.Threads to register the task.  This unit also lists the
3705 targets and runtime systems for which this pragma is supported.
3706
3707 A thread body subprogram may not be called directly from Ada code, and
3708 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3709 to such a subprogram. The only legitimate way of calling such a subprogram
3710 is to pass its Address to foreign code and then make the call from the
3711 foreign code.
3712
3713 A thread body subprogram may have any parameters, and it may be a function
3714 returning a result. The convention of the thread body subprogram may be
3715 set in the usual manner using @code{pragma Convention}.
3716
3717 The secondary stack size parameter, if given, is used to set the size
3718 of secondary stack for the thread. The secondary stack is allocated as
3719 a local variable of the expanded thread body subprogram, and thus is
3720 allocated out of the main thread stack size. If no secondary stack
3721 size parameter is present, the default size (from the declaration in
3722 @code{System.Secondary_Stack} is used.
3723
3724 @node Pragma Time_Slice
3725 @unnumberedsec Pragma Time_Slice
3726 @findex Time_Slice
3727 @noindent
3728 Syntax:
3729
3730 @smallexample @c ada
3731 pragma Time_Slice (static_duration_EXPRESSION);
3732 @end smallexample
3733
3734 @noindent
3735 For implementations of GNAT on operating systems where it is possible
3736 to supply a time slice value, this pragma may be used for this purpose.
3737 It is ignored if it is used in a system that does not allow this control,
3738 or if it appears in other than the main program unit.
3739 @cindex OpenVMS
3740 Note that the effect of this pragma is identical to the effect of the
3741 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3742
3743 @node Pragma Title
3744 @unnumberedsec Pragma Title
3745 @findex Title
3746 @noindent
3747 Syntax:
3748
3749 @smallexample @c ada
3750 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3751
3752 TITLING_OPTION ::=
3753   [Title    =>] STRING_LITERAL,
3754 | [Subtitle =>] STRING_LITERAL
3755 @end smallexample
3756
3757 @noindent
3758 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3759 pragma used in DEC Ada 83 implementations to provide a title and/or
3760 subtitle for the program listing.  The program listing generated by GNAT
3761 does not have titles or subtitles.
3762
3763 Unlike other pragmas, the full flexibility of named notation is allowed
3764 for this pragma, i.e.@: the parameters may be given in any order if named
3765 notation is used, and named and positional notation can be mixed
3766 following the normal rules for procedure calls in Ada.
3767
3768 @node Pragma Unchecked_Union
3769 @unnumberedsec Pragma Unchecked_Union
3770 @cindex Unions in C
3771 @findex Unchecked_Union
3772 @noindent
3773 Syntax:
3774
3775 @smallexample @c ada
3776 pragma Unchecked_Union (first_subtype_local_NAME);
3777 @end smallexample
3778
3779 @noindent
3780 This pragma is used to declare that the specified type should be represented
3781 in a manner
3782 equivalent to a C union type, and is intended only for use in
3783 interfacing with C code that uses union types.  In Ada terms, the named
3784 type must obey the following rules:
3785
3786 @itemize @bullet
3787 @item
3788 It is a non-tagged non-limited record type.
3789 @item
3790 It has a single discrete discriminant with a default value.
3791 @item
3792 The component list consists of a single variant part.
3793 @item
3794 Each variant has a component list with a single component.
3795 @item
3796 No nested variants are allowed.
3797 @item
3798 No component has an explicit default value.
3799 @item
3800 No component has a non-static constraint.
3801 @end itemize
3802
3803 @noindent
3804 In addition, given a type that meets the above requirements, the
3805 following restrictions apply to its use throughout the program:
3806
3807 @itemize @bullet
3808 @item
3809 The discriminant name can be mentioned only in an aggregate.
3810 @item
3811 No subtypes may be created of this type.
3812 @item
3813 The type may not be constrained by giving a discriminant value.
3814 @item
3815 The type cannot be passed as the actual for a generic formal with a
3816 discriminant.
3817 @end itemize
3818
3819 @noindent
3820 Equality and inequality operations on @code{unchecked_unions} are not
3821 available, since there is no discriminant to compare and the compiler
3822 does not even know how many bits to compare.  It is implementation
3823 dependent whether this is detected at compile time as an illegality or
3824 whether it is undetected and considered to be an erroneous construct.  In
3825 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3826 the composite case (where two composites are compared that contain an
3827 unchecked union component), so such comparisons are simply considered
3828 erroneous.
3829
3830 The layout of the resulting type corresponds exactly to a C union, where
3831 each branch of the union corresponds to a single variant in the Ada
3832 record.  The semantics of the Ada program is not changed in any way by
3833 the pragma, i.e.@: provided the above restrictions are followed, and no
3834 erroneous incorrect references to fields or erroneous comparisons occur,
3835 the semantics is exactly as described by the Ada reference manual.
3836 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3837 type and the default convention is C.
3838
3839 @node Pragma Unimplemented_Unit
3840 @unnumberedsec Pragma Unimplemented_Unit
3841 @findex Unimplemented_Unit
3842 @noindent
3843 Syntax:
3844
3845 @smallexample @c ada
3846 pragma Unimplemented_Unit;
3847 @end smallexample
3848
3849 @noindent
3850 If this pragma occurs in a unit that is processed by the compiler, GNAT
3851 aborts with the message @samp{@var{xxx} not implemented}, where
3852 @var{xxx} is the name of the current compilation unit.  This pragma is
3853 intended to allow the compiler to handle unimplemented library units in
3854 a clean manner.
3855
3856 The abort only happens if code is being generated.  Thus you can use
3857 specs of unimplemented packages in syntax or semantic checking mode.
3858
3859 @node Pragma Universal_Data
3860 @unnumberedsec Pragma Universal_Data
3861 @findex Universal_Data
3862 @noindent
3863 Syntax:
3864
3865 @smallexample @c ada
3866 pragma Universal_Data [(library_unit_Name)];
3867 @end smallexample
3868
3869 @noindent
3870 This pragma is supported only for the AAMP target and is ignored for
3871 other targets. The pragma specifies that all library-level objects
3872 (Counter 0 data) associated with the library unit are to be accessed
3873 and updated using universal addressing (24-bit addresses for AAMP5)
3874 rather than the default of 16-bit Data Environment (DENV) addressing.
3875 Use of this pragma will generally result in less efficient code for
3876 references to global data associated with the library unit, but
3877 allows such data to be located anywhere in memory. This pragma is
3878 a library unit pragma, but can also be used as a configuration pragma
3879 (including use in the @file{gnat.adc} file). The functionality
3880 of this pragma is also available by applying the -univ switch on the
3881 compilations of units where universal addressing of the data is desired.
3882
3883 @node Pragma Unreferenced
3884 @unnumberedsec Pragma Unreferenced
3885 @findex Unreferenced
3886 @cindex Warnings, unreferenced
3887 @noindent
3888 Syntax:
3889
3890 @smallexample @c ada
3891 pragma Unreferenced (local_NAME @{, local_NAME@});
3892 @end smallexample
3893
3894 @noindent
3895 This pragma signals that the entities whose names are listed are
3896 deliberately not referenced in the current source unit. This
3897 suppresses warnings about the
3898 entities being unreferenced, and in addition a warning will be
3899 generated if one of these entities is in fact referenced in the
3900 same unit as the pragma (or in the corresponding body, or one
3901 of its subunits).
3902
3903 This is particularly useful for clearly signaling that a particular
3904 parameter is not referenced in some particular subprogram implementation
3905 and that this is deliberate. It can also be useful in the case of
3906 objects declared only for their initialization or finalization side
3907 effects.
3908
3909 If @code{local_NAME} identifies more than one matching homonym in the
3910 current scope, then the entity most recently declared is the one to which
3911 the pragma applies.
3912
3913 The left hand side of an assignment does not count as a reference for the
3914 purpose of this pragma. Thus it is fine to assign to an entity for which
3915 pragma Unreferenced is given.
3916
3917 @node Pragma Unreserve_All_Interrupts
3918 @unnumberedsec Pragma Unreserve_All_Interrupts
3919 @findex Unreserve_All_Interrupts
3920 @noindent
3921 Syntax:
3922
3923 @smallexample @c ada
3924 pragma Unreserve_All_Interrupts;
3925 @end smallexample
3926
3927 @noindent
3928 Normally certain interrupts are reserved to the implementation.  Any attempt
3929 to attach an interrupt causes Program_Error to be raised, as described in
3930 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3931 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3932 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3933 interrupt execution.
3934
3935 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3936 a program, then all such interrupts are unreserved.  This allows the
3937 program to handle these interrupts, but disables their standard
3938 functions.  For example, if this pragma is used, then pressing
3939 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3940 a program can then handle the @code{SIGINT} interrupt as it chooses.
3941
3942 For a full list of the interrupts handled in a specific implementation,
3943 see the source code for the specification of @code{Ada.Interrupts.Names} in
3944 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3945 list of interrupts recognized for a given target.  The documentation in
3946 this file also specifies what interrupts are affected by the use of
3947 the @code{Unreserve_All_Interrupts} pragma.
3948
3949 For a more general facility for controlling what interrupts can be
3950 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3951 of the @code{Unreserve_All_Interrupts} pragma.
3952
3953 @node Pragma Unsuppress
3954 @unnumberedsec Pragma Unsuppress
3955 @findex Unsuppress
3956 @noindent
3957 Syntax:
3958
3959 @smallexample @c ada
3960 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3961 @end smallexample
3962
3963 @noindent
3964 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3965 there is no corresponding pragma @code{Suppress} in effect, it has no
3966 effect.  The range of the effect is the same as for pragma
3967 @code{Suppress}.  The meaning of the arguments is identical to that used
3968 in pragma @code{Suppress}.
3969
3970 One important application is to ensure that checks are on in cases where
3971 code depends on the checks for its correct functioning, so that the code
3972 will compile correctly even if the compiler switches are set to suppress
3973 checks.
3974
3975 @node Pragma Use_VADS_Size
3976 @unnumberedsec Pragma Use_VADS_Size
3977 @cindex @code{Size}, VADS compatibility
3978 @findex Use_VADS_Size
3979 @noindent
3980 Syntax:
3981
3982 @smallexample @c ada
3983 pragma Use_VADS_Size;
3984 @end smallexample
3985
3986 @noindent
3987 This is a configuration pragma.  In a unit to which it applies, any use
3988 of the 'Size attribute is automatically interpreted as a use of the
3989 'VADS_Size attribute.  Note that this may result in incorrect semantic
3990 processing of valid Ada 95 programs.  This is intended to aid in the
3991 handling of legacy code which depends on the interpretation of Size
3992 as implemented in the VADS compiler.  See description of the VADS_Size
3993 attribute for further details.
3994
3995 @node Pragma Validity_Checks
3996 @unnumberedsec Pragma Validity_Checks
3997 @findex Validity_Checks
3998 @noindent
3999 Syntax:
4000
4001 @smallexample @c ada
4002 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4003 @end smallexample
4004
4005 @noindent
4006 This pragma is used in conjunction with compiler switches to control the
4007 built-in validity checking provided by GNAT@.  The compiler switches, if set
4008 provide an initial setting for the switches, and this pragma may be used
4009 to modify these settings, or the settings may be provided entirely by
4010 the use of the pragma.  This pragma can be used anywhere that a pragma
4011 is legal, including use as a configuration pragma (including use in
4012 the @file{gnat.adc} file).
4013
4014 The form with a string literal specifies which validity options are to be
4015 activated.  The validity checks are first set to include only the default
4016 reference manual settings, and then a string of letters in the string
4017 specifies the exact set of options required.  The form of this string
4018 is exactly as described for the @code{-gnatVx} compiler switch (see the
4019 GNAT users guide for details).  For example the following two methods
4020 can be used to enable validity checking for mode @code{in} and
4021 @code{in out} subprogram parameters:
4022
4023 @itemize @bullet
4024 @item
4025 @smallexample @c ada
4026 pragma Validity_Checks ("im");
4027 @end smallexample
4028
4029 @item
4030 @smallexample
4031 gcc -c -gnatVim @dots{}
4032 @end smallexample
4033 @end itemize
4034
4035 @noindent
4036 The form ALL_CHECKS activates all standard checks (its use is equivalent
4037 to the use of the @code{gnatva} switch.
4038
4039 The forms with @code{Off} and @code{On}
4040 can be used to temporarily disable validity checks
4041 as shown in the following example:
4042
4043 @smallexample @c ada
4044 @iftex
4045 @leftskip=0cm
4046 @end iftex
4047 pragma Validity_Checks ("c"); -- validity checks for copies
4048 pragma Validity_Checks (Off); -- turn off validity checks
4049 A := B;                       -- B will not be validity checked
4050 pragma Validity_Checks (On);  -- turn validity checks back on
4051 A := C;                       -- C will be validity checked
4052 @end smallexample
4053
4054 @node Pragma Volatile
4055 @unnumberedsec Pragma Volatile
4056 @findex Volatile
4057 @noindent
4058 Syntax:
4059
4060 @smallexample @c ada
4061 pragma Volatile (local_NAME);
4062 @end smallexample
4063
4064 @noindent
4065 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4066 implementation is fully conformant with this definition.  The reason it
4067 is mentioned in this section is that a pragma of the same name was supplied
4068 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
4069 of pragma Volatile is upwards compatible with the implementation in
4070 Dec Ada 83.
4071
4072 @node Pragma Warnings
4073 @unnumberedsec Pragma Warnings
4074 @findex Warnings
4075 @noindent
4076 Syntax:
4077
4078 @smallexample @c ada
4079 pragma Warnings (On | Off [, local_NAME]);
4080 @end smallexample
4081
4082 @noindent
4083 Normally warnings are enabled, with the output being controlled by
4084 the command line switch.  Warnings (@code{Off}) turns off generation of
4085 warnings until a Warnings (@code{On}) is encountered or the end of the
4086 current unit.  If generation of warnings is turned off using this
4087 pragma, then no warning messages are output, regardless of the
4088 setting of the command line switches.
4089
4090 The form with a single argument is a configuration pragma.
4091
4092 If the @var{local_NAME} parameter is present, warnings are suppressed for
4093 the specified entity.  This suppression is effective from the point where
4094 it occurs till the end of the extended scope of the variable (similar to
4095 the scope of @code{Suppress}).
4096
4097 @node Pragma Weak_External
4098 @unnumberedsec Pragma Weak_External
4099 @findex Weak_External
4100 @noindent
4101 Syntax:
4102
4103 @smallexample @c ada
4104 pragma Weak_External ([Entity =>] local_NAME);
4105 @end smallexample
4106
4107 @noindent
4108 This pragma specifies that the given entity should be marked as a weak
4109 external (one that does not have to be resolved) for the linker.  For
4110 further details, consult the GCC manual.
4111
4112 @node Implementation Defined Attributes
4113 @chapter Implementation Defined Attributes
4114 Ada 95 defines (throughout the Ada 95 reference manual,
4115 summarized in annex K),
4116 a set of attributes that provide useful additional functionality in all
4117 areas of the language.  These language defined attributes are implemented
4118 in GNAT and work as described in the Ada 95 Reference Manual.
4119
4120 In addition, Ada 95 allows implementations to define additional
4121 attributes whose meaning is defined by the implementation.  GNAT provides
4122 a number of these implementation-dependent attributes which can be used
4123 to extend and enhance the functionality of the compiler.  This section of
4124 the GNAT reference manual describes these additional attributes.
4125
4126 Note that any program using these attributes may not be portable to
4127 other compilers (although GNAT implements this set of attributes on all
4128 platforms).  Therefore if portability to other compilers is an important
4129 consideration, you should minimize the use of these attributes.
4130
4131 @menu
4132 * Abort_Signal::
4133 * Address_Size::
4134 * Asm_Input::
4135 * Asm_Output::
4136 * AST_Entry::
4137 * Bit::
4138 * Bit_Position::
4139 * Code_Address::
4140 * Default_Bit_Order::
4141 * Elaborated::
4142 * Elab_Body::
4143 * Elab_Spec::
4144 * Emax::
4145 * Enum_Rep::
4146 * Epsilon::
4147 * Fixed_Value::
4148 * Has_Access_Values::
4149 * Has_Discriminants::
4150 * Img::
4151 * Integer_Value::
4152 * Large::
4153 * Machine_Size::
4154 * Mantissa::
4155 * Max_Interrupt_Priority::
4156 * Max_Priority::
4157 * Maximum_Alignment::
4158 * Mechanism_Code::
4159 * Null_Parameter::
4160 * Object_Size::
4161 * Passed_By_Reference::
4162 * Range_Length::
4163 * Safe_Emax::
4164 * Safe_Large::
4165 * Small::
4166 * Storage_Unit::
4167 * Target_Name::
4168 * Tick::
4169 * To_Address::
4170 * Type_Class::
4171 * UET_Address::
4172 * Unconstrained_Array::
4173 * Universal_Literal_String::
4174 * Unrestricted_Access::
4175 * VADS_Size::
4176 * Value_Size::
4177 * Wchar_T_Size::
4178 * Word_Size::
4179 @end menu
4180
4181 @node Abort_Signal
4182 @unnumberedsec Abort_Signal
4183 @findex Abort_Signal
4184 @noindent
4185 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4186 prefix) provides the entity for the special exception used to signal
4187 task abort or asynchronous transfer of control.  Normally this attribute
4188 should only be used in the tasking runtime (it is highly peculiar, and
4189 completely outside the normal semantics of Ada, for a user program to
4190 intercept the abort exception).
4191
4192 @node Address_Size
4193 @unnumberedsec Address_Size
4194 @cindex Size of @code{Address}
4195 @findex Address_Size
4196 @noindent
4197 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4198 prefix) is a static constant giving the number of bits in an
4199 @code{Address}. It is the same value as System.Address'Size,
4200 but has the advantage of being static, while a direct
4201 reference to System.Address'Size is non-static because Address
4202 is a private type.
4203
4204 @node Asm_Input
4205 @unnumberedsec Asm_Input
4206 @findex Asm_Input
4207 @noindent
4208 The @code{Asm_Input} attribute denotes a function that takes two
4209 parameters.  The first is a string, the second is an expression of the
4210 type designated by the prefix.  The first (string) argument is required
4211 to be a static expression, and is the constraint for the parameter,
4212 (e.g.@: what kind of register is required).  The second argument is the
4213 value to be used as the input argument.  The possible values for the
4214 constant are the same as those used in the RTL, and are dependent on
4215 the configuration file used to built the GCC back end.
4216 @ref{Machine Code Insertions}
4217
4218 @node Asm_Output
4219 @unnumberedsec Asm_Output
4220 @findex Asm_Output
4221 @noindent
4222 The @code{Asm_Output} attribute denotes a function that takes two
4223 parameters.  The first is a string, the second is the name of a variable
4224 of the type designated by the attribute prefix.  The first (string)
4225 argument is required to be a static expression and designates the
4226 constraint for the parameter (e.g.@: what kind of register is
4227 required).  The second argument is the variable to be updated with the
4228 result.  The possible values for constraint are the same as those used in
4229 the RTL, and are dependent on the configuration file used to build the
4230 GCC back end.  If there are no output operands, then this argument may
4231 either be omitted, or explicitly given as @code{No_Output_Operands}.
4232 @ref{Machine Code Insertions}
4233
4234 @node AST_Entry
4235 @unnumberedsec AST_Entry
4236 @cindex OpenVMS
4237 @findex AST_Entry
4238 @noindent
4239 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4240 the name of an entry, it yields a value of the predefined type AST_Handler
4241 (declared in the predefined package System, as extended by the use of
4242 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4243 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4244 Language Reference Manual}, section 9.12a.
4245
4246 @node Bit
4247 @unnumberedsec Bit
4248 @findex Bit
4249 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4250 offset within the storage unit (byte) that contains the first bit of
4251 storage allocated for the object.  The value of this attribute is of the
4252 type @code{Universal_Integer}, and is always a non-negative number not
4253 exceeding the value of @code{System.Storage_Unit}.
4254
4255 For an object that is a variable or a constant allocated in a register,
4256 the value is zero.  (The use of this attribute does not force the
4257 allocation of a variable to memory).
4258
4259 For an object that is a formal parameter, this attribute applies
4260 to either the matching actual parameter or to a copy of the
4261 matching actual parameter.
4262
4263 For an access object the value is zero.  Note that
4264 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4265 designated object.  Similarly for a record component
4266 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4267 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4268 are subject to index checks.
4269
4270 This attribute is designed to be compatible with the DEC Ada 83 definition
4271 and implementation of the @code{Bit} attribute.
4272
4273 @node Bit_Position
4274 @unnumberedsec Bit_Position
4275 @findex Bit_Position
4276 @noindent
4277 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4278 of the fields of the record type, yields the bit
4279 offset within the record contains the first bit of
4280 storage allocated for the object.  The value of this attribute is of the
4281 type @code{Universal_Integer}.  The value depends only on the field
4282 @var{C} and is independent of the alignment of
4283 the containing record @var{R}.
4284
4285 @node Code_Address
4286 @unnumberedsec Code_Address
4287 @findex Code_Address
4288 @cindex Subprogram address
4289 @cindex Address of subprogram code
4290 @noindent
4291 The @code{'Address}
4292 attribute may be applied to subprograms in Ada 95, but the
4293 intended effect from the Ada 95 reference manual seems to be to provide
4294 an address value which can be used to call the subprogram by means of
4295 an address clause as in the following example:
4296
4297 @smallexample @c ada
4298 procedure K is @dots{}
4299
4300 procedure L;
4301 for L'Address use K'Address;
4302 pragma Import (Ada, L);
4303 @end smallexample
4304
4305 @noindent
4306 A call to @code{L} is then expected to result in a call to @code{K}@.
4307 In Ada 83, where there were no access-to-subprogram values, this was
4308 a common work around for getting the effect of an indirect call.
4309 GNAT implements the above use of @code{Address} and the technique
4310 illustrated by the example code works correctly.
4311
4312 However, for some purposes, it is useful to have the address of the start
4313 of the generated code for the subprogram.  On some architectures, this is
4314 not necessarily the same as the @code{Address} value described above.
4315 For example, the @code{Address} value may reference a subprogram
4316 descriptor rather than the subprogram itself.
4317
4318 The @code{'Code_Address} attribute, which can only be applied to
4319 subprogram entities, always returns the address of the start of the
4320 generated code of the specified subprogram, which may or may not be
4321 the same value as is returned by the corresponding @code{'Address}
4322 attribute.
4323
4324 @node Default_Bit_Order
4325 @unnumberedsec Default_Bit_Order
4326 @cindex Big endian
4327 @cindex Little endian
4328 @findex Default_Bit_Order
4329 @noindent
4330 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4331 permissible prefix), provides the value @code{System.Default_Bit_Order}
4332 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4333 @code{Low_Order_First}).  This is used to construct the definition of
4334 @code{Default_Bit_Order} in package @code{System}.
4335
4336 @node Elaborated
4337 @unnumberedsec Elaborated
4338 @findex Elaborated
4339 @noindent
4340 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4341 value is a Boolean which indicates whether or not the given unit has been
4342 elaborated.  This attribute is primarily intended for internal use by the
4343 generated code for dynamic elaboration checking, but it can also be used
4344 in user programs.  The value will always be True once elaboration of all
4345 units has been completed.  An exception is for units which need no
4346 elaboration, the value is always False for such units.
4347
4348 @node Elab_Body
4349 @unnumberedsec Elab_Body
4350 @findex Elab_Body
4351 @noindent
4352 This attribute can only be applied to a program unit name.  It returns
4353 the entity for the corresponding elaboration procedure for elaborating
4354 the body of the referenced unit.  This is used in the main generated
4355 elaboration procedure by the binder and is not normally used in any
4356 other context.  However, there may be specialized situations in which it
4357 is useful to be able to call this elaboration procedure from Ada code,
4358 e.g.@: if it is necessary to do selective re-elaboration to fix some
4359 error.
4360
4361 @node Elab_Spec
4362 @unnumberedsec Elab_Spec
4363 @findex Elab_Spec
4364 @noindent
4365 This attribute can only be applied to a program unit name.  It returns
4366 the entity for the corresponding elaboration procedure for elaborating
4367 the specification of the referenced unit.  This is used in the main
4368 generated elaboration procedure by the binder and is not normally used
4369 in any other context.  However, there may be specialized situations in
4370 which it is useful to be able to call this elaboration procedure from
4371 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4372 some error.
4373
4374 @node Emax
4375 @unnumberedsec Emax
4376 @cindex Ada 83 attributes
4377 @findex Emax
4378 @noindent
4379 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4380 the Ada 83 reference manual for an exact description of the semantics of
4381 this attribute.
4382
4383 @node Enum_Rep
4384 @unnumberedsec Enum_Rep
4385 @cindex Representation of enums
4386 @findex Enum_Rep
4387 @noindent
4388 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4389 function with the following spec:
4390
4391 @smallexample @c ada
4392 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4393   return @i{Universal_Integer};
4394 @end smallexample
4395
4396 @noindent
4397 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4398 enumeration type or to a non-overloaded enumeration
4399 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4400 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4401 enumeration literal or object.
4402
4403 The function returns the representation value for the given enumeration
4404 value.  This will be equal to value of the @code{Pos} attribute in the
4405 absence of an enumeration representation clause.  This is a static
4406 attribute (i.e.@: the result is static if the argument is static).
4407
4408 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4409 in which case it simply returns the integer value.  The reason for this
4410 is to allow it to be used for @code{(<>)} discrete formal arguments in
4411 a generic unit that can be instantiated with either enumeration types
4412 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4413 type whose upper bound exceeds the upper bound of the largest signed
4414 integer type, and the argument is a variable, so that the universal
4415 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4416 may raise @code{Constraint_Error}.
4417
4418 @node Epsilon
4419 @unnumberedsec Epsilon
4420 @cindex Ada 83 attributes
4421 @findex Epsilon
4422 @noindent
4423 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4424 the Ada 83 reference manual for an exact description of the semantics of
4425 this attribute.
4426
4427 @node Fixed_Value
4428 @unnumberedsec Fixed_Value
4429 @findex Fixed_Value
4430 @noindent
4431 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4432 function with the following specification:
4433
4434 @smallexample @c ada
4435 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4436   return @var{S};
4437 @end smallexample
4438
4439 @noindent
4440 The value returned is the fixed-point value @var{V} such that
4441
4442 @smallexample @c ada
4443 @var{V} = Arg * @var{S}'Small
4444 @end smallexample
4445
4446 @noindent
4447 The effect is thus similar to first converting the argument to the
4448 integer type used to represent @var{S}, and then doing an unchecked
4449 conversion to the fixed-point type.  The difference is
4450 that there are full range checks, to ensure that the result is in range.
4451 This attribute is primarily intended for use in implementation of the
4452 input-output functions for fixed-point values.
4453
4454 @node Has_Access_Values
4455 @unnumberedsec Has_Access_Values
4456 @cindex Access values, testing for
4457 @findex Has_Access_Values
4458 @noindent
4459 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4460 is a Boolean value which is True if the is an access type, or is a composite
4461 type with a component (at any nesting depth) that is an access type, and is
4462 False otherwise.
4463 The intended use of this attribute is in conjunction with generic
4464 definitions.  If the attribute is applied to a generic private type, it
4465 indicates whether or not the corresponding actual type has access values.
4466
4467 @node Has_Discriminants
4468 @unnumberedsec Has_Discriminants
4469 @cindex Discriminants, testing for
4470 @findex Has_Discriminants
4471 @noindent
4472 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4473 is a Boolean value which is True if the type has discriminants, and False
4474 otherwise.  The intended use of this attribute is in conjunction with generic
4475 definitions.  If the attribute is applied to a generic private type, it
4476 indicates whether or not the corresponding actual type has discriminants.
4477
4478 @node Img
4479 @unnumberedsec Img
4480 @findex Img
4481 @noindent
4482 The @code{Img} attribute differs from @code{Image} in that it may be
4483 applied to objects as well as types, in which case it gives the
4484 @code{Image} for the subtype of the object.  This is convenient for
4485 debugging:
4486
4487 @smallexample @c ada
4488 Put_Line ("X = " & X'Img);
4489 @end smallexample
4490
4491 @noindent
4492 has the same meaning as the more verbose:
4493
4494 @smallexample @c ada
4495 Put_Line ("X = " & @var{T}'Image (X));
4496 @end smallexample
4497
4498 @noindent
4499 where @var{T} is the (sub)type of the object @code{X}.
4500
4501 @node Integer_Value
4502 @unnumberedsec Integer_Value
4503 @findex Integer_Value
4504 @noindent
4505 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4506 function with the following spec:
4507
4508 @smallexample @c ada
4509 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4510   return @var{S};
4511 @end smallexample
4512
4513 @noindent
4514 The value returned is the integer value @var{V}, such that
4515
4516 @smallexample @c ada
4517 Arg = @var{V} * @var{T}'Small
4518 @end smallexample
4519
4520 @noindent
4521 where @var{T} is the type of @code{Arg}.
4522 The effect is thus similar to first doing an unchecked conversion from
4523 the fixed-point type to its corresponding implementation type, and then
4524 converting the result to the target integer type.  The difference is
4525 that there are full range checks, to ensure that the result is in range.
4526 This attribute is primarily intended for use in implementation of the
4527 standard input-output functions for fixed-point values.
4528
4529 @node Large
4530 @unnumberedsec Large
4531 @cindex Ada 83 attributes
4532 @findex Large
4533 @noindent
4534 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4535 the Ada 83 reference manual for an exact description of the semantics of
4536 this attribute.
4537
4538 @node Machine_Size
4539 @unnumberedsec Machine_Size
4540 @findex Machine_Size
4541 @noindent
4542 This attribute is identical to the @code{Object_Size} attribute.  It is
4543 provided for compatibility with the DEC Ada 83 attribute of this name.
4544
4545 @node Mantissa
4546 @unnumberedsec Mantissa
4547 @cindex Ada 83 attributes
4548 @findex Mantissa
4549 @noindent
4550 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4551 the Ada 83 reference manual for an exact description of the semantics of
4552 this attribute.
4553
4554 @node Max_Interrupt_Priority
4555 @unnumberedsec Max_Interrupt_Priority
4556 @cindex Interrupt priority, maximum
4557 @findex Max_Interrupt_Priority
4558 @noindent
4559 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4560 permissible prefix), provides the same value as
4561 @code{System.Max_Interrupt_Priority}.
4562
4563 @node Max_Priority
4564 @unnumberedsec Max_Priority
4565 @cindex Priority, maximum
4566 @findex Max_Priority
4567 @noindent
4568 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4569 prefix) provides the same value as @code{System.Max_Priority}.
4570
4571 @node Maximum_Alignment
4572 @unnumberedsec Maximum_Alignment
4573 @cindex Alignment, maximum
4574 @findex Maximum_Alignment
4575 @noindent
4576 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4577 permissible prefix) provides the maximum useful alignment value for the
4578 target.  This is a static value that can be used to specify the alignment
4579 for an object, guaranteeing that it is properly aligned in all
4580 cases.
4581
4582 @node Mechanism_Code
4583 @unnumberedsec Mechanism_Code
4584 @cindex Return values, passing mechanism
4585 @cindex Parameters, passing mechanism
4586 @findex Mechanism_Code
4587 @noindent
4588 @code{@var{function}'Mechanism_Code} yields an integer code for the
4589 mechanism used for the result of function, and
4590 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4591 used for formal parameter number @var{n} (a static integer value with 1
4592 meaning the first parameter) of @var{subprogram}.  The code returned is:
4593
4594 @table @asis
4595 @item 1
4596 by copy (value)
4597 @item 2
4598 by reference
4599 @item 3
4600 by descriptor (default descriptor class)
4601 @item 4
4602 by descriptor (UBS: unaligned bit string)
4603 @item 5
4604 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4605 @item 6
4606 by descriptor (UBA: unaligned bit array)
4607 @item 7
4608 by descriptor (S: string, also scalar access type parameter)
4609 @item 8
4610 by descriptor (SB: string with arbitrary bounds)
4611 @item 9
4612 by descriptor (A: contiguous array)
4613 @item 10
4614 by descriptor (NCA: non-contiguous array)
4615 @end table
4616
4617 @noindent
4618 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4619 @cindex OpenVMS
4620
4621 @node Null_Parameter
4622 @unnumberedsec Null_Parameter
4623 @cindex Zero address, passing
4624 @findex Null_Parameter
4625 @noindent
4626 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4627 type or subtype @var{T} allocated at machine address zero.  The attribute
4628 is allowed only as the default expression of a formal parameter, or as
4629 an actual expression of a subprogram call.  In either case, the
4630 subprogram must be imported.
4631
4632 The identity of the object is represented by the address zero in the
4633 argument list, independent of the passing mechanism (explicit or
4634 default).
4635
4636 This capability is needed to specify that a zero address should be
4637 passed for a record or other composite object passed by reference.
4638 There is no way of indicating this without the @code{Null_Parameter}
4639 attribute.
4640
4641 @node Object_Size
4642 @unnumberedsec Object_Size
4643 @cindex Size, used for objects
4644 @findex Object_Size
4645 @noindent
4646 The size of an object is not necessarily the same as the size of the type
4647 of an object.  This is because by default object sizes are increased to be
4648 a multiple of the alignment of the object.  For example,
4649 @code{Natural'Size} is
4650 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4651 Similarly, a record containing an integer and a character:
4652
4653 @smallexample @c ada
4654 type Rec is record
4655    I : Integer;
4656    C : Character;
4657 end record;
4658 @end smallexample
4659
4660 @noindent
4661 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4662 alignment will be 4, because of the
4663 integer field, and so the default size of record objects for this type
4664 will be 64 (8 bytes).
4665
4666 The @code{@var{type}'Object_Size} attribute
4667 has been added to GNAT to allow the
4668 default object size of a type to be easily determined.  For example,
4669 @code{Natural'Object_Size} is 32, and
4670 @code{Rec'Object_Size} (for the record type in the above example) will be
4671 64.  Note also that, unlike the situation with the
4672 @code{Size} attribute as defined in the Ada RM, the
4673 @code{Object_Size} attribute can be specified individually
4674 for different subtypes.  For example:
4675
4676 @smallexample @c ada
4677 type R is new Integer;
4678 subtype R1 is R range 1 .. 10;
4679 subtype R2 is R range 1 .. 10;
4680 for R2'Object_Size use 8;
4681 @end smallexample
4682
4683 @noindent
4684 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4685 32 since the default object size for a subtype is the same as the object size
4686 for the parent subtype.  This means that objects of type @code{R}
4687 or @code{R1} will
4688 by default be 32 bits (four bytes).  But objects of type
4689 @code{R2} will be only
4690 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4691
4692 @node Passed_By_Reference
4693 @unnumberedsec Passed_By_Reference
4694 @cindex Parameters, when passed by reference
4695 @findex Passed_By_Reference
4696 @noindent
4697 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4698 a value of type @code{Boolean} value that is @code{True} if the type is
4699 normally passed by reference and @code{False} if the type is normally
4700 passed by copy in calls.  For scalar types, the result is always @code{False}
4701 and is static.  For non-scalar types, the result is non-static.
4702
4703 @node Range_Length
4704 @unnumberedsec Range_Length
4705 @findex Range_Length
4706 @noindent
4707 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4708 the number of values represented by the subtype (zero for a null
4709 range).  The result is static for static subtypes.  @code{Range_Length}
4710 applied to the index subtype of a one dimensional array always gives the
4711 same result as @code{Range} applied to the array itself.
4712
4713 @node Safe_Emax
4714 @unnumberedsec Safe_Emax
4715 @cindex Ada 83 attributes
4716 @findex Safe_Emax
4717 @noindent
4718 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4719 the Ada 83 reference manual for an exact description of the semantics of
4720 this attribute.
4721
4722 @node Safe_Large
4723 @unnumberedsec Safe_Large
4724 @cindex Ada 83 attributes
4725 @findex Safe_Large
4726 @noindent
4727 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4728 the Ada 83 reference manual for an exact description of the semantics of
4729 this attribute.
4730
4731 @node Small
4732 @unnumberedsec Small
4733 @cindex Ada 83 attributes
4734 @findex Small
4735 @noindent
4736 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4737 GNAT also allows this attribute to be applied to floating-point types
4738 for compatibility with Ada 83.  See
4739 the Ada 83 reference manual for an exact description of the semantics of
4740 this attribute when applied to floating-point types.
4741
4742 @node Storage_Unit
4743 @unnumberedsec Storage_Unit
4744 @findex Storage_Unit
4745 @noindent
4746 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4747 prefix) provides the same value as @code{System.Storage_Unit}.
4748
4749 @node Target_Name
4750 @unnumberedsec Target_Name
4751 @findex Target_Name
4752 @noindent
4753 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4754 prefix) provides a static string value that identifies the target
4755 for the current compilation. For GCC implementations, this is the
4756 standard gcc target name without the terminating slash (for
4757 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4758
4759 @node Tick
4760 @unnumberedsec Tick
4761 @findex Tick
4762 @noindent
4763 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4764 provides the same value as @code{System.Tick},
4765
4766 @node To_Address
4767 @unnumberedsec To_Address
4768 @findex To_Address
4769 @noindent
4770 The @code{System'To_Address}
4771 (@code{System} is the only permissible prefix)
4772 denotes a function identical to
4773 @code{System.Storage_Elements.To_Address} except that
4774 it is a static attribute.  This means that if its argument is
4775 a static expression, then the result of the attribute is a
4776 static expression.  The result is that such an expression can be
4777 used in contexts (e.g.@: preelaborable packages) which require a
4778 static expression and where the function call could not be used
4779 (since the function call is always non-static, even if its
4780 argument is static).
4781
4782 @node Type_Class
4783 @unnumberedsec Type_Class
4784 @findex Type_Class
4785 @noindent
4786 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4787 the value of the type class for the full type of @var{type}.  If
4788 @var{type} is a generic formal type, the value is the value for the
4789 corresponding actual subtype.  The value of this attribute is of type
4790 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4791
4792 @smallexample @c ada
4793   type Type_Class is
4794     (Type_Class_Enumeration,
4795      Type_Class_Integer,
4796      Type_Class_Fixed_Point,
4797      Type_Class_Floating_Point,
4798      Type_Class_Array,
4799      Type_Class_Record,
4800      Type_Class_Access,
4801      Type_Class_Task,
4802      Type_Class_Address);
4803 @end smallexample
4804
4805 @noindent
4806 Protected types yield the value @code{Type_Class_Task}, which thus
4807 applies to all concurrent types.  This attribute is designed to
4808 be compatible with the DEC Ada 83 attribute of the same name.
4809
4810 @node UET_Address
4811 @unnumberedsec UET_Address
4812 @findex UET_Address
4813 @noindent
4814 The @code{UET_Address} attribute can only be used for a prefix which
4815 denotes a library package.  It yields the address of the unit exception
4816 table when zero cost exception handling is used.  This attribute is
4817 intended only for use within the GNAT implementation.  See the unit
4818 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4819 for details on how this attribute is used in the implementation.
4820
4821 @node Unconstrained_Array
4822 @unnumberedsec Unconstrained_Array
4823 @findex Unconstrained_Array
4824 @noindent
4825 The @code{Unconstrained_Array} attribute can be used with a prefix that
4826 denotes any type or subtype. It is a static attribute that yields
4827 @code{True} if the prefix designates an unconstrained array,
4828 and @code{False} otherwise. In a generic instance, the result is
4829 still static, and yields the result of applying this test to the
4830 generic actual.
4831
4832 @node Universal_Literal_String
4833 @unnumberedsec Universal_Literal_String
4834 @cindex Named numbers, representation of
4835 @findex Universal_Literal_String
4836 @noindent
4837 The prefix of @code{Universal_Literal_String} must be a named
4838 number.  The static result is the string consisting of the characters of
4839 the number as defined in the original source.  This allows the user
4840 program to access the actual text of named numbers without intermediate
4841 conversions and without the need to enclose the strings in quotes (which
4842 would preclude their use as numbers).  This is used internally for the
4843 construction of values of the floating-point attributes from the file
4844 @file{ttypef.ads}, but may also be used by user programs.
4845
4846 @node Unrestricted_Access
4847 @unnumberedsec Unrestricted_Access
4848 @cindex @code{Access}, unrestricted
4849 @findex Unrestricted_Access
4850 @noindent
4851 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4852 except that all accessibility and aliased view checks are omitted.  This
4853 is a user-beware attribute.  It is similar to
4854 @code{Address}, for which it is a desirable replacement where the value
4855 desired is an access type.  In other words, its effect is identical to
4856 first applying the @code{Address} attribute and then doing an unchecked
4857 conversion to a desired access type.  In GNAT, but not necessarily in
4858 other implementations, the use of static chains for inner level
4859 subprograms means that @code{Unrestricted_Access} applied to a
4860 subprogram yields a value that can be called as long as the subprogram
4861 is in scope (normal Ada 95 accessibility rules restrict this usage).
4862
4863 It is possible to use @code{Unrestricted_Access} for any type, but care
4864 must be exercised if it is used to create pointers to unconstrained
4865 objects. In this case, the resulting pointer has the same scope as the
4866 context of the attribute, and may not be returned to some enclosing
4867 scope. For instance, a function cannot use @code{Unrestricted_Access}
4868 to create a unconstrained pointer and then return that value to the
4869 caller.
4870
4871 @node VADS_Size
4872 @unnumberedsec VADS_Size
4873 @cindex @code{Size}, VADS compatibility
4874 @findex VADS_Size
4875 @noindent
4876 The @code{'VADS_Size} attribute is intended to make it easier to port
4877 legacy code which relies on the semantics of @code{'Size} as implemented
4878 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4879 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4880 to a predefined or other primitive type with no Size clause yields the
4881 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4882 typical machines).  In addition @code{'VADS_Size} applied to an object
4883 gives the result that would be obtained by applying the attribute to
4884 the corresponding type.
4885
4886 @node Value_Size
4887 @unnumberedsec Value_Size
4888 @cindex @code{Size}, setting for not-first subtype
4889 @findex Value_Size
4890 @code{@var{type}'Value_Size} is the number of bits required to represent
4891 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4892 but, unlike @code{Size}, may be set for non-first subtypes.
4893
4894 @node Wchar_T_Size
4895 @unnumberedsec Wchar_T_Size
4896 @findex Wchar_T_Size
4897 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4898 prefix) provides the size in bits of the C @code{wchar_t} type
4899 primarily for constructing the definition of this type in
4900 package @code{Interfaces.C}.
4901
4902 @node Word_Size
4903 @unnumberedsec Word_Size
4904 @findex Word_Size
4905 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4906 prefix) provides the value @code{System.Word_Size}.
4907
4908 @c ------------------------
4909 @node Implementation Advice
4910 @chapter Implementation Advice
4911 @noindent
4912 The main text of the Ada 95 Reference Manual describes the required
4913 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4914 these requirements.
4915
4916 In addition, there are sections throughout the Ada 95
4917 reference manual headed
4918 by the phrase ``implementation advice''.  These sections are not normative,
4919 i.e.@: they do not specify requirements that all compilers must
4920 follow.  Rather they provide advice on generally desirable behavior.  You
4921 may wonder why they are not requirements.  The most typical answer is
4922 that they describe behavior that seems generally desirable, but cannot
4923 be provided on all systems, or which may be undesirable on some systems.
4924
4925 As far as practical, GNAT follows the implementation advice sections in
4926 the Ada 95 Reference Manual.  This chapter contains a table giving the
4927 reference manual section number, paragraph number and several keywords
4928 for each advice.  Each entry consists of the text of the advice followed
4929 by the GNAT interpretation of this advice.  Most often, this simply says
4930 ``followed'', which means that GNAT follows the advice.  However, in a
4931 number of cases, GNAT deliberately deviates from this advice, in which
4932 case the text describes what GNAT does and why.
4933
4934 @cindex Error detection
4935 @unnumberedsec 1.1.3(20): Error Detection
4936 @sp 1
4937 @cartouche
4938 If an implementation detects the use of an unsupported Specialized Needs
4939 Annex feature at run time, it should raise @code{Program_Error} if
4940 feasible.
4941 @end cartouche
4942 Not relevant.  All specialized needs annex features are either supported,
4943 or diagnosed at compile time.
4944
4945 @cindex Child Units
4946 @unnumberedsec 1.1.3(31): Child Units
4947 @sp 1
4948 @cartouche
4949 If an implementation wishes to provide implementation-defined
4950 extensions to the functionality of a language-defined library unit, it
4951 should normally do so by adding children to the library unit.
4952 @end cartouche
4953 Followed.
4954
4955 @cindex Bounded errors
4956 @unnumberedsec 1.1.5(12): Bounded Errors
4957 @sp 1
4958 @cartouche
4959 If an implementation detects a bounded error or erroneous
4960 execution, it should raise @code{Program_Error}.
4961 @end cartouche
4962 Followed in all cases in which the implementation detects a bounded
4963 error or erroneous execution.  Not all such situations are detected at
4964 runtime.
4965
4966 @cindex Pragmas
4967 @unnumberedsec 2.8(16): Pragmas
4968 @sp 1
4969 @cartouche
4970 Normally, implementation-defined pragmas should have no semantic effect
4971 for error-free programs; that is, if the implementation-defined pragmas
4972 are removed from a working program, the program should still be legal,
4973 and should still have the same semantics.
4974 @end cartouche
4975 The following implementation defined pragmas are exceptions to this
4976 rule:
4977
4978 @table @code
4979 @item Abort_Defer
4980 Affects semantics
4981 @item Ada_83
4982 Affects legality
4983 @item Assert
4984 Affects semantics
4985 @item CPP_Class
4986 Affects semantics
4987 @item CPP_Constructor
4988 Affects semantics
4989 @item CPP_Virtual
4990 Affects semantics
4991 @item CPP_Vtable
4992 Affects semantics
4993 @item Debug
4994 Affects semantics
4995 @item Interface_Name
4996 Affects semantics
4997 @item Machine_Attribute
4998 Affects semantics
4999 @item Unimplemented_Unit
5000 Affects legality
5001 @item Unchecked_Union
5002 Affects semantics
5003 @end table
5004
5005 @noindent
5006 In each of the above cases, it is essential to the purpose of the pragma
5007 that this advice not be followed.  For details see the separate section
5008 on implementation defined pragmas.
5009
5010 @unnumberedsec 2.8(17-19): Pragmas
5011 @sp 1
5012 @cartouche
5013 Normally, an implementation should not define pragmas that can
5014 make an illegal program legal, except as follows:
5015 @end cartouche
5016 @sp 1
5017 @cartouche
5018 A pragma used to complete a declaration, such as a pragma @code{Import};
5019 @end cartouche
5020 @sp 1
5021 @cartouche
5022 A pragma used to configure the environment by adding, removing, or
5023 replacing @code{library_items}.
5024 @end cartouche
5025 See response to paragraph 16 of this same section.
5026
5027 @cindex Character Sets
5028 @cindex Alternative Character Sets
5029 @unnumberedsec 3.5.2(5): Alternative Character Sets
5030 @sp 1
5031 @cartouche
5032 If an implementation supports a mode with alternative interpretations
5033 for @code{Character} and @code{Wide_Character}, the set of graphic
5034 characters of @code{Character} should nevertheless remain a proper
5035 subset of the set of graphic characters of @code{Wide_Character}.  Any
5036 character set ``localizations'' should be reflected in the results of
5037 the subprograms defined in the language-defined package
5038 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5039 an alternative interpretation of @code{Character}, the implementation should
5040 also support a corresponding change in what is a legal
5041 @code{identifier_letter}.
5042 @end cartouche
5043 Not all wide character modes follow this advice, in particular the JIS
5044 and IEC modes reflect standard usage in Japan, and in these encoding,
5045 the upper half of the Latin-1 set is not part of the wide-character
5046 subset, since the most significant bit is used for wide character
5047 encoding.  However, this only applies to the external forms.  Internally
5048 there is no such restriction.
5049
5050 @cindex Integer types
5051 @unnumberedsec 3.5.4(28): Integer Types
5052
5053 @sp 1
5054 @cartouche
5055 An implementation should support @code{Long_Integer} in addition to
5056 @code{Integer} if the target machine supports 32-bit (or longer)
5057 arithmetic.  No other named integer subtypes are recommended for package
5058 @code{Standard}.  Instead, appropriate named integer subtypes should be
5059 provided in the library package @code{Interfaces} (see B.2).
5060 @end cartouche
5061 @code{Long_Integer} is supported.  Other standard integer types are supported
5062 so this advice is not fully followed.  These types
5063 are supported for convenient interface to C, and so that all hardware
5064 types of the machine are easily available.
5065 @unnumberedsec 3.5.4(29): Integer Types
5066
5067 @sp 1
5068 @cartouche
5069 An implementation for a two's complement machine should support
5070 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5071 implementation should support a non-binary modules up to @code{Integer'Last}.
5072 @end cartouche
5073 Followed.
5074
5075 @cindex Enumeration values
5076 @unnumberedsec 3.5.5(8): Enumeration Values
5077 @sp 1
5078 @cartouche
5079 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5080 subtype, if the value of the operand does not correspond to the internal
5081 code for any enumeration literal of its type (perhaps due to an
5082 un-initialized variable), then the implementation should raise
5083 @code{Program_Error}.  This is particularly important for enumeration
5084 types with noncontiguous internal codes specified by an
5085 enumeration_representation_clause.
5086 @end cartouche
5087 Followed.
5088
5089 @cindex Float types
5090 @unnumberedsec 3.5.7(17): Float Types
5091 @sp 1
5092 @cartouche
5093 An implementation should support @code{Long_Float} in addition to
5094 @code{Float} if the target machine supports 11 or more digits of
5095 precision.  No other named floating point subtypes are recommended for
5096 package @code{Standard}.  Instead, appropriate named floating point subtypes
5097 should be provided in the library package @code{Interfaces} (see B.2).
5098 @end cartouche
5099 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5100 former provides improved compatibility with other implementations
5101 supporting this type.  The latter corresponds to the highest precision
5102 floating-point type supported by the hardware.  On most machines, this
5103 will be the same as @code{Long_Float}, but on some machines, it will
5104 correspond to the IEEE extended form.  The notable case is all ia32
5105 (x86) implementations, where @code{Long_Long_Float} corresponds to
5106 the 80-bit extended precision format supported in hardware on this
5107 processor.  Note that the 128-bit format on SPARC is not supported,
5108 since this is a software rather than a hardware format.
5109
5110 @cindex Multidimensional arrays
5111 @cindex Arrays, multidimensional
5112 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5113 @sp 1
5114 @cartouche
5115 An implementation should normally represent multidimensional arrays in
5116 row-major order, consistent with the notation used for multidimensional
5117 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5118 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5119 column-major order should be used instead (see B.5, ``Interfacing with
5120 Fortran'').
5121 @end cartouche
5122 Followed.
5123
5124 @findex Duration'Small
5125 @unnumberedsec 9.6(30-31): Duration'Small
5126 @sp 1
5127 @cartouche
5128 Whenever possible in an implementation, the value of @code{Duration'Small}
5129 should be no greater than 100 microseconds.
5130 @end cartouche
5131 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5132
5133 @sp 1
5134 @cartouche
5135 The time base for @code{delay_relative_statements} should be monotonic;
5136 it need not be the same time base as used for @code{Calendar.Clock}.
5137 @end cartouche
5138 Followed.
5139
5140 @unnumberedsec 10.2.1(12): Consistent Representation
5141 @sp 1
5142 @cartouche
5143 In an implementation, a type declared in a pre-elaborated package should
5144 have the same representation in every elaboration of a given version of
5145 the package, whether the elaborations occur in distinct executions of
5146 the same program, or in executions of distinct programs or partitions
5147 that include the given version.
5148 @end cartouche
5149 Followed, except in the case of tagged types.  Tagged types involve
5150 implicit pointers to a local copy of a dispatch table, and these pointers
5151 have representations which thus depend on a particular elaboration of the
5152 package.  It is not easy to see how it would be possible to follow this
5153 advice without severely impacting efficiency of execution.
5154
5155 @cindex Exception information
5156 @unnumberedsec 11.4.1(19): Exception Information
5157 @sp 1
5158 @cartouche
5159 @code{Exception_Message} by default and @code{Exception_Information}
5160 should produce information useful for
5161 debugging.  @code{Exception_Message} should be short, about one
5162 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5163 should not include the
5164 @code{Exception_Name}.  @code{Exception_Information} should include both
5165 the @code{Exception_Name} and the @code{Exception_Message}.
5166 @end cartouche
5167 Followed.  For each exception that doesn't have a specified
5168 @code{Exception_Message}, the compiler generates one containing the location
5169 of the raise statement.  This location has the form ``file:line'', where
5170 file is the short file name (without path information) and line is the line
5171 number in the file.  Note that in the case of the Zero Cost Exception
5172 mechanism, these messages become redundant with the Exception_Information that
5173 contains a full backtrace of the calling sequence, so they are disabled.
5174 To disable explicitly the generation of the source location message, use the
5175 Pragma @code{Discard_Names}.
5176
5177 @cindex Suppression of checks
5178 @cindex Checks, suppression of
5179 @unnumberedsec 11.5(28): Suppression of Checks
5180 @sp 1
5181 @cartouche
5182 The implementation should minimize the code executed for checks that
5183 have been suppressed.
5184 @end cartouche
5185 Followed.
5186
5187 @cindex Representation clauses
5188 @unnumberedsec 13.1 (21-24): Representation Clauses
5189 @sp 1
5190 @cartouche
5191 The recommended level of support for all representation items is
5192 qualified as follows:
5193 @end cartouche
5194 @sp 1
5195 @cartouche
5196 An implementation need not support representation items containing
5197 non-static expressions, except that an implementation should support a
5198 representation item for a given entity if each non-static expression in
5199 the representation item is a name that statically denotes a constant
5200 declared before the entity.
5201 @end cartouche
5202 Followed.  In fact, GNAT goes beyond the recommended level of support
5203 by allowing nonstatic expressions in some representation clauses even
5204 without the need to declare constants initialized with the values of
5205 such expressions.
5206 For example:
5207
5208 @smallexample @c ada
5209   X : Integer;
5210   Y : Float;
5211   for Y'Address use X'Address;>>
5212 @end smallexample
5213
5214
5215 @sp 1
5216 @cartouche
5217 An implementation need not support a specification for the @code{Size}
5218 for a given composite subtype, nor the size or storage place for an
5219 object (including a component) of a given composite subtype, unless the
5220 constraints on the subtype and its composite subcomponents (if any) are
5221 all static constraints.
5222 @end cartouche
5223 Followed.  Size Clauses are not permitted on non-static components, as
5224 described above.
5225
5226 @sp 1
5227 @cartouche
5228 An aliased component, or a component whose type is by-reference, should
5229 always be allocated at an addressable location.
5230 @end cartouche
5231 Followed.
5232
5233 @cindex Packed types
5234 @unnumberedsec 13.2(6-8): Packed Types
5235 @sp 1
5236 @cartouche
5237 If a type is packed, then the implementation should try to minimize
5238 storage allocated to objects of the type, possibly at the expense of
5239 speed of accessing components, subject to reasonable complexity in
5240 addressing calculations.
5241 @end cartouche
5242 @sp 1
5243 @cartouche
5244 The recommended level of support pragma @code{Pack} is:
5245
5246 For a packed record type, the components should be packed as tightly as
5247 possible subject to the Sizes of the component subtypes, and subject to
5248 any @code{record_representation_clause} that applies to the type; the
5249 implementation may, but need not, reorder components or cross aligned
5250 word boundaries to improve the packing.  A component whose @code{Size} is
5251 greater than the word size may be allocated an integral number of words.
5252 @end cartouche
5253 Followed.  Tight packing of arrays is supported for all component sizes
5254 up to 64-bits. If the array component size is 1 (that is to say, if
5255 the component is a boolean type or an enumeration type with two values)
5256 then values of the type are implicitly initialized to zero. This
5257 happens both for objects of the packed type, and for objects that have a
5258 subcomponent of the packed type.
5259
5260 @sp 1
5261 @cartouche
5262 An implementation should support Address clauses for imported
5263 subprograms.
5264 @end cartouche
5265 Followed.
5266 @cindex @code{Address} clauses
5267 @unnumberedsec 13.3(14-19): Address Clauses
5268
5269 @sp 1
5270 @cartouche
5271 For an array @var{X}, @code{@var{X}'Address} should point at the first
5272 component of the array, and not at the array bounds.
5273 @end cartouche
5274 Followed.
5275
5276 @sp 1
5277 @cartouche
5278 The recommended level of support for the @code{Address} attribute is:
5279
5280 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5281 object that is aliased or of a by-reference type, or is an entity whose
5282 @code{Address} has been specified.
5283 @end cartouche
5284 Followed.  A valid address will be produced even if none of those
5285 conditions have been met.  If necessary, the object is forced into
5286 memory to ensure the address is valid.
5287
5288 @sp 1
5289 @cartouche
5290 An implementation should support @code{Address} clauses for imported
5291 subprograms.
5292 @end cartouche
5293 Followed.
5294
5295 @sp 1
5296 @cartouche
5297 Objects (including subcomponents) that are aliased or of a by-reference
5298 type should be allocated on storage element boundaries.
5299 @end cartouche
5300 Followed.
5301
5302 @sp 1
5303 @cartouche
5304 If the @code{Address} of an object is specified, or it is imported or exported,
5305 then the implementation should not perform optimizations based on
5306 assumptions of no aliases.
5307 @end cartouche
5308 Followed.
5309
5310 @cindex @code{Alignment} clauses
5311 @unnumberedsec 13.3(29-35): Alignment Clauses
5312 @sp 1
5313 @cartouche
5314 The recommended level of support for the @code{Alignment} attribute for
5315 subtypes is:
5316
5317 An implementation should support specified Alignments that are factors
5318 and multiples of the number of storage elements per word, subject to the
5319 following:
5320 @end cartouche
5321 Followed.
5322
5323 @sp 1
5324 @cartouche
5325 An implementation need not support specified @code{Alignment}s for
5326 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5327 loaded and stored by available machine instructions.
5328 @end cartouche
5329 Followed.
5330
5331 @sp 1
5332 @cartouche
5333 An implementation need not support specified @code{Alignment}s that are
5334 greater than the maximum @code{Alignment} the implementation ever returns by
5335 default.
5336 @end cartouche
5337 Followed.
5338
5339 @sp 1
5340 @cartouche
5341 The recommended level of support for the @code{Alignment} attribute for
5342 objects is:
5343
5344 Same as above, for subtypes, but in addition:
5345 @end cartouche
5346 Followed.
5347
5348 @sp 1
5349 @cartouche
5350 For stand-alone library-level objects of statically constrained
5351 subtypes, the implementation should support all @code{Alignment}s
5352 supported by the target linker.  For example, page alignment is likely to
5353 be supported for such objects, but not for subtypes.
5354 @end cartouche
5355 Followed.
5356
5357 @cindex @code{Size} clauses
5358 @unnumberedsec 13.3(42-43): Size Clauses
5359 @sp 1
5360 @cartouche
5361 The recommended level of support for the @code{Size} attribute of
5362 objects is:
5363
5364 A @code{Size} clause should be supported for an object if the specified
5365 @code{Size} is at least as large as its subtype's @code{Size}, and
5366 corresponds to a size in storage elements that is a multiple of the
5367 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5368 @end cartouche
5369 Followed.
5370
5371 @unnumberedsec 13.3(50-56): Size Clauses
5372 @sp 1
5373 @cartouche
5374 If the @code{Size} of a subtype is specified, and allows for efficient
5375 independent addressability (see 9.10) on the target architecture, then
5376 the @code{Size} of the following objects of the subtype should equal the
5377 @code{Size} of the subtype:
5378
5379 Aliased objects (including components).
5380 @end cartouche
5381 Followed.
5382
5383 @sp 1
5384 @cartouche
5385 @code{Size} clause on a composite subtype should not affect the
5386 internal layout of components.
5387 @end cartouche
5388 Followed.
5389
5390 @sp 1
5391 @cartouche
5392 The recommended level of support for the @code{Size} attribute of subtypes is:
5393 @end cartouche
5394 @sp 1
5395 @cartouche
5396 The @code{Size} (if not specified) of a static discrete or fixed point
5397 subtype should be the number of bits needed to represent each value
5398 belonging to the subtype using an unbiased representation, leaving space
5399 for a sign bit only if the subtype contains negative values.  If such a
5400 subtype is a first subtype, then an implementation should support a
5401 specified @code{Size} for it that reflects this representation.
5402 @end cartouche
5403 Followed.
5404
5405 @sp 1
5406 @cartouche
5407 For a subtype implemented with levels of indirection, the @code{Size}
5408 should include the size of the pointers, but not the size of what they
5409 point at.
5410 @end cartouche
5411 Followed.
5412
5413 @cindex @code{Component_Size} clauses
5414 @unnumberedsec 13.3(71-73): Component Size Clauses
5415 @sp 1
5416 @cartouche
5417 The recommended level of support for the @code{Component_Size}
5418 attribute is:
5419 @end cartouche
5420 @sp 1
5421 @cartouche
5422 An implementation need not support specified @code{Component_Sizes} that are
5423 less than the @code{Size} of the component subtype.
5424 @end cartouche
5425 Followed.
5426
5427 @sp 1
5428 @cartouche
5429 An implementation should support specified @code{Component_Size}s that
5430 are factors and multiples of the word size.  For such
5431 @code{Component_Size}s, the array should contain no gaps between
5432 components.  For other @code{Component_Size}s (if supported), the array
5433 should contain no gaps between components when packing is also
5434 specified; the implementation should forbid this combination in cases
5435 where it cannot support a no-gaps representation.
5436 @end cartouche
5437 Followed.
5438
5439 @cindex Enumeration representation clauses
5440 @cindex Representation clauses, enumeration
5441 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5442 @sp 1
5443 @cartouche
5444 The recommended level of support for enumeration representation clauses
5445 is:
5446
5447 An implementation need not support enumeration representation clauses
5448 for boolean types, but should at minimum support the internal codes in
5449 the range @code{System.Min_Int.System.Max_Int}.
5450 @end cartouche
5451 Followed.
5452
5453 @cindex Record representation clauses
5454 @cindex Representation clauses, records
5455 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5456 @sp 1
5457 @cartouche
5458 The recommended level of support for
5459 @*@code{record_representation_clauses} is:
5460
5461 An implementation should support storage places that can be extracted
5462 with a load, mask, shift sequence of machine code, and set with a load,
5463 shift, mask, store sequence, given the available machine instructions
5464 and run-time model.
5465 @end cartouche
5466 Followed.
5467
5468 @sp 1
5469 @cartouche
5470 A storage place should be supported if its size is equal to the
5471 @code{Size} of the component subtype, and it starts and ends on a
5472 boundary that obeys the @code{Alignment} of the component subtype.
5473 @end cartouche
5474 Followed.
5475
5476 @sp 1
5477 @cartouche
5478 If the default bit ordering applies to the declaration of a given type,
5479 then for a component whose subtype's @code{Size} is less than the word
5480 size, any storage place that does not cross an aligned word boundary
5481 should be supported.
5482 @end cartouche
5483 Followed.
5484
5485 @sp 1
5486 @cartouche
5487 An implementation may reserve a storage place for the tag field of a
5488 tagged type, and disallow other components from overlapping that place.
5489 @end cartouche
5490 Followed.  The storage place for the tag field is the beginning of the tagged
5491 record, and its size is Address'Size.  GNAT will reject an explicit component
5492 clause for the tag field.
5493
5494 @sp 1
5495 @cartouche
5496 An implementation need not support a @code{component_clause} for a
5497 component of an extension part if the storage place is not after the
5498 storage places of all components of the parent type, whether or not
5499 those storage places had been specified.
5500 @end cartouche
5501 Followed.  The above advice on record representation clauses is followed,
5502 and all mentioned features are implemented.
5503
5504 @cindex Storage place attributes
5505 @unnumberedsec 13.5.2(5): Storage Place Attributes
5506 @sp 1
5507 @cartouche
5508 If a component is represented using some form of pointer (such as an
5509 offset) to the actual data of the component, and this data is contiguous
5510 with the rest of the object, then the storage place attributes should
5511 reflect the place of the actual data, not the pointer.  If a component is
5512 allocated discontinuously from the rest of the object, then a warning
5513 should be generated upon reference to one of its storage place
5514 attributes.
5515 @end cartouche
5516 Followed.  There are no such components in GNAT@.
5517
5518 @cindex Bit ordering
5519 @unnumberedsec 13.5.3(7-8): Bit Ordering
5520 @sp 1
5521 @cartouche
5522 The recommended level of support for the non-default bit ordering is:
5523 @end cartouche
5524 @sp 1
5525 @cartouche
5526 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5527 should support the non-default bit ordering in addition to the default
5528 bit ordering.
5529 @end cartouche
5530 Followed.  Word size does not equal storage size in this implementation.
5531 Thus non-default bit ordering is not supported.
5532
5533 @cindex @code{Address}, as private type
5534 @unnumberedsec 13.7(37): Address as Private
5535 @sp 1
5536 @cartouche
5537 @code{Address} should be of a private type.
5538 @end cartouche
5539 Followed.
5540
5541 @cindex Operations, on @code{Address}
5542 @cindex @code{Address}, operations of
5543 @unnumberedsec 13.7.1(16): Address Operations
5544 @sp 1
5545 @cartouche
5546 Operations in @code{System} and its children should reflect the target
5547 environment semantics as closely as is reasonable.  For example, on most
5548 machines, it makes sense for address arithmetic to ``wrap around''.
5549 Operations that do not make sense should raise @code{Program_Error}.
5550 @end cartouche
5551 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5552 operation raises @code{Program_Error}, since all operations make sense.
5553
5554 @cindex Unchecked conversion
5555 @unnumberedsec 13.9(14-17): Unchecked Conversion
5556 @sp 1
5557 @cartouche
5558 The @code{Size} of an array object should not include its bounds; hence,
5559 the bounds should not be part of the converted data.
5560 @end cartouche
5561 Followed.
5562
5563 @sp 1
5564 @cartouche
5565 The implementation should not generate unnecessary run-time checks to
5566 ensure that the representation of @var{S} is a representation of the
5567 target type.  It should take advantage of the permission to return by
5568 reference when possible.  Restrictions on unchecked conversions should be
5569 avoided unless required by the target environment.
5570 @end cartouche
5571 Followed.  There are no restrictions on unchecked conversion.  A warning is
5572 generated if the source and target types do not have the same size since
5573 the semantics in this case may be target dependent.
5574
5575 @sp 1
5576 @cartouche
5577 The recommended level of support for unchecked conversions is:
5578 @end cartouche
5579 @sp 1
5580 @cartouche
5581 Unchecked conversions should be supported and should be reversible in
5582 the cases where this clause defines the result.  To enable meaningful use
5583 of unchecked conversion, a contiguous representation should be used for
5584 elementary subtypes, for statically constrained array subtypes whose
5585 component subtype is one of the subtypes described in this paragraph,
5586 and for record subtypes without discriminants whose component subtypes
5587 are described in this paragraph.
5588 @end cartouche
5589 Followed.
5590
5591 @cindex Heap usage, implicit
5592 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5593 @sp 1
5594 @cartouche
5595 An implementation should document any cases in which it dynamically
5596 allocates heap storage for a purpose other than the evaluation of an
5597 allocator.
5598 @end cartouche
5599 Followed, the only other points at which heap storage is dynamically
5600 allocated are as follows:
5601
5602 @itemize @bullet
5603 @item
5604 At initial elaboration time, to allocate dynamically sized global
5605 objects.
5606
5607 @item
5608 To allocate space for a task when a task is created.
5609
5610 @item
5611 To extend the secondary stack dynamically when needed.  The secondary
5612 stack is used for returning variable length results.
5613 @end itemize
5614
5615 @sp 1
5616 @cartouche
5617 A default (implementation-provided) storage pool for an
5618 access-to-constant type should not have overhead to support deallocation of
5619 individual objects.
5620 @end cartouche
5621 Followed.
5622
5623 @sp 1
5624 @cartouche
5625 A storage pool for an anonymous access type should be created at the
5626 point of an allocator for the type, and be reclaimed when the designated
5627 object becomes inaccessible.
5628 @end cartouche
5629 Followed.
5630
5631 @cindex Unchecked deallocation
5632 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5633 @sp 1
5634 @cartouche
5635 For a standard storage pool, @code{Free} should actually reclaim the
5636 storage.
5637 @end cartouche
5638 Followed.
5639
5640 @cindex Stream oriented attributes
5641 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5642 @sp 1
5643 @cartouche
5644 If a stream element is the same size as a storage element, then the
5645 normal in-memory representation should be used by @code{Read} and
5646 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5647 should use the smallest number of stream elements needed to represent
5648 all values in the base range of the scalar type.
5649 @end cartouche
5650
5651 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5652 which specifies using the size of the first subtype.
5653 However, such an implementation is based on direct binary
5654 representations and is therefore target- and endianness-dependent.
5655 To address this issue, GNAT also supplies an alternate implementation
5656 of the stream attributes @code{Read} and @code{Write},
5657 which uses the target-independent XDR standard representation
5658 for scalar types.
5659 @cindex XDR representation
5660 @cindex @code{Read} attribute
5661 @cindex @code{Write} attribute
5662 @cindex Stream oriented attributes
5663 The XDR implementation is provided as an alternative body of the
5664 @code{System.Stream_Attributes} package, in the file
5665 @file{s-strxdr.adb} in the GNAT library.
5666 There is no @file{s-strxdr.ads} file.
5667 In order to install the XDR implementation, do the following:
5668 @enumerate
5669 @item Replace the default implementation of the
5670 @code{System.Stream_Attributes} package with the XDR implementation.
5671 For example on a Unix platform issue the commands:
5672 @smallexample
5673 $ mv s-stratt.adb s-strold.adb
5674 $ mv s-strxdr.adb s-stratt.adb
5675 @end smallexample
5676
5677 @item
5678 Rebuild the GNAT run-time library as documented in the
5679 @cite{GNAT User's Guide}
5680 @end enumerate
5681
5682 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5683 @sp 1
5684 @cartouche
5685 If an implementation provides additional named predefined integer types,
5686 then the names should end with @samp{Integer} as in
5687 @samp{Long_Integer}.  If an implementation provides additional named
5688 predefined floating point types, then the names should end with
5689 @samp{Float} as in @samp{Long_Float}.
5690 @end cartouche
5691 Followed.
5692
5693 @findex Ada.Characters.Handling
5694 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5695 @sp 1
5696 @cartouche
5697 If an implementation provides a localized definition of @code{Character}
5698 or @code{Wide_Character}, then the effects of the subprograms in
5699 @code{Characters.Handling} should reflect the localizations.  See also
5700 3.5.2.
5701 @end cartouche
5702 Followed.  GNAT provides no such localized definitions.
5703
5704 @cindex Bounded-length strings
5705 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5706 @sp 1
5707 @cartouche
5708 Bounded string objects should not be implemented by implicit pointers
5709 and dynamic allocation.
5710 @end cartouche
5711 Followed.  No implicit pointers or dynamic allocation are used.
5712
5713 @cindex Random number generation
5714 @unnumberedsec A.5.2(46-47): Random Number Generation
5715 @sp 1
5716 @cartouche
5717 Any storage associated with an object of type @code{Generator} should be
5718 reclaimed on exit from the scope of the object.
5719 @end cartouche
5720 Followed.
5721
5722 @sp 1
5723 @cartouche
5724 If the generator period is sufficiently long in relation to the number
5725 of distinct initiator values, then each possible value of
5726 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5727 random numbers that does not, in a practical sense, overlap the sequence
5728 initiated by any other value.  If this is not possible, then the mapping
5729 between initiator values and generator states should be a rapidly
5730 varying function of the initiator value.
5731 @end cartouche
5732 Followed.  The generator period is sufficiently long for the first
5733 condition here to hold true.
5734
5735 @findex Get_Immediate
5736 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5737 @sp 1
5738 @cartouche
5739 The @code{Get_Immediate} procedures should be implemented with
5740 unbuffered input.  For a device such as a keyboard, input should be
5741 @dfn{available} if a key has already been typed, whereas for a disk
5742 file, input should always be available except at end of file.  For a file
5743 associated with a keyboard-like device, any line-editing features of the
5744 underlying operating system should be disabled during the execution of
5745 @code{Get_Immediate}.
5746 @end cartouche
5747 Followed on all targets except VxWorks. For VxWorks, there is no way to
5748 provide this functionality that does not result in the input buffer being
5749 flushed before the @code{Get_Immediate} call. A special unit
5750 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5751 this functionality.
5752
5753 @findex Export
5754 @unnumberedsec B.1(39-41): Pragma @code{Export}
5755 @sp 1
5756 @cartouche
5757 If an implementation supports pragma @code{Export} to a given language,
5758 then it should also allow the main subprogram to be written in that
5759 language.  It should support some mechanism for invoking the elaboration
5760 of the Ada library units included in the system, and for invoking the
5761 finalization of the environment task.  On typical systems, the
5762 recommended mechanism is to provide two subprograms whose link names are
5763 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5764 elaboration code for library units.  @code{adafinal} should contain the
5765 finalization code.  These subprograms should have no effect the second
5766 and subsequent time they are called.
5767 @end cartouche
5768 Followed.
5769
5770 @sp 1
5771 @cartouche
5772 Automatic elaboration of pre-elaborated packages should be
5773 provided when pragma @code{Export} is supported.
5774 @end cartouche
5775 Followed when the main program is in Ada.  If the main program is in a
5776 foreign language, then
5777 @code{adainit} must be called to elaborate pre-elaborated
5778 packages.
5779
5780 @sp 1
5781 @cartouche
5782 For each supported convention @var{L} other than @code{Intrinsic}, an
5783 implementation should support @code{Import} and @code{Export} pragmas
5784 for objects of @var{L}-compatible types and for subprograms, and pragma
5785 @code{Convention} for @var{L}-eligible types and for subprograms,
5786 presuming the other language has corresponding features.  Pragma
5787 @code{Convention} need not be supported for scalar types.
5788 @end cartouche
5789 Followed.
5790
5791 @cindex Package @code{Interfaces}
5792 @findex Interfaces
5793 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5794 @sp 1
5795 @cartouche
5796 For each implementation-defined convention identifier, there should be a
5797 child package of package Interfaces with the corresponding name.  This
5798 package should contain any declarations that would be useful for
5799 interfacing to the language (implementation) represented by the
5800 convention.  Any declarations useful for interfacing to any language on
5801 the given hardware architecture should be provided directly in
5802 @code{Interfaces}.
5803 @end cartouche
5804 Followed.  An additional package not defined
5805 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5806 for interfacing to C++.
5807
5808 @sp 1
5809 @cartouche
5810 An implementation supporting an interface to C, COBOL, or Fortran should
5811 provide the corresponding package or packages described in the following
5812 clauses.
5813 @end cartouche
5814 Followed.  GNAT provides all the packages described in this section.
5815
5816 @cindex C, interfacing with
5817 @unnumberedsec B.3(63-71): Interfacing with C
5818 @sp 1
5819 @cartouche
5820 An implementation should support the following interface correspondences
5821 between Ada and C@.
5822 @end cartouche
5823 Followed.
5824
5825 @sp 1
5826 @cartouche
5827 An Ada procedure corresponds to a void-returning C function.
5828 @end cartouche
5829 Followed.
5830
5831 @sp 1
5832 @cartouche
5833 An Ada function corresponds to a non-void C function.
5834 @end cartouche
5835 Followed.
5836
5837 @sp 1
5838 @cartouche
5839 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5840 function.
5841 @end cartouche
5842 Followed.
5843
5844 @sp 1
5845 @cartouche
5846 An Ada @code{in} parameter of an access-to-object type with designated
5847 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5848 where @var{t} is the C type corresponding to the Ada type @var{T}.
5849 @end cartouche
5850 Followed.
5851
5852 @sp 1
5853 @cartouche
5854 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5855 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5856 argument to a C function, where @var{t} is the C type corresponding to
5857 the Ada type @var{T}.  In the case of an elementary @code{out} or
5858 @code{in out} parameter, a pointer to a temporary copy is used to
5859 preserve by-copy semantics.
5860 @end cartouche
5861 Followed.
5862
5863 @sp 1
5864 @cartouche
5865 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5866 @code{@var{t}*} argument to a C function, where @var{t} is the C
5867 structure corresponding to the Ada type @var{T}.
5868 @end cartouche
5869 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5870 pragma, or Convention, or by explicitly specifying the mechanism for a given
5871 call using an extended import or export pragma.
5872
5873 @sp 1
5874 @cartouche
5875 An Ada parameter of an array type with component type @var{T}, of any
5876 mode, is passed as a @code{@var{t}*} argument to a C function, where
5877 @var{t} is the C type corresponding to the Ada type @var{T}.
5878 @end cartouche
5879 Followed.
5880
5881 @sp 1
5882 @cartouche
5883 An Ada parameter of an access-to-subprogram type is passed as a pointer
5884 to a C function whose prototype corresponds to the designated
5885 subprogram's specification.
5886 @end cartouche
5887 Followed.
5888
5889 @cindex COBOL, interfacing with
5890 @unnumberedsec B.4(95-98): Interfacing with COBOL
5891 @sp 1
5892 @cartouche
5893 An Ada implementation should support the following interface
5894 correspondences between Ada and COBOL@.
5895 @end cartouche
5896 Followed.
5897
5898 @sp 1
5899 @cartouche
5900 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5901 the COBOL type corresponding to @var{T}.
5902 @end cartouche
5903 Followed.
5904
5905 @sp 1
5906 @cartouche
5907 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5908 the corresponding COBOL type.
5909 @end cartouche
5910 Followed.
5911
5912 @sp 1
5913 @cartouche
5914 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5915 COBOL type corresponding to the Ada parameter type; for scalars, a local
5916 copy is used if necessary to ensure by-copy semantics.
5917 @end cartouche
5918 Followed.
5919
5920 @cindex Fortran, interfacing with
5921 @unnumberedsec B.5(22-26): Interfacing with Fortran
5922 @sp 1
5923 @cartouche
5924 An Ada implementation should support the following interface
5925 correspondences between Ada and Fortran:
5926 @end cartouche
5927 Followed.
5928
5929 @sp 1
5930 @cartouche
5931 An Ada procedure corresponds to a Fortran subroutine.
5932 @end cartouche
5933 Followed.
5934
5935 @sp 1
5936 @cartouche
5937 An Ada function corresponds to a Fortran function.
5938 @end cartouche
5939 Followed.
5940
5941 @sp 1
5942 @cartouche
5943 An Ada parameter of an elementary, array, or record type @var{T} is
5944 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5945 the Fortran type corresponding to the Ada type @var{T}, and where the
5946 INTENT attribute of the corresponding dummy argument matches the Ada
5947 formal parameter mode; the Fortran implementation's parameter passing
5948 conventions are used.  For elementary types, a local copy is used if
5949 necessary to ensure by-copy semantics.
5950 @end cartouche
5951 Followed.
5952
5953 @sp 1
5954 @cartouche
5955 An Ada parameter of an access-to-subprogram type is passed as a
5956 reference to a Fortran procedure whose interface corresponds to the
5957 designated subprogram's specification.
5958 @end cartouche
5959 Followed.
5960
5961 @cindex Machine operations
5962 @unnumberedsec C.1(3-5): Access to Machine Operations
5963 @sp 1
5964 @cartouche
5965 The machine code or intrinsic support should allow access to all
5966 operations normally available to assembly language programmers for the
5967 target environment, including privileged instructions, if any.
5968 @end cartouche
5969 Followed.
5970
5971 @sp 1
5972 @cartouche
5973 The interfacing pragmas (see Annex B) should support interface to
5974 assembler; the default assembler should be associated with the
5975 convention identifier @code{Assembler}.
5976 @end cartouche
5977 Followed.
5978
5979 @sp 1
5980 @cartouche
5981 If an entity is exported to assembly language, then the implementation
5982 should allocate it at an addressable location, and should ensure that it
5983 is retained by the linking process, even if not otherwise referenced
5984 from the Ada code.  The implementation should assume that any call to a
5985 machine code or assembler subprogram is allowed to read or update every
5986 object that is specified as exported.
5987 @end cartouche
5988 Followed.
5989
5990 @unnumberedsec C.1(10-16): Access to Machine Operations
5991 @sp 1
5992 @cartouche
5993 The implementation should ensure that little or no overhead is
5994 associated with calling intrinsic and machine-code subprograms.
5995 @end cartouche
5996 Followed for both intrinsics and machine-code subprograms.
5997
5998 @sp 1
5999 @cartouche
6000 It is recommended that intrinsic subprograms be provided for convenient
6001 access to any machine operations that provide special capabilities or
6002 efficiency and that are not otherwise available through the language
6003 constructs.
6004 @end cartouche
6005 Followed.  A full set of machine operation intrinsic subprograms is provided.
6006
6007 @sp 1
6008 @cartouche
6009 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6010 swap, decrement and test, enqueue/dequeue.
6011 @end cartouche
6012 Followed on any target supporting such operations.
6013
6014 @sp 1
6015 @cartouche
6016 Standard numeric functions---e.g.@:, sin, log.
6017 @end cartouche
6018 Followed on any target supporting such operations.
6019
6020 @sp 1
6021 @cartouche
6022 String manipulation operations---e.g.@:, translate and test.
6023 @end cartouche
6024 Followed on any target supporting such operations.
6025
6026 @sp 1
6027 @cartouche
6028 Vector operations---e.g.@:, compare vector against thresholds.
6029 @end cartouche
6030 Followed on any target supporting such operations.
6031
6032 @sp 1
6033 @cartouche
6034 Direct operations on I/O ports.
6035 @end cartouche
6036 Followed on any target supporting such operations.
6037
6038 @cindex Interrupt support
6039 @unnumberedsec C.3(28): Interrupt Support
6040 @sp 1
6041 @cartouche
6042 If the @code{Ceiling_Locking} policy is not in effect, the
6043 implementation should provide means for the application to specify which
6044 interrupts are to be blocked during protected actions, if the underlying
6045 system allows for a finer-grain control of interrupt blocking.
6046 @end cartouche
6047 Followed.  The underlying system does not allow for finer-grain control
6048 of interrupt blocking.
6049
6050 @cindex Protected procedure handlers
6051 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6052 @sp 1
6053 @cartouche
6054 Whenever possible, the implementation should allow interrupt handlers to
6055 be called directly by the hardware.
6056 @end cartouche
6057 @c SGI info:
6058 @ignore
6059 This is never possible under IRIX, so this is followed by default.
6060 @end ignore
6061 Followed on any target where the underlying operating system permits
6062 such direct calls.
6063
6064 @sp 1
6065 @cartouche
6066 Whenever practical, violations of any
6067 implementation-defined restrictions should be detected before run time.
6068 @end cartouche
6069 Followed.  Compile time warnings are given when possible.
6070
6071 @cindex Package @code{Interrupts}
6072 @findex Interrupts
6073 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6074
6075 @sp 1
6076 @cartouche
6077 If implementation-defined forms of interrupt handler procedures are
6078 supported, such as protected procedures with parameters, then for each
6079 such form of a handler, a type analogous to @code{Parameterless_Handler}
6080 should be specified in a child package of @code{Interrupts}, with the
6081 same operations as in the predefined package Interrupts.
6082 @end cartouche
6083 Followed.
6084
6085 @cindex Pre-elaboration requirements
6086 @unnumberedsec C.4(14): Pre-elaboration Requirements
6087 @sp 1
6088 @cartouche
6089 It is recommended that pre-elaborated packages be implemented in such a
6090 way that there should be little or no code executed at run time for the
6091 elaboration of entities not already covered by the Implementation
6092 Requirements.
6093 @end cartouche
6094 Followed.  Executable code is generated in some cases, e.g.@: loops
6095 to initialize large arrays.
6096
6097 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6098
6099 @sp 1
6100 @cartouche
6101 If the pragma applies to an entity, then the implementation should
6102 reduce the amount of storage used for storing names associated with that
6103 entity.
6104 @end cartouche
6105 Followed.
6106
6107 @cindex Package @code{Task_Attributes}
6108 @findex Task_Attributes
6109 @unnumberedsec C.7.2(30): The Package Task_Attributes
6110 @sp 1
6111 @cartouche
6112 Some implementations are targeted to domains in which memory use at run
6113 time must be completely deterministic.  For such implementations, it is
6114 recommended that the storage for task attributes will be pre-allocated
6115 statically and not from the heap.  This can be accomplished by either
6116 placing restrictions on the number and the size of the task's
6117 attributes, or by using the pre-allocated storage for the first @var{N}
6118 attribute objects, and the heap for the others.  In the latter case,
6119 @var{N} should be documented.
6120 @end cartouche
6121 Not followed.  This implementation is not targeted to such a domain.
6122
6123 @cindex Locking Policies
6124 @unnumberedsec D.3(17): Locking Policies
6125
6126 @sp 1
6127 @cartouche
6128 The implementation should use names that end with @samp{_Locking} for
6129 locking policies defined by the implementation.
6130 @end cartouche
6131 Followed.  A single implementation-defined locking policy is defined,
6132 whose name (@code{Inheritance_Locking}) follows this suggestion.
6133
6134 @cindex Entry queuing policies
6135 @unnumberedsec D.4(16): Entry Queuing Policies
6136 @sp 1
6137 @cartouche
6138 Names that end with @samp{_Queuing} should be used
6139 for all implementation-defined queuing policies.
6140 @end cartouche
6141 Followed.  No such implementation-defined queuing policies exist.
6142
6143 @cindex Preemptive abort
6144 @unnumberedsec D.6(9-10): Preemptive Abort
6145 @sp 1
6146 @cartouche
6147 Even though the @code{abort_statement} is included in the list of
6148 potentially blocking operations (see 9.5.1), it is recommended that this
6149 statement be implemented in a way that never requires the task executing
6150 the @code{abort_statement} to block.
6151 @end cartouche
6152 Followed.
6153
6154 @sp 1
6155 @cartouche
6156 On a multi-processor, the delay associated with aborting a task on
6157 another processor should be bounded; the implementation should use
6158 periodic polling, if necessary, to achieve this.
6159 @end cartouche
6160 Followed.
6161
6162 @cindex Tasking restrictions
6163 @unnumberedsec D.7(21): Tasking Restrictions
6164 @sp 1
6165 @cartouche
6166 When feasible, the implementation should take advantage of the specified
6167 restrictions to produce a more efficient implementation.
6168 @end cartouche
6169 GNAT currently takes advantage of these restrictions by providing an optimized
6170 run time when the Ravenscar profile and the GNAT restricted run time set
6171 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6172 pragma @code{Profile (Restricted)} for more details.
6173
6174 @cindex Time, monotonic
6175 @unnumberedsec D.8(47-49): Monotonic Time
6176 @sp 1
6177 @cartouche
6178 When appropriate, implementations should provide configuration
6179 mechanisms to change the value of @code{Tick}.
6180 @end cartouche
6181 Such configuration mechanisms are not appropriate to this implementation
6182 and are thus not supported.
6183
6184 @sp 1
6185 @cartouche
6186 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6187 be implemented as transformations of the same time base.
6188 @end cartouche
6189 Followed.
6190
6191 @sp 1
6192 @cartouche
6193 It is recommended that the @dfn{best} time base which exists in
6194 the underlying system be available to the application through
6195 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6196 @end cartouche
6197 Followed.
6198
6199 @cindex Partition communication subsystem
6200 @cindex PCS
6201 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6202 @sp 1
6203 @cartouche
6204 Whenever possible, the PCS on the called partition should allow for
6205 multiple tasks to call the RPC-receiver with different messages and
6206 should allow them to block until the corresponding subprogram body
6207 returns.
6208 @end cartouche
6209 Followed by GLADE, a separately supplied PCS that can be used with
6210 GNAT.
6211
6212 @sp 1
6213 @cartouche
6214 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6215 should raise @code{Storage_Error} if it runs out of space trying to
6216 write the @code{Item} into the stream.
6217 @end cartouche
6218 Followed by GLADE, a separately supplied PCS that can be used with
6219 GNAT@.
6220
6221 @cindex COBOL support
6222 @unnumberedsec F(7): COBOL Support
6223 @sp 1
6224 @cartouche
6225 If COBOL (respectively, C) is widely supported in the target
6226 environment, implementations supporting the Information Systems Annex
6227 should provide the child package @code{Interfaces.COBOL} (respectively,
6228 @code{Interfaces.C}) specified in Annex B and should support a
6229 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6230 pragmas (see Annex B), thus allowing Ada programs to interface with
6231 programs written in that language.
6232 @end cartouche
6233 Followed.
6234
6235 @cindex Decimal radix support
6236 @unnumberedsec F.1(2): Decimal Radix Support
6237 @sp 1
6238 @cartouche
6239 Packed decimal should be used as the internal representation for objects
6240 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6241 @end cartouche
6242 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6243 representations.
6244
6245 @cindex Numerics
6246 @unnumberedsec G: Numerics
6247 @sp 2
6248 @cartouche
6249 If Fortran (respectively, C) is widely supported in the target
6250 environment, implementations supporting the Numerics Annex
6251 should provide the child package @code{Interfaces.Fortran} (respectively,
6252 @code{Interfaces.C}) specified in Annex B and should support a
6253 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6254 pragmas (see Annex B), thus allowing Ada programs to interface with
6255 programs written in that language.
6256 @end cartouche
6257 Followed.
6258
6259 @cindex Complex types
6260 @unnumberedsec G.1.1(56-58): Complex Types
6261 @sp 2
6262 @cartouche
6263 Because the usual mathematical meaning of multiplication of a complex
6264 operand and a real operand is that of the scaling of both components of
6265 the former by the latter, an implementation should not perform this
6266 operation by first promoting the real operand to complex type and then
6267 performing a full complex multiplication.  In systems that, in the
6268 future, support an Ada binding to IEC 559:1989, the latter technique
6269 will not generate the required result when one of the components of the
6270 complex operand is infinite.  (Explicit multiplication of the infinite
6271 component by the zero component obtained during promotion yields a NaN
6272 that propagates into the final result.) Analogous advice applies in the
6273 case of multiplication of a complex operand and a pure-imaginary
6274 operand, and in the case of division of a complex operand by a real or
6275 pure-imaginary operand.
6276 @end cartouche
6277 Not followed.
6278
6279 @sp 1
6280 @cartouche
6281 Similarly, because the usual mathematical meaning of addition of a
6282 complex operand and a real operand is that the imaginary operand remains
6283 unchanged, an implementation should not perform this operation by first
6284 promoting the real operand to complex type and then performing a full
6285 complex addition.  In implementations in which the @code{Signed_Zeros}
6286 attribute of the component type is @code{True} (and which therefore
6287 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6288 predefined arithmetic operations), the latter technique will not
6289 generate the required result when the imaginary component of the complex
6290 operand is a negatively signed zero.  (Explicit addition of the negative
6291 zero to the zero obtained during promotion yields a positive zero.)
6292 Analogous advice applies in the case of addition of a complex operand
6293 and a pure-imaginary operand, and in the case of subtraction of a
6294 complex operand and a real or pure-imaginary operand.
6295 @end cartouche
6296 Not followed.
6297
6298 @sp 1
6299 @cartouche
6300 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6301 attempt to provide a rational treatment of the signs of zero results and
6302 result components.  As one example, the result of the @code{Argument}
6303 function should have the sign of the imaginary component of the
6304 parameter @code{X} when the point represented by that parameter lies on
6305 the positive real axis; as another, the sign of the imaginary component
6306 of the @code{Compose_From_Polar} function should be the same as
6307 (respectively, the opposite of) that of the @code{Argument} parameter when that
6308 parameter has a value of zero and the @code{Modulus} parameter has a
6309 nonnegative (respectively, negative) value.
6310 @end cartouche
6311 Followed.
6312
6313 @cindex Complex elementary functions
6314 @unnumberedsec G.1.2(49): Complex Elementary Functions
6315 @sp 1
6316 @cartouche
6317 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6318 @code{True} should attempt to provide a rational treatment of the signs
6319 of zero results and result components.  For example, many of the complex
6320 elementary functions have components that are odd functions of one of
6321 the parameter components; in these cases, the result component should
6322 have the sign of the parameter component at the origin.  Other complex
6323 elementary functions have zero components whose sign is opposite that of
6324 a parameter component at the origin, or is always positive or always
6325 negative.
6326 @end cartouche
6327 Followed.
6328
6329 @cindex Accuracy requirements
6330 @unnumberedsec G.2.4(19): Accuracy Requirements
6331 @sp 1
6332 @cartouche
6333 The versions of the forward trigonometric functions without a
6334 @code{Cycle} parameter should not be implemented by calling the
6335 corresponding version with a @code{Cycle} parameter of
6336 @code{2.0*Numerics.Pi}, since this will not provide the required
6337 accuracy in some portions of the domain.  For the same reason, the
6338 version of @code{Log} without a @code{Base} parameter should not be
6339 implemented by calling the corresponding version with a @code{Base}
6340 parameter of @code{Numerics.e}.
6341 @end cartouche
6342 Followed.
6343
6344 @cindex Complex arithmetic accuracy
6345 @cindex Accuracy, complex arithmetic
6346 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6347
6348 @sp 1
6349 @cartouche
6350 The version of the @code{Compose_From_Polar} function without a
6351 @code{Cycle} parameter should not be implemented by calling the
6352 corresponding version with a @code{Cycle} parameter of
6353 @code{2.0*Numerics.Pi}, since this will not provide the required
6354 accuracy in some portions of the domain.
6355 @end cartouche
6356 Followed.
6357
6358 @c -----------------------------------------
6359 @node Implementation Defined Characteristics
6360 @chapter Implementation Defined Characteristics
6361
6362 @noindent
6363 In addition to the implementation dependent pragmas and attributes, and
6364 the implementation advice, there are a number of other features of Ada
6365 95 that are potentially implementation dependent.  These are mentioned
6366 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6367
6368 A requirement for conforming Ada compilers is that they provide
6369 documentation describing how the implementation deals with each of these
6370 issues.  In this chapter, you will find each point in annex M listed
6371 followed by a description in italic font of how GNAT
6372 @c SGI info:
6373 @ignore
6374 in the ProDev Ada
6375 implementation on IRIX 5.3 operating system or greater
6376 @end ignore
6377 handles the implementation dependence.
6378
6379 You can use this chapter as a guide to minimizing implementation
6380 dependent features in your programs if portability to other compilers
6381 and other operating systems is an important consideration.  The numbers
6382 in each section below correspond to the paragraph number in the Ada 95
6383 Reference Manual.
6384
6385 @sp 1
6386 @cartouche
6387 @noindent
6388 @strong{2}.  Whether or not each recommendation given in Implementation
6389 Advice is followed.  See 1.1.2(37).
6390 @end cartouche
6391 @noindent
6392 @xref{Implementation Advice}.
6393
6394 @sp 1
6395 @cartouche
6396 @noindent
6397 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6398 @end cartouche
6399 @noindent
6400 The complexity of programs that can be processed is limited only by the
6401 total amount of available virtual memory, and disk space for the
6402 generated object files.
6403
6404 @sp 1
6405 @cartouche
6406 @noindent
6407 @strong{4}.  Variations from the standard that are impractical to avoid
6408 given the implementation's execution environment.  See 1.1.3(6).
6409 @end cartouche
6410 @noindent
6411 There are no variations from the standard.
6412
6413 @sp 1
6414 @cartouche
6415 @noindent
6416 @strong{5}.  Which @code{code_statement}s cause external
6417 interactions.  See 1.1.3(10).
6418 @end cartouche
6419 @noindent
6420 Any @code{code_statement} can potentially cause external interactions.
6421
6422 @sp 1
6423 @cartouche
6424 @noindent
6425 @strong{6}.  The coded representation for the text of an Ada
6426 program.  See 2.1(4).
6427 @end cartouche
6428 @noindent
6429 See separate section on source representation.
6430
6431 @sp 1
6432 @cartouche
6433 @noindent
6434 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6435 @end cartouche
6436 @noindent
6437 See separate section on source representation.
6438
6439 @sp 1
6440 @cartouche
6441 @noindent
6442 @strong{8}.  The representation for an end of line.  See 2.2(2).
6443 @end cartouche
6444 @noindent
6445 See separate section on source representation.
6446
6447 @sp 1
6448 @cartouche
6449 @noindent
6450 @strong{9}.  Maximum supported line length and lexical element
6451 length.  See 2.2(15).
6452 @end cartouche
6453 @noindent
6454 The maximum line length is 255 characters an the maximum length of a
6455 lexical element is also 255 characters.
6456
6457 @sp 1
6458 @cartouche
6459 @noindent
6460 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6461 @end cartouche
6462 @noindent
6463
6464 @xref{Implementation Defined Pragmas}.
6465
6466 @sp 1
6467 @cartouche
6468 @noindent
6469 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6470 @end cartouche
6471 @noindent
6472 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6473 parameter, checks that the optimization flag is set, and aborts if it is
6474 not.
6475
6476 @sp 1
6477 @cartouche
6478 @noindent
6479 @strong{12}.  The sequence of characters of the value returned by
6480 @code{@var{S}'Image} when some of the graphic characters of
6481 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6482 3.5(37).
6483 @end cartouche
6484 @noindent
6485 The sequence of characters is as defined by the wide character encoding
6486 method used for the source.  See section on source representation for
6487 further details.
6488
6489 @sp 1
6490 @cartouche
6491 @noindent
6492 @strong{13}.  The predefined integer types declared in
6493 @code{Standard}.  See 3.5.4(25).
6494 @end cartouche
6495 @noindent
6496 @table @code
6497 @item Short_Short_Integer
6498 8 bit signed
6499 @item Short_Integer
6500 (Short) 16 bit signed
6501 @item Integer
6502 32 bit signed
6503 @item Long_Integer
6504 64 bit signed (Alpha OpenVMS only)
6505 32 bit signed (all other targets)
6506 @item Long_Long_Integer
6507 64 bit signed
6508 @end table
6509
6510 @sp 1
6511 @cartouche
6512 @noindent
6513 @strong{14}.  Any nonstandard integer types and the operators defined
6514 for them.  See 3.5.4(26).
6515 @end cartouche
6516 @noindent
6517 There are no nonstandard integer types.
6518
6519 @sp 1
6520 @cartouche
6521 @noindent
6522 @strong{15}.  Any nonstandard real types and the operators defined for
6523 them.  See 3.5.6(8).
6524 @end cartouche
6525 @noindent
6526 There are no nonstandard real types.
6527
6528 @sp 1
6529 @cartouche
6530 @noindent
6531 @strong{16}.  What combinations of requested decimal precision and range
6532 are supported for floating point types.  See 3.5.7(7).
6533 @end cartouche
6534 @noindent
6535 The precision and range is as defined by the IEEE standard.
6536
6537 @sp 1
6538 @cartouche
6539 @noindent
6540 @strong{17}.  The predefined floating point types declared in
6541 @code{Standard}.  See 3.5.7(16).
6542 @end cartouche
6543 @noindent
6544 @table @code
6545 @item Short_Float
6546 32 bit IEEE short
6547 @item Float
6548 (Short) 32 bit IEEE short
6549 @item Long_Float
6550 64 bit IEEE long
6551 @item Long_Long_Float
6552 64 bit IEEE long (80 bit IEEE long on x86 processors)
6553 @end table
6554
6555 @sp 1
6556 @cartouche
6557 @noindent
6558 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6559 @end cartouche
6560 @noindent
6561 @code{Fine_Delta} is 2**(@minus{}63)
6562
6563 @sp 1
6564 @cartouche
6565 @noindent
6566 @strong{19}.  What combinations of small, range, and digits are
6567 supported for fixed point types.  See 3.5.9(10).
6568 @end cartouche
6569 @noindent
6570 Any combinations are permitted that do not result in a small less than
6571 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6572 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6573 is 64 bits (true of all architectures except ia32), then the output from
6574 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6575 is because floating-point conversions are used to convert fixed point.
6576
6577 @sp 1
6578 @cartouche
6579 @noindent
6580 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6581 within an unnamed @code{block_statement}.  See 3.9(10).
6582 @end cartouche
6583 @noindent
6584 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6585 decimal integer are allocated.
6586
6587 @sp 1
6588 @cartouche
6589 @noindent
6590 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6591 @end cartouche
6592 @noindent
6593 @xref{Implementation Defined Attributes}.
6594
6595 @sp 1
6596 @cartouche
6597 @noindent
6598 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6599 @end cartouche
6600 @noindent
6601 There are no implementation-defined time types.
6602
6603 @sp 1
6604 @cartouche
6605 @noindent
6606 @strong{23}.  The time base associated with relative delays.
6607 @end cartouche
6608 @noindent
6609 See 9.6(20).  The time base used is that provided by the C library
6610 function @code{gettimeofday}.
6611
6612 @sp 1
6613 @cartouche
6614 @noindent
6615 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6616 9.6(23).
6617 @end cartouche
6618 @noindent
6619 The time base used is that provided by the C library function
6620 @code{gettimeofday}.
6621
6622 @sp 1
6623 @cartouche
6624 @noindent
6625 @strong{25}.  The time zone used for package @code{Calendar}
6626 operations.  See 9.6(24).
6627 @end cartouche
6628 @noindent
6629 The time zone used by package @code{Calendar} is the current system time zone
6630 setting for local time, as accessed by the C library function
6631 @code{localtime}.
6632
6633 @sp 1
6634 @cartouche
6635 @noindent
6636 @strong{26}.  Any limit on @code{delay_until_statements} of
6637 @code{select_statements}.  See 9.6(29).
6638 @end cartouche
6639 @noindent
6640 There are no such limits.
6641
6642 @sp 1
6643 @cartouche
6644 @noindent
6645 @strong{27}.  Whether or not two non overlapping parts of a composite
6646 object are independently addressable, in the case where packing, record
6647 layout, or @code{Component_Size} is specified for the object.  See
6648 9.10(1).
6649 @end cartouche
6650 @noindent
6651 Separate components are independently addressable if they do not share
6652 overlapping storage units.
6653
6654 @sp 1
6655 @cartouche
6656 @noindent
6657 @strong{28}.  The representation for a compilation.  See 10.1(2).
6658 @end cartouche
6659 @noindent
6660 A compilation is represented by a sequence of files presented to the
6661 compiler in a single invocation of the @code{gcc} command.
6662
6663 @sp 1
6664 @cartouche
6665 @noindent
6666 @strong{29}.  Any restrictions on compilations that contain multiple
6667 compilation_units.  See 10.1(4).
6668 @end cartouche
6669 @noindent
6670 No single file can contain more than one compilation unit, but any
6671 sequence of files can be presented to the compiler as a single
6672 compilation.
6673
6674 @sp 1
6675 @cartouche
6676 @noindent
6677 @strong{30}.  The mechanisms for creating an environment and for adding
6678 and replacing compilation units.  See 10.1.4(3).
6679 @end cartouche
6680 @noindent
6681 See separate section on compilation model.
6682
6683 @sp 1
6684 @cartouche
6685 @noindent
6686 @strong{31}.  The manner of explicitly assigning library units to a
6687 partition.  See 10.2(2).
6688 @end cartouche
6689 @noindent
6690 If a unit contains an Ada main program, then the Ada units for the partition
6691 are determined by recursive application of the rules in the Ada Reference
6692 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6693 are needed by the main program, and then this definition of need is applied
6694 recursively to those units, and the partition contains the transitive
6695 closure determined by this relationship.  In short, all the necessary units
6696 are included, with no need to explicitly specify the list.  If additional
6697 units are required, e.g.@: by foreign language units, then all units must be
6698 mentioned in the context clause of one of the needed Ada units.
6699
6700 If the partition contains no main program, or if the main program is in
6701 a language other than Ada, then GNAT
6702 provides the binder options @code{-z} and @code{-n} respectively, and in
6703 this case a list of units can be explicitly supplied to the binder for
6704 inclusion in the partition (all units needed by these units will also
6705 be included automatically).  For full details on the use of these
6706 options, refer to the @cite{GNAT User's Guide} sections on Binding
6707 and Linking.
6708
6709 @sp 1
6710 @cartouche
6711 @noindent
6712 @strong{32}.  The implementation-defined means, if any, of specifying
6713 which compilation units are needed by a given compilation unit.  See
6714 10.2(2).
6715 @end cartouche
6716 @noindent
6717 The units needed by a given compilation unit are as defined in
6718 the Ada Reference Manual section 10.2(2-6).  There are no
6719 implementation-defined pragmas or other implementation-defined
6720 means for specifying needed units.
6721
6722 @sp 1
6723 @cartouche
6724 @noindent
6725 @strong{33}.  The manner of designating the main subprogram of a
6726 partition.  See 10.2(7).
6727 @end cartouche
6728 @noindent
6729 The main program is designated by providing the name of the
6730 corresponding @file{ALI} file as the input parameter to the binder.
6731
6732 @sp 1
6733 @cartouche
6734 @noindent
6735 @strong{34}.  The order of elaboration of @code{library_items}.  See
6736 10.2(18).
6737 @end cartouche
6738 @noindent
6739 The first constraint on ordering is that it meets the requirements of
6740 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6741 implementation dependent choices, which are resolved by first
6742 elaborating bodies as early as possible (i.e.@: in preference to specs
6743 where there is a choice), and second by evaluating the immediate with
6744 clauses of a unit to determine the probably best choice, and
6745 third by elaborating in alphabetical order of unit names
6746 where a choice still remains.
6747
6748 @sp 1
6749 @cartouche
6750 @noindent
6751 @strong{35}.  Parameter passing and function return for the main
6752 subprogram.  See 10.2(21).
6753 @end cartouche
6754 @noindent
6755 The main program has no parameters.  It may be a procedure, or a function
6756 returning an integer type.  In the latter case, the returned integer
6757 value is the return code of the program (overriding any value that
6758 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6759
6760 @sp 1
6761 @cartouche
6762 @noindent
6763 @strong{36}.  The mechanisms for building and running partitions.  See
6764 10.2(24).
6765 @end cartouche
6766 @noindent
6767 GNAT itself supports programs with only a single partition.  The GNATDIST
6768 tool provided with the GLADE package (which also includes an implementation
6769 of the PCS) provides a completely flexible method for building and running
6770 programs consisting of multiple partitions.  See the separate GLADE manual
6771 for details.
6772
6773 @sp 1
6774 @cartouche
6775 @noindent
6776 @strong{37}.  The details of program execution, including program
6777 termination.  See 10.2(25).
6778 @end cartouche
6779 @noindent
6780 See separate section on compilation model.
6781
6782 @sp 1
6783 @cartouche
6784 @noindent
6785 @strong{38}.  The semantics of any non-active partitions supported by the
6786 implementation.  See 10.2(28).
6787 @end cartouche
6788 @noindent
6789 Passive partitions are supported on targets where shared memory is
6790 provided by the operating system.  See the GLADE reference manual for
6791 further details.
6792
6793 @sp 1
6794 @cartouche
6795 @noindent
6796 @strong{39}.  The information returned by @code{Exception_Message}.  See
6797 11.4.1(10).
6798 @end cartouche
6799 @noindent
6800 Exception message returns the null string unless a specific message has
6801 been passed by the program.
6802
6803 @sp 1
6804 @cartouche
6805 @noindent
6806 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6807 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6808 @end cartouche
6809 @noindent
6810 Blocks have implementation defined names of the form @code{B@var{nnn}}
6811 where @var{nnn} is an integer.
6812
6813 @sp 1
6814 @cartouche
6815 @noindent
6816 @strong{41}.  The information returned by
6817 @code{Exception_Information}.  See 11.4.1(13).
6818 @end cartouche
6819 @noindent
6820 @code{Exception_Information} returns a string in the following format:
6821
6822 @smallexample
6823 @emph{Exception_Name:} nnnnn
6824 @emph{Message:} mmmmm
6825 @emph{PID:} ppp
6826 @emph{Call stack traceback locations:}
6827 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6828 @end smallexample
6829
6830 @noindent
6831 where
6832
6833 @itemize @bullet
6834 @item
6835 @code{nnnn} is the fully qualified name of the exception in all upper
6836 case letters. This line is always present.
6837
6838 @item
6839 @code{mmmm} is the message (this line present only if message is non-null)
6840
6841 @item
6842 @code{ppp} is the Process Id value as a decimal integer (this line is
6843 present only if the Process Id is non-zero). Currently we are
6844 not making use of this field.
6845
6846 @item
6847 The Call stack traceback locations line and the following values
6848 are present only if at least one traceback location was recorded.
6849 The values are given in C style format, with lower case letters
6850 for a-f, and only as many digits present as are necessary.
6851 @end itemize
6852
6853 @noindent
6854 The line terminator sequence at the end of each line, including
6855 the last line is a single @code{LF} character (@code{16#0A#}).
6856
6857 @sp 1
6858 @cartouche
6859 @noindent
6860 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6861 @end cartouche
6862 @noindent
6863 No implementation-defined check names are supported.
6864
6865 @sp 1
6866 @cartouche
6867 @noindent
6868 @strong{43}.  The interpretation of each aspect of representation.  See
6869 13.1(20).
6870 @end cartouche
6871 @noindent
6872 See separate section on data representations.
6873
6874 @sp 1
6875 @cartouche
6876 @noindent
6877 @strong{44}.  Any restrictions placed upon representation items.  See
6878 13.1(20).
6879 @end cartouche
6880 @noindent
6881 See separate section on data representations.
6882
6883 @sp 1
6884 @cartouche
6885 @noindent
6886 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6887 13.3(48).
6888 @end cartouche
6889 @noindent
6890 Size for an indefinite subtype is the maximum possible size, except that
6891 for the case of a subprogram parameter, the size of the parameter object
6892 is the actual size.
6893
6894 @sp 1
6895 @cartouche
6896 @noindent
6897 @strong{46}.  The default external representation for a type tag.  See
6898 13.3(75).
6899 @end cartouche
6900 @noindent
6901 The default external representation for a type tag is the fully expanded
6902 name of the type in upper case letters.
6903
6904 @sp 1
6905 @cartouche
6906 @noindent
6907 @strong{47}.  What determines whether a compilation unit is the same in
6908 two different partitions.  See 13.3(76).
6909 @end cartouche
6910 @noindent
6911 A compilation unit is the same in two different partitions if and only
6912 if it derives from the same source file.
6913
6914 @sp 1
6915 @cartouche
6916 @noindent
6917 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6918 @end cartouche
6919 @noindent
6920 The only implementation defined component is the tag for a tagged type,
6921 which contains a pointer to the dispatching table.
6922
6923 @sp 1
6924 @cartouche
6925 @noindent
6926 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6927 ordering.  See 13.5.3(5).
6928 @end cartouche
6929 @noindent
6930 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6931 implementation, so no non-default bit ordering is supported.  The default
6932 bit ordering corresponds to the natural endianness of the target architecture.
6933
6934 @sp 1
6935 @cartouche
6936 @noindent
6937 @strong{50}.  The contents of the visible part of package @code{System}
6938 and its language-defined children.  See 13.7(2).
6939 @end cartouche
6940 @noindent
6941 See the definition of these packages in files @file{system.ads} and
6942 @file{s-stoele.ads}.
6943
6944 @sp 1
6945 @cartouche
6946 @noindent
6947 @strong{51}.  The contents of the visible part of package
6948 @code{System.Machine_Code}, and the meaning of
6949 @code{code_statements}.  See 13.8(7).
6950 @end cartouche
6951 @noindent
6952 See the definition and documentation in file @file{s-maccod.ads}.
6953
6954 @sp 1
6955 @cartouche
6956 @noindent
6957 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6958 @end cartouche
6959 @noindent
6960 Unchecked conversion between types of the same size
6961 and results in an uninterpreted transmission of the bits from one type
6962 to the other.  If the types are of unequal sizes, then in the case of
6963 discrete types, a shorter source is first zero or sign extended as
6964 necessary, and a shorter target is simply truncated on the left.
6965 For all non-discrete types, the source is first copied if necessary
6966 to ensure that the alignment requirements of the target are met, then
6967 a pointer is constructed to the source value, and the result is obtained
6968 by dereferencing this pointer after converting it to be a pointer to the
6969 target type.
6970
6971 @sp 1
6972 @cartouche
6973 @noindent
6974 @strong{53}.  The manner of choosing a storage pool for an access type
6975 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6976 @end cartouche
6977 @noindent
6978 There are 3 different standard pools used by the compiler when
6979 @code{Storage_Pool} is not specified depending whether the type is local
6980 to a subprogram or defined at the library level and whether
6981 @code{Storage_Size}is specified or not.  See documentation in the runtime
6982 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6983 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6984 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6985 default pools used.
6986
6987 @sp 1
6988 @cartouche
6989 @noindent
6990 @strong{54}.  Whether or not the implementation provides user-accessible
6991 names for the standard pool type(s).  See 13.11(17).
6992 @end cartouche
6993 @noindent
6994
6995 See documentation in the sources of the run time mentioned in paragraph
6996 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6997 these units.
6998
6999 @sp 1
7000 @cartouche
7001 @noindent
7002 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7003 @end cartouche
7004 @noindent
7005 @code{Storage_Size} is measured in storage units, and refers to the
7006 total space available for an access type collection, or to the primary
7007 stack space for a task.
7008
7009 @sp 1
7010 @cartouche
7011 @noindent
7012 @strong{56}.  Implementation-defined aspects of storage pools.  See
7013 13.11(22).
7014 @end cartouche
7015 @noindent
7016 See documentation in the sources of the run time mentioned in paragraph
7017 @strong{53} for details on GNAT-defined aspects of storage pools.
7018
7019 @sp 1
7020 @cartouche
7021 @noindent
7022 @strong{57}.  The set of restrictions allowed in a pragma
7023 @code{Restrictions}.  See 13.12(7).
7024 @end cartouche
7025 @noindent
7026 All RM defined Restriction identifiers are implemented.  The following
7027 additional restriction identifiers are provided.  There are two separate
7028 lists of implementation dependent restriction identifiers.  The first
7029 set requires consistency throughout a partition (in other words, if the
7030 restriction identifier is used for any compilation unit in the partition,
7031 then all compilation units in the partition must obey the restriction.
7032
7033 @table @code
7034
7035 @item Simple_Barriers
7036 @findex Simple_Barriers
7037 This restriction ensures at compile time that barriers in entry declarations
7038 for protected types are restricted to either static boolean expressions or
7039 references to simple boolean variables defined in the private part of the
7040 protected type.  No other form of entry barriers is permitted.  This is one
7041 of the restrictions of the Ravenscar profile for limited tasking (see also
7042 pragma @code{Profile (Ravenscar)}).
7043
7044 @item Max_Entry_Queue_Length => Expr
7045 @findex Max_Entry_Queue_Length
7046 This restriction is a declaration that any protected entry compiled in
7047 the scope of the restriction has at most the specified number of
7048 tasks waiting on the entry
7049 at any one time, and so no queue is required.  This restriction is not
7050 checked at compile time.  A program execution is erroneous if an attempt
7051 is made to queue more than the specified number of tasks on such an entry.
7052
7053 @item No_Calendar
7054 @findex No_Calendar
7055 This restriction ensures at compile time that there is no implicit or
7056 explicit dependence on the package @code{Ada.Calendar}.
7057
7058 @item No_Direct_Boolean_Operators
7059 @findex No_Direct_Boolean_Operators
7060 This restriction ensures that no logical (and/or/xor) or comparison
7061 operators are used on operands of type Boolean (or any type derived
7062 from Boolean). This is intended for use in safety critical programs
7063 where the certification protocol requires the use of short-circuit
7064 (and then, or else) forms for all composite boolean operations.
7065
7066 @item No_Dynamic_Attachment
7067 @findex No_Dynamic_Attachment
7068 This restriction ensures that there is no call to any of the operations
7069 defined in package Ada.Interrupts.
7070
7071 @item No_Enumeration_Maps
7072 @findex No_Enumeration_Maps
7073 This restriction ensures at compile time that no operations requiring
7074 enumeration maps are used (that is Image and Value attributes applied
7075 to enumeration types).
7076
7077 @item No_Entry_Calls_In_Elaboration_Code
7078 @findex No_Entry_Calls_In_Elaboration_Code
7079 This restriction ensures at compile time that no task or protected entry
7080 calls are made during elaboration code.  As a result of the use of this
7081 restriction, the compiler can assume that no code past an accept statement
7082 in a task can be executed at elaboration time.
7083
7084 @item No_Exception_Handlers
7085 @findex No_Exception_Handlers
7086 This restriction ensures at compile time that there are no explicit
7087 exception handlers. It also indicates that no exception propagation will
7088 be provided. In this mode, exceptions may be raised but will result in
7089 an immediate call to the last chance handler, a routine that the user
7090 must define with the following profile:
7091
7092    procedure Last_Chance_Handler
7093      (Source_Location : System.Address; Line : Integer);
7094    pragma Export (C, Last_Chance_Handler,
7095                   "__gnat_last_chance_handler");
7096
7097    The parameter is a C null-terminated string representing a message to be
7098    associated with the exception (typically the source location of the raise
7099    statement generated by the compiler). The Line parameter when non-zero
7100    represents the line number in the source program where the raise occurs.
7101
7102 @item No_Exception_Streams
7103 @findex No_Exception_Streams
7104 This restriction ensures at compile time that no stream operations for
7105 types Exception_Id or Exception_Occurrence are used. This also makes it
7106 impossible to pass exceptions to or from a partition with this restriction
7107 in a distributed environment. If this exception is active, then the generated
7108 code is simplified by omitting the otherwise-required global registration
7109 of exceptions when they are declared.
7110
7111 @item No_Implicit_Conditionals
7112 @findex No_Implicit_Conditionals
7113 This restriction ensures that the generated code does not contain any
7114 implicit conditionals, either by modifying the generated code where possible,
7115 or by rejecting any construct that would otherwise generate an implicit
7116 conditional. Note that this check does not include run time constraint
7117 checks, which on some targets may generate implicit conditionals as
7118 well. To control the latter, constraint checks can be suppressed in the
7119 normal manner.
7120
7121 @item No_Implicit_Dynamic_Code
7122 @findex No_Implicit_Dynamic_Code
7123 This restriction prevents the compiler from building ``trampolines''.
7124 This is a structure that is built on the stack and contains dynamic
7125 code to be executed at run time. A trampoline is needed to indirectly
7126 address a nested subprogram (that is a subprogram that is not at the
7127 library level). The restriction prevents the use of any of the
7128 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7129 being applied to a subprogram that is not at the library level.
7130
7131 @item No_Implicit_Loops
7132 @findex No_Implicit_Loops
7133 This restriction ensures that the generated code does not contain any
7134 implicit @code{for} loops, either by modifying
7135 the generated code where possible,
7136 or by rejecting any construct that would otherwise generate an implicit
7137 @code{for} loop.
7138
7139 @item No_Initialize_Scalars
7140 @findex No_Initialize_Scalars
7141 This restriction ensures that no unit in the partition is compiled with
7142 pragma Initialize_Scalars. This allows the generation of more efficient
7143 code, and in particular eliminates dummy null initialization routines that
7144 are otherwise generated for some record and array types.
7145
7146 @item No_Local_Protected_Objects
7147 @findex No_Local_Protected_Objects
7148 This restriction ensures at compile time that protected objects are
7149 only declared at the library level.
7150
7151 @item No_Protected_Type_Allocators
7152 @findex No_Protected_Type_Allocators
7153 This restriction ensures at compile time that there are no allocator
7154 expressions that attempt to allocate protected objects.
7155
7156 @item No_Secondary_Stack
7157 @findex No_Secondary_Stack
7158 This restriction ensures at compile time that the generated code does not
7159 contain any reference to the secondary stack.  The secondary stack is used
7160 to implement functions returning unconstrained objects (arrays or records)
7161 on some targets.
7162
7163 @item No_Select_Statements
7164 @findex No_Select_Statements
7165 This restriction ensures at compile time no select statements of any kind
7166 are permitted, that is the keyword @code{select} may not appear.
7167 This is one of the restrictions of the Ravenscar
7168 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7169
7170 @item No_Standard_Storage_Pools
7171 @findex No_Standard_Storage_Pools
7172 This restriction ensures at compile time that no access types
7173 use the standard default storage pool.  Any access type declared must
7174 have an explicit Storage_Pool attribute defined specifying a
7175 user-defined storage pool.
7176
7177 @item No_Streams
7178 @findex No_Streams
7179 This restriction ensures at compile/bind time that there are no
7180 stream objects created (and therefore no actual stream operations).
7181 This restriction does not forbid dependences on the package
7182 @code{Ada.Streams}. So it is permissible to with
7183 @code{Ada.Streams} (or another package that does so itself)
7184 as long as no actual stream objects are created.
7185
7186 @item No_Task_Attributes_Package
7187 @findex No_Task_Attributes_Package
7188 This restriction ensures at compile time that there are no implicit or
7189 explicit dependencies on the package @code{Ada.Task_Attributes}.
7190
7191 @item No_Task_Termination
7192 @findex No_Task_Termination
7193 This restriction ensures at compile time that no terminate alternatives
7194 appear in any task body.
7195
7196 @item No_Tasking
7197 @findex No_Tasking
7198 This restriction prevents the declaration of tasks or task types throughout
7199 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7200 except that violations are caught at compile time and cause an error message
7201 to be output either by the compiler or binder.
7202
7203 @item No_Wide_Characters
7204 @findex No_Wide_Characters
7205 This restriction ensures at compile time that no uses of the types
7206 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7207 wide types
7208 appear, and that no wide or wide wide string or character literals
7209 appear in the program (that is literals representing characters not in
7210 type @code{Character}.
7211
7212 @item Static_Priorities
7213 @findex Static_Priorities
7214 This restriction ensures at compile time that all priority expressions
7215 are static, and that there are no dependencies on the package
7216 @code{Ada.Dynamic_Priorities}.
7217
7218 @item Static_Storage_Size
7219 @findex Static_Storage_Size
7220 This restriction ensures at compile time that any expression appearing
7221 in a Storage_Size pragma or attribute definition clause is static.
7222
7223 @end table
7224
7225 @noindent
7226 The second set of implementation dependent restriction identifiers
7227 does not require partition-wide consistency.
7228 The restriction may be enforced for a single
7229 compilation unit without any effect on any of the
7230 other compilation units in the partition.
7231
7232 @table @code
7233
7234 @item No_Elaboration_Code
7235 @findex No_Elaboration_Code
7236 This restriction ensures at compile time that no elaboration code is
7237 generated.  Note that this is not the same condition as is enforced
7238 by pragma @code{Preelaborate}.  There are cases in which pragma
7239 @code{Preelaborate} still permits code to be generated (e.g.@: code
7240 to initialize a large array to all zeroes), and there are cases of units
7241 which do not meet the requirements for pragma @code{Preelaborate},
7242 but for which no elaboration code is generated.  Generally, it is
7243 the case that preelaborable units will meet the restrictions, with
7244 the exception of large aggregates initialized with an others_clause,
7245 and exception declarations (which generate calls to a run-time
7246 registry procedure).  Note that this restriction is enforced on
7247 a unit by unit basis, it need not be obeyed consistently
7248 throughout a partition.
7249
7250 @item No_Entry_Queue
7251 @findex No_Entry_Queue
7252 This restriction is a declaration that any protected entry compiled in
7253 the scope of the restriction has at most one task waiting on the entry
7254 at any one time, and so no queue is required.  This restriction is not
7255 checked at compile time.  A program execution is erroneous if an attempt
7256 is made to queue a second task on such an entry.
7257
7258 @item No_Implementation_Attributes
7259 @findex No_Implementation_Attributes
7260 This restriction checks at compile time that no GNAT-defined attributes
7261 are present.  With this restriction, the only attributes that can be used
7262 are those defined in the Ada 95 Reference Manual.
7263
7264 @item No_Implementation_Pragmas
7265 @findex No_Implementation_Pragmas
7266 This restriction checks at compile time that no GNAT-defined pragmas
7267 are present.  With this restriction, the only pragmas that can be used
7268 are those defined in the Ada 95 Reference Manual.
7269
7270 @item No_Implementation_Restrictions
7271 @findex No_Implementation_Restrictions
7272 This restriction checks at compile time that no GNAT-defined restriction
7273 identifiers (other than @code{No_Implementation_Restrictions} itself)
7274 are present.  With this restriction, the only other restriction identifiers
7275 that can be used are those defined in the Ada 95 Reference Manual.
7276
7277 @end table
7278
7279 @sp 1
7280 @cartouche
7281 @noindent
7282 @strong{58}.  The consequences of violating limitations on
7283 @code{Restrictions} pragmas.  See 13.12(9).
7284 @end cartouche
7285 @noindent
7286 Restrictions that can be checked at compile time result in illegalities
7287 if violated.  Currently there are no other consequences of violating
7288 restrictions.
7289
7290 @sp 1
7291 @cartouche
7292 @noindent
7293 @strong{59}.  The representation used by the @code{Read} and
7294 @code{Write} attributes of elementary types in terms of stream
7295 elements.  See 13.13.2(9).
7296 @end cartouche
7297 @noindent
7298 The representation is the in-memory representation of the base type of
7299 the type, using the number of bits corresponding to the
7300 @code{@var{type}'Size} value, and the natural ordering of the machine.
7301
7302 @sp 1
7303 @cartouche
7304 @noindent
7305 @strong{60}.  The names and characteristics of the numeric subtypes
7306 declared in the visible part of package @code{Standard}.  See A.1(3).
7307 @end cartouche
7308 @noindent
7309 See items describing the integer and floating-point types supported.
7310
7311 @sp 1
7312 @cartouche
7313 @noindent
7314 @strong{61}.  The accuracy actually achieved by the elementary
7315 functions.  See A.5.1(1).
7316 @end cartouche
7317 @noindent
7318 The elementary functions correspond to the functions available in the C
7319 library.  Only fast math mode is implemented.
7320
7321 @sp 1
7322 @cartouche
7323 @noindent
7324 @strong{62}.  The sign of a zero result from some of the operators or
7325 functions in @code{Numerics.Generic_Elementary_Functions}, when
7326 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7327 @end cartouche
7328 @noindent
7329 The sign of zeroes follows the requirements of the IEEE 754 standard on
7330 floating-point.
7331
7332 @sp 1
7333 @cartouche
7334 @noindent
7335 @strong{63}.  The value of
7336 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7337 @end cartouche
7338 @noindent
7339 Maximum image width is 649, see library file @file{a-numran.ads}.
7340
7341 @sp 1
7342 @cartouche
7343 @noindent
7344 @strong{64}.  The value of
7345 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7346 @end cartouche
7347 @noindent
7348 Maximum image width is 80, see library file @file{a-nudira.ads}.
7349
7350 @sp 1
7351 @cartouche
7352 @noindent
7353 @strong{65}.  The algorithms for random number generation.  See
7354 A.5.2(32).
7355 @end cartouche
7356 @noindent
7357 The algorithm is documented in the source files @file{a-numran.ads} and
7358 @file{a-numran.adb}.
7359
7360 @sp 1
7361 @cartouche
7362 @noindent
7363 @strong{66}.  The string representation of a random number generator's
7364 state.  See A.5.2(38).
7365 @end cartouche
7366 @noindent
7367 See the documentation contained in the file @file{a-numran.adb}.
7368
7369 @sp 1
7370 @cartouche
7371 @noindent
7372 @strong{67}.  The minimum time interval between calls to the
7373 time-dependent Reset procedure that are guaranteed to initiate different
7374 random number sequences.  See A.5.2(45).
7375 @end cartouche
7376 @noindent
7377 The minimum period between reset calls to guarantee distinct series of
7378 random numbers is one microsecond.
7379
7380 @sp 1
7381 @cartouche
7382 @noindent
7383 @strong{68}.  The values of the @code{Model_Mantissa},
7384 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7385 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7386 Annex is not supported.  See A.5.3(72).
7387 @end cartouche
7388 @noindent
7389 See the source file @file{ttypef.ads} for the values of all numeric
7390 attributes.
7391
7392 @sp 1
7393 @cartouche
7394 @noindent
7395 @strong{69}.  Any implementation-defined characteristics of the
7396 input-output packages.  See A.7(14).
7397 @end cartouche
7398 @noindent
7399 There are no special implementation defined characteristics for these
7400 packages.
7401
7402 @sp 1
7403 @cartouche
7404 @noindent
7405 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7406 A.9(10).
7407 @end cartouche
7408 @noindent
7409 All type representations are contiguous, and the @code{Buffer_Size} is
7410 the value of @code{@var{type}'Size} rounded up to the next storage unit
7411 boundary.
7412
7413 @sp 1
7414 @cartouche
7415 @noindent
7416 @strong{71}.  External files for standard input, standard output, and
7417 standard error See A.10(5).
7418 @end cartouche
7419 @noindent
7420 These files are mapped onto the files provided by the C streams
7421 libraries.  See source file @file{i-cstrea.ads} for further details.
7422
7423 @sp 1
7424 @cartouche
7425 @noindent
7426 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7427 A.10.9(36).
7428 @end cartouche
7429 @noindent
7430 If more digits are requested in the output than are represented by the
7431 precision of the value, zeroes are output in the corresponding least
7432 significant digit positions.
7433
7434 @sp 1
7435 @cartouche
7436 @noindent
7437 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7438 @code{Command_Name}.  See A.15(1).
7439 @end cartouche
7440 @noindent
7441 These are mapped onto the @code{argv} and @code{argc} parameters of the
7442 main program in the natural manner.
7443
7444 @sp 1
7445 @cartouche
7446 @noindent
7447 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7448 @end cartouche
7449 @noindent
7450 The following convention names are supported
7451
7452 @table @code
7453 @item  Ada
7454 Ada
7455 @item Assembler
7456 Assembly language
7457 @item Asm
7458 Synonym for Assembler
7459 @item Assembly
7460 Synonym for Assembler
7461 @item C
7462 C
7463 @item C_Pass_By_Copy
7464 Allowed only for record types, like C, but also notes that record
7465 is to be passed by copy rather than reference.
7466 @item COBOL
7467 COBOL
7468 @item CPP
7469 C++
7470 @item Default
7471 Treated the same as C
7472 @item External
7473 Treated the same as C
7474 @item Fortran
7475 Fortran
7476 @item Intrinsic
7477 For support of pragma @code{Import} with convention Intrinsic, see
7478 separate section on Intrinsic Subprograms.
7479 @item Stdcall
7480 Stdcall (used for Windows implementations only).  This convention correspond
7481 to the WINAPI (previously called Pascal convention) C/C++ convention under
7482 Windows.  A function with this convention cleans the stack before exit.
7483 @item DLL
7484 Synonym for Stdcall
7485 @item Win32
7486 Synonym for Stdcall
7487 @item Stubbed
7488 Stubbed is a special convention used to indicate that the body of the
7489 subprogram will be entirely ignored.  Any call to the subprogram
7490 is converted into a raise of the @code{Program_Error} exception.  If a
7491 pragma @code{Import} specifies convention @code{stubbed} then no body need
7492 be present at all.  This convention is useful during development for the
7493 inclusion of subprograms whose body has not yet been written.
7494
7495 @end table
7496 @noindent
7497 In addition, all otherwise unrecognized convention names are also
7498 treated as being synonymous with convention C@.  In all implementations
7499 except for VMS, use of such other names results in a warning.  In VMS
7500 implementations, these names are accepted silently.
7501
7502 @sp 1
7503 @cartouche
7504 @noindent
7505 @strong{75}.  The meaning of link names.  See B.1(36).
7506 @end cartouche
7507 @noindent
7508 Link names are the actual names used by the linker.
7509
7510 @sp 1
7511 @cartouche
7512 @noindent
7513 @strong{76}.  The manner of choosing link names when neither the link
7514 name nor the address of an imported or exported entity is specified.  See
7515 B.1(36).
7516 @end cartouche
7517 @noindent
7518 The default linker name is that which would be assigned by the relevant
7519 external language, interpreting the Ada name as being in all lower case
7520 letters.
7521
7522 @sp 1
7523 @cartouche
7524 @noindent
7525 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7526 @end cartouche
7527 @noindent
7528 The string passed to @code{Linker_Options} is presented uninterpreted as
7529 an argument to the link command, unless it contains Ascii.NUL characters.
7530 NUL characters if they appear act as argument separators, so for example
7531
7532 @smallexample @c ada
7533 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7534 @end smallexample
7535
7536 @noindent
7537 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7538 linker. The order of linker options is preserved for a given unit. The final
7539 list of options passed to the linker is in reverse order of the elaboration
7540 order. For example, linker options fo a body always appear before the options
7541 from the corresponding package spec.
7542
7543 @sp 1
7544 @cartouche
7545 @noindent
7546 @strong{78}.  The contents of the visible part of package
7547 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7548 @end cartouche
7549 @noindent
7550 See files with prefix @file{i-} in the distributed library.
7551
7552 @sp 1
7553 @cartouche
7554 @noindent
7555 @strong{79}.  Implementation-defined children of package
7556 @code{Interfaces}.  The contents of the visible part of package
7557 @code{Interfaces}.  See B.2(11).
7558 @end cartouche
7559 @noindent
7560 See files with prefix @file{i-} in the distributed library.
7561
7562 @sp 1
7563 @cartouche
7564 @noindent
7565 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7566 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7567 @code{COBOL_Character}; and the initialization of the variables
7568 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7569 @code{Interfaces.COBOL}.  See B.4(50).
7570 @end cartouche
7571 @noindent
7572 @table @code
7573 @item Floating
7574 Float
7575 @item Long_Floating
7576 (Floating) Long_Float
7577 @item Binary
7578 Integer
7579 @item Long_Binary
7580 Long_Long_Integer
7581 @item Decimal_Element
7582 Character
7583 @item COBOL_Character
7584 Character
7585 @end table
7586
7587 @noindent
7588 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7589
7590 @sp 1
7591 @cartouche
7592 @noindent
7593 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7594 @end cartouche
7595 @noindent
7596 See documentation in file @file{s-maccod.ads} in the distributed library.
7597
7598 @sp 1
7599 @cartouche
7600 @noindent
7601 @strong{82}.  Implementation-defined aspects of access to machine
7602 operations.  See C.1(9).
7603 @end cartouche
7604 @noindent
7605 See documentation in file @file{s-maccod.ads} in the distributed library.
7606
7607 @sp 1
7608 @cartouche
7609 @noindent
7610 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7611 @end cartouche
7612 @noindent
7613 Interrupts are mapped to signals or conditions as appropriate.  See
7614 definition of unit
7615 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7616 on the interrupts supported on a particular target.
7617
7618 @sp 1
7619 @cartouche
7620 @noindent
7621 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7622 C.4(13).
7623 @end cartouche
7624 @noindent
7625 GNAT does not permit a partition to be restarted without reloading,
7626 except under control of the debugger.
7627
7628 @sp 1
7629 @cartouche
7630 @noindent
7631 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7632 @end cartouche
7633 @noindent
7634 Pragma @code{Discard_Names} causes names of enumeration literals to
7635 be suppressed.  In the presence of this pragma, the Image attribute
7636 provides the image of the Pos of the literal, and Value accepts
7637 Pos values.
7638
7639 @sp 1
7640 @cartouche
7641 @noindent
7642 @strong{86}.  The result of the @code{Task_Identification.Image}
7643 attribute.  See C.7.1(7).
7644 @end cartouche
7645 @noindent
7646 The result of this attribute is an 8-digit hexadecimal string
7647 representing the virtual address of the task control block.
7648
7649 @sp 1
7650 @cartouche
7651 @noindent
7652 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7653 or interrupt handler.  See C.7.1(17).
7654 @end cartouche
7655 @noindent
7656 Protected entries or interrupt handlers can be executed by any
7657 convenient thread, so the value of @code{Current_Task} is undefined.
7658
7659 @sp 1
7660 @cartouche
7661 @noindent
7662 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7663 body or interrupt handler.  See C.7.1(19).
7664 @end cartouche
7665 @noindent
7666 The effect of calling @code{Current_Task} from an entry body or
7667 interrupt handler is to return the identification of the task currently
7668 executing the code.
7669
7670 @sp 1
7671 @cartouche
7672 @noindent
7673 @strong{89}.  Implementation-defined aspects of
7674 @code{Task_Attributes}.  See C.7.2(19).
7675 @end cartouche
7676 @noindent
7677 There are no implementation-defined aspects of @code{Task_Attributes}.
7678
7679 @sp 1
7680 @cartouche
7681 @noindent
7682 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7683 @end cartouche
7684 @noindent
7685 The metrics information for GNAT depends on the performance of the
7686 underlying operating system.  The sources of the run-time for tasking
7687 implementation, together with the output from @code{-gnatG} can be
7688 used to determine the exact sequence of operating systems calls made
7689 to implement various tasking constructs.  Together with appropriate
7690 information on the performance of the underlying operating system,
7691 on the exact target in use, this information can be used to determine
7692 the required metrics.
7693
7694 @sp 1
7695 @cartouche
7696 @noindent
7697 @strong{91}.  The declarations of @code{Any_Priority} and
7698 @code{Priority}.  See D.1(11).
7699 @end cartouche
7700 @noindent
7701 See declarations in file @file{system.ads}.
7702
7703 @sp 1
7704 @cartouche
7705 @noindent
7706 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7707 @end cartouche
7708 @noindent
7709 There are no implementation-defined execution resources.
7710
7711 @sp 1
7712 @cartouche
7713 @noindent
7714 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7715 access to a protected object keeps its processor busy.  See D.2.1(3).
7716 @end cartouche
7717 @noindent
7718 On a multi-processor, a task that is waiting for access to a protected
7719 object does not keep its processor busy.
7720
7721 @sp 1
7722 @cartouche
7723 @noindent
7724 @strong{94}.  The affect of implementation defined execution resources
7725 on task dispatching.  See D.2.1(9).
7726 @end cartouche
7727 @noindent
7728 @c SGI info
7729 @ignore
7730 Tasks map to IRIX threads, and the dispatching policy is as defined by
7731 the IRIX implementation of threads.
7732 @end ignore
7733 Tasks map to threads in the threads package used by GNAT@.  Where possible
7734 and appropriate, these threads correspond to native threads of the
7735 underlying operating system.
7736
7737 @sp 1
7738 @cartouche
7739 @noindent
7740 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7741 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7742 @end cartouche
7743 @noindent
7744 There are no implementation-defined policy-identifiers allowed in this
7745 pragma.
7746
7747 @sp 1
7748 @cartouche
7749 @noindent
7750 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7751 D.2.2(16).
7752 @end cartouche
7753 @noindent
7754 Execution of a task cannot be preempted by the implementation processing
7755 of delay expirations for lower priority tasks.
7756
7757 @sp 1
7758 @cartouche
7759 @noindent
7760 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7761 @end cartouche
7762 @noindent
7763 @c SGI info:
7764 @ignore
7765 Tasks map to IRIX threads, and the dispatching policy is as defied by
7766 the IRIX implementation of threads.
7767 @end ignore
7768 The policy is the same as that of the underlying threads implementation.
7769
7770 @sp 1
7771 @cartouche
7772 @noindent
7773 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7774 in a pragma @code{Locking_Policy}.  See D.3(4).
7775 @end cartouche
7776 @noindent
7777 The only implementation defined policy permitted in GNAT is
7778 @code{Inheritance_Locking}.  On targets that support this policy, locking
7779 is implemented by inheritance, i.e.@: the task owning the lock operates
7780 at a priority equal to the highest priority of any task currently
7781 requesting the lock.
7782
7783 @sp 1
7784 @cartouche
7785 @noindent
7786 @strong{99}.  Default ceiling priorities.  See D.3(10).
7787 @end cartouche
7788 @noindent
7789 The ceiling priority of protected objects of the type
7790 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7791 Reference Manual D.3(10),
7792
7793 @sp 1
7794 @cartouche
7795 @noindent
7796 @strong{100}.  The ceiling of any protected object used internally by
7797 the implementation.  See D.3(16).
7798 @end cartouche
7799 @noindent
7800 The ceiling priority of internal protected objects is
7801 @code{System.Priority'Last}.
7802
7803 @sp 1
7804 @cartouche
7805 @noindent
7806 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7807 @end cartouche
7808 @noindent
7809 There are no implementation-defined queueing policies.
7810
7811 @sp 1
7812 @cartouche
7813 @noindent
7814 @strong{102}.  On a multiprocessor, any conditions that cause the
7815 completion of an aborted construct to be delayed later than what is
7816 specified for a single processor.  See D.6(3).
7817 @end cartouche
7818 @noindent
7819 The semantics for abort on a multi-processor is the same as on a single
7820 processor, there are no further delays.
7821
7822 @sp 1
7823 @cartouche
7824 @noindent
7825 @strong{103}.  Any operations that implicitly require heap storage
7826 allocation.  See D.7(8).
7827 @end cartouche
7828 @noindent
7829 The only operation that implicitly requires heap storage allocation is
7830 task creation.
7831
7832 @sp 1
7833 @cartouche
7834 @noindent
7835 @strong{104}.  Implementation-defined aspects of pragma
7836 @code{Restrictions}.  See D.7(20).
7837 @end cartouche
7838 @noindent
7839 There are no such implementation-defined aspects.
7840
7841 @sp 1
7842 @cartouche
7843 @noindent
7844 @strong{105}.  Implementation-defined aspects of package
7845 @code{Real_Time}.  See D.8(17).
7846 @end cartouche
7847 @noindent
7848 There are no implementation defined aspects of package @code{Real_Time}.
7849
7850 @sp 1
7851 @cartouche
7852 @noindent
7853 @strong{106}.  Implementation-defined aspects of
7854 @code{delay_statements}.  See D.9(8).
7855 @end cartouche
7856 @noindent
7857 Any difference greater than one microsecond will cause the task to be
7858 delayed (see D.9(7)).
7859
7860 @sp 1
7861 @cartouche
7862 @noindent
7863 @strong{107}.  The upper bound on the duration of interrupt blocking
7864 caused by the implementation.  See D.12(5).
7865 @end cartouche
7866 @noindent
7867 The upper bound is determined by the underlying operating system.  In
7868 no cases is it more than 10 milliseconds.
7869
7870 @sp 1
7871 @cartouche
7872 @noindent
7873 @strong{108}.  The means for creating and executing distributed
7874 programs.  See E(5).
7875 @end cartouche
7876 @noindent
7877 The GLADE package provides a utility GNATDIST for creating and executing
7878 distributed programs.  See the GLADE reference manual for further details.
7879
7880 @sp 1
7881 @cartouche
7882 @noindent
7883 @strong{109}.  Any events that can result in a partition becoming
7884 inaccessible.  See E.1(7).
7885 @end cartouche
7886 @noindent
7887 See the GLADE reference manual for full details on such events.
7888
7889 @sp 1
7890 @cartouche
7891 @noindent
7892 @strong{110}.  The scheduling policies, treatment of priorities, and
7893 management of shared resources between partitions in certain cases.  See
7894 E.1(11).
7895 @end cartouche
7896 @noindent
7897 See the GLADE reference manual for full details on these aspects of
7898 multi-partition execution.
7899
7900 @sp 1
7901 @cartouche
7902 @noindent
7903 @strong{111}.  Events that cause the version of a compilation unit to
7904 change.  See E.3(5).
7905 @end cartouche
7906 @noindent
7907 Editing the source file of a compilation unit, or the source files of
7908 any units on which it is dependent in a significant way cause the version
7909 to change.  No other actions cause the version number to change.  All changes
7910 are significant except those which affect only layout, capitalization or
7911 comments.
7912
7913 @sp 1
7914 @cartouche
7915 @noindent
7916 @strong{112}.  Whether the execution of the remote subprogram is
7917 immediately aborted as a result of cancellation.  See E.4(13).
7918 @end cartouche
7919 @noindent
7920 See the GLADE reference manual for details on the effect of abort in
7921 a distributed application.
7922
7923 @sp 1
7924 @cartouche
7925 @noindent
7926 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7927 @end cartouche
7928 @noindent
7929 See the GLADE reference manual for a full description of all implementation
7930 defined aspects of the PCS@.
7931
7932 @sp 1
7933 @cartouche
7934 @noindent
7935 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7936 E.5(26).
7937 @end cartouche
7938 @noindent
7939 See the GLADE reference manual for a full description of all
7940 implementation defined interfaces.
7941
7942 @sp 1
7943 @cartouche
7944 @noindent
7945 @strong{115}.  The values of named numbers in the package
7946 @code{Decimal}.  See F.2(7).
7947 @end cartouche
7948 @noindent
7949 @table @code
7950 @item Max_Scale
7951 +18
7952 @item Min_Scale
7953 -18
7954 @item Min_Delta
7955 1.0E-18
7956 @item Max_Delta
7957 1.0E+18
7958 @item Max_Decimal_Digits
7959 18
7960 @end table
7961
7962 @sp 1
7963 @cartouche
7964 @noindent
7965 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7966 @code{Text_IO.Editing}.  See F.3.3(16).
7967 @end cartouche
7968 @noindent
7969 64
7970
7971 @sp 1
7972 @cartouche
7973 @noindent
7974 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7975 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7976 @end cartouche
7977 @noindent
7978 64
7979
7980 @sp 1
7981 @cartouche
7982 @noindent
7983 @strong{118}.  The accuracy actually achieved by the complex elementary
7984 functions and by other complex arithmetic operations.  See G.1(1).
7985 @end cartouche
7986 @noindent
7987 Standard library functions are used for the complex arithmetic
7988 operations.  Only fast math mode is currently supported.
7989
7990 @sp 1
7991 @cartouche
7992 @noindent
7993 @strong{119}.  The sign of a zero result (or a component thereof) from
7994 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7995 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7996 @end cartouche
7997 @noindent
7998 The signs of zero values are as recommended by the relevant
7999 implementation advice.
8000
8001 @sp 1
8002 @cartouche
8003 @noindent
8004 @strong{120}.  The sign of a zero result (or a component thereof) from
8005 any operator or function in
8006 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8007 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8008 @end cartouche
8009 @noindent
8010 The signs of zero values are as recommended by the relevant
8011 implementation advice.
8012
8013 @sp 1
8014 @cartouche
8015 @noindent
8016 @strong{121}.  Whether the strict mode or the relaxed mode is the
8017 default.  See G.2(2).
8018 @end cartouche
8019 @noindent
8020 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8021 provides a highly efficient implementation of strict mode.
8022
8023 @sp 1
8024 @cartouche
8025 @noindent
8026 @strong{122}.  The result interval in certain cases of fixed-to-float
8027 conversion.  See G.2.1(10).
8028 @end cartouche
8029 @noindent
8030 For cases where the result interval is implementation dependent, the
8031 accuracy is that provided by performing all operations in 64-bit IEEE
8032 floating-point format.
8033
8034 @sp 1
8035 @cartouche
8036 @noindent
8037 @strong{123}.  The result of a floating point arithmetic operation in
8038 overflow situations, when the @code{Machine_Overflows} attribute of the
8039 result type is @code{False}.  See G.2.1(13).
8040 @end cartouche
8041 @noindent
8042 Infinite and Nan values are produced as dictated by the IEEE
8043 floating-point standard.
8044
8045 @sp 1
8046 @cartouche
8047 @noindent
8048 @strong{124}.  The result interval for division (or exponentiation by a
8049 negative exponent), when the floating point hardware implements division
8050 as multiplication by a reciprocal.  See G.2.1(16).
8051 @end cartouche
8052 @noindent
8053 Not relevant, division is IEEE exact.
8054
8055 @sp 1
8056 @cartouche
8057 @noindent
8058 @strong{125}.  The definition of close result set, which determines the
8059 accuracy of certain fixed point multiplications and divisions.  See
8060 G.2.3(5).
8061 @end cartouche
8062 @noindent
8063 Operations in the close result set are performed using IEEE long format
8064 floating-point arithmetic.  The input operands are converted to
8065 floating-point, the operation is done in floating-point, and the result
8066 is converted to the target type.
8067
8068 @sp 1
8069 @cartouche
8070 @noindent
8071 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8072 point multiplication or division for which the result shall be in the
8073 perfect result set.  See G.2.3(22).
8074 @end cartouche
8075 @noindent
8076 The result is only defined to be in the perfect result set if the result
8077 can be computed by a single scaling operation involving a scale factor
8078 representable in 64-bits.
8079
8080 @sp 1
8081 @cartouche
8082 @noindent
8083 @strong{127}.  The result of a fixed point arithmetic operation in
8084 overflow situations, when the @code{Machine_Overflows} attribute of the
8085 result type is @code{False}.  See G.2.3(27).
8086 @end cartouche
8087 @noindent
8088 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8089 types.
8090
8091 @sp 1
8092 @cartouche
8093 @noindent
8094 @strong{128}.  The result of an elementary function reference in
8095 overflow situations, when the @code{Machine_Overflows} attribute of the
8096 result type is @code{False}.  See G.2.4(4).
8097 @end cartouche
8098 @noindent
8099 IEEE infinite and Nan values are produced as appropriate.
8100
8101 @sp 1
8102 @cartouche
8103 @noindent
8104 @strong{129}.  The value of the angle threshold, within which certain
8105 elementary functions, complex arithmetic operations, and complex
8106 elementary functions yield results conforming to a maximum relative
8107 error bound.  See G.2.4(10).
8108 @end cartouche
8109 @noindent
8110 Information on this subject is not yet available.
8111
8112 @sp 1
8113 @cartouche
8114 @noindent
8115 @strong{130}.  The accuracy of certain elementary functions for
8116 parameters beyond the angle threshold.  See G.2.4(10).
8117 @end cartouche
8118 @noindent
8119 Information on this subject is not yet available.
8120
8121 @sp 1
8122 @cartouche
8123 @noindent
8124 @strong{131}.  The result of a complex arithmetic operation or complex
8125 elementary function reference in overflow situations, when the
8126 @code{Machine_Overflows} attribute of the corresponding real type is
8127 @code{False}.  See G.2.6(5).
8128 @end cartouche
8129 @noindent
8130 IEEE infinite and Nan values are produced as appropriate.
8131
8132 @sp 1
8133 @cartouche
8134 @noindent
8135 @strong{132}.  The accuracy of certain complex arithmetic operations and
8136 certain complex elementary functions for parameters (or components
8137 thereof) beyond the angle threshold.  See G.2.6(8).
8138 @end cartouche
8139 @noindent
8140 Information on those subjects is not yet available.
8141
8142 @sp 1
8143 @cartouche
8144 @noindent
8145 @strong{133}.  Information regarding bounded errors and erroneous
8146 execution.  See H.2(1).
8147 @end cartouche
8148 @noindent
8149 Information on this subject is not yet available.
8150
8151 @sp 1
8152 @cartouche
8153 @noindent
8154 @strong{134}.  Implementation-defined aspects of pragma
8155 @code{Inspection_Point}.  See H.3.2(8).
8156 @end cartouche
8157 @noindent
8158 Pragma @code{Inspection_Point} ensures that the variable is live and can
8159 be examined by the debugger at the inspection point.
8160
8161 @sp 1
8162 @cartouche
8163 @noindent
8164 @strong{135}.  Implementation-defined aspects of pragma
8165 @code{Restrictions}.  See H.4(25).
8166 @end cartouche
8167 @noindent
8168 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8169 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8170 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8171
8172 @sp 1
8173 @cartouche
8174 @noindent
8175 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8176 H.4(27).
8177 @end cartouche
8178 @noindent
8179 There are no restrictions on pragma @code{Restrictions}.
8180
8181 @node Intrinsic Subprograms
8182 @chapter Intrinsic Subprograms
8183 @cindex Intrinsic Subprograms
8184
8185 @menu
8186 * Intrinsic Operators::
8187 * Enclosing_Entity::
8188 * Exception_Information::
8189 * Exception_Message::
8190 * Exception_Name::
8191 * File::
8192 * Line::
8193 * Rotate_Left::
8194 * Rotate_Right::
8195 * Shift_Left::
8196 * Shift_Right::
8197 * Shift_Right_Arithmetic::
8198 * Source_Location::
8199 @end menu
8200
8201 @noindent
8202 GNAT allows a user application program to write the declaration:
8203
8204 @smallexample @c ada
8205    pragma Import (Intrinsic, name);
8206 @end smallexample
8207
8208 @noindent
8209 providing that the name corresponds to one of the implemented intrinsic
8210 subprograms in GNAT, and that the parameter profile of the referenced
8211 subprogram meets the requirements.  This chapter describes the set of
8212 implemented intrinsic subprograms, and the requirements on parameter profiles.
8213 Note that no body is supplied; as with other uses of pragma Import, the
8214 body is supplied elsewhere (in this case by the compiler itself).  Note
8215 that any use of this feature is potentially non-portable, since the
8216 Ada standard does not require Ada compilers to implement this feature.
8217
8218 @node Intrinsic Operators
8219 @section Intrinsic Operators
8220 @cindex Intrinsic operator
8221
8222 @noindent
8223 All the predefined numeric operators in package Standard
8224 in @code{pragma Import (Intrinsic,..)}
8225 declarations.  In the binary operator case, the operands must have the same
8226 size.  The operand or operands must also be appropriate for
8227 the operator.  For example, for addition, the operands must
8228 both be floating-point or both be fixed-point, and the
8229 right operand for @code{"**"} must have a root type of
8230 @code{Standard.Integer'Base}.
8231 You can use an intrinsic operator declaration as in the following example:
8232
8233 @smallexample @c ada
8234    type Int1 is new Integer;
8235    type Int2 is new Integer;
8236
8237    function "+" (X1 : Int1; X2 : Int2) return Int1;
8238    function "+" (X1 : Int1; X2 : Int2) return Int2;
8239    pragma Import (Intrinsic, "+");
8240 @end smallexample
8241
8242 @noindent
8243 This declaration would permit ``mixed mode'' arithmetic on items
8244 of the differing types @code{Int1} and @code{Int2}.
8245 It is also possible to specify such operators for private types, if the
8246 full views are appropriate arithmetic types.
8247
8248 @node Enclosing_Entity
8249 @section Enclosing_Entity
8250 @cindex Enclosing_Entity
8251 @noindent
8252 This intrinsic subprogram is used in the implementation of the
8253 library routine @code{GNAT.Source_Info}.  The only useful use of the
8254 intrinsic import in this case is the one in this unit, so an
8255 application program should simply call the function
8256 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8257 the current subprogram, package, task, entry, or protected subprogram.
8258
8259 @node Exception_Information
8260 @section Exception_Information
8261 @cindex Exception_Information'
8262 @noindent
8263 This intrinsic subprogram is used in the implementation of the
8264 library routine @code{GNAT.Current_Exception}.  The only useful
8265 use of the intrinsic import in this case is the one in this unit,
8266 so an application program should simply call the function
8267 @code{GNAT.Current_Exception.Exception_Information} to obtain
8268 the exception information associated with the current exception.
8269
8270 @node Exception_Message
8271 @section Exception_Message
8272 @cindex Exception_Message
8273 @noindent
8274 This intrinsic subprogram is used in the implementation of the
8275 library routine @code{GNAT.Current_Exception}.  The only useful
8276 use of the intrinsic import in this case is the one in this unit,
8277 so an application program should simply call the function
8278 @code{GNAT.Current_Exception.Exception_Message} to obtain
8279 the message associated with the current exception.
8280
8281 @node Exception_Name
8282 @section Exception_Name
8283 @cindex Exception_Name
8284 @noindent
8285 This intrinsic subprogram is used in the implementation of the
8286 library routine @code{GNAT.Current_Exception}.  The only useful
8287 use of the intrinsic import in this case is the one in this unit,
8288 so an application program should simply call the function
8289 @code{GNAT.Current_Exception.Exception_Name} to obtain
8290 the name of the current exception.
8291
8292 @node File
8293 @section File
8294 @cindex File
8295 @noindent
8296 This intrinsic subprogram is used in the implementation of the
8297 library routine @code{GNAT.Source_Info}.  The only useful use of the
8298 intrinsic import in this case is the one in this unit, so an
8299 application program should simply call the function
8300 @code{GNAT.Source_Info.File} to obtain the name of the current
8301 file.
8302
8303 @node Line
8304 @section Line
8305 @cindex Line
8306 @noindent
8307 This intrinsic subprogram is used in the implementation of the
8308 library routine @code{GNAT.Source_Info}.  The only useful use of the
8309 intrinsic import in this case is the one in this unit, so an
8310 application program should simply call the function
8311 @code{GNAT.Source_Info.Line} to obtain the number of the current
8312 source line.
8313
8314 @node Rotate_Left
8315 @section Rotate_Left
8316 @cindex Rotate_Left
8317 @noindent
8318 In standard Ada 95, the @code{Rotate_Left} function is available only
8319 for the predefined modular types in package @code{Interfaces}.  However, in
8320 GNAT it is possible to define a Rotate_Left function for a user
8321 defined modular type or any signed integer type as in this example:
8322
8323 @smallexample @c ada
8324    function Shift_Left
8325      (Value  : My_Modular_Type;
8326       Amount : Natural)
8327       return   My_Modular_Type;
8328 @end smallexample
8329
8330 @noindent
8331 The requirements are that the profile be exactly as in the example
8332 above.  The only modifications allowed are in the formal parameter
8333 names, and in the type of @code{Value} and the return type, which
8334 must be the same, and must be either a signed integer type, or
8335 a modular integer type with a binary modulus, and the size must
8336 be 8.  16, 32 or 64 bits.
8337
8338 @node Rotate_Right
8339 @section Rotate_Right
8340 @cindex Rotate_Right
8341 @noindent
8342 A @code{Rotate_Right} function can be defined for any user defined
8343 binary modular integer type, or signed integer type, as described
8344 above for @code{Rotate_Left}.
8345
8346 @node Shift_Left
8347 @section Shift_Left
8348 @cindex Shift_Left
8349 @noindent
8350 A @code{Shift_Left} function can be defined for any user defined
8351 binary modular integer type, or signed integer type, as described
8352 above for @code{Rotate_Left}.
8353
8354 @node Shift_Right
8355 @section Shift_Right
8356 @cindex Shift_Right
8357 @noindent
8358 A @code{Shift_Right} function can be defined for any user defined
8359 binary modular integer type, or signed integer type, as described
8360 above for @code{Rotate_Left}.
8361
8362 @node Shift_Right_Arithmetic
8363 @section Shift_Right_Arithmetic
8364 @cindex Shift_Right_Arithmetic
8365 @noindent
8366 A @code{Shift_Right_Arithmetic} function can be defined for any user
8367 defined binary modular integer type, or signed integer type, as described
8368 above for @code{Rotate_Left}.
8369
8370 @node Source_Location
8371 @section Source_Location
8372 @cindex Source_Location
8373 @noindent
8374 This intrinsic subprogram is used in the implementation of the
8375 library routine @code{GNAT.Source_Info}.  The only useful use of the
8376 intrinsic import in this case is the one in this unit, so an
8377 application program should simply call the function
8378 @code{GNAT.Source_Info.Source_Location} to obtain the current
8379 source file location.
8380
8381 @node Representation Clauses and Pragmas
8382 @chapter Representation Clauses and Pragmas
8383 @cindex Representation Clauses
8384
8385 @menu
8386 * Alignment Clauses::
8387 * Size Clauses::
8388 * Storage_Size Clauses::
8389 * Size of Variant Record Objects::
8390 * Biased Representation ::
8391 * Value_Size and Object_Size Clauses::
8392 * Component_Size Clauses::
8393 * Bit_Order Clauses::
8394 * Effect of Bit_Order on Byte Ordering::
8395 * Pragma Pack for Arrays::
8396 * Pragma Pack for Records::
8397 * Record Representation Clauses::
8398 * Enumeration Clauses::
8399 * Address Clauses::
8400 * Effect of Convention on Representation::
8401 * Determining the Representations chosen by GNAT::
8402 @end menu
8403
8404 @noindent
8405 @cindex Representation Clause
8406 @cindex Representation Pragma
8407 @cindex Pragma, representation
8408 This section describes the representation clauses accepted by GNAT, and
8409 their effect on the representation of corresponding data objects.
8410
8411 GNAT fully implements Annex C (Systems Programming).  This means that all
8412 the implementation advice sections in chapter 13 are fully implemented.
8413 However, these sections only require a minimal level of support for
8414 representation clauses.  GNAT provides much more extensive capabilities,
8415 and this section describes the additional capabilities provided.
8416
8417 @node Alignment Clauses
8418 @section Alignment Clauses
8419 @cindex Alignment Clause
8420
8421 @noindent
8422 GNAT requires that all alignment clauses specify a power of 2, and all
8423 default alignments are always a power of 2.  The default alignment
8424 values are as follows:
8425
8426 @itemize @bullet
8427 @item @emph{Primitive Types}.
8428 For primitive types, the alignment is the minimum of the actual size of
8429 objects of the type divided by @code{Storage_Unit},
8430 and the maximum alignment supported by the target.
8431 (This maximum alignment is given by the GNAT-specific attribute
8432 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8433 @cindex @code{Maximum_Alignment} attribute
8434 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8435 default alignment will be 8 on any target that supports alignments
8436 this large, but on some targets, the maximum alignment may be smaller
8437 than 8, in which case objects of type @code{Long_Float} will be maximally
8438 aligned.
8439
8440 @item @emph{Arrays}.
8441 For arrays, the alignment is equal to the alignment of the component type
8442 for the normal case where no packing or component size is given.  If the
8443 array is packed, and the packing is effective (see separate section on
8444 packed arrays), then the alignment will be one for long packed arrays,
8445 or arrays whose length is not known at compile time.  For short packed
8446 arrays, which are handled internally as modular types, the alignment
8447 will be as described for primitive types, e.g.@: a packed array of length
8448 31 bits will have an object size of four bytes, and an alignment of 4.
8449
8450 @item @emph{Records}.
8451 For the normal non-packed case, the alignment of a record is equal to
8452 the maximum alignment of any of its components.  For tagged records, this
8453 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8454 used and all fields are packable (see separate section on pragma @code{Pack}),
8455 then the resulting alignment is 1.
8456
8457 A special case is when:
8458 @itemize @bullet
8459 @item
8460 the size of the record is given explicitly, or a
8461 full record representation clause is given, and
8462 @item
8463 the size of the record is 2, 4, or 8 bytes.
8464 @end itemize
8465 @noindent
8466 In this case, an alignment is chosen to match the
8467 size of the record. For example, if we have:
8468
8469 @smallexample @c ada
8470    type Small is record
8471       A, B : Character;
8472    end record;
8473    for Small'Size use 16;
8474 @end smallexample
8475
8476 @noindent
8477 then the default alignment of the record type @code{Small} is 2, not 1. This
8478 leads to more efficient code when the record is treated as a unit, and also
8479 allows the type to specified as @code{Atomic} on architectures requiring
8480 strict alignment.
8481
8482 @end itemize
8483
8484 @noindent
8485 An alignment clause may
8486 always specify a larger alignment than the default value, up to some
8487 maximum value dependent on the target (obtainable by using the
8488 attribute reference @code{Standard'Maximum_Alignment}).
8489 The only case where
8490 it is permissible to specify a smaller alignment than the default value
8491 is for a record with a record representation clause.
8492 In this case, packable fields for which a component clause is
8493 given still result in a default alignment corresponding to the original
8494 type, but this may be overridden, since these components in fact only
8495 require an alignment of one byte.  For example, given
8496
8497 @smallexample @c ada
8498   type V is record
8499      A : Integer;
8500   end record;
8501
8502   for V use record
8503      A at 0  range 0 .. 31;
8504   end record;
8505
8506   for V'alignment use 1;
8507 @end smallexample
8508
8509 @noindent
8510 @cindex Alignment, default
8511 The default alignment for the type @code{V} is 4, as a result of the
8512 Integer field in the record, but since this field is placed with a
8513 component clause, it is permissible, as shown, to override the default
8514 alignment of the record with a smaller value.
8515
8516 @node Size Clauses
8517 @section Size Clauses
8518 @cindex Size Clause
8519
8520 @noindent
8521 The default size for a type @code{T} is obtainable through the
8522 language-defined attribute @code{T'Size} and also through the
8523 equivalent GNAT-defined attribute @code{T'Value_Size}.
8524 For objects of type @code{T}, GNAT will generally increase the type size
8525 so that the object size (obtainable through the GNAT-defined attribute
8526 @code{T'Object_Size})
8527 is a multiple of @code{T'Alignment * Storage_Unit}.
8528 For example
8529
8530 @smallexample @c ada
8531    type Smallint is range 1 .. 6;
8532
8533    type Rec is record
8534       Y1 : integer;
8535       Y2 : boolean;
8536    end record;
8537 @end smallexample
8538
8539 @noindent
8540 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8541 as specified by the RM rules,
8542 but objects of this type will have a size of 8
8543 (@code{Smallint'Object_Size} = 8),
8544 since objects by default occupy an integral number
8545 of storage units.  On some targets, notably older
8546 versions of the Digital Alpha, the size of stand
8547 alone objects of this type may be 32, reflecting
8548 the inability of the hardware to do byte load/stores.
8549
8550 Similarly, the size of type @code{Rec} is 40 bits
8551 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8552 the alignment is 4, so objects of this type will have
8553 their size increased to 64 bits so that it is a multiple
8554 of the alignment (in bits).  This decision is
8555 in accordance with the specific Implementation Advice in RM 13.3(43):
8556
8557 @quotation
8558 A @code{Size} clause should be supported for an object if the specified
8559 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8560 to a size in storage elements that is a multiple of the object's
8561 @code{Alignment} (if the @code{Alignment} is nonzero).
8562 @end quotation
8563
8564 @noindent
8565 An explicit size clause may be used to override the default size by
8566 increasing it.  For example, if we have:
8567
8568 @smallexample @c ada
8569    type My_Boolean is new Boolean;
8570    for My_Boolean'Size use 32;
8571 @end smallexample
8572
8573 @noindent
8574 then values of this type will always be 32 bits long.  In the case of
8575 discrete types, the size can be increased up to 64 bits, with the effect
8576 that the entire specified field is used to hold the value, sign- or
8577 zero-extended as appropriate.  If more than 64 bits is specified, then
8578 padding space is allocated after the value, and a warning is issued that
8579 there are unused bits.
8580
8581 Similarly the size of records and arrays may be increased, and the effect
8582 is to add padding bits after the value.  This also causes a warning message
8583 to be generated.
8584
8585 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8586 Size in bits, this corresponds to an object of size 256 megabytes (minus
8587 one).  This limitation is true on all targets.  The reason for this
8588 limitation is that it improves the quality of the code in many cases
8589 if it is known that a Size value can be accommodated in an object of
8590 type Integer.
8591
8592 @node Storage_Size Clauses
8593 @section Storage_Size Clauses
8594 @cindex Storage_Size Clause
8595
8596 @noindent
8597 For tasks, the @code{Storage_Size} clause specifies the amount of space
8598 to be allocated for the task stack.  This cannot be extended, and if the
8599 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8600 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8601 or a @code{Storage_Size} pragma in the task definition to set the
8602 appropriate required size.  A useful technique is to include in every
8603 task definition a pragma of the form:
8604
8605 @smallexample @c ada
8606    pragma Storage_Size (Default_Stack_Size);
8607 @end smallexample
8608
8609 @noindent
8610 Then @code{Default_Stack_Size} can be defined in a global package, and
8611 modified as required.  Any tasks requiring stack sizes different from the
8612 default can have an appropriate alternative reference in the pragma.
8613
8614 For access types, the @code{Storage_Size} clause specifies the maximum
8615 space available for allocation of objects of the type.  If this space is
8616 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8617 In the case where the access type is declared local to a subprogram, the
8618 use of a @code{Storage_Size} clause triggers automatic use of a special
8619 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8620 space for the pool is automatically reclaimed on exit from the scope in
8621 which the type is declared.
8622
8623 A special case recognized by the compiler is the specification of a
8624 @code{Storage_Size} of zero for an access type.  This means that no
8625 items can be allocated from the pool, and this is recognized at compile
8626 time, and all the overhead normally associated with maintaining a fixed
8627 size storage pool is eliminated.  Consider the following example:
8628
8629 @smallexample @c ada
8630    procedure p is
8631       type R is array (Natural) of Character;
8632       type P is access all R;
8633       for P'Storage_Size use 0;
8634       --  Above access type intended only for interfacing purposes
8635
8636       y : P;
8637
8638       procedure g (m : P);
8639       pragma Import (C, g);
8640
8641       --  @dots{}
8642
8643    begin
8644       --  @dots{}
8645       y := new R;
8646    end;
8647 @end smallexample
8648
8649 @noindent
8650 As indicated in this example, these dummy storage pools are often useful in
8651 connection with interfacing where no object will ever be allocated.  If you
8652 compile the above example, you get the warning:
8653
8654 @smallexample
8655    p.adb:16:09: warning: allocation from empty storage pool
8656    p.adb:16:09: warning: Storage_Error will be raised at run time
8657 @end smallexample
8658
8659 @noindent
8660 Of course in practice, there will not be any explicit allocators in the
8661 case of such an access declaration.
8662
8663 @node Size of Variant Record Objects
8664 @section Size of Variant Record Objects
8665 @cindex Size, variant record objects
8666 @cindex Variant record objects, size
8667
8668 @noindent
8669 In the case of variant record objects, there is a question whether Size gives
8670 information about a particular variant, or the maximum size required
8671 for any variant.  Consider the following program
8672
8673 @smallexample @c ada
8674 with Text_IO; use Text_IO;
8675 procedure q is
8676    type R1 (A : Boolean := False) is record
8677      case A is
8678        when True  => X : Character;
8679        when False => null;
8680      end case;
8681    end record;
8682
8683    V1 : R1 (False);
8684    V2 : R1;
8685
8686 begin
8687    Put_Line (Integer'Image (V1'Size));
8688    Put_Line (Integer'Image (V2'Size));
8689 end q;
8690 @end smallexample
8691
8692 @noindent
8693 Here we are dealing with a variant record, where the True variant
8694 requires 16 bits, and the False variant requires 8 bits.
8695 In the above example, both V1 and V2 contain the False variant,
8696 which is only 8 bits long.  However, the result of running the
8697 program is:
8698
8699 @smallexample
8700 8
8701 16
8702 @end smallexample
8703
8704 @noindent
8705 The reason for the difference here is that the discriminant value of
8706 V1 is fixed, and will always be False.  It is not possible to assign
8707 a True variant value to V1, therefore 8 bits is sufficient.  On the
8708 other hand, in the case of V2, the initial discriminant value is
8709 False (from the default), but it is possible to assign a True
8710 variant value to V2, therefore 16 bits must be allocated for V2
8711 in the general case, even fewer bits may be needed at any particular
8712 point during the program execution.
8713
8714 As can be seen from the output of this program, the @code{'Size}
8715 attribute applied to such an object in GNAT gives the actual allocated
8716 size of the variable, which is the largest size of any of the variants.
8717 The Ada Reference Manual is not completely clear on what choice should
8718 be made here, but the GNAT behavior seems most consistent with the
8719 language in the RM@.
8720
8721 In some cases, it may be desirable to obtain the size of the current
8722 variant, rather than the size of the largest variant.  This can be
8723 achieved in GNAT by making use of the fact that in the case of a
8724 subprogram parameter, GNAT does indeed return the size of the current
8725 variant (because a subprogram has no way of knowing how much space
8726 is actually allocated for the actual).
8727
8728 Consider the following modified version of the above program:
8729
8730 @smallexample @c ada
8731 with Text_IO; use Text_IO;
8732 procedure q is
8733    type R1 (A : Boolean := False) is record
8734      case A is
8735        when True  => X : Character;
8736        when False => null;
8737      end case;
8738    end record;
8739
8740    V2 : R1;
8741
8742    function Size (V : R1) return Integer is
8743    begin
8744       return V'Size;
8745    end Size;
8746
8747 begin
8748    Put_Line (Integer'Image (V2'Size));
8749    Put_Line (Integer'IMage (Size (V2)));
8750    V2 := (True, 'x');
8751    Put_Line (Integer'Image (V2'Size));
8752    Put_Line (Integer'IMage (Size (V2)));
8753 end q;
8754 @end smallexample
8755
8756 @noindent
8757 The output from this program is
8758
8759 @smallexample
8760 16
8761 8
8762 16
8763 16
8764 @end smallexample
8765
8766 @noindent
8767 Here we see that while the @code{'Size} attribute always returns
8768 the maximum size, regardless of the current variant value, the
8769 @code{Size} function does indeed return the size of the current
8770 variant value.
8771
8772 @node Biased Representation
8773 @section Biased Representation
8774 @cindex Size for biased representation
8775 @cindex Biased representation
8776
8777 @noindent
8778 In the case of scalars with a range starting at other than zero, it is
8779 possible in some cases to specify a size smaller than the default minimum
8780 value, and in such cases, GNAT uses an unsigned biased representation,
8781 in which zero is used to represent the lower bound, and successive values
8782 represent successive values of the type.
8783
8784 For example, suppose we have the declaration:
8785
8786 @smallexample @c ada
8787    type Small is range -7 .. -4;
8788    for Small'Size use 2;
8789 @end smallexample
8790
8791 @noindent
8792 Although the default size of type @code{Small} is 4, the @code{Size}
8793 clause is accepted by GNAT and results in the following representation
8794 scheme:
8795
8796 @smallexample
8797   -7 is represented as 2#00#
8798   -6 is represented as 2#01#
8799   -5 is represented as 2#10#
8800   -4 is represented as 2#11#
8801 @end smallexample
8802
8803 @noindent
8804 Biased representation is only used if the specified @code{Size} clause
8805 cannot be accepted in any other manner.  These reduced sizes that force
8806 biased representation can be used for all discrete types except for
8807 enumeration types for which a representation clause is given.
8808
8809 @node Value_Size and Object_Size Clauses
8810 @section Value_Size and Object_Size Clauses
8811 @findex Value_Size
8812 @findex Object_Size
8813 @cindex Size, of objects
8814
8815 @noindent
8816 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8817 required to hold values of type @code{T}.  Although this interpretation was
8818 allowed in Ada 83, it was not required, and this requirement in practice
8819 can cause some significant difficulties.  For example, in most Ada 83
8820 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8821 @code{Natural'Size} is
8822 typically 31.  This means that code may change in behavior when moving
8823 from Ada 83 to Ada 95.  For example, consider:
8824
8825 @smallexample @c ada
8826    type Rec is record;
8827       A : Natural;
8828       B : Natural;
8829    end record;
8830
8831    for Rec use record
8832       at 0  range 0 .. Natural'Size - 1;
8833       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8834    end record;
8835 @end smallexample
8836
8837 @noindent
8838 In the above code, since the typical size of @code{Natural} objects
8839 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8840 unexpected inefficient packing in Ada 95, and in general there are
8841 cases where the fact that the object size can exceed the
8842 size of the type causes surprises.
8843
8844 To help get around this problem GNAT provides two implementation
8845 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8846 applied to a type, these attributes yield the size of the type
8847 (corresponding to the RM defined size attribute), and the size of
8848 objects of the type respectively.
8849
8850 The @code{Object_Size} is used for determining the default size of
8851 objects and components.  This size value can be referred to using the
8852 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8853 the basis of the determination of the size.  The backend is free to
8854 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8855 character might be stored in 32 bits on a machine with no efficient
8856 byte access instructions such as the Alpha.
8857
8858 The default rules for the value of @code{Object_Size} for
8859 discrete types are as follows:
8860
8861 @itemize @bullet
8862 @item
8863 The @code{Object_Size} for base subtypes reflect the natural hardware
8864 size in bits (run the compiler with @option{-gnatS} to find those values
8865 for numeric types). Enumeration types and fixed-point base subtypes have
8866 8, 16, 32 or 64 bits for this size, depending on the range of values
8867 to be stored.
8868
8869 @item
8870 The @code{Object_Size} of a subtype is the same as the
8871 @code{Object_Size} of
8872 the type from which it is obtained.
8873
8874 @item
8875 The @code{Object_Size} of a derived base type is copied from the parent
8876 base type, and the @code{Object_Size} of a derived first subtype is copied
8877 from the parent first subtype.
8878 @end itemize
8879
8880 @noindent
8881 The @code{Value_Size} attribute
8882 is the (minimum) number of bits required to store a value
8883 of the type.
8884 This value is used to determine how tightly to pack
8885 records or arrays with components of this type, and also affects
8886 the semantics of unchecked conversion (unchecked conversions where
8887 the @code{Value_Size} values differ generate a warning, and are potentially
8888 target dependent).
8889
8890 The default rules for the value of @code{Value_Size} are as follows:
8891
8892 @itemize @bullet
8893 @item
8894 The @code{Value_Size} for a base subtype is the minimum number of bits
8895 required to store all values of the type (including the sign bit
8896 only if negative values are possible).
8897
8898 @item
8899 If a subtype statically matches the first subtype of a given type, then it has
8900 by default the same @code{Value_Size} as the first subtype.  This is a
8901 consequence of RM 13.1(14) (``if two subtypes statically match,
8902 then their subtype-specific aspects are the same''.)
8903
8904 @item
8905 All other subtypes have a @code{Value_Size} corresponding to the minimum
8906 number of bits required to store all values of the subtype.  For
8907 dynamic bounds, it is assumed that the value can range down or up
8908 to the corresponding bound of the ancestor
8909 @end itemize
8910
8911 @noindent
8912 The RM defined attribute @code{Size} corresponds to the
8913 @code{Value_Size} attribute.
8914
8915 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8916 the @code{Value_Size} of
8917 the first-named subtype to the given value, and the
8918 @code{Object_Size} of this first-named subtype to the given value padded up
8919 to an appropriate boundary.  It is a consequence of the default rules
8920 above that this @code{Object_Size} will apply to all further subtypes.  On the
8921 other hand, @code{Value_Size} is affected only for the first subtype, any
8922 dynamic subtypes obtained from it directly, and any statically matching
8923 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8924
8925 @code{Value_Size} and
8926 @code{Object_Size} may be explicitly set for any subtype using
8927 an attribute definition clause.  Note that the use of these attributes
8928 can cause the RM 13.1(14) rule to be violated.  If two access types
8929 reference aliased objects whose subtypes have differing @code{Object_Size}
8930 values as a result of explicit attribute definition clauses, then it
8931 is erroneous to convert from one access subtype to the other.
8932
8933 At the implementation level, Esize stores the Object_Size and the
8934 RM_Size field stores the @code{Value_Size} (and hence the value of the
8935 @code{Size} attribute,
8936 which, as noted above, is equivalent to @code{Value_Size}).
8937
8938 To get a feel for the difference, consider the following examples (note
8939 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8940
8941 @smallexample
8942                                        Object_Size     Value_Size
8943
8944 type x1 is range 0 .. 5;                    8               3
8945
8946 type x2 is range 0 .. 5;
8947 for x2'size use 12;                        16              12
8948
8949 subtype x3 is x2 range 0 .. 3;             16               2
8950
8951 subtype x4 is x2'base range 0 .. 10;        8               4
8952
8953 subtype x5 is x2 range 0 .. dynamic;       16               3*
8954
8955 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8956
8957 @end smallexample
8958
8959 @noindent
8960 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8961 but it seems in the spirit of the RM rules to allocate the minimum number
8962 of bits (here 3, given the range for @code{x2})
8963 known to be large enough to hold the given range of values.
8964
8965 So far, so good, but GNAT has to obey the RM rules, so the question is
8966 under what conditions must the RM @code{Size} be used.
8967 The following is a list
8968 of the occasions on which the RM @code{Size} must be used:
8969
8970 @itemize @bullet
8971 @item
8972 Component size for packed arrays or records
8973
8974 @item
8975 Value of the attribute @code{Size} for a type
8976
8977 @item
8978 Warning about sizes not matching for unchecked conversion
8979 @end itemize
8980
8981 @noindent
8982 For record types, the @code{Object_Size} is always a multiple of the
8983 alignment of the type (this is true for all types). In some cases the
8984 @code{Value_Size} can be smaller. Consider:
8985
8986 @smallexample
8987    type R is record
8988      X : Integer;
8989      Y : Character;
8990    end record;
8991 @end smallexample
8992
8993 @noindent
8994 On a typical 32-bit architecture, the X component will be four bytes, and
8995 require four-byte alignment, and the Y component will be one byte. In this
8996 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8997 required to store a value of this type, and for example, it is permissible
8998 to have a component of type R in an outer record whose component size is
8999 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9000 since it must be rounded up so that this value is a multiple of the
9001 alignment (4 bytes = 32 bits).
9002
9003 @noindent
9004 For all other types, the @code{Object_Size}
9005 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9006 Only @code{Size} may be specified for such types.
9007
9008 @node Component_Size Clauses
9009 @section Component_Size Clauses
9010 @cindex Component_Size Clause
9011
9012 @noindent
9013 Normally, the value specified in a component clause must be consistent
9014 with the subtype of the array component with regard to size and alignment.
9015 In other words, the value specified must be at least equal to the size
9016 of this subtype, and must be a multiple of the alignment value.
9017
9018 In addition, component size clauses are allowed which cause the array
9019 to be packed, by specifying a smaller value.  The cases in which this
9020 is allowed are for component size values in the range 1 through 63.  The value
9021 specified must not be smaller than the Size of the subtype.  GNAT will
9022 accurately honor all packing requests in this range.  For example, if
9023 we have:
9024
9025 @smallexample @c ada
9026 type r is array (1 .. 8) of Natural;
9027 for r'Component_Size use 31;
9028 @end smallexample
9029
9030 @noindent
9031 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9032 Of course access to the components of such an array is considerably
9033 less efficient than if the natural component size of 32 is used.
9034
9035 @node Bit_Order Clauses
9036 @section Bit_Order Clauses
9037 @cindex Bit_Order Clause
9038 @cindex bit ordering
9039 @cindex ordering, of bits
9040
9041 @noindent
9042 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9043 attribute.  The specification may either correspond to the default bit
9044 order for the target, in which case the specification has no effect and
9045 places no additional restrictions, or it may be for the non-standard
9046 setting (that is the opposite of the default).
9047
9048 In the case where the non-standard value is specified, the effect is
9049 to renumber bits within each byte, but the ordering of bytes is not
9050 affected.  There are certain
9051 restrictions placed on component clauses as follows:
9052
9053 @itemize @bullet
9054
9055 @item Components fitting within a single storage unit.
9056 @noindent
9057 These are unrestricted, and the effect is merely to renumber bits.  For
9058 example if we are on a little-endian machine with @code{Low_Order_First}
9059 being the default, then the following two declarations have exactly
9060 the same effect:
9061
9062 @smallexample @c ada
9063    type R1 is record
9064       A : Boolean;
9065       B : Integer range 1 .. 120;
9066    end record;
9067
9068    for R1 use record
9069       A at 0 range 0 .. 0;
9070       B at 0 range 1 .. 7;
9071    end record;
9072
9073    type R2 is record
9074       A : Boolean;
9075       B : Integer range 1 .. 120;
9076    end record;
9077
9078    for R2'Bit_Order use High_Order_First;
9079
9080    for R2 use record
9081       A at 0 range 7 .. 7;
9082       B at 0 range 0 .. 6;
9083    end record;
9084 @end smallexample
9085
9086 @noindent
9087 The useful application here is to write the second declaration with the
9088 @code{Bit_Order} attribute definition clause, and know that it will be treated
9089 the same, regardless of whether the target is little-endian or big-endian.
9090
9091 @item Components occupying an integral number of bytes.
9092 @noindent
9093 These are components that exactly fit in two or more bytes.  Such component
9094 declarations are allowed, but have no effect, since it is important to realize
9095 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9096 In particular, the following attempt at getting an endian-independent integer
9097 does not work:
9098
9099 @smallexample @c ada
9100    type R2 is record
9101       A : Integer;
9102    end record;
9103
9104    for R2'Bit_Order use High_Order_First;
9105
9106    for R2 use record
9107       A at 0 range 0 .. 31;
9108    end record;
9109 @end smallexample
9110
9111 @noindent
9112 This declaration will result in a little-endian integer on a
9113 little-endian machine, and a big-endian integer on a big-endian machine.
9114 If byte flipping is required for interoperability between big- and
9115 little-endian machines, this must be explicitly programmed.  This capability
9116 is not provided by @code{Bit_Order}.
9117
9118 @item Components that are positioned across byte boundaries
9119 @noindent
9120 but do not occupy an integral number of bytes.  Given that bytes are not
9121 reordered, such fields would occupy a non-contiguous sequence of bits
9122 in memory, requiring non-trivial code to reassemble.  They are for this
9123 reason not permitted, and any component clause specifying such a layout
9124 will be flagged as illegal by GNAT@.
9125
9126 @end itemize
9127
9128 @noindent
9129 Since the misconception that Bit_Order automatically deals with all
9130 endian-related incompatibilities is a common one, the specification of
9131 a component field that is an integral number of bytes will always
9132 generate a warning.  This warning may be suppressed using
9133 @code{pragma Suppress} if desired.  The following section contains additional
9134 details regarding the issue of byte ordering.
9135
9136 @node Effect of Bit_Order on Byte Ordering
9137 @section Effect of Bit_Order on Byte Ordering
9138 @cindex byte ordering
9139 @cindex ordering, of bytes
9140
9141 @noindent
9142 In this section we will review the effect of the @code{Bit_Order} attribute
9143 definition clause on byte ordering.  Briefly, it has no effect at all, but
9144 a detailed example will be helpful.  Before giving this
9145 example, let us review the precise
9146 definition of the effect of defining @code{Bit_Order}.  The effect of a
9147 non-standard bit order is described in section 15.5.3 of the Ada
9148 Reference Manual:
9149
9150 @quotation
9151 2   A bit ordering is a method of interpreting the meaning of
9152 the storage place attributes.
9153 @end quotation
9154
9155 @noindent
9156 To understand the precise definition of storage place attributes in
9157 this context, we visit section 13.5.1 of the manual:
9158
9159 @quotation
9160 13   A record_representation_clause (without the mod_clause)
9161 specifies the layout.  The storage place attributes (see 13.5.2)
9162 are taken from the values of the position, first_bit, and last_bit
9163 expressions after normalizing those values so that first_bit is
9164 less than Storage_Unit.
9165 @end quotation
9166
9167 @noindent
9168 The critical point here is that storage places are taken from
9169 the values after normalization, not before.  So the @code{Bit_Order}
9170 interpretation applies to normalized values.  The interpretation
9171 is described in the later part of the 15.5.3 paragraph:
9172
9173 @quotation
9174 2   A bit ordering is a method of interpreting the meaning of
9175 the storage place attributes.  High_Order_First (known in the
9176 vernacular as ``big endian'') means that the first bit of a
9177 storage element (bit 0) is the most significant bit (interpreting
9178 the sequence of bits that represent a component as an unsigned
9179 integer value).  Low_Order_First (known in the vernacular as
9180 ``little endian'') means the opposite: the first bit is the
9181 least significant.
9182 @end quotation
9183
9184 @noindent
9185 Note that the numbering is with respect to the bits of a storage
9186 unit.  In other words, the specification affects only the numbering
9187 of bits within a single storage unit.
9188
9189 We can make the effect clearer by giving an example.
9190
9191 Suppose that we have an external device which presents two bytes, the first
9192 byte presented, which is the first (low addressed byte) of the two byte
9193 record is called Master, and the second byte is called Slave.
9194
9195 The left most (most significant bit is called Control for each byte, and
9196 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9197 (least significant) bit.
9198
9199 On a big-endian machine, we can write the following representation clause
9200
9201 @smallexample @c ada
9202    type Data is record
9203       Master_Control : Bit;
9204       Master_V1      : Bit;
9205       Master_V2      : Bit;
9206       Master_V3      : Bit;
9207       Master_V4      : Bit;
9208       Master_V5      : Bit;
9209       Master_V6      : Bit;
9210       Master_V7      : Bit;
9211       Slave_Control  : Bit;
9212       Slave_V1       : Bit;
9213       Slave_V2       : Bit;
9214       Slave_V3       : Bit;
9215       Slave_V4       : Bit;
9216       Slave_V5       : Bit;
9217       Slave_V6       : Bit;
9218       Slave_V7       : Bit;
9219    end record;
9220
9221    for Data use record
9222       Master_Control at 0 range 0 .. 0;
9223       Master_V1      at 0 range 1 .. 1;
9224       Master_V2      at 0 range 2 .. 2;
9225       Master_V3      at 0 range 3 .. 3;
9226       Master_V4      at 0 range 4 .. 4;
9227       Master_V5      at 0 range 5 .. 5;
9228       Master_V6      at 0 range 6 .. 6;
9229       Master_V7      at 0 range 7 .. 7;
9230       Slave_Control  at 1 range 0 .. 0;
9231       Slave_V1       at 1 range 1 .. 1;
9232       Slave_V2       at 1 range 2 .. 2;
9233       Slave_V3       at 1 range 3 .. 3;
9234       Slave_V4       at 1 range 4 .. 4;
9235       Slave_V5       at 1 range 5 .. 5;
9236       Slave_V6       at 1 range 6 .. 6;
9237       Slave_V7       at 1 range 7 .. 7;
9238    end record;
9239 @end smallexample
9240
9241 @noindent
9242 Now if we move this to a little endian machine, then the bit ordering within
9243 the byte is backwards, so we have to rewrite the record rep clause as:
9244
9245 @smallexample @c ada
9246    for Data use record
9247       Master_Control at 0 range 7 .. 7;
9248       Master_V1      at 0 range 6 .. 6;
9249       Master_V2      at 0 range 5 .. 5;
9250       Master_V3      at 0 range 4 .. 4;
9251       Master_V4      at 0 range 3 .. 3;
9252       Master_V5      at 0 range 2 .. 2;
9253       Master_V6      at 0 range 1 .. 1;
9254       Master_V7      at 0 range 0 .. 0;
9255       Slave_Control  at 1 range 7 .. 7;
9256       Slave_V1       at 1 range 6 .. 6;
9257       Slave_V2       at 1 range 5 .. 5;
9258       Slave_V3       at 1 range 4 .. 4;
9259       Slave_V4       at 1 range 3 .. 3;
9260       Slave_V5       at 1 range 2 .. 2;
9261       Slave_V6       at 1 range 1 .. 1;
9262       Slave_V7       at 1 range 0 .. 0;
9263    end record;
9264 @end smallexample
9265
9266 @noindent
9267 It is a nuisance to have to rewrite the clause, especially if
9268 the code has to be maintained on both machines.  However,
9269 this is a case that we can handle with the
9270 @code{Bit_Order} attribute if it is implemented.
9271 Note that the implementation is not required on byte addressed
9272 machines, but it is indeed implemented in GNAT.
9273 This means that we can simply use the
9274 first record clause, together with the declaration
9275
9276 @smallexample @c ada
9277    for Data'Bit_Order use High_Order_First;
9278 @end smallexample
9279
9280 @noindent
9281 and the effect is what is desired, namely the layout is exactly the same,
9282 independent of whether the code is compiled on a big-endian or little-endian
9283 machine.
9284
9285 The important point to understand is that byte ordering is not affected.
9286 A @code{Bit_Order} attribute definition never affects which byte a field
9287 ends up in, only where it ends up in that byte.
9288 To make this clear, let us rewrite the record rep clause of the previous
9289 example as:
9290
9291 @smallexample @c ada
9292    for Data'Bit_Order use High_Order_First;
9293    for Data use record
9294       Master_Control at 0 range  0 .. 0;
9295       Master_V1      at 0 range  1 .. 1;
9296       Master_V2      at 0 range  2 .. 2;
9297       Master_V3      at 0 range  3 .. 3;
9298       Master_V4      at 0 range  4 .. 4;
9299       Master_V5      at 0 range  5 .. 5;
9300       Master_V6      at 0 range  6 .. 6;
9301       Master_V7      at 0 range  7 .. 7;
9302       Slave_Control  at 0 range  8 .. 8;
9303       Slave_V1       at 0 range  9 .. 9;
9304       Slave_V2       at 0 range 10 .. 10;
9305       Slave_V3       at 0 range 11 .. 11;
9306       Slave_V4       at 0 range 12 .. 12;
9307       Slave_V5       at 0 range 13 .. 13;
9308       Slave_V6       at 0 range 14 .. 14;
9309       Slave_V7       at 0 range 15 .. 15;
9310    end record;
9311 @end smallexample
9312
9313 @noindent
9314 This is exactly equivalent to saying (a repeat of the first example):
9315
9316 @smallexample @c ada
9317    for Data'Bit_Order use High_Order_First;
9318    for Data use record
9319       Master_Control at 0 range 0 .. 0;
9320       Master_V1      at 0 range 1 .. 1;
9321       Master_V2      at 0 range 2 .. 2;
9322       Master_V3      at 0 range 3 .. 3;
9323       Master_V4      at 0 range 4 .. 4;
9324       Master_V5      at 0 range 5 .. 5;
9325       Master_V6      at 0 range 6 .. 6;
9326       Master_V7      at 0 range 7 .. 7;
9327       Slave_Control  at 1 range 0 .. 0;
9328       Slave_V1       at 1 range 1 .. 1;
9329       Slave_V2       at 1 range 2 .. 2;
9330       Slave_V3       at 1 range 3 .. 3;
9331       Slave_V4       at 1 range 4 .. 4;
9332       Slave_V5       at 1 range 5 .. 5;
9333       Slave_V6       at 1 range 6 .. 6;
9334       Slave_V7       at 1 range 7 .. 7;
9335    end record;
9336 @end smallexample
9337
9338 @noindent
9339 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9340 field.  The storage place attributes are obtained by normalizing the
9341 values given so that the @code{First_Bit} value is less than 8.  After
9342 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9343 we specified in the other case.
9344
9345 Now one might expect that the @code{Bit_Order} attribute might affect
9346 bit numbering within the entire record component (two bytes in this
9347 case, thus affecting which byte fields end up in), but that is not
9348 the way this feature is defined, it only affects numbering of bits,
9349 not which byte they end up in.
9350
9351 Consequently it never makes sense to specify a starting bit number
9352 greater than 7 (for a byte addressable field) if an attribute
9353 definition for @code{Bit_Order} has been given, and indeed it
9354 may be actively confusing to specify such a value, so the compiler
9355 generates a warning for such usage.
9356
9357 If you do need to control byte ordering then appropriate conditional
9358 values must be used.  If in our example, the slave byte came first on
9359 some machines we might write:
9360
9361 @smallexample @c ada
9362    Master_Byte_First constant Boolean := @dots{};
9363
9364    Master_Byte : constant Natural :=
9365                    1 - Boolean'Pos (Master_Byte_First);
9366    Slave_Byte  : constant Natural :=
9367                    Boolean'Pos (Master_Byte_First);
9368
9369    for Data'Bit_Order use High_Order_First;
9370    for Data use record
9371       Master_Control at Master_Byte range 0 .. 0;
9372       Master_V1      at Master_Byte range 1 .. 1;
9373       Master_V2      at Master_Byte range 2 .. 2;
9374       Master_V3      at Master_Byte range 3 .. 3;
9375       Master_V4      at Master_Byte range 4 .. 4;
9376       Master_V5      at Master_Byte range 5 .. 5;
9377       Master_V6      at Master_Byte range 6 .. 6;
9378       Master_V7      at Master_Byte range 7 .. 7;
9379       Slave_Control  at Slave_Byte  range 0 .. 0;
9380       Slave_V1       at Slave_Byte  range 1 .. 1;
9381       Slave_V2       at Slave_Byte  range 2 .. 2;
9382       Slave_V3       at Slave_Byte  range 3 .. 3;
9383       Slave_V4       at Slave_Byte  range 4 .. 4;
9384       Slave_V5       at Slave_Byte  range 5 .. 5;
9385       Slave_V6       at Slave_Byte  range 6 .. 6;
9386       Slave_V7       at Slave_Byte  range 7 .. 7;
9387    end record;
9388 @end smallexample
9389
9390 @noindent
9391 Now to switch between machines, all that is necessary is
9392 to set the boolean constant @code{Master_Byte_First} in
9393 an appropriate manner.
9394
9395 @node Pragma Pack for Arrays
9396 @section Pragma Pack for Arrays
9397 @cindex Pragma Pack (for arrays)
9398
9399 @noindent
9400 Pragma @code{Pack} applied to an array has no effect unless the component type
9401 is packable.  For a component type to be packable, it must be one of the
9402 following cases:
9403
9404 @itemize @bullet
9405 @item
9406 Any scalar type
9407 @item
9408 Any type whose size is specified with a size clause
9409 @item
9410 Any packed array type with a static size
9411 @end itemize
9412
9413 @noindent
9414 For all these cases, if the component subtype size is in the range
9415 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9416 component size were specified giving the component subtype size.
9417 For example if we have:
9418
9419 @smallexample @c ada
9420    type r is range 0 .. 17;
9421
9422    type ar is array (1 .. 8) of r;
9423    pragma Pack (ar);
9424 @end smallexample
9425
9426 @noindent
9427 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9428 and the size of the array @code{ar} will be exactly 40 bits.
9429
9430 Note that in some cases this rather fierce approach to packing can produce
9431 unexpected effects.  For example, in Ada 95, type Natural typically has a
9432 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9433 close packing, which saves a few bits, but results in far less efficient
9434 access.  Since many other Ada compilers will ignore such a packing request,
9435 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9436 might not be what is intended.  You can easily remove this warning by
9437 using an explicit @code{Component_Size} setting instead, which never generates
9438 a warning, since the intention of the programmer is clear in this case.
9439
9440 GNAT treats packed arrays in one of two ways.  If the size of the array is
9441 known at compile time and is less than 64 bits, then internally the array
9442 is represented as a single modular type, of exactly the appropriate number
9443 of bits.  If the length is greater than 63 bits, or is not known at compile
9444 time, then the packed array is represented as an array of bytes, and the
9445 length is always a multiple of 8 bits.
9446
9447 Note that to represent a packed array as a modular type, the alignment must
9448 be suitable for the modular type involved. For example, on typical machines
9449 a 32-bit packed array will be represented by a 32-bit modular integer with
9450 an alignment of four bytes. If you explicitly override the default alignment
9451 with an alignment clause that is too small, the modular representation
9452 cannot be used. For example, consider the following set of declarations:
9453
9454 @smallexample @c ada
9455    type R is range 1 .. 3;
9456    type S is array (1 .. 31) of R;
9457    for S'Component_Size use 2;
9458    for S'Size use 62;
9459    for S'Alignment use 1;
9460 @end smallexample
9461
9462 @noindent
9463 If the alignment clause were not present, then a 62-bit modular
9464 representation would be chosen (typically with an alignment of 4 or 8
9465 bytes depending on the target). But the default alignment is overridden
9466 with the explicit alignment clause. This means that the modular
9467 representation cannot be used, and instead the array of bytes
9468 representation must be used, meaning that the length must be a multiple
9469 of 8. Thus the above set of declarations will result in a diagnostic
9470 rejecting the size clause and noting that the minimum size allowed is 64.
9471
9472 @cindex Pragma Pack (for type Natural)
9473 @cindex Pragma Pack warning
9474
9475 One special case that is worth noting occurs when the base type of the
9476 component size is 8/16/32 and the subtype is one bit less. Notably this
9477 occurs with subtype @code{Natural}. Consider:
9478
9479 @smallexample @c ada
9480    type Arr is array (1 .. 32) of Natural;
9481    pragma Pack (Arr);
9482 @end smallexample
9483
9484 @noindent
9485 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9486 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9487 Ada 83 compilers did not attempt 31 bit packing.
9488
9489 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9490 does pack 31-bit subtype to 31 bits. This may result in a substantial
9491 unintended performance penalty when porting legacy Ada 83 code. To help
9492 prevent this, GNAT generates a warning in such cases. If you really want 31
9493 bit packing in a case like this, you can set the component size explicitly:
9494
9495 @smallexample @c ada
9496    type Arr is array (1 .. 32) of Natural;
9497    for Arr'Component_Size use 31;
9498 @end smallexample
9499
9500 @noindent
9501 Here 31-bit packing is achieved as required, and no warning is generated,
9502 since in this case the programmer intention is clear.
9503
9504 @node Pragma Pack for Records
9505 @section Pragma Pack for Records
9506 @cindex Pragma Pack (for records)
9507
9508 @noindent
9509 Pragma @code{Pack} applied to a record will pack the components to reduce
9510 wasted space from alignment gaps and by reducing the amount of space
9511 taken by components.  We distinguish between @emph{packable} components and
9512 @emph{non-packable} components.
9513 Components of the following types are considered packable:
9514 @itemize @bullet
9515 @item
9516 All primitive types are packable.
9517
9518 @item
9519 Small packed arrays, whose size does not exceed 64 bits, and where the
9520 size is statically known at compile time, are represented internally
9521 as modular integers, and so they are also packable.
9522
9523 @end itemize
9524
9525 @noindent
9526 All packable components occupy the exact number of bits corresponding to
9527 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9528 can start on an arbitrary bit boundary.
9529
9530 All other types are non-packable, they occupy an integral number of
9531 storage units, and
9532 are placed at a boundary corresponding to their alignment requirements.
9533
9534 For example, consider the record
9535
9536 @smallexample @c ada
9537    type Rb1 is array (1 .. 13) of Boolean;
9538    pragma Pack (rb1);
9539
9540    type Rb2 is array (1 .. 65) of Boolean;
9541    pragma Pack (rb2);
9542
9543    type x2 is record
9544       l1 : Boolean;
9545       l2 : Duration;
9546       l3 : Float;
9547       l4 : Boolean;
9548       l5 : Rb1;
9549       l6 : Rb2;
9550    end record;
9551    pragma Pack (x2);
9552 @end smallexample
9553
9554 @noindent
9555 The representation for the record x2 is as follows:
9556
9557 @smallexample @c ada
9558 for x2'Size use 224;
9559 for x2 use record
9560    l1 at  0 range  0 .. 0;
9561    l2 at  0 range  1 .. 64;
9562    l3 at 12 range  0 .. 31;
9563    l4 at 16 range  0 .. 0;
9564    l5 at 16 range  1 .. 13;
9565    l6 at 18 range  0 .. 71;
9566 end record;
9567 @end smallexample
9568
9569 @noindent
9570 Studying this example, we see that the packable fields @code{l1}
9571 and @code{l2} are
9572 of length equal to their sizes, and placed at specific bit boundaries (and
9573 not byte boundaries) to
9574 eliminate padding.  But @code{l3} is of a non-packable float type, so
9575 it is on the next appropriate alignment boundary.
9576
9577 The next two fields are fully packable, so @code{l4} and @code{l5} are
9578 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9579 array that is longer than 64 bits, so it is itself non-packable.  Thus
9580 the @code{l6} field is aligned to the next byte boundary, and takes an
9581 integral number of bytes, i.e.@: 72 bits.
9582
9583 @node Record Representation Clauses
9584 @section Record Representation Clauses
9585 @cindex Record Representation Clause
9586
9587 @noindent
9588 Record representation clauses may be given for all record types, including
9589 types obtained by record extension.  Component clauses are allowed for any
9590 static component.  The restrictions on component clauses depend on the type
9591 of the component.
9592
9593 @cindex Component Clause
9594 For all components of an elementary type, the only restriction on component
9595 clauses is that the size must be at least the 'Size value of the type
9596 (actually the Value_Size).  There are no restrictions due to alignment,
9597 and such components may freely cross storage boundaries.
9598
9599 Packed arrays with a size up to and including 64 bits are represented
9600 internally using a modular type with the appropriate number of bits, and
9601 thus the same lack of restriction applies.  For example, if you declare:
9602
9603 @smallexample @c ada
9604    type R is array (1 .. 49) of Boolean;
9605    pragma Pack (R);
9606    for R'Size use 49;
9607 @end smallexample
9608
9609 @noindent
9610 then a component clause for a component of type R may start on any
9611 specified bit boundary, and may specify a value of 49 bits or greater.
9612
9613 For packed bit arrays that are longer than 64 bits, there are two
9614 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
9615 including the important case of single bits or boolean values, then
9616 there are no limitations on placement of such components, and they
9617 may start and end at arbitrary bit boundaries.
9618
9619 If the component size is not a power of 2 (e.g. 3 or 5), then
9620 an array of this type longer than 64 bits must always be placed on
9621 on a storage unit (byte) boundary and occupy an integral number
9622 of storage units (bytes). Any component clause that does not
9623 meet this requirement will be rejected.
9624
9625 Any aliased component, or component of an aliased type, must
9626 have its normal alignment and size. A component clause that
9627 does not meet this requirement will be rejected.
9628
9629 The tag field of a tagged type always occupies an address sized field at
9630 the start of the record.  No component clause may attempt to overlay this
9631 tag. When a tagged type appears as a component, the tag field must have
9632 proper alignment
9633
9634 In the case of a record extension T1, of a type T, no component clause applied
9635 to the type T1 can specify a storage location that would overlap the first
9636 T'Size bytes of the record.
9637
9638 For all other component types, including non-bit-packed arrays,
9639 the component can be placed at an arbitrary bit boundary,
9640 so for example, the following is permitted:
9641
9642 @smallexample @c ada
9643    type R is array (1 .. 10) of Boolean;
9644    for R'Size use 80;
9645
9646    type Q is record
9647       G, H : Boolean;
9648       L, M : R;
9649    end record;
9650
9651    for Q use record
9652       G at 0 range  0 ..   0;
9653       H at 0 range  1 ..   1;
9654       L at 0 range  2 ..  81;
9655       R at 0 range 82 .. 161;
9656    end record;
9657 @end smallexample
9658
9659 @noindent
9660 Note: the above rules apply to recent releases of GNAT 5.
9661 In GNAT 3, there are more severe restrictions on larger components.
9662 For non-primitive types, including packed arrays with a size greater than
9663 64 bits, component clauses must respect the alignment requirement of the
9664 type, in particular, always starting on a byte boundary, and the length
9665 must be a multiple of the storage unit.
9666
9667 @node Enumeration Clauses
9668 @section Enumeration Clauses
9669
9670 The only restriction on enumeration clauses is that the range of values
9671 must be representable.  For the signed case, if one or more of the
9672 representation values are negative, all values must be in the range:
9673
9674 @smallexample @c ada
9675    System.Min_Int .. System.Max_Int
9676 @end smallexample
9677
9678 @noindent
9679 For the unsigned case, where all values are non negative, the values must
9680 be in the range:
9681
9682 @smallexample @c ada
9683    0 .. System.Max_Binary_Modulus;
9684 @end smallexample
9685
9686 @noindent
9687 A @emph{confirming} representation clause is one in which the values range
9688 from 0 in sequence, i.e.@: a clause that confirms the default representation
9689 for an enumeration type.
9690 Such a confirming representation
9691 is permitted by these rules, and is specially recognized by the compiler so
9692 that no extra overhead results from the use of such a clause.
9693
9694 If an array has an index type which is an enumeration type to which an
9695 enumeration clause has been applied, then the array is stored in a compact
9696 manner.  Consider the declarations:
9697
9698 @smallexample @c ada
9699    type r is (A, B, C);
9700    for r use (A => 1, B => 5, C => 10);
9701    type t is array (r) of Character;
9702 @end smallexample
9703
9704 @noindent
9705 The array type t corresponds to a vector with exactly three elements and
9706 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9707 use of space, but means that accesses to elements of the array will incur
9708 the overhead of converting representation values to the corresponding
9709 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9710
9711 @node Address Clauses
9712 @section Address Clauses
9713 @cindex Address Clause
9714
9715 The reference manual allows a general restriction on representation clauses,
9716 as found in RM 13.1(22):
9717
9718 @quotation
9719 An implementation need not support representation
9720 items containing nonstatic expressions, except that
9721 an implementation should support a representation item
9722 for a given entity if each nonstatic expression in the
9723 representation item is a name that statically denotes
9724 a constant declared before the entity.
9725 @end quotation
9726
9727 @noindent
9728 In practice this is applicable only to address clauses, since this is the
9729 only case in which a non-static expression is permitted by the syntax.  As
9730 the AARM notes in sections 13.1 (22.a-22.h):
9731
9732 @display
9733   22.a   Reason: This is to avoid the following sort of thing:
9734
9735   22.b        X : Integer := F(@dots{});
9736               Y : Address := G(@dots{});
9737               for X'Address use Y;
9738
9739   22.c   In the above, we have to evaluate the
9740          initialization expression for X before we
9741          know where to put the result.  This seems
9742          like an unreasonable implementation burden.
9743
9744   22.d   The above code should instead be written
9745          like this:
9746
9747   22.e        Y : constant Address := G(@dots{});
9748               X : Integer := F(@dots{});
9749               for X'Address use Y;
9750
9751   22.f   This allows the expression ``Y'' to be safely
9752          evaluated before X is created.
9753
9754   22.g   The constant could be a formal parameter of mode in.
9755
9756   22.h   An implementation can support other nonstatic
9757          expressions if it wants to.  Expressions of type
9758          Address are hardly ever static, but their value
9759          might be known at compile time anyway in many
9760          cases.
9761 @end display
9762
9763 @noindent
9764 GNAT does indeed permit many additional cases of non-static expressions.  In
9765 particular, if the type involved is elementary there are no restrictions
9766 (since in this case, holding a temporary copy of the initialization value,
9767 if one is present, is inexpensive).  In addition, if there is no implicit or
9768 explicit initialization, then there are no restrictions.  GNAT will reject
9769 only the case where all three of these conditions hold:
9770
9771 @itemize @bullet
9772
9773 @item
9774 The type of the item is non-elementary (e.g.@: a record or array).
9775
9776 @item
9777 There is explicit or implicit initialization required for the object.
9778 Note that access values are always implicitly initialized, and also
9779 in GNAT, certain bit-packed arrays (those having a dynamic length or
9780 a length greater than 64) will also be implicitly initialized to zero.
9781
9782 @item
9783 The address value is non-static.  Here GNAT is more permissive than the
9784 RM, and allows the address value to be the address of a previously declared
9785 stand-alone variable, as long as it does not itself have an address clause.
9786
9787 @smallexample @c ada
9788            Anchor  : Some_Initialized_Type;
9789            Overlay : Some_Initialized_Type;
9790            for Overlay'Address use Anchor'Address;
9791 @end smallexample
9792
9793 @noindent
9794 However, the prefix of the address clause cannot be an array component, or
9795 a component of a discriminated record.
9796
9797 @end itemize
9798
9799 @noindent
9800 As noted above in section 22.h, address values are typically non-static.  In
9801 particular the To_Address function, even if applied to a literal value, is
9802 a non-static function call.  To avoid this minor annoyance, GNAT provides
9803 the implementation defined attribute 'To_Address.  The following two
9804 expressions have identical values:
9805
9806 @findex Attribute
9807 @findex To_Address
9808 @smallexample @c ada
9809    To_Address (16#1234_0000#)
9810    System'To_Address (16#1234_0000#);
9811 @end smallexample
9812
9813 @noindent
9814 except that the second form is considered to be a static expression, and
9815 thus when used as an address clause value is always permitted.
9816
9817 @noindent
9818 Additionally, GNAT treats as static an address clause that is an
9819 unchecked_conversion of a static integer value.  This simplifies the porting
9820 of legacy code, and provides a portable equivalent to the GNAT attribute
9821 @code{To_Address}.
9822
9823 Another issue with address clauses is the interaction with alignment
9824 requirements.  When an address clause is given for an object, the address
9825 value must be consistent with the alignment of the object (which is usually
9826 the same as the alignment of the type of the object).  If an address clause
9827 is given that specifies an inappropriately aligned address value, then the
9828 program execution is erroneous.
9829
9830 Since this source of erroneous behavior can have unfortunate effects, GNAT
9831 checks (at compile time if possible, generating a warning, or at execution
9832 time with a run-time check) that the alignment is appropriate.  If the
9833 run-time check fails, then @code{Program_Error} is raised.  This run-time
9834 check is suppressed if range checks are suppressed, or if
9835 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9836
9837 @findex Export
9838 An address clause cannot be given for an exported object.  More
9839 understandably the real restriction is that objects with an address
9840 clause cannot be exported.  This is because such variables are not
9841 defined by the Ada program, so there is no external object to export.
9842
9843 @findex Import
9844 It is permissible to give an address clause and a pragma Import for the
9845 same object.  In this case, the variable is not really defined by the
9846 Ada program, so there is no external symbol to be linked.  The link name
9847 and the external name are ignored in this case.  The reason that we allow this
9848 combination is that it provides a useful idiom to avoid unwanted
9849 initializations on objects with address clauses.
9850
9851 When an address clause is given for an object that has implicit or
9852 explicit initialization, then by default initialization takes place.  This
9853 means that the effect of the object declaration is to overwrite the
9854 memory at the specified address.  This is almost always not what the
9855 programmer wants, so GNAT will output a warning:
9856
9857 @smallexample
9858   with System;
9859   package G is
9860      type R is record
9861         M : Integer := 0;
9862      end record;
9863
9864      Ext : R;
9865      for Ext'Address use System'To_Address (16#1234_1234#);
9866          |
9867   >>> warning: implicit initialization of "Ext" may
9868       modify overlaid storage
9869   >>> warning: use pragma Import for "Ext" to suppress
9870       initialization (RM B(24))
9871
9872   end G;
9873 @end smallexample
9874
9875 @noindent
9876 As indicated by the warning message, the solution is to use a (dummy) pragma
9877 Import to suppress this initialization.  The pragma tell the compiler that the
9878 object is declared and initialized elsewhere.  The following package compiles
9879 without warnings (and the initialization is suppressed):
9880
9881 @smallexample @c ada
9882    with System;
9883    package G is
9884       type R is record
9885          M : Integer := 0;
9886       end record;
9887
9888       Ext : R;
9889       for Ext'Address use System'To_Address (16#1234_1234#);
9890       pragma Import (Ada, Ext);
9891    end G;
9892 @end smallexample
9893
9894 @noindent
9895 A final issue with address clauses involves their use for overlaying
9896 variables, as in the following example:
9897 @cindex Overlaying of objects
9898
9899 @smallexample @c ada
9900   A : Integer;
9901   B : Integer;
9902   for B'Address use A'Address;
9903 @end smallexample
9904
9905 @noindent
9906 or alternatively, using the form recommended by the RM:
9907
9908 @smallexample @c ada
9909   A    : Integer;
9910   Addr : constant Address := A'Address;
9911   B    : Integer;
9912   for B'Address use Addr;
9913 @end smallexample
9914
9915 @noindent
9916 In both of these cases, @code{A}
9917 and @code{B} become aliased to one another via the
9918 address clause. This use of address clauses to overlay
9919 variables, achieving an effect similar to unchecked
9920 conversion was erroneous in Ada 83, but in Ada 95
9921 the effect is implementation defined. Furthermore, the
9922 Ada 95 RM specifically recommends that in a situation
9923 like this, @code{B} should be subject to the following
9924 implementation advice (RM 13.3(19)):
9925
9926 @quotation
9927 19  If the Address of an object is specified, or it is imported
9928     or exported, then the implementation should not perform
9929     optimizations based on assumptions of no aliases.
9930 @end quotation
9931
9932 @noindent
9933 GNAT follows this recommendation, and goes further by also applying
9934 this recommendation to the overlaid variable (@code{A}
9935 in the above example) in this case. This means that the overlay
9936 works "as expected", in that a modification to one of the variables
9937 will affect the value of the other.
9938
9939 @node Effect of Convention on Representation
9940 @section Effect of Convention on Representation
9941 @cindex Convention, effect on representation
9942
9943 @noindent
9944 Normally the specification of a foreign language convention for a type or
9945 an object has no effect on the chosen representation.  In particular, the
9946 representation chosen for data in GNAT generally meets the standard system
9947 conventions, and for example records are laid out in a manner that is
9948 consistent with C@.  This means that specifying convention C (for example)
9949 has no effect.
9950
9951 There are three exceptions to this general rule:
9952
9953 @itemize @bullet
9954
9955 @item Convention Fortran and array subtypes
9956 If pragma Convention Fortran is specified for an array subtype, then in
9957 accordance with the implementation advice in section 3.6.2(11) of the
9958 Ada Reference Manual, the array will be stored in a Fortran-compatible
9959 column-major manner, instead of the normal default row-major order.
9960
9961 @item Convention C and enumeration types
9962 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9963 to accommodate all values of the type.  For example, for the enumeration
9964 type declared by:
9965
9966 @smallexample @c ada
9967    type Color is (Red, Green, Blue);
9968 @end smallexample
9969
9970 @noindent
9971 8 bits is sufficient to store all values of the type, so by default, objects
9972 of type @code{Color} will be represented using 8 bits.  However, normal C
9973 convention is to use 32 bits for all enum values in C, since enum values
9974 are essentially of type int.  If pragma @code{Convention C} is specified for an
9975 Ada enumeration type, then the size is modified as necessary (usually to
9976 32 bits) to be consistent with the C convention for enum values.
9977
9978 @item Convention C/Fortran and Boolean types
9979 In C, the usual convention for boolean values, that is values used for
9980 conditions, is that zero represents false, and nonzero values represent
9981 true.  In Ada, the normal convention is that two specific values, typically
9982 0/1, are used to represent false/true respectively.
9983
9984 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9985 value represents true).
9986
9987 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9988 C or Fortran convention for a derived Boolean, as in the following example:
9989
9990 @smallexample @c ada
9991    type C_Switch is new Boolean;
9992    pragma Convention (C, C_Switch);
9993 @end smallexample
9994
9995 @noindent
9996 then the GNAT generated code will treat any nonzero value as true.  For truth
9997 values generated by GNAT, the conventional value 1 will be used for True, but
9998 when one of these values is read, any nonzero value is treated as True.
9999
10000 @end itemize
10001
10002 @node Determining the Representations chosen by GNAT
10003 @section Determining the Representations chosen by GNAT
10004 @cindex Representation, determination of
10005 @cindex @code{-gnatR} switch
10006
10007 @noindent
10008 Although the descriptions in this section are intended to be complete, it is
10009 often easier to simply experiment to see what GNAT accepts and what the
10010 effect is on the layout of types and objects.
10011
10012 As required by the Ada RM, if a representation clause is not accepted, then
10013 it must be rejected as illegal by the compiler.  However, when a
10014 representation clause or pragma is accepted, there can still be questions
10015 of what the compiler actually does.  For example, if a partial record
10016 representation clause specifies the location of some components and not
10017 others, then where are the non-specified components placed? Or if pragma
10018 @code{Pack} is used on a record, then exactly where are the resulting
10019 fields placed? The section on pragma @code{Pack} in this chapter can be
10020 used to answer the second question, but it is often easier to just see
10021 what the compiler does.
10022
10023 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10024 with this option, then the compiler will output information on the actual
10025 representations chosen, in a format similar to source representation
10026 clauses.  For example, if we compile the package:
10027
10028 @smallexample @c ada
10029 package q is
10030    type r (x : boolean) is tagged record
10031       case x is
10032          when True => S : String (1 .. 100);
10033          when False => null;
10034       end case;
10035    end record;
10036
10037    type r2 is new r (false) with record
10038       y2 : integer;
10039    end record;
10040
10041    for r2 use record
10042       y2 at 16 range 0 .. 31;
10043    end record;
10044
10045    type x is record
10046       y : character;
10047    end record;
10048
10049    type x1 is array (1 .. 10) of x;
10050    for x1'component_size use 11;
10051
10052    type ia is access integer;
10053
10054    type Rb1 is array (1 .. 13) of Boolean;
10055    pragma Pack (rb1);
10056
10057    type Rb2 is array (1 .. 65) of Boolean;
10058    pragma Pack (rb2);
10059
10060    type x2 is record
10061       l1 : Boolean;
10062       l2 : Duration;
10063       l3 : Float;
10064       l4 : Boolean;
10065       l5 : Rb1;
10066       l6 : Rb2;
10067    end record;
10068    pragma Pack (x2);
10069 end q;
10070 @end smallexample
10071
10072 @noindent
10073 using the switch @code{-gnatR} we obtain the following output:
10074
10075 @smallexample
10076 Representation information for unit q
10077 -------------------------------------
10078
10079 for r'Size use ??;
10080 for r'Alignment use 4;
10081 for r use record
10082    x    at 4 range  0 .. 7;
10083    _tag at 0 range  0 .. 31;
10084    s    at 5 range  0 .. 799;
10085 end record;
10086
10087 for r2'Size use 160;
10088 for r2'Alignment use 4;
10089 for r2 use record
10090    x       at  4 range  0 .. 7;
10091    _tag    at  0 range  0 .. 31;
10092    _parent at  0 range  0 .. 63;
10093    y2      at 16 range  0 .. 31;
10094 end record;
10095
10096 for x'Size use 8;
10097 for x'Alignment use 1;
10098 for x use record
10099    y at 0 range  0 .. 7;
10100 end record;
10101
10102 for x1'Size use 112;
10103 for x1'Alignment use 1;
10104 for x1'Component_Size use 11;
10105
10106 for rb1'Size use 13;
10107 for rb1'Alignment use 2;
10108 for rb1'Component_Size use 1;
10109
10110 for rb2'Size use 72;
10111 for rb2'Alignment use 1;
10112 for rb2'Component_Size use 1;
10113
10114 for x2'Size use 224;
10115 for x2'Alignment use 4;
10116 for x2 use record
10117    l1 at  0 range  0 .. 0;
10118    l2 at  0 range  1 .. 64;
10119    l3 at 12 range  0 .. 31;
10120    l4 at 16 range  0 .. 0;
10121    l5 at 16 range  1 .. 13;
10122    l6 at 18 range  0 .. 71;
10123 end record;
10124 @end smallexample
10125
10126 @noindent
10127 The Size values are actually the Object_Size, i.e.@: the default size that
10128 will be allocated for objects of the type.
10129 The ?? size for type r indicates that we have a variant record, and the
10130 actual size of objects will depend on the discriminant value.
10131
10132 The Alignment values show the actual alignment chosen by the compiler
10133 for each record or array type.
10134
10135 The record representation clause for type r shows where all fields
10136 are placed, including the compiler generated tag field (whose location
10137 cannot be controlled by the programmer).
10138
10139 The record representation clause for the type extension r2 shows all the
10140 fields present, including the parent field, which is a copy of the fields
10141 of the parent type of r2, i.e.@: r1.
10142
10143 The component size and size clauses for types rb1 and rb2 show
10144 the exact effect of pragma @code{Pack} on these arrays, and the record
10145 representation clause for type x2 shows how pragma @code{Pack} affects
10146 this record type.
10147
10148 In some cases, it may be useful to cut and paste the representation clauses
10149 generated by the compiler into the original source to fix and guarantee
10150 the actual representation to be used.
10151
10152 @node Standard Library Routines
10153 @chapter Standard Library Routines
10154
10155 @noindent
10156 The Ada 95 Reference Manual contains in Annex A a full description of an
10157 extensive set of standard library routines that can be used in any Ada
10158 program, and which must be provided by all Ada compilers.  They are
10159 analogous to the standard C library used by C programs.
10160
10161 GNAT implements all of the facilities described in annex A, and for most
10162 purposes the description in the Ada 95
10163 reference manual, or appropriate Ada
10164 text book, will be sufficient for making use of these facilities.
10165
10166 In the case of the input-output facilities, @xref{The Implementation of
10167 Standard I/O}, gives details on exactly how GNAT interfaces to the
10168 file system.  For the remaining packages, the Ada 95 reference manual
10169 should be sufficient.  The following is a list of the packages included,
10170 together with a brief description of the functionality that is provided.
10171
10172 For completeness, references are included to other predefined library
10173 routines defined in other sections of the Ada 95 reference manual (these are
10174 cross-indexed from annex A).
10175
10176 @table @code
10177 @item Ada (A.2)
10178 This is a parent package for all the standard library packages.  It is
10179 usually included implicitly in your program, and itself contains no
10180 useful data or routines.
10181
10182 @item Ada.Calendar (9.6)
10183 @code{Calendar} provides time of day access, and routines for
10184 manipulating times and durations.
10185
10186 @item Ada.Characters (A.3.1)
10187 This is a dummy parent package that contains no useful entities
10188
10189 @item Ada.Characters.Handling (A.3.2)
10190 This package provides some basic character handling capabilities,
10191 including classification functions for classes of characters (e.g.@: test
10192 for letters, or digits).
10193
10194 @item Ada.Characters.Latin_1 (A.3.3)
10195 This package includes a complete set of definitions of the characters
10196 that appear in type CHARACTER@.  It is useful for writing programs that
10197 will run in international environments.  For example, if you want an
10198 upper case E with an acute accent in a string, it is often better to use
10199 the definition of @code{UC_E_Acute} in this package.  Then your program
10200 will print in an understandable manner even if your environment does not
10201 support these extended characters.
10202
10203 @item Ada.Command_Line (A.15)
10204 This package provides access to the command line parameters and the name
10205 of the current program (analogous to the use of @code{argc} and @code{argv}
10206 in C), and also allows the exit status for the program to be set in a
10207 system-independent manner.
10208
10209 @item Ada.Decimal (F.2)
10210 This package provides constants describing the range of decimal numbers
10211 implemented, and also a decimal divide routine (analogous to the COBOL
10212 verb DIVIDE .. GIVING .. REMAINDER ..)
10213
10214 @item Ada.Direct_IO (A.8.4)
10215 This package provides input-output using a model of a set of records of
10216 fixed-length, containing an arbitrary definite Ada type, indexed by an
10217 integer record number.
10218
10219 @item Ada.Dynamic_Priorities (D.5)
10220 This package allows the priorities of a task to be adjusted dynamically
10221 as the task is running.
10222
10223 @item Ada.Exceptions (11.4.1)
10224 This package provides additional information on exceptions, and also
10225 contains facilities for treating exceptions as data objects, and raising
10226 exceptions with associated messages.
10227
10228 @item Ada.Finalization (7.6)
10229 This package contains the declarations and subprograms to support the
10230 use of controlled types, providing for automatic initialization and
10231 finalization (analogous to the constructors and destructors of C++)
10232
10233 @item Ada.Interrupts (C.3.2)
10234 This package provides facilities for interfacing to interrupts, which
10235 includes the set of signals or conditions that can be raised and
10236 recognized as interrupts.
10237
10238 @item Ada.Interrupts.Names (C.3.2)
10239 This package provides the set of interrupt names (actually signal
10240 or condition names) that can be handled by GNAT@.
10241
10242 @item Ada.IO_Exceptions (A.13)
10243 This package defines the set of exceptions that can be raised by use of
10244 the standard IO packages.
10245
10246 @item Ada.Numerics
10247 This package contains some standard constants and exceptions used
10248 throughout the numerics packages.  Note that the constants pi and e are
10249 defined here, and it is better to use these definitions than rolling
10250 your own.
10251
10252 @item Ada.Numerics.Complex_Elementary_Functions
10253 Provides the implementation of standard elementary functions (such as
10254 log and trigonometric functions) operating on complex numbers using the
10255 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10256 created by the package @code{Numerics.Complex_Types}.
10257
10258 @item Ada.Numerics.Complex_Types
10259 This is a predefined instantiation of
10260 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10261 build the type @code{Complex} and @code{Imaginary}.
10262
10263 @item Ada.Numerics.Discrete_Random
10264 This package provides a random number generator suitable for generating
10265 random integer values from a specified range.
10266
10267 @item Ada.Numerics.Float_Random
10268 This package provides a random number generator suitable for generating
10269 uniformly distributed floating point values.
10270
10271 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10272 This is a generic version of the package that provides the
10273 implementation of standard elementary functions (such as log and
10274 trigonometric functions) for an arbitrary complex type.
10275
10276 The following predefined instantiations of this package are provided:
10277
10278 @table @code
10279 @item Short_Float
10280 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10281 @item Float
10282 @code{Ada.Numerics.Complex_Elementary_Functions}
10283 @item Long_Float
10284 @code{Ada.Numerics.
10285  Long_Complex_Elementary_Functions}
10286 @end table
10287
10288 @item Ada.Numerics.Generic_Complex_Types
10289 This is a generic package that allows the creation of complex types,
10290 with associated complex arithmetic operations.
10291
10292 The following predefined instantiations of this package exist
10293 @table @code
10294 @item Short_Float
10295 @code{Ada.Numerics.Short_Complex_Complex_Types}
10296 @item Float
10297 @code{Ada.Numerics.Complex_Complex_Types}
10298 @item Long_Float
10299 @code{Ada.Numerics.Long_Complex_Complex_Types}
10300 @end table
10301
10302 @item Ada.Numerics.Generic_Elementary_Functions
10303 This is a generic package that provides the implementation of standard
10304 elementary functions (such as log an trigonometric functions) for an
10305 arbitrary float type.
10306
10307 The following predefined instantiations of this package exist
10308
10309 @table @code
10310 @item Short_Float
10311 @code{Ada.Numerics.Short_Elementary_Functions}
10312 @item Float
10313 @code{Ada.Numerics.Elementary_Functions}
10314 @item Long_Float
10315 @code{Ada.Numerics.Long_Elementary_Functions}
10316 @end table
10317
10318 @item Ada.Real_Time (D.8)
10319 This package provides facilities similar to those of @code{Calendar}, but
10320 operating with a finer clock suitable for real time control. Note that
10321 annex D requires that there be no backward clock jumps, and GNAT generally
10322 guarantees this behavior, but of course if the external clock on which
10323 the GNAT runtime depends is deliberately reset by some external event,
10324 then such a backward jump may occur.
10325
10326 @item Ada.Sequential_IO (A.8.1)
10327 This package provides input-output facilities for sequential files,
10328 which can contain a sequence of values of a single type, which can be
10329 any Ada type, including indefinite (unconstrained) types.
10330
10331 @item Ada.Storage_IO (A.9)
10332 This package provides a facility for mapping arbitrary Ada types to and
10333 from a storage buffer.  It is primarily intended for the creation of new
10334 IO packages.
10335
10336 @item Ada.Streams (13.13.1)
10337 This is a generic package that provides the basic support for the
10338 concept of streams as used by the stream attributes (@code{Input},
10339 @code{Output}, @code{Read} and @code{Write}).
10340
10341 @item Ada.Streams.Stream_IO (A.12.1)
10342 This package is a specialization of the type @code{Streams} defined in
10343 package @code{Streams} together with a set of operations providing
10344 Stream_IO capability.  The Stream_IO model permits both random and
10345 sequential access to a file which can contain an arbitrary set of values
10346 of one or more Ada types.
10347
10348 @item Ada.Strings (A.4.1)
10349 This package provides some basic constants used by the string handling
10350 packages.
10351
10352 @item Ada.Strings.Bounded (A.4.4)
10353 This package provides facilities for handling variable length
10354 strings.  The bounded model requires a maximum length.  It is thus
10355 somewhat more limited than the unbounded model, but avoids the use of
10356 dynamic allocation or finalization.
10357
10358 @item Ada.Strings.Fixed (A.4.3)
10359 This package provides facilities for handling fixed length strings.
10360
10361 @item Ada.Strings.Maps (A.4.2)
10362 This package provides facilities for handling character mappings and
10363 arbitrarily defined subsets of characters.  For instance it is useful in
10364 defining specialized translation tables.
10365
10366 @item Ada.Strings.Maps.Constants (A.4.6)
10367 This package provides a standard set of predefined mappings and
10368 predefined character sets.  For example, the standard upper to lower case
10369 conversion table is found in this package.  Note that upper to lower case
10370 conversion is non-trivial if you want to take the entire set of
10371 characters, including extended characters like E with an acute accent,
10372 into account.  You should use the mappings in this package (rather than
10373 adding 32 yourself) to do case mappings.
10374
10375 @item Ada.Strings.Unbounded (A.4.5)
10376 This package provides facilities for handling variable length
10377 strings.  The unbounded model allows arbitrary length strings, but
10378 requires the use of dynamic allocation and finalization.
10379
10380 @item Ada.Strings.Wide_Bounded (A.4.7)
10381 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10382 @itemx Ada.Strings.Wide_Maps (A.4.7)
10383 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10384 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10385 These packages provide analogous capabilities to the corresponding
10386 packages without @samp{Wide_} in the name, but operate with the types
10387 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10388 and @code{Character}.
10389
10390 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10391 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10392 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10393 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10394 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10395 These packages provide analogous capabilities to the corresponding
10396 packages without @samp{Wide_} in the name, but operate with the types
10397 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10398 of @code{String} and @code{Character}.
10399
10400 @item Ada.Synchronous_Task_Control (D.10)
10401 This package provides some standard facilities for controlling task
10402 communication in a synchronous manner.
10403
10404 @item Ada.Tags
10405 This package contains definitions for manipulation of the tags of tagged
10406 values.
10407
10408 @item Ada.Task_Attributes
10409 This package provides the capability of associating arbitrary
10410 task-specific data with separate tasks.
10411
10412 @item Ada.Text_IO
10413 This package provides basic text input-output capabilities for
10414 character, string and numeric data.  The subpackages of this
10415 package are listed next.
10416
10417 @item Ada.Text_IO.Decimal_IO
10418 Provides input-output facilities for decimal fixed-point types
10419
10420 @item Ada.Text_IO.Enumeration_IO
10421 Provides input-output facilities for enumeration types.
10422
10423 @item Ada.Text_IO.Fixed_IO
10424 Provides input-output facilities for ordinary fixed-point types.
10425
10426 @item Ada.Text_IO.Float_IO
10427 Provides input-output facilities for float types.  The following
10428 predefined instantiations of this generic package are available:
10429
10430 @table @code
10431 @item Short_Float
10432 @code{Short_Float_Text_IO}
10433 @item Float
10434 @code{Float_Text_IO}
10435 @item Long_Float
10436 @code{Long_Float_Text_IO}
10437 @end table
10438
10439 @item Ada.Text_IO.Integer_IO
10440 Provides input-output facilities for integer types.  The following
10441 predefined instantiations of this generic package are available:
10442
10443 @table @code
10444 @item Short_Short_Integer
10445 @code{Ada.Short_Short_Integer_Text_IO}
10446 @item Short_Integer
10447 @code{Ada.Short_Integer_Text_IO}
10448 @item Integer
10449 @code{Ada.Integer_Text_IO}
10450 @item Long_Integer
10451 @code{Ada.Long_Integer_Text_IO}
10452 @item Long_Long_Integer
10453 @code{Ada.Long_Long_Integer_Text_IO}
10454 @end table
10455
10456 @item Ada.Text_IO.Modular_IO
10457 Provides input-output facilities for modular (unsigned) types
10458
10459 @item Ada.Text_IO.Complex_IO (G.1.3)
10460 This package provides basic text input-output capabilities for complex
10461 data.
10462
10463 @item Ada.Text_IO.Editing (F.3.3)
10464 This package contains routines for edited output, analogous to the use
10465 of pictures in COBOL@.  The picture formats used by this package are a
10466 close copy of the facility in COBOL@.
10467
10468 @item Ada.Text_IO.Text_Streams (A.12.2)
10469 This package provides a facility that allows Text_IO files to be treated
10470 as streams, so that the stream attributes can be used for writing
10471 arbitrary data, including binary data, to Text_IO files.
10472
10473 @item Ada.Unchecked_Conversion (13.9)
10474 This generic package allows arbitrary conversion from one type to
10475 another of the same size, providing for breaking the type safety in
10476 special circumstances.
10477
10478 If the types have the same Size (more accurately the same Value_Size),
10479 then the effect is simply to transfer the bits from the source to the
10480 target type without any modification.  This usage is well defined, and
10481 for simple types whose representation is typically the same across
10482 all implementations, gives a portable method of performing such
10483 conversions.
10484
10485 If the types do not have the same size, then the result is implementation
10486 defined, and thus may be non-portable.  The following describes how GNAT
10487 handles such unchecked conversion cases.
10488
10489 If the types are of different sizes, and are both discrete types, then
10490 the effect is of a normal type conversion without any constraint checking.
10491 In particular if the result type has a larger size, the result will be
10492 zero or sign extended.  If the result type has a smaller size, the result
10493 will be truncated by ignoring high order bits.
10494
10495 If the types are of different sizes, and are not both discrete types,
10496 then the conversion works as though pointers were created to the source
10497 and target, and the pointer value is converted.  The effect is that bits
10498 are copied from successive low order storage units and bits of the source
10499 up to the length of the target type.
10500
10501 A warning is issued if the lengths differ, since the effect in this
10502 case is implementation dependent, and the above behavior may not match
10503 that of some other compiler.
10504
10505 A pointer to one type may be converted to a pointer to another type using
10506 unchecked conversion.  The only case in which the effect is undefined is
10507 when one or both pointers are pointers to unconstrained array types.  In
10508 this case, the bounds information may get incorrectly transferred, and in
10509 particular, GNAT uses double size pointers for such types, and it is
10510 meaningless to convert between such pointer types.  GNAT will issue a
10511 warning if the alignment of the target designated type is more strict
10512 than the alignment of the source designated type (since the result may
10513 be unaligned in this case).
10514
10515 A pointer other than a pointer to an unconstrained array type may be
10516 converted to and from System.Address.  Such usage is common in Ada 83
10517 programs, but note that Ada.Address_To_Access_Conversions is the
10518 preferred method of performing such conversions in Ada 95.  Neither
10519 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10520 used in conjunction with pointers to unconstrained objects, since
10521 the bounds information cannot be handled correctly in this case.
10522
10523 @item Ada.Unchecked_Deallocation (13.11.2)
10524 This generic package allows explicit freeing of storage previously
10525 allocated by use of an allocator.
10526
10527 @item Ada.Wide_Text_IO (A.11)
10528 This package is similar to @code{Ada.Text_IO}, except that the external
10529 file supports wide character representations, and the internal types are
10530 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10531 and @code{String}.  It contains generic subpackages listed next.
10532
10533 @item Ada.Wide_Text_IO.Decimal_IO
10534 Provides input-output facilities for decimal fixed-point types
10535
10536 @item Ada.Wide_Text_IO.Enumeration_IO
10537 Provides input-output facilities for enumeration types.
10538
10539 @item Ada.Wide_Text_IO.Fixed_IO
10540 Provides input-output facilities for ordinary fixed-point types.
10541
10542 @item Ada.Wide_Text_IO.Float_IO
10543 Provides input-output facilities for float types.  The following
10544 predefined instantiations of this generic package are available:
10545
10546 @table @code
10547 @item Short_Float
10548 @code{Short_Float_Wide_Text_IO}
10549 @item Float
10550 @code{Float_Wide_Text_IO}
10551 @item Long_Float
10552 @code{Long_Float_Wide_Text_IO}
10553 @end table
10554
10555 @item Ada.Wide_Text_IO.Integer_IO
10556 Provides input-output facilities for integer types.  The following
10557 predefined instantiations of this generic package are available:
10558
10559 @table @code
10560 @item Short_Short_Integer
10561 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10562 @item Short_Integer
10563 @code{Ada.Short_Integer_Wide_Text_IO}
10564 @item Integer
10565 @code{Ada.Integer_Wide_Text_IO}
10566 @item Long_Integer
10567 @code{Ada.Long_Integer_Wide_Text_IO}
10568 @item Long_Long_Integer
10569 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10570 @end table
10571
10572 @item Ada.Wide_Text_IO.Modular_IO
10573 Provides input-output facilities for modular (unsigned) types
10574
10575 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10576 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10577 external file supports wide character representations.
10578
10579 @item Ada.Wide_Text_IO.Editing (F.3.4)
10580 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10581 types are @code{Wide_Character} and @code{Wide_String} instead of
10582 @code{Character} and @code{String}.
10583
10584 @item Ada.Wide_Text_IO.Streams (A.12.3)
10585 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10586 types are @code{Wide_Character} and @code{Wide_String} instead of
10587 @code{Character} and @code{String}.
10588
10589 @item Ada.Wide_Wide_Text_IO (A.11)
10590 This package is similar to @code{Ada.Text_IO}, except that the external
10591 file supports wide character representations, and the internal types are
10592 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10593 and @code{String}.  It contains generic subpackages listed next.
10594
10595 @item Ada.Wide_Wide_Text_IO.Decimal_IO
10596 Provides input-output facilities for decimal fixed-point types
10597
10598 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
10599 Provides input-output facilities for enumeration types.
10600
10601 @item Ada.Wide_Wide_Text_IO.Fixed_IO
10602 Provides input-output facilities for ordinary fixed-point types.
10603
10604 @item Ada.Wide_Wide_Text_IO.Float_IO
10605 Provides input-output facilities for float types.  The following
10606 predefined instantiations of this generic package are available:
10607
10608 @table @code
10609 @item Short_Float
10610 @code{Short_Float_Wide_Wide_Text_IO}
10611 @item Float
10612 @code{Float_Wide_Wide_Text_IO}
10613 @item Long_Float
10614 @code{Long_Float_Wide_Wide_Text_IO}
10615 @end table
10616
10617 @item Ada.Wide_Wide_Text_IO.Integer_IO
10618 Provides input-output facilities for integer types.  The following
10619 predefined instantiations of this generic package are available:
10620
10621 @table @code
10622 @item Short_Short_Integer
10623 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
10624 @item Short_Integer
10625 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
10626 @item Integer
10627 @code{Ada.Integer_Wide_Wide_Text_IO}
10628 @item Long_Integer
10629 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
10630 @item Long_Long_Integer
10631 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
10632 @end table
10633
10634 @item Ada.Wide_Wide_Text_IO.Modular_IO
10635 Provides input-output facilities for modular (unsigned) types
10636
10637 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
10638 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10639 external file supports wide character representations.
10640
10641 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
10642 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10643 types are @code{Wide_Character} and @code{Wide_String} instead of
10644 @code{Character} and @code{String}.
10645
10646 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
10647 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10648 types are @code{Wide_Character} and @code{Wide_String} instead of
10649 @code{Character} and @code{String}.
10650 @end table
10651
10652
10653
10654 @node The Implementation of Standard I/O
10655 @chapter The Implementation of Standard I/O
10656
10657 @noindent
10658 GNAT implements all the required input-output facilities described in
10659 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10660 required behavior of these packages from the Ada point of view, and if
10661 you are writing a portable Ada program that does not need to know the
10662 exact manner in which Ada maps to the outside world when it comes to
10663 reading or writing external files, then you do not need to read this
10664 chapter.  As long as your files are all regular files (not pipes or
10665 devices), and as long as you write and read the files only from Ada, the
10666 description in the Ada 95 reference manual is sufficient.
10667
10668 However, if you want to do input-output to pipes or other devices, such
10669 as the keyboard or screen, or if the files you are dealing with are
10670 either generated by some other language, or to be read by some other
10671 language, then you need to know more about the details of how the GNAT
10672 implementation of these input-output facilities behaves.
10673
10674 In this chapter we give a detailed description of exactly how GNAT
10675 interfaces to the file system.  As always, the sources of the system are
10676 available to you for answering questions at an even more detailed level,
10677 but for most purposes the information in this chapter will suffice.
10678
10679 Another reason that you may need to know more about how input-output is
10680 implemented arises when you have a program written in mixed languages
10681 where, for example, files are shared between the C and Ada sections of
10682 the same program.  GNAT provides some additional facilities, in the form
10683 of additional child library packages, that facilitate this sharing, and
10684 these additional facilities are also described in this chapter.
10685
10686 @menu
10687 * Standard I/O Packages::
10688 * FORM Strings::
10689 * Direct_IO::
10690 * Sequential_IO::
10691 * Text_IO::
10692 * Wide_Text_IO::
10693 * Wide_Wide_Text_IO::
10694 * Stream_IO::
10695 * Shared Files::
10696 * Open Modes::
10697 * Operations on C Streams::
10698 * Interfacing to C Streams::
10699 @end menu
10700
10701 @node Standard I/O Packages
10702 @section Standard I/O Packages
10703
10704 @noindent
10705 The Standard I/O packages described in Annex A for
10706
10707 @itemize @bullet
10708 @item
10709 Ada.Text_IO
10710 @item
10711 Ada.Text_IO.Complex_IO
10712 @item
10713 Ada.Text_IO.Text_Streams
10714 @item
10715 Ada.Wide_Text_IO
10716 @item
10717 Ada.Wide_Text_IO.Complex_IO
10718 @item
10719 Ada.Wide_Text_IO.Text_Streams
10720 @item
10721 Ada.Wide_Wide_Text_IO
10722 @item
10723 Ada.Wide_Wide_Text_IO.Complex_IO
10724 @item
10725 Ada.Wide_Wide_Text_IO.Text_Streams
10726 @item
10727 Ada.Stream_IO
10728 @item
10729 Ada.Sequential_IO
10730 @item
10731 Ada.Direct_IO
10732 @end itemize
10733
10734 @noindent
10735 are implemented using the C
10736 library streams facility; where
10737
10738 @itemize @bullet
10739 @item
10740 All files are opened using @code{fopen}.
10741 @item
10742 All input/output operations use @code{fread}/@code{fwrite}.
10743 @end itemize
10744
10745 @noindent
10746 There is no internal buffering of any kind at the Ada library level.  The
10747 only buffering is that provided at the system level in the
10748 implementation of the C library routines that support streams.  This
10749 facilitates shared use of these streams by mixed language programs.
10750
10751 @node FORM Strings
10752 @section FORM Strings
10753
10754 @noindent
10755 The format of a FORM string in GNAT is:
10756
10757 @smallexample
10758 "keyword=value,keyword=value,@dots{},keyword=value"
10759 @end smallexample
10760
10761 @noindent
10762 where letters may be in upper or lower case, and there are no spaces
10763 between values.  The order of the entries is not important.  Currently
10764 there are two keywords defined.
10765
10766 @smallexample
10767 SHARED=[YES|NO]
10768 WCEM=[n|h|u|s\e]
10769 @end smallexample
10770
10771 @noindent
10772 The use of these parameters is described later in this section.
10773
10774 @node Direct_IO
10775 @section Direct_IO
10776
10777 @noindent
10778 Direct_IO can only be instantiated for definite types.  This is a
10779 restriction of the Ada language, which means that the records are fixed
10780 length (the length being determined by @code{@var{type}'Size}, rounded
10781 up to the next storage unit boundary if necessary).
10782
10783 The records of a Direct_IO file are simply written to the file in index
10784 sequence, with the first record starting at offset zero, and subsequent
10785 records following.  There is no control information of any kind.  For
10786 example, if 32-bit integers are being written, each record takes
10787 4-bytes, so the record at index @var{K} starts at offset
10788 (@var{K}@minus{}1)*4.
10789
10790 There is no limit on the size of Direct_IO files, they are expanded as
10791 necessary to accommodate whatever records are written to the file.
10792
10793 @node Sequential_IO
10794 @section Sequential_IO
10795
10796 @noindent
10797 Sequential_IO may be instantiated with either a definite (constrained)
10798 or indefinite (unconstrained) type.
10799
10800 For the definite type case, the elements written to the file are simply
10801 the memory images of the data values with no control information of any
10802 kind.  The resulting file should be read using the same type, no validity
10803 checking is performed on input.
10804
10805 For the indefinite type case, the elements written consist of two
10806 parts.  First is the size of the data item, written as the memory image
10807 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10808 the data value.  The resulting file can only be read using the same
10809 (unconstrained) type.  Normal assignment checks are performed on these
10810 read operations, and if these checks fail, @code{Data_Error} is
10811 raised.  In particular, in the array case, the lengths must match, and in
10812 the variant record case, if the variable for a particular read operation
10813 is constrained, the discriminants must match.
10814
10815 Note that it is not possible to use Sequential_IO to write variable
10816 length array items, and then read the data back into different length
10817 arrays.  For example, the following will raise @code{Data_Error}:
10818
10819 @smallexample @c ada
10820  package IO is new Sequential_IO (String);
10821  F : IO.File_Type;
10822  S : String (1..4);
10823  @dots{}
10824  IO.Create (F)
10825  IO.Write (F, "hello!")
10826  IO.Reset (F, Mode=>In_File);
10827  IO.Read (F, S);
10828  Put_Line (S);
10829
10830 @end smallexample
10831
10832 @noindent
10833 On some Ada implementations, this will print @code{hell}, but the program is
10834 clearly incorrect, since there is only one element in the file, and that
10835 element is the string @code{hello!}.
10836
10837 In Ada 95, this kind of behavior can be legitimately achieved using
10838 Stream_IO, and this is the preferred mechanism.  In particular, the above
10839 program fragment rewritten to use Stream_IO will work correctly.
10840
10841 @node Text_IO
10842 @section Text_IO
10843
10844 @noindent
10845 Text_IO files consist of a stream of characters containing the following
10846 special control characters:
10847
10848 @smallexample
10849 LF (line feed, 16#0A#) Line Mark
10850 FF (form feed, 16#0C#) Page Mark
10851 @end smallexample
10852
10853 @noindent
10854 A canonical Text_IO file is defined as one in which the following
10855 conditions are met:
10856
10857 @itemize @bullet
10858 @item
10859 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10860 of the line.
10861
10862 @item
10863 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10864 end of a page and consequently can appear only immediately following a
10865 @code{LF} (line mark) character.
10866
10867 @item
10868 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10869 (line mark, page mark).  In the former case, the page mark is implicitly
10870 assumed to be present.
10871 @end itemize
10872
10873 @noindent
10874 A file written using Text_IO will be in canonical form provided that no
10875 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10876 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10877 the file unless an explicit @code{New_Page} operation was performed
10878 before closing the file.
10879
10880 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10881 pipe, can be read using any of the routines in Text_IO@.  The
10882 semantics in this case will be exactly as defined in the Ada 95 reference
10883 manual and all the routines in Text_IO are fully implemented.
10884
10885 A text file that does not meet the requirements for a canonical Text_IO
10886 file has one of the following:
10887
10888 @itemize @bullet
10889 @item
10890 The file contains @code{FF} characters not immediately following a
10891 @code{LF} character.
10892
10893 @item
10894 The file contains @code{LF} or @code{FF} characters written by
10895 @code{Put} or @code{Put_Line}, which are not logically considered to be
10896 line marks or page marks.
10897
10898 @item
10899 The file ends in a character other than @code{LF} or @code{FF},
10900 i.e.@: there is no explicit line mark or page mark at the end of the file.
10901 @end itemize
10902
10903 @noindent
10904 Text_IO can be used to read such non-standard text files but subprograms
10905 to do with line or page numbers do not have defined meanings.  In
10906 particular, a @code{FF} character that does not follow a @code{LF}
10907 character may or may not be treated as a page mark from the point of
10908 view of page and line numbering.  Every @code{LF} character is considered
10909 to end a line, and there is an implied @code{LF} character at the end of
10910 the file.
10911
10912 @menu
10913 * Text_IO Stream Pointer Positioning::
10914 * Text_IO Reading and Writing Non-Regular Files::
10915 * Get_Immediate::
10916 * Treating Text_IO Files as Streams::
10917 * Text_IO Extensions::
10918 * Text_IO Facilities for Unbounded Strings::
10919 @end menu
10920
10921 @node Text_IO Stream Pointer Positioning
10922 @subsection Stream Pointer Positioning
10923
10924 @noindent
10925 @code{Ada.Text_IO} has a definition of current position for a file that
10926 is being read.  No internal buffering occurs in Text_IO, and usually the
10927 physical position in the stream used to implement the file corresponds
10928 to this logical position defined by Text_IO@.  There are two exceptions:
10929
10930 @itemize @bullet
10931 @item
10932 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10933 is positioned past the @code{LF} (line mark) that precedes the page
10934 mark.  Text_IO maintains an internal flag so that subsequent read
10935 operations properly handle the logical position which is unchanged by
10936 the @code{End_Of_Page} call.
10937
10938 @item
10939 After a call to @code{End_Of_File} that returns @code{True}, if the
10940 Text_IO file was positioned before the line mark at the end of file
10941 before the call, then the logical position is unchanged, but the stream
10942 is physically positioned right at the end of file (past the line mark,
10943 and past a possible page mark following the line mark.  Again Text_IO
10944 maintains internal flags so that subsequent read operations properly
10945 handle the logical position.
10946 @end itemize
10947
10948 @noindent
10949 These discrepancies have no effect on the observable behavior of
10950 Text_IO, but if a single Ada stream is shared between a C program and
10951 Ada program, or shared (using @samp{shared=yes} in the form string)
10952 between two Ada files, then the difference may be observable in some
10953 situations.
10954
10955 @node Text_IO Reading and Writing Non-Regular Files
10956 @subsection Reading and Writing Non-Regular Files
10957
10958 @noindent
10959 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10960 can be used for reading and writing.  Writing is not affected and the
10961 sequence of characters output is identical to the normal file case, but
10962 for reading, the behavior of Text_IO is modified to avoid undesirable
10963 look-ahead as follows:
10964
10965 An input file that is not a regular file is considered to have no page
10966 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10967 page mark) appearing in the file are considered to be data
10968 characters.  In particular:
10969
10970 @itemize @bullet
10971 @item
10972 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10973 following a line mark.  If a page mark appears, it will be treated as a
10974 data character.
10975
10976 @item
10977 This avoids the need to wait for an extra character to be typed or
10978 entered from the pipe to complete one of these operations.
10979
10980 @item
10981 @code{End_Of_Page} always returns @code{False}
10982
10983 @item
10984 @code{End_Of_File} will return @code{False} if there is a page mark at
10985 the end of the file.
10986 @end itemize
10987
10988 @noindent
10989 Output to non-regular files is the same as for regular files.  Page marks
10990 may be written to non-regular files using @code{New_Page}, but as noted
10991 above they will not be treated as page marks on input if the output is
10992 piped to another Ada program.
10993
10994 Another important discrepancy when reading non-regular files is that the end
10995 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10996 pressing the @key{EOT} key,
10997 then end of file
10998 is signaled once (i.e.@: the test @code{End_Of_File}
10999 will yield @code{True}, or a read will
11000 raise @code{End_Error}), but then reading can resume
11001 to read data past that end of
11002 file indication, until another end of file indication is entered.
11003
11004 @node Get_Immediate
11005 @subsection Get_Immediate
11006 @cindex Get_Immediate
11007
11008 @noindent
11009 Get_Immediate returns the next character (including control characters)
11010 from the input file.  In particular, Get_Immediate will return LF or FF
11011 characters used as line marks or page marks.  Such operations leave the
11012 file positioned past the control character, and it is thus not treated
11013 as having its normal function.  This means that page, line and column
11014 counts after this kind of Get_Immediate call are set as though the mark
11015 did not occur.  In the case where a Get_Immediate leaves the file
11016 positioned between the line mark and page mark (which is not normally
11017 possible), it is undefined whether the FF character will be treated as a
11018 page mark.
11019
11020 @node Treating Text_IO Files as Streams
11021 @subsection Treating Text_IO Files as Streams
11022 @cindex Stream files
11023
11024 @noindent
11025 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11026 as a stream.  Data written to a Text_IO file in this stream mode is
11027 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11028 16#0C# (@code{FF}), the resulting file may have non-standard
11029 format.  Similarly if read operations are used to read from a Text_IO
11030 file treated as a stream, then @code{LF} and @code{FF} characters may be
11031 skipped and the effect is similar to that described above for
11032 @code{Get_Immediate}.
11033
11034 @node Text_IO Extensions
11035 @subsection Text_IO Extensions
11036 @cindex Text_IO extensions
11037
11038 @noindent
11039 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11040 to the standard @code{Text_IO} package:
11041
11042 @itemize @bullet
11043 @item function File_Exists (Name : String) return Boolean;
11044 Determines if a file of the given name exists.
11045
11046 @item function Get_Line return String;
11047 Reads a string from the standard input file.  The value returned is exactly
11048 the length of the line that was read.
11049
11050 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11051 Similar, except that the parameter File specifies the file from which
11052 the string is to be read.
11053
11054 @end itemize
11055
11056 @node Text_IO Facilities for Unbounded Strings
11057 @subsection Text_IO Facilities for Unbounded Strings
11058 @cindex Text_IO for unbounded strings
11059 @cindex Unbounded_String, Text_IO operations
11060
11061 @noindent
11062 The package @code{Ada.Strings.Unbounded.Text_IO}
11063 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11064 subprograms useful for Text_IO operations on unbounded strings:
11065
11066 @itemize @bullet
11067
11068 @item function Get_Line (File : File_Type) return Unbounded_String;
11069 Reads a line from the specified file
11070 and returns the result as an unbounded string.
11071
11072 @item procedure Put (File : File_Type; U : Unbounded_String);
11073 Writes the value of the given unbounded string to the specified file
11074 Similar to the effect of
11075 @code{Put (To_String (U))} except that an extra copy is avoided.
11076
11077 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11078 Writes the value of the given unbounded string to the specified file,
11079 followed by a @code{New_Line}.
11080 Similar to the effect of @code{Put_Line (To_String (U))} except
11081 that an extra copy is avoided.
11082 @end itemize
11083
11084 @noindent
11085 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11086 and is optional.  If the parameter is omitted, then the standard input or
11087 output file is referenced as appropriate.
11088
11089 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11090 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11091 @code{Wide_Text_IO} functionality for unbounded wide strings.
11092
11093 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11094 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11095 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11096
11097 @node Wide_Text_IO
11098 @section Wide_Text_IO
11099
11100 @noindent
11101 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11102 both input and output files may contain special sequences that represent
11103 wide character values.  The encoding scheme for a given file may be
11104 specified using a FORM parameter:
11105
11106 @smallexample
11107 WCEM=@var{x}
11108 @end smallexample
11109
11110 @noindent
11111 as part of the FORM string (WCEM = wide character encoding method),
11112 where @var{x} is one of the following characters
11113
11114 @table @samp
11115 @item h
11116 Hex ESC encoding
11117 @item u
11118 Upper half encoding
11119 @item s
11120 Shift-JIS encoding
11121 @item e
11122 EUC Encoding
11123 @item 8
11124 UTF-8 encoding
11125 @item b
11126 Brackets encoding
11127 @end table
11128
11129 @noindent
11130 The encoding methods match those that
11131 can be used in a source
11132 program, but there is no requirement that the encoding method used for
11133 the source program be the same as the encoding method used for files,
11134 and different files may use different encoding methods.
11135
11136 The default encoding method for the standard files, and for opened files
11137 for which no WCEM parameter is given in the FORM string matches the
11138 wide character encoding specified for the main program (the default
11139 being brackets encoding if no coding method was specified with -gnatW).
11140
11141 @table @asis
11142 @item Hex Coding
11143 In this encoding, a wide character is represented by a five character
11144 sequence:
11145
11146 @smallexample
11147 ESC a b c d
11148 @end smallexample
11149
11150 @noindent
11151 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11152 characters (using upper case letters) of the wide character code.  For
11153 example, ESC A345 is used to represent the wide character with code
11154 16#A345#.  This scheme is compatible with use of the full
11155 @code{Wide_Character} set.
11156
11157 @item Upper Half Coding
11158 The wide character with encoding 16#abcd#, where the upper bit is on
11159 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11160 16#cd#.  The second byte may never be a format control character, but is
11161 not required to be in the upper half.  This method can be also used for
11162 shift-JIS or EUC where the internal coding matches the external coding.
11163
11164 @item Shift JIS Coding
11165 A wide character is represented by a two character sequence 16#ab# and
11166 16#cd#, with the restrictions described for upper half encoding as
11167 described above.  The internal character code is the corresponding JIS
11168 character according to the standard algorithm for Shift-JIS
11169 conversion.  Only characters defined in the JIS code set table can be
11170 used with this encoding method.
11171
11172 @item EUC Coding
11173 A wide character is represented by a two character sequence 16#ab# and
11174 16#cd#, with both characters being in the upper half.  The internal
11175 character code is the corresponding JIS character according to the EUC
11176 encoding algorithm.  Only characters defined in the JIS code set table
11177 can be used with this encoding method.
11178
11179 @item UTF-8 Coding
11180 A wide character is represented using
11181 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11182 10646-1/Am.2.  Depending on the character value, the representation
11183 is a one, two, or three byte sequence:
11184
11185 @smallexample
11186 16#0000#-16#007f#: 2#0xxxxxxx#
11187 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11188 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11189 @end smallexample
11190
11191 @noindent
11192 where the xxx bits correspond to the left-padded bits of the
11193 16-bit character value.  Note that all lower half ASCII characters
11194 are represented as ASCII bytes and all upper half characters and
11195 other wide characters are represented as sequences of upper-half
11196 (The full UTF-8 scheme allows for encoding 31-bit characters as
11197 6-byte sequences, but in this implementation, all UTF-8 sequences
11198 of four or more bytes length will raise a Constraint_Error, as
11199 will all invalid UTF-8 sequences.)
11200
11201 @item Brackets Coding
11202 In this encoding, a wide character is represented by the following eight
11203 character sequence:
11204
11205 @smallexample
11206 [ " a b c d " ]
11207 @end smallexample
11208
11209 @noindent
11210 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11211 characters (using uppercase letters) of the wide character code.  For
11212 example, @code{["A345"]} is used to represent the wide character with code
11213 @code{16#A345#}.
11214 This scheme is compatible with use of the full Wide_Character set.
11215 On input, brackets coding can also be used for upper half characters,
11216 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11217 is only used for wide characters with a code greater than @code{16#FF#}.
11218
11219 @end table
11220
11221 @noindent
11222 For the coding schemes other than Hex and Brackets encoding,
11223 not all wide character
11224 values can be represented.  An attempt to output a character that cannot
11225 be represented using the encoding scheme for the file causes
11226 Constraint_Error to be raised.  An invalid wide character sequence on
11227 input also causes Constraint_Error to be raised.
11228
11229 @menu
11230 * Wide_Text_IO Stream Pointer Positioning::
11231 * Wide_Text_IO Reading and Writing Non-Regular Files::
11232 @end menu
11233
11234 @node Wide_Text_IO Stream Pointer Positioning
11235 @subsection Stream Pointer Positioning
11236
11237 @noindent
11238 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11239 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11240 case:
11241
11242 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11243 normal lower ASCII set (i.e.@: a character in the range:
11244
11245 @smallexample @c ada
11246 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11247 @end smallexample
11248
11249 @noindent
11250 then although the logical position of the file pointer is unchanged by
11251 the @code{Look_Ahead} call, the stream is physically positioned past the
11252 wide character sequence.  Again this is to avoid the need for buffering
11253 or backup, and all @code{Wide_Text_IO} routines check the internal
11254 indication that this situation has occurred so that this is not visible
11255 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11256 can be observed if the wide text file shares a stream with another file.
11257
11258 @node Wide_Text_IO Reading and Writing Non-Regular Files
11259 @subsection Reading and Writing Non-Regular Files
11260
11261 @noindent
11262 As in the case of Text_IO, when a non-regular file is read, it is
11263 assumed that the file contains no page marks (any form characters are
11264 treated as data characters), and @code{End_Of_Page} always returns
11265 @code{False}.  Similarly, the end of file indication is not sticky, so
11266 it is possible to read beyond an end of file.
11267
11268 @node Wide_Wide_Text_IO
11269 @section Wide_Wide_Text_IO
11270
11271 @noindent
11272 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11273 both input and output files may contain special sequences that represent
11274 wide wide character values.  The encoding scheme for a given file may be
11275 specified using a FORM parameter:
11276
11277 @smallexample
11278 WCEM=@var{x}
11279 @end smallexample
11280
11281 @noindent
11282 as part of the FORM string (WCEM = wide character encoding method),
11283 where @var{x} is one of the following characters
11284
11285 @table @samp
11286 @item h
11287 Hex ESC encoding
11288 @item u
11289 Upper half encoding
11290 @item s
11291 Shift-JIS encoding
11292 @item e
11293 EUC Encoding
11294 @item 8
11295 UTF-8 encoding
11296 @item b
11297 Brackets encoding
11298 @end table
11299
11300 @noindent
11301 The encoding methods match those that
11302 can be used in a source
11303 program, but there is no requirement that the encoding method used for
11304 the source program be the same as the encoding method used for files,
11305 and different files may use different encoding methods.
11306
11307 The default encoding method for the standard files, and for opened files
11308 for which no WCEM parameter is given in the FORM string matches the
11309 wide character encoding specified for the main program (the default
11310 being brackets encoding if no coding method was specified with -gnatW).
11311
11312 @table @asis
11313
11314 @item UTF-8 Coding
11315 A wide character is represented using
11316 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11317 10646-1/Am.2.  Depending on the character value, the representation
11318 is a one, two, three, or four byte sequence:
11319
11320 @smallexample
11321 16#000000#-16#00007f#: 2#0xxxxxxx#
11322 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11323 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11324 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11325 @end smallexample
11326
11327 @noindent
11328 where the xxx bits correspond to the left-padded bits of the
11329 21-bit character value.  Note that all lower half ASCII characters
11330 are represented as ASCII bytes and all upper half characters and
11331 other wide characters are represented as sequences of upper-half
11332 characters.
11333
11334 @item Brackets Coding
11335 In this encoding, a wide wide character is represented by the following eight
11336 character sequence if is in wide character range
11337
11338 @smallexample
11339 [ " a b c d " ]
11340 @end smallexample
11341
11342 and by the following ten character sequence if not
11343
11344 @smallexample
11345 [ " a b c d e f " ]
11346 @end smallexample
11347
11348 @noindent
11349 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11350 are the four or six hexadecimal
11351 characters (using uppercase letters) of the wide wide character code.  For
11352 example, @code{["01A345"]} is used to represent the wide wide character
11353 with code @code{16#01A345#}.
11354
11355 This scheme is compatible with use of the full Wide_Wide_Character set.
11356 On input, brackets coding can also be used for upper half characters,
11357 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11358 is only used for wide characters with a code greater than @code{16#FF#}.
11359
11360 @end table
11361
11362 @noindent
11363 If is also possible to use the other Wide_Character encoding methods,
11364 such as Shift-JIS, but the other schemes cannot support the full range
11365 of wide wide characters.
11366 An attempt to output a character that cannot
11367 be represented using the encoding scheme for the file causes
11368 Constraint_Error to be raised.  An invalid wide character sequence on
11369 input also causes Constraint_Error to be raised.
11370
11371 @menu
11372 * Wide_Wide_Text_IO Stream Pointer Positioning::
11373 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11374 @end menu
11375
11376 @node Wide_Wide_Text_IO Stream Pointer Positioning
11377 @subsection Stream Pointer Positioning
11378
11379 @noindent
11380 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11381 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11382 case:
11383
11384 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11385 normal lower ASCII set (i.e.@: a character in the range:
11386
11387 @smallexample @c ada
11388 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11389 @end smallexample
11390
11391 @noindent
11392 then although the logical position of the file pointer is unchanged by
11393 the @code{Look_Ahead} call, the stream is physically positioned past the
11394 wide character sequence.  Again this is to avoid the need for buffering
11395 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11396 indication that this situation has occurred so that this is not visible
11397 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
11398 can be observed if the wide text file shares a stream with another file.
11399
11400 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11401 @subsection Reading and Writing Non-Regular Files
11402
11403 @noindent
11404 As in the case of Text_IO, when a non-regular file is read, it is
11405 assumed that the file contains no page marks (any form characters are
11406 treated as data characters), and @code{End_Of_Page} always returns
11407 @code{False}.  Similarly, the end of file indication is not sticky, so
11408 it is possible to read beyond an end of file.
11409
11410 @node Stream_IO
11411 @section Stream_IO
11412
11413 @noindent
11414 A stream file is a sequence of bytes, where individual elements are
11415 written to the file as described in the Ada 95 reference manual.  The type
11416 @code{Stream_Element} is simply a byte.  There are two ways to read or
11417 write a stream file.
11418
11419 @itemize @bullet
11420 @item
11421 The operations @code{Read} and @code{Write} directly read or write a
11422 sequence of stream elements with no control information.
11423
11424 @item
11425 The stream attributes applied to a stream file transfer data in the
11426 manner described for stream attributes.
11427 @end itemize
11428
11429 @node Shared Files
11430 @section Shared Files
11431
11432 @noindent
11433 Section A.14 of the Ada 95 Reference Manual allows implementations to
11434 provide a wide variety of behavior if an attempt is made to access the
11435 same external file with two or more internal files.
11436
11437 To provide a full range of functionality, while at the same time
11438 minimizing the problems of portability caused by this implementation
11439 dependence, GNAT handles file sharing as follows:
11440
11441 @itemize @bullet
11442 @item
11443 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11444 to open two or more files with the same full name is considered an error
11445 and is not supported.  The exception @code{Use_Error} will be
11446 raised.  Note that a file that is not explicitly closed by the program
11447 remains open until the program terminates.
11448
11449 @item
11450 If the form parameter @samp{shared=no} appears in the form string, the
11451 file can be opened or created with its own separate stream identifier,
11452 regardless of whether other files sharing the same external file are
11453 opened.  The exact effect depends on how the C stream routines handle
11454 multiple accesses to the same external files using separate streams.
11455
11456 @item
11457 If the form parameter @samp{shared=yes} appears in the form string for
11458 each of two or more files opened using the same full name, the same
11459 stream is shared between these files, and the semantics are as described
11460 in Ada 95 Reference Manual, Section A.14.
11461 @end itemize
11462
11463 @noindent
11464 When a program that opens multiple files with the same name is ported
11465 from another Ada compiler to GNAT, the effect will be that
11466 @code{Use_Error} is raised.
11467
11468 The documentation of the original compiler and the documentation of the
11469 program should then be examined to determine if file sharing was
11470 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11471 and @code{Create} calls as required.
11472
11473 When a program is ported from GNAT to some other Ada compiler, no
11474 special attention is required unless the @samp{shared=@var{xxx}} form
11475 parameter is used in the program.  In this case, you must examine the
11476 documentation of the new compiler to see if it supports the required
11477 file sharing semantics, and form strings modified appropriately.  Of
11478 course it may be the case that the program cannot be ported if the
11479 target compiler does not support the required functionality.  The best
11480 approach in writing portable code is to avoid file sharing (and hence
11481 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11482 completely.
11483
11484 One common use of file sharing in Ada 83 is the use of instantiations of
11485 Sequential_IO on the same file with different types, to achieve
11486 heterogeneous input-output.  Although this approach will work in GNAT if
11487 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11488 for this purpose (using the stream attributes)
11489
11490 @node Open Modes
11491 @section Open Modes
11492
11493 @noindent
11494 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11495 using the mode shown in the following table:
11496
11497 @sp 2
11498 @center @code{Open} and @code{Create} Call Modes
11499 @smallexample
11500                                @b{OPEN }           @b{CREATE}
11501 Append_File                    "r+"             "w+"
11502 In_File                        "r"              "w+"
11503 Out_File (Direct_IO)           "r+"             "w"
11504 Out_File (all other cases)     "w"              "w"
11505 Inout_File                     "r+"             "w+"
11506 @end smallexample
11507
11508 @noindent
11509 If text file translation is required, then either @samp{b} or @samp{t}
11510 is added to the mode, depending on the setting of Text.  Text file
11511 translation refers to the mapping of CR/LF sequences in an external file
11512 to LF characters internally.  This mapping only occurs in DOS and
11513 DOS-like systems, and is not relevant to other systems.
11514
11515 A special case occurs with Stream_IO@.  As shown in the above table, the
11516 file is initially opened in @samp{r} or @samp{w} mode for the
11517 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11518 subsequently requires switching from reading to writing or vice-versa,
11519 then the file is reopened in @samp{r+} mode to permit the required operation.
11520
11521 @node Operations on C Streams
11522 @section Operations on C Streams
11523 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11524 access to the C library functions for operations on C streams:
11525
11526 @smallexample @c adanocomment
11527 package Interfaces.C_Streams is
11528   -- Note: the reason we do not use the types that are in
11529   -- Interfaces.C is that we want to avoid dragging in the
11530   -- code in this unit if possible.
11531   subtype chars is System.Address;
11532   -- Pointer to null-terminated array of characters
11533   subtype FILEs is System.Address;
11534   -- Corresponds to the C type FILE*
11535   subtype voids is System.Address;
11536   -- Corresponds to the C type void*
11537   subtype int is Integer;
11538   subtype long is Long_Integer;
11539   -- Note: the above types are subtypes deliberately, and it
11540   -- is part of this spec that the above correspondences are
11541   -- guaranteed.  This means that it is legitimate to, for
11542   -- example, use Integer instead of int.  We provide these
11543   -- synonyms for clarity, but in some cases it may be
11544   -- convenient to use the underlying types (for example to
11545   -- avoid an unnecessary dependency of a spec on the spec
11546   -- of this unit).
11547   type size_t is mod 2 ** Standard'Address_Size;
11548   NULL_Stream : constant FILEs;
11549   -- Value returned (NULL in C) to indicate an
11550   -- fdopen/fopen/tmpfile error
11551   ----------------------------------
11552   -- Constants Defined in stdio.h --
11553   ----------------------------------
11554   EOF : constant int;
11555   -- Used by a number of routines to indicate error or
11556   -- end of file
11557   IOFBF : constant int;
11558   IOLBF : constant int;
11559   IONBF : constant int;
11560   -- Used to indicate buffering mode for setvbuf call
11561   SEEK_CUR : constant int;
11562   SEEK_END : constant int;
11563   SEEK_SET : constant int;
11564   -- Used to indicate origin for fseek call
11565   function stdin return FILEs;
11566   function stdout return FILEs;
11567   function stderr return FILEs;
11568   -- Streams associated with standard files
11569   --------------------------
11570   -- Standard C functions --
11571   --------------------------
11572   -- The functions selected below are ones that are
11573   -- available in DOS, OS/2, UNIX and Xenix (but not
11574   -- necessarily in ANSI C).  These are very thin interfaces
11575   -- which copy exactly the C headers.  For more
11576   -- documentation on these functions, see the Microsoft C
11577   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11578   -- ISBN 1-55615-225-6), which includes useful information
11579   -- on system compatibility.
11580   procedure clearerr (stream : FILEs);
11581   function fclose (stream : FILEs) return int;
11582   function fdopen (handle : int; mode : chars) return FILEs;
11583   function feof (stream : FILEs) return int;
11584   function ferror (stream : FILEs) return int;
11585   function fflush (stream : FILEs) return int;
11586   function fgetc (stream : FILEs) return int;
11587   function fgets (strng : chars; n : int; stream : FILEs)
11588       return chars;
11589   function fileno (stream : FILEs) return int;
11590   function fopen (filename : chars; Mode : chars)
11591       return FILEs;
11592   -- Note: to maintain target independence, use
11593   -- text_translation_required, a boolean variable defined in
11594   -- a-sysdep.c to deal with the target dependent text
11595   -- translation requirement.  If this variable is set,
11596   -- then  b/t should be appended to the standard mode
11597   -- argument to set the text translation mode off or on
11598   -- as required.
11599   function fputc (C : int; stream : FILEs) return int;
11600   function fputs (Strng : chars; Stream : FILEs) return int;
11601   function fread
11602      (buffer : voids;
11603       size : size_t;
11604       count : size_t;
11605       stream : FILEs)
11606       return size_t;
11607   function freopen
11608      (filename : chars;
11609       mode : chars;
11610       stream : FILEs)
11611       return FILEs;
11612   function fseek
11613      (stream : FILEs;
11614       offset : long;
11615       origin : int)
11616       return int;
11617   function ftell (stream : FILEs) return long;
11618   function fwrite
11619      (buffer : voids;
11620       size : size_t;
11621       count : size_t;
11622       stream : FILEs)
11623       return size_t;
11624   function isatty (handle : int) return int;
11625   procedure mktemp (template : chars);
11626   -- The return value (which is just a pointer to template)
11627   -- is discarded
11628   procedure rewind (stream : FILEs);
11629   function rmtmp return int;
11630   function setvbuf
11631      (stream : FILEs;
11632       buffer : chars;
11633       mode : int;
11634       size : size_t)
11635       return int;
11636
11637   function tmpfile return FILEs;
11638   function ungetc (c : int; stream : FILEs) return int;
11639   function unlink (filename : chars) return int;
11640   ---------------------
11641   -- Extra functions --
11642   ---------------------
11643   -- These functions supply slightly thicker bindings than
11644   -- those above.  They are derived from functions in the
11645   -- C Run-Time Library, but may do a bit more work than
11646   -- just directly calling one of the Library functions.
11647   function is_regular_file (handle : int) return int;
11648   -- Tests if given handle is for a regular file (result 1)
11649   -- or for a non-regular file (pipe or device, result 0).
11650   ---------------------------------
11651   -- Control of Text/Binary Mode --
11652   ---------------------------------
11653   -- If text_translation_required is true, then the following
11654   -- functions may be used to dynamically switch a file from
11655   -- binary to text mode or vice versa.  These functions have
11656   -- no effect if text_translation_required is false (i.e.  in
11657   -- normal UNIX mode).  Use fileno to get a stream handle.
11658   procedure set_binary_mode (handle : int);
11659   procedure set_text_mode (handle : int);
11660   ----------------------------
11661   -- Full Path Name support --
11662   ----------------------------
11663   procedure full_name (nam : chars; buffer : chars);
11664   -- Given a NUL terminated string representing a file
11665   -- name, returns in buffer a NUL terminated string
11666   -- representing the full path name for the file name.
11667   -- On systems where it is relevant the   drive is also
11668   -- part of the full path name.  It is the responsibility
11669   -- of the caller to pass an actual parameter for buffer
11670   -- that is big enough for any full path name.  Use
11671   -- max_path_len given below as the size of buffer.
11672   max_path_len : integer;
11673   -- Maximum length of an allowable full path name on the
11674   -- system, including a terminating NUL character.
11675 end Interfaces.C_Streams;
11676 @end smallexample
11677
11678 @node Interfacing to C Streams
11679 @section Interfacing to C Streams
11680
11681 @noindent
11682 The packages in this section permit interfacing Ada files to C Stream
11683 operations.
11684
11685 @smallexample @c ada
11686  with Interfaces.C_Streams;
11687  package Ada.Sequential_IO.C_Streams is
11688     function C_Stream (F : File_Type)
11689        return Interfaces.C_Streams.FILEs;
11690     procedure Open
11691       (File : in out File_Type;
11692        Mode : in File_Mode;
11693        C_Stream : in Interfaces.C_Streams.FILEs;
11694        Form : in String := "");
11695  end Ada.Sequential_IO.C_Streams;
11696
11697   with Interfaces.C_Streams;
11698   package Ada.Direct_IO.C_Streams is
11699      function C_Stream (F : File_Type)
11700         return Interfaces.C_Streams.FILEs;
11701      procedure Open
11702        (File : in out File_Type;
11703         Mode : in File_Mode;
11704         C_Stream : in Interfaces.C_Streams.FILEs;
11705         Form : in String := "");
11706   end Ada.Direct_IO.C_Streams;
11707
11708   with Interfaces.C_Streams;
11709   package Ada.Text_IO.C_Streams is
11710      function C_Stream (F : File_Type)
11711         return Interfaces.C_Streams.FILEs;
11712      procedure Open
11713        (File : in out File_Type;
11714         Mode : in File_Mode;
11715         C_Stream : in Interfaces.C_Streams.FILEs;
11716         Form : in String := "");
11717   end Ada.Text_IO.C_Streams;
11718
11719   with Interfaces.C_Streams;
11720   package Ada.Wide_Text_IO.C_Streams is
11721      function C_Stream (F : File_Type)
11722         return Interfaces.C_Streams.FILEs;
11723      procedure Open
11724        (File : in out File_Type;
11725         Mode : in File_Mode;
11726         C_Stream : in Interfaces.C_Streams.FILEs;
11727         Form : in String := "");
11728  end Ada.Wide_Text_IO.C_Streams;
11729
11730   with Interfaces.C_Streams;
11731   package Ada.Wide_Wide_Text_IO.C_Streams is
11732      function C_Stream (F : File_Type)
11733         return Interfaces.C_Streams.FILEs;
11734      procedure Open
11735        (File : in out File_Type;
11736         Mode : in File_Mode;
11737         C_Stream : in Interfaces.C_Streams.FILEs;
11738         Form : in String := "");
11739  end Ada.Wide_Wide_Text_IO.C_Streams;
11740
11741  with Interfaces.C_Streams;
11742  package Ada.Stream_IO.C_Streams is
11743     function C_Stream (F : File_Type)
11744        return Interfaces.C_Streams.FILEs;
11745     procedure Open
11746       (File : in out File_Type;
11747        Mode : in File_Mode;
11748        C_Stream : in Interfaces.C_Streams.FILEs;
11749        Form : in String := "");
11750  end Ada.Stream_IO.C_Streams;
11751 @end smallexample
11752
11753 @noindent
11754 In each of these six packages, the @code{C_Stream} function obtains the
11755 @code{FILE} pointer from a currently opened Ada file.  It is then
11756 possible to use the @code{Interfaces.C_Streams} package to operate on
11757 this stream, or the stream can be passed to a C program which can
11758 operate on it directly.  Of course the program is responsible for
11759 ensuring that only appropriate sequences of operations are executed.
11760
11761 One particular use of relevance to an Ada program is that the
11762 @code{setvbuf} function can be used to control the buffering of the
11763 stream used by an Ada file.  In the absence of such a call the standard
11764 default buffering is used.
11765
11766 The @code{Open} procedures in these packages open a file giving an
11767 existing C Stream instead of a file name.  Typically this stream is
11768 imported from a C program, allowing an Ada file to operate on an
11769 existing C file.
11770
11771 @node The GNAT Library
11772 @chapter The GNAT Library
11773
11774 @noindent
11775 The GNAT library contains a number of general and special purpose packages.
11776 It represents functionality that the GNAT developers have found useful, and
11777 which is made available to GNAT users.  The packages described here are fully
11778 supported, and upwards compatibility will be maintained in future releases,
11779 so you can use these facilities with the confidence that the same functionality
11780 will be available in future releases.
11781
11782 The chapter here simply gives a brief summary of the facilities available.
11783 The full documentation is found in the spec file for the package.  The full
11784 sources of these library packages, including both spec and body, are provided
11785 with all GNAT releases.  For example, to find out the full specifications of
11786 the SPITBOL pattern matching capability, including a full tutorial and
11787 extensive examples, look in the @file{g-spipat.ads} file in the library.
11788
11789 For each entry here, the package name (as it would appear in a @code{with}
11790 clause) is given, followed by the name of the corresponding spec file in
11791 parentheses.  The packages are children in four hierarchies, @code{Ada},
11792 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11793 GNAT-specific hierarchy.
11794
11795 Note that an application program should only use packages in one of these
11796 four hierarchies if the package is defined in the Ada Reference Manual,
11797 or is listed in this section of the GNAT Programmers Reference Manual.
11798 All other units should be considered internal implementation units and
11799 should not be directly @code{with}'ed by application code.  The use of
11800 a @code{with} statement that references one of these internal implementation
11801 units makes an application potentially dependent on changes in versions
11802 of GNAT, and will generate a warning message.
11803
11804 @menu
11805 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11806 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11807 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11808 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
11809 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
11810 * Ada.Command_Line.Remove (a-colire.ads)::
11811 * Ada.Command_Line.Environment (a-colien.ads)::
11812 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11813 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11814 * Ada.Exceptions.Traceback (a-exctra.ads)::
11815 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11816 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11817 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11818 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11819 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
11820 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11821 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11822 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
11823 * GNAT.Array_Split (g-arrspl.ads)::
11824 * GNAT.AWK (g-awk.ads)::
11825 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11826 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11827 * GNAT.Bubble_Sort (g-bubsor.ads)::
11828 * GNAT.Bubble_Sort_A (g-busora.ads)::
11829 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11830 * GNAT.Calendar (g-calend.ads)::
11831 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11832 * GNAT.CRC32 (g-crc32.ads)::
11833 * GNAT.Case_Util (g-casuti.ads)::
11834 * GNAT.CGI (g-cgi.ads)::
11835 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11836 * GNAT.CGI.Debug (g-cgideb.ads)::
11837 * GNAT.Command_Line (g-comlin.ads)::
11838 * GNAT.Compiler_Version (g-comver.ads)::
11839 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11840 * GNAT.Current_Exception (g-curexc.ads)::
11841 * GNAT.Debug_Pools (g-debpoo.ads)::
11842 * GNAT.Debug_Utilities (g-debuti.ads)::
11843 * GNAT.Directory_Operations (g-dirope.ads)::
11844 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11845 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11846 * GNAT.Exception_Actions (g-excact.ads)::
11847 * GNAT.Exception_Traces (g-exctra.ads)::
11848 * GNAT.Exceptions (g-except.ads)::
11849 * GNAT.Expect (g-expect.ads)::
11850 * GNAT.Float_Control (g-flocon.ads)::
11851 * GNAT.Heap_Sort (g-heasor.ads)::
11852 * GNAT.Heap_Sort_A (g-hesora.ads)::
11853 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11854 * GNAT.HTable (g-htable.ads)::
11855 * GNAT.IO (g-io.ads)::
11856 * GNAT.IO_Aux (g-io_aux.ads)::
11857 * GNAT.Lock_Files (g-locfil.ads)::
11858 * GNAT.MD5 (g-md5.ads)::
11859 * GNAT.Memory_Dump (g-memdum.ads)::
11860 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11861 * GNAT.OS_Lib (g-os_lib.ads)::
11862 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
11863 * GNAT.Regexp (g-regexp.ads)::
11864 * GNAT.Registry (g-regist.ads)::
11865 * GNAT.Regpat (g-regpat.ads)::
11866 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11867 * GNAT.Semaphores (g-semaph.ads)::
11868 * GNAT.Signals (g-signal.ads)::
11869 * GNAT.Sockets (g-socket.ads)::
11870 * GNAT.Source_Info (g-souinf.ads)::
11871 * GNAT.Spell_Checker (g-speche.ads)::
11872 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11873 * GNAT.Spitbol (g-spitbo.ads)::
11874 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11875 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11876 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11877 * GNAT.Strings (g-string.ads)::
11878 * GNAT.String_Split (g-strspl.ads)::
11879 * GNAT.UTF_32 (g-utf_32.ads)::
11880 * GNAT.Table (g-table.ads)::
11881 * GNAT.Task_Lock (g-tasloc.ads)::
11882 * GNAT.Threads (g-thread.ads)::
11883 * GNAT.Traceback (g-traceb.ads)::
11884 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11885 * GNAT.Wide_String_Split (g-wistsp.ads)::
11886 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
11887 * Interfaces.C.Extensions (i-cexten.ads)::
11888 * Interfaces.C.Streams (i-cstrea.ads)::
11889 * Interfaces.CPP (i-cpp.ads)::
11890 * Interfaces.Os2lib (i-os2lib.ads)::
11891 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11892 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11893 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11894 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11895 * Interfaces.VxWorks (i-vxwork.ads)::
11896 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11897 * System.Address_Image (s-addima.ads)::
11898 * System.Assertions (s-assert.ads)::
11899 * System.Memory (s-memory.ads)::
11900 * System.Partition_Interface (s-parint.ads)::
11901 * System.Restrictions (s-restri.ads)::
11902 * System.Rident (s-rident.ads)::
11903 * System.Task_Info (s-tasinf.ads)::
11904 * System.Wch_Cnv (s-wchcnv.ads)::
11905 * System.Wch_Con (s-wchcon.ads)::
11906 @end menu
11907
11908 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11909 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11910 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11911 @cindex Latin_9 constants for Character
11912
11913 @noindent
11914 This child of @code{Ada.Characters}
11915 provides a set of definitions corresponding to those in the
11916 RM-defined package @code{Ada.Characters.Latin_1} but with the
11917 few modifications required for @code{Latin-9}
11918 The provision of such a package
11919 is specifically authorized by the Ada Reference Manual
11920 (RM A.3(27)).
11921
11922 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11923 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11924 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11925 @cindex Latin_1 constants for Wide_Character
11926
11927 @noindent
11928 This child of @code{Ada.Characters}
11929 provides a set of definitions corresponding to those in the
11930 RM-defined package @code{Ada.Characters.Latin_1} but with the
11931 types of the constants being @code{Wide_Character}
11932 instead of @code{Character}.  The provision of such a package
11933 is specifically authorized by the Ada Reference Manual
11934 (RM A.3(27)).
11935
11936 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11937 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11938 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11939 @cindex Latin_9 constants for Wide_Character
11940
11941 @noindent
11942 This child of @code{Ada.Characters}
11943 provides a set of definitions corresponding to those in the
11944 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11945 types of the constants being @code{Wide_Character}
11946 instead of @code{Character}.  The provision of such a package
11947 is specifically authorized by the Ada Reference Manual
11948 (RM A.3(27)).
11949
11950 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
11951 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11952 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11953 @cindex Latin_1 constants for Wide_Wide_Character
11954
11955 @noindent
11956 This child of @code{Ada.Characters}
11957 provides a set of definitions corresponding to those in the
11958 RM-defined package @code{Ada.Characters.Latin_1} but with the
11959 types of the constants being @code{Wide_Wide_Character}
11960 instead of @code{Character}.  The provision of such a package
11961 is specifically authorized by the Ada Reference Manual
11962 (RM A.3(27)).
11963
11964 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
11965 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11966 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11967 @cindex Latin_9 constants for Wide_Wide_Character
11968
11969 @noindent
11970 This child of @code{Ada.Characters}
11971 provides a set of definitions corresponding to those in the
11972 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11973 types of the constants being @code{Wide_Wide_Character}
11974 instead of @code{Character}.  The provision of such a package
11975 is specifically authorized by the Ada Reference Manual
11976 (RM A.3(27)).
11977
11978 @node Ada.Command_Line.Remove (a-colire.ads)
11979 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11980 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11981 @cindex Removing command line arguments
11982 @cindex Command line, argument removal
11983
11984 @noindent
11985 This child of @code{Ada.Command_Line}
11986 provides a mechanism for logically removing
11987 arguments from the argument list.  Once removed, an argument is not visible
11988 to further calls on the subprograms in @code{Ada.Command_Line} will not
11989 see the removed argument.
11990
11991 @node Ada.Command_Line.Environment (a-colien.ads)
11992 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11993 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11994 @cindex Environment entries
11995
11996 @noindent
11997 This child of @code{Ada.Command_Line}
11998 provides a mechanism for obtaining environment values on systems
11999 where this concept makes sense.
12000
12001 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12002 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12003 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12004 @cindex C Streams, Interfacing with Direct_IO
12005
12006 @noindent
12007 This package provides subprograms that allow interfacing between
12008 C streams and @code{Direct_IO}.  The stream identifier can be
12009 extracted from a file opened on the Ada side, and an Ada file
12010 can be constructed from a stream opened on the C side.
12011
12012 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12013 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12014 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12015 @cindex Null_Occurrence, testing for
12016
12017 @noindent
12018 This child subprogram provides a way of testing for the null
12019 exception occurrence (@code{Null_Occurrence}) without raising
12020 an exception.
12021
12022 @node Ada.Exceptions.Traceback (a-exctra.ads)
12023 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12024 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12025 @cindex Traceback for Exception Occurrence
12026
12027 @noindent
12028 This child package provides the subprogram (@code{Tracebacks}) to
12029 give a traceback array of addresses based on an exception
12030 occurrence.
12031
12032 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12033 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12034 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12035 @cindex C Streams, Interfacing with Sequential_IO
12036
12037 @noindent
12038 This package provides subprograms that allow interfacing between
12039 C streams and @code{Sequential_IO}.  The stream identifier can be
12040 extracted from a file opened on the Ada side, and an Ada file
12041 can be constructed from a stream opened on the C side.
12042
12043 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12044 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12045 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12046 @cindex C Streams, Interfacing with Stream_IO
12047
12048 @noindent
12049 This package provides subprograms that allow interfacing between
12050 C streams and @code{Stream_IO}.  The stream identifier can be
12051 extracted from a file opened on the Ada side, and an Ada file
12052 can be constructed from a stream opened on the C side.
12053
12054 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12055 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12056 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12057 @cindex @code{Unbounded_String}, IO support
12058 @cindex @code{Text_IO}, extensions for unbounded strings
12059
12060 @noindent
12061 This package provides subprograms for Text_IO for unbounded
12062 strings, avoiding the necessity for an intermediate operation
12063 with ordinary strings.
12064
12065 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12066 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12067 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12068 @cindex @code{Unbounded_Wide_String}, IO support
12069 @cindex @code{Text_IO}, extensions for unbounded wide strings
12070
12071 @noindent
12072 This package provides subprograms for Text_IO for unbounded
12073 wide strings, avoiding the necessity for an intermediate operation
12074 with ordinary wide strings.
12075
12076 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12077 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12078 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12079 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12080 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12081
12082 @noindent
12083 This package provides subprograms for Text_IO for unbounded
12084 wide wide strings, avoiding the necessity for an intermediate operation
12085 with ordinary wide wide strings.
12086
12087 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12088 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12089 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12090 @cindex C Streams, Interfacing with @code{Text_IO}
12091
12092 @noindent
12093 This package provides subprograms that allow interfacing between
12094 C streams and @code{Text_IO}.  The stream identifier can be
12095 extracted from a file opened on the Ada side, and an Ada file
12096 can be constructed from a stream opened on the C side.
12097
12098 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12099 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12100 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12101 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12102
12103 @noindent
12104 This package provides subprograms that allow interfacing between
12105 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12106 extracted from a file opened on the Ada side, and an Ada file
12107 can be constructed from a stream opened on the C side.
12108
12109 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12110 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12111 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12112 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12113
12114 @noindent
12115 This package provides subprograms that allow interfacing between
12116 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12117 extracted from a file opened on the Ada side, and an Ada file
12118 can be constructed from a stream opened on the C side.
12119
12120
12121 @node GNAT.Array_Split (g-arrspl.ads)
12122 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12123 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12124 @cindex Array splitter
12125
12126 @noindent
12127 Useful array-manipulation routines: given a set of separators, split
12128 an array wherever the separators appear, and provide direct access
12129 to the resulting slices.
12130
12131 @node GNAT.AWK (g-awk.ads)
12132 @section @code{GNAT.AWK} (@file{g-awk.ads})
12133 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12134 @cindex Parsing
12135 @cindex AWK
12136
12137 @noindent
12138 Provides AWK-like parsing functions, with an easy interface for parsing one
12139 or more files containing formatted data.  The file is viewed as a database
12140 where each record is a line and a field is a data element in this line.
12141
12142 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12143 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12144 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12145 @cindex Parsing
12146 @cindex Bounded Buffers
12147
12148 @noindent
12149 Provides a concurrent generic bounded buffer abstraction.  Instances are
12150 useful directly or as parts of the implementations of other abstractions,
12151 such as mailboxes.
12152
12153 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12154 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12155 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12156 @cindex Parsing
12157 @cindex Mailboxes
12158
12159 @noindent
12160 Provides a thread-safe asynchronous intertask mailbox communication facility.
12161
12162 @node GNAT.Bubble_Sort (g-bubsor.ads)
12163 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12164 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12165 @cindex Sorting
12166 @cindex Bubble sort
12167
12168 @noindent
12169 Provides a general implementation of bubble sort usable for sorting arbitrary
12170 data items.  Exchange and comparison procedures are provided by passing
12171 access-to-procedure values.
12172
12173 @node GNAT.Bubble_Sort_A (g-busora.ads)
12174 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12175 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12176 @cindex Sorting
12177 @cindex Bubble sort
12178
12179 @noindent
12180 Provides a general implementation of bubble sort usable for sorting arbitrary
12181 data items.  Move and comparison procedures are provided by passing
12182 access-to-procedure values. This is an older version, retained for
12183 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12184
12185 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12186 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12187 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12188 @cindex Sorting
12189 @cindex Bubble sort
12190
12191 @noindent
12192 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12193 are provided as generic parameters, this improves efficiency, especially
12194 if the procedures can be inlined, at the expense of duplicating code for
12195 multiple instantiations.
12196
12197 @node GNAT.Calendar (g-calend.ads)
12198 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12199 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12200 @cindex @code{Calendar}
12201
12202 @noindent
12203 Extends the facilities provided by @code{Ada.Calendar} to include handling
12204 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12205 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12206 C @code{timeval} format.
12207
12208 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12209 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12210 @cindex @code{Calendar}
12211 @cindex Time
12212 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12213
12214 @node GNAT.CRC32 (g-crc32.ads)
12215 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12216 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12217 @cindex CRC32
12218 @cindex Cyclic Redundancy Check
12219
12220 @noindent
12221 This package implements the CRC-32 algorithm.  For a full description
12222 of this algorithm see
12223 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12224 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12225 Aug.@: 1988.  Sarwate, D.V@.
12226
12227 @noindent
12228 Provides an extended capability for formatted output of time values with
12229 full user control over the format.  Modeled on the GNU Date specification.
12230
12231 @node GNAT.Case_Util (g-casuti.ads)
12232 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12233 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12234 @cindex Casing utilities
12235 @cindex Character handling (@code{GNAT.Case_Util})
12236
12237 @noindent
12238 A set of simple routines for handling upper and lower casing of strings
12239 without the overhead of the full casing tables
12240 in @code{Ada.Characters.Handling}.
12241
12242 @node GNAT.CGI (g-cgi.ads)
12243 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12244 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12245 @cindex CGI (Common Gateway Interface)
12246
12247 @noindent
12248 This is a package for interfacing a GNAT program with a Web server via the
12249 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12250 parameters, which are a set of key/value pairs sent by the Web server.  It
12251 builds a table whose index is the key and provides some services to deal
12252 with this table.
12253
12254 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12255 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12256 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12257 @cindex CGI (Common Gateway Interface) cookie support
12258 @cindex Cookie support in CGI
12259
12260 @noindent
12261 This is a package to interface a GNAT program with a Web server via the
12262 Common Gateway Interface (CGI).  It exports services to deal with Web
12263 cookies (piece of information kept in the Web client software).
12264
12265 @node GNAT.CGI.Debug (g-cgideb.ads)
12266 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12267 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12268 @cindex CGI (Common Gateway Interface) debugging
12269
12270 @noindent
12271 This is a package to help debugging CGI (Common Gateway Interface)
12272 programs written in Ada.
12273
12274 @node GNAT.Command_Line (g-comlin.ads)
12275 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12276 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12277 @cindex Command line
12278
12279 @noindent
12280 Provides a high level interface to @code{Ada.Command_Line} facilities,
12281 including the ability to scan for named switches with optional parameters
12282 and expand file names using wild card notations.
12283
12284 @node GNAT.Compiler_Version (g-comver.ads)
12285 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12286 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12287 @cindex Compiler Version
12288 @cindex Version, of compiler
12289
12290 @noindent
12291 Provides a routine for obtaining the version of the compiler used to
12292 compile the program. More accurately this is the version of the binder
12293 used to bind the program (this will normally be the same as the version
12294 of the compiler if a consistent tool set is used to compile all units
12295 of a partition).
12296
12297 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12298 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12299 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12300 @cindex Interrupt
12301
12302 @noindent
12303 Provides a simple interface to handle Ctrl-C keyboard events.
12304
12305 @node GNAT.Current_Exception (g-curexc.ads)
12306 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12307 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12308 @cindex Current exception
12309 @cindex Exception retrieval
12310
12311 @noindent
12312 Provides access to information on the current exception that has been raised
12313 without the need for using the Ada-95 exception choice parameter specification
12314 syntax.  This is particularly useful in simulating typical facilities for
12315 obtaining information about exceptions provided by Ada 83 compilers.
12316
12317 @node GNAT.Debug_Pools (g-debpoo.ads)
12318 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12319 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12320 @cindex Debugging
12321 @cindex Debug pools
12322 @cindex Memory corruption debugging
12323
12324 @noindent
12325 Provide a debugging storage pools that helps tracking memory corruption
12326 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
12327 the @cite{GNAT User's Guide}.
12328
12329 @node GNAT.Debug_Utilities (g-debuti.ads)
12330 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12331 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12332 @cindex Debugging
12333
12334 @noindent
12335 Provides a few useful utilities for debugging purposes, including conversion
12336 to and from string images of address values. Supports both C and Ada formats
12337 for hexadecimal literals.
12338
12339 @node GNAT.Directory_Operations (g-dirope.ads)
12340 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12341 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12342 @cindex Directory operations
12343
12344 @noindent
12345 Provides a set of routines for manipulating directories, including changing
12346 the current directory, making new directories, and scanning the files in a
12347 directory.
12348
12349 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12350 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12351 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12352 @cindex Hash tables
12353
12354 @noindent
12355 A generic implementation of hash tables that can be used to hash arbitrary
12356 data.  Provided in two forms, a simple form with built in hash functions,
12357 and a more complex form in which the hash function is supplied.
12358
12359 @noindent
12360 This package provides a facility similar to that of @code{GNAT.HTable},
12361 except that this package declares a type that can be used to define
12362 dynamic instances of the hash table, while an instantiation of
12363 @code{GNAT.HTable} creates a single instance of the hash table.
12364
12365 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12366 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12367 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12368 @cindex Table implementation
12369 @cindex Arrays, extendable
12370
12371 @noindent
12372 A generic package providing a single dimension array abstraction where the
12373 length of the array can be dynamically modified.
12374
12375 @noindent
12376 This package provides a facility similar to that of @code{GNAT.Table},
12377 except that this package declares a type that can be used to define
12378 dynamic instances of the table, while an instantiation of
12379 @code{GNAT.Table} creates a single instance of the table type.
12380
12381 @node GNAT.Exception_Actions (g-excact.ads)
12382 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12383 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12384 @cindex Exception actions
12385
12386 @noindent
12387 Provides callbacks when an exception is raised. Callbacks can be registered
12388 for specific exceptions, or when any exception is raised. This
12389 can be used for instance to force a core dump to ease debugging.
12390
12391 @node GNAT.Exception_Traces (g-exctra.ads)
12392 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12393 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12394 @cindex Exception traces
12395 @cindex Debugging
12396
12397 @noindent
12398 Provides an interface allowing to control automatic output upon exception
12399 occurrences.
12400
12401 @node GNAT.Exceptions (g-except.ads)
12402 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12403 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12404 @cindex Exceptions, Pure
12405 @cindex Pure packages, exceptions
12406
12407 @noindent
12408 Normally it is not possible to raise an exception with
12409 a message from a subprogram in a pure package, since the
12410 necessary types and subprograms are in @code{Ada.Exceptions}
12411 which is not a pure unit. @code{GNAT.Exceptions} provides a
12412 facility for getting around this limitation for a few
12413 predefined exceptions, and for example allow raising
12414 @code{Constraint_Error} with a message from a pure subprogram.
12415
12416 @node GNAT.Expect (g-expect.ads)
12417 @section @code{GNAT.Expect} (@file{g-expect.ads})
12418 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12419
12420 @noindent
12421 Provides a set of subprograms similar to what is available
12422 with the standard Tcl Expect tool.
12423 It allows you to easily spawn and communicate with an external process.
12424 You can send commands or inputs to the process, and compare the output
12425 with some expected regular expression. Currently @code{GNAT.Expect}
12426 is implemented on all native GNAT ports except for OpenVMS@.
12427 It is not implemented for cross ports, and in particular is not
12428 implemented for VxWorks or LynxOS@.
12429
12430 @node GNAT.Float_Control (g-flocon.ads)
12431 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12432 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12433 @cindex Floating-Point Processor
12434
12435 @noindent
12436 Provides an interface for resetting the floating-point processor into the
12437 mode required for correct semantic operation in Ada.  Some third party
12438 library calls may cause this mode to be modified, and the Reset procedure
12439 in this package can be used to reestablish the required mode.
12440
12441 @node GNAT.Heap_Sort (g-heasor.ads)
12442 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12443 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12444 @cindex Sorting
12445
12446 @noindent
12447 Provides a general implementation of heap sort usable for sorting arbitrary
12448 data items. Exchange and comparison procedures are provided by passing
12449 access-to-procedure values.  The algorithm used is a modified heap sort
12450 that performs approximately N*log(N) comparisons in the worst case.
12451
12452 @node GNAT.Heap_Sort_A (g-hesora.ads)
12453 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12454 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12455 @cindex Sorting
12456
12457 @noindent
12458 Provides a general implementation of heap sort usable for sorting arbitrary
12459 data items. Move and comparison procedures are provided by passing
12460 access-to-procedure values.  The algorithm used is a modified heap sort
12461 that performs approximately N*log(N) comparisons in the worst case.
12462 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12463 interface, but may be slightly more efficient.
12464
12465 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12466 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12467 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12468 @cindex Sorting
12469
12470 @noindent
12471 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12472 are provided as generic parameters, this improves efficiency, especially
12473 if the procedures can be inlined, at the expense of duplicating code for
12474 multiple instantiations.
12475
12476 @node GNAT.HTable (g-htable.ads)
12477 @section @code{GNAT.HTable} (@file{g-htable.ads})
12478 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12479 @cindex Hash tables
12480
12481 @noindent
12482 A generic implementation of hash tables that can be used to hash arbitrary
12483 data.  Provides two approaches, one a simple static approach, and the other
12484 allowing arbitrary dynamic hash tables.
12485
12486 @node GNAT.IO (g-io.ads)
12487 @section @code{GNAT.IO} (@file{g-io.ads})
12488 @cindex @code{GNAT.IO} (@file{g-io.ads})
12489 @cindex Simple I/O
12490 @cindex Input/Output facilities
12491
12492 @noindent
12493 A simple preelaborable input-output package that provides a subset of
12494 simple Text_IO functions for reading characters and strings from
12495 Standard_Input, and writing characters, strings and integers to either
12496 Standard_Output or Standard_Error.
12497
12498 @node GNAT.IO_Aux (g-io_aux.ads)
12499 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12500 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12501 @cindex Text_IO
12502 @cindex Input/Output facilities
12503
12504 Provides some auxiliary functions for use with Text_IO, including a test
12505 for whether a file exists, and functions for reading a line of text.
12506
12507 @node GNAT.Lock_Files (g-locfil.ads)
12508 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12509 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12510 @cindex File locking
12511 @cindex Locking using files
12512
12513 @noindent
12514 Provides a general interface for using files as locks.  Can be used for
12515 providing program level synchronization.
12516
12517 @node GNAT.MD5 (g-md5.ads)
12518 @section @code{GNAT.MD5} (@file{g-md5.ads})
12519 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12520 @cindex Message Digest MD5
12521
12522 @noindent
12523 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12524
12525 @node GNAT.Memory_Dump (g-memdum.ads)
12526 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12527 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12528 @cindex Dump Memory
12529
12530 @noindent
12531 Provides a convenient routine for dumping raw memory to either the
12532 standard output or standard error files. Uses GNAT.IO for actual
12533 output.
12534
12535 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12536 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12537 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12538 @cindex Exception, obtaining most recent
12539
12540 @noindent
12541 Provides access to the most recently raised exception.  Can be used for
12542 various logging purposes, including duplicating functionality of some
12543 Ada 83 implementation dependent extensions.
12544
12545 @node GNAT.OS_Lib (g-os_lib.ads)
12546 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12547 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12548 @cindex Operating System interface
12549 @cindex Spawn capability
12550
12551 @noindent
12552 Provides a range of target independent operating system interface functions,
12553 including time/date management, file operations, subprocess management,
12554 including a portable spawn procedure, and access to environment variables
12555 and error return codes.
12556
12557 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
12558 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12559 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12560 @cindex Hash functions
12561
12562 @noindent
12563 Provides a generator of static minimal perfect hash functions. No
12564 collisions occur and each item can be retrieved from the table in one
12565 probe (perfect property). The hash table size corresponds to the exact
12566 size of the key set and no larger (minimal property). The key set has to
12567 be know in advance (static property). The hash functions are also order
12568 preserving. If w2 is inserted after w1 in the generator, their
12569 hashcode are in the same order. These hashing functions are very
12570 convenient for use with realtime applications.
12571
12572 @node GNAT.Regexp (g-regexp.ads)
12573 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12574 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12575 @cindex Regular expressions
12576 @cindex Pattern matching
12577
12578 @noindent
12579 A simple implementation of regular expressions, using a subset of regular
12580 expression syntax copied from familiar Unix style utilities.  This is the
12581 simples of the three pattern matching packages provided, and is particularly
12582 suitable for ``file globbing'' applications.
12583
12584 @node GNAT.Registry (g-regist.ads)
12585 @section @code{GNAT.Registry} (@file{g-regist.ads})
12586 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12587 @cindex Windows Registry
12588
12589 @noindent
12590 This is a high level binding to the Windows registry.  It is possible to
12591 do simple things like reading a key value, creating a new key.  For full
12592 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12593 package provided with the Win32Ada binding
12594
12595 @node GNAT.Regpat (g-regpat.ads)
12596 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12597 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12598 @cindex Regular expressions
12599 @cindex Pattern matching
12600
12601 @noindent
12602 A complete implementation of Unix-style regular expression matching, copied
12603 from the original V7 style regular expression library written in C by
12604 Henry Spencer (and binary compatible with this C library).
12605
12606 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12607 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12608 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12609 @cindex Secondary Stack Info
12610
12611 @noindent
12612 Provide the capability to query the high water mark of the current task's
12613 secondary stack.
12614
12615 @node GNAT.Semaphores (g-semaph.ads)
12616 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12617 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12618 @cindex Semaphores
12619
12620 @noindent
12621 Provides classic counting and binary semaphores using protected types.
12622
12623 @node GNAT.Signals (g-signal.ads)
12624 @section @code{GNAT.Signals} (@file{g-signal.ads})
12625 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12626 @cindex Signals
12627
12628 @noindent
12629 Provides the ability to manipulate the blocked status of signals on supported
12630 targets.
12631
12632 @node GNAT.Sockets (g-socket.ads)
12633 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12634 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12635 @cindex Sockets
12636
12637 @noindent
12638 A high level and portable interface to develop sockets based applications.
12639 This package is based on the sockets thin binding found in
12640 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12641 on all native GNAT ports except for OpenVMS@.  It is not implemented
12642 for the LynxOS@ cross port.
12643
12644 @node GNAT.Source_Info (g-souinf.ads)
12645 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12646 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12647 @cindex Source Information
12648
12649 @noindent
12650 Provides subprograms that give access to source code information known at
12651 compile time, such as the current file name and line number.
12652
12653 @node GNAT.Spell_Checker (g-speche.ads)
12654 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12655 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12656 @cindex Spell checking
12657
12658 @noindent
12659 Provides a function for determining whether one string is a plausible
12660 near misspelling of another string.
12661
12662 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12663 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12664 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12665 @cindex SPITBOL pattern matching
12666 @cindex Pattern matching
12667
12668 @noindent
12669 A complete implementation of SNOBOL4 style pattern matching.  This is the
12670 most elaborate of the pattern matching packages provided.  It fully duplicates
12671 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12672 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12673
12674 @node GNAT.Spitbol (g-spitbo.ads)
12675 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12676 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12677 @cindex SPITBOL interface
12678
12679 @noindent
12680 The top level package of the collection of SPITBOL-style functionality, this
12681 package provides basic SNOBOL4 string manipulation functions, such as
12682 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12683 useful for constructing arbitrary mappings from strings in the style of
12684 the SNOBOL4 TABLE function.
12685
12686 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12687 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12688 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12689 @cindex Sets of strings
12690 @cindex SPITBOL Tables
12691
12692 @noindent
12693 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12694 for type @code{Standard.Boolean}, giving an implementation of sets of
12695 string values.
12696
12697 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12698 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12699 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12700 @cindex Integer maps
12701 @cindex Maps
12702 @cindex SPITBOL Tables
12703
12704 @noindent
12705 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12706 for type @code{Standard.Integer}, giving an implementation of maps
12707 from string to integer values.
12708
12709 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12710 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12711 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12712 @cindex String maps
12713 @cindex Maps
12714 @cindex SPITBOL Tables
12715
12716 @noindent
12717 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12718 a variable length string type, giving an implementation of general
12719 maps from strings to strings.
12720
12721 @node GNAT.Strings (g-string.ads)
12722 @section @code{GNAT.Strings} (@file{g-string.ads})
12723 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12724
12725 @noindent
12726 Common String access types and related subprograms. Basically it
12727 defines a string access and an array of string access types.
12728
12729 @node GNAT.String_Split (g-strspl.ads)
12730 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12731 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12732 @cindex String splitter
12733
12734 @noindent
12735 Useful string manipulation routines: given a set of separators, split
12736 a string wherever the separators appear, and provide direct access
12737 to the resulting slices. This package is instantiated from
12738 @code{GNAT.Array_Split}.
12739
12740 @node GNAT.UTF_32 (g-utf_32.ads)
12741 @section @code{GNAT.UTF_32} (@file{g-table.ads})
12742 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
12743 @cindex Wide character codes
12744
12745 @noindent
12746 This is a package intended to be used in conjunction with the
12747 @code{Wide_Character} type in Ada 95 and the
12748 @code{Wide_Wide_Character} type in Ada 2005 (available
12749 in @code{GNAT} in Ada 2005 mode). This package contains
12750 Unicode categorization routines, as well as lexical
12751 categorization routines corresponding to the Ada 2005
12752 lexical rules for identifiers and strings, and also a
12753 lower case to upper case fold routine corresponding to
12754 the Ada 2005 rules for identifier equivalence.
12755
12756 @node GNAT.Table (g-table.ads)
12757 @section @code{GNAT.Table} (@file{g-table.ads})
12758 @cindex @code{GNAT.Table} (@file{g-table.ads})
12759 @cindex Table implementation
12760 @cindex Arrays, extendable
12761
12762 @noindent
12763 A generic package providing a single dimension array abstraction where the
12764 length of the array can be dynamically modified.
12765
12766 @noindent
12767 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12768 except that this package declares a single instance of the table type,
12769 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12770 used to define dynamic instances of the table.
12771
12772 @node GNAT.Task_Lock (g-tasloc.ads)
12773 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12774 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12775 @cindex Task synchronization
12776 @cindex Task locking
12777 @cindex Locking
12778
12779 @noindent
12780 A very simple facility for locking and unlocking sections of code using a
12781 single global task lock.  Appropriate for use in situations where contention
12782 between tasks is very rarely expected.
12783
12784 @node GNAT.Threads (g-thread.ads)
12785 @section @code{GNAT.Threads} (@file{g-thread.ads})
12786 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12787 @cindex Foreign threads
12788 @cindex Threads, foreign
12789
12790 @noindent
12791 Provides facilities for creating and destroying threads with explicit calls.
12792 These threads are known to the GNAT run-time system.  These subprograms are
12793 exported C-convention procedures intended to be called from foreign code.
12794 By using these primitives rather than directly calling operating systems
12795 routines, compatibility with the Ada tasking run-time is provided.
12796
12797 @node GNAT.Traceback (g-traceb.ads)
12798 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12799 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12800 @cindex Trace back facilities
12801
12802 @noindent
12803 Provides a facility for obtaining non-symbolic traceback information, useful
12804 in various debugging situations.
12805
12806 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12807 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12808 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12809 @cindex Trace back facilities
12810
12811 @noindent
12812 Provides symbolic traceback information that includes the subprogram
12813 name and line number information.
12814
12815 @node GNAT.Wide_String_Split (g-wistsp.ads)
12816 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12817 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12818 @cindex Wide_String splitter
12819
12820 @noindent
12821 Useful wide string manipulation routines: given a set of separators, split
12822 a wide string wherever the separators appear, and provide direct access
12823 to the resulting slices. This package is instantiated from
12824 @code{GNAT.Array_Split}.
12825
12826 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
12827 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12828 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12829 @cindex Wide_Wide_String splitter
12830
12831 @noindent
12832 Useful wide wide string manipulation routines: given a set of separators, split
12833 a wide wide string wherever the separators appear, and provide direct access
12834 to the resulting slices. This package is instantiated from
12835 @code{GNAT.Array_Split}.
12836
12837 @node Interfaces.C.Extensions (i-cexten.ads)
12838 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12839 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12840
12841 @noindent
12842 This package contains additional C-related definitions, intended
12843 for use with either manually or automatically generated bindings
12844 to C libraries.
12845
12846 @node Interfaces.C.Streams (i-cstrea.ads)
12847 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12848 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12849 @cindex  C streams, interfacing
12850
12851 @noindent
12852 This package is a binding for the most commonly used operations
12853 on C streams.
12854
12855 @node Interfaces.CPP (i-cpp.ads)
12856 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12857 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12858 @cindex  C++ interfacing
12859 @cindex  Interfacing, to C++
12860
12861 @noindent
12862 This package provides facilities for use in interfacing to C++.  It
12863 is primarily intended to be used in connection with automated tools
12864 for the generation of C++ interfaces.
12865
12866 @node Interfaces.Os2lib (i-os2lib.ads)
12867 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12868 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12869 @cindex Interfacing, to OS/2
12870 @cindex OS/2 interfacing
12871
12872 @noindent
12873 This package provides interface definitions to the OS/2 library.
12874 It is a thin binding which is a direct translation of the
12875 various @file{<bse@.h>} files.
12876
12877 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12878 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12879 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12880 @cindex OS/2 Error codes
12881 @cindex Interfacing, to OS/2
12882 @cindex OS/2 interfacing
12883
12884 @noindent
12885 This package provides definitions of the OS/2 error codes.
12886
12887 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12888 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12889 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12890 @cindex Interfacing, to OS/2
12891 @cindex Synchronization, OS/2
12892 @cindex OS/2 synchronization primitives
12893
12894 @noindent
12895 This is a child package that provides definitions for interfacing
12896 to the @code{OS/2} synchronization primitives.
12897
12898 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12899 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12900 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12901 @cindex Interfacing, to OS/2
12902 @cindex Thread control, OS/2
12903 @cindex OS/2 thread interfacing
12904
12905 @noindent
12906 This is a child package that provides definitions for interfacing
12907 to the @code{OS/2} thread primitives.
12908
12909 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12910 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12911 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12912 @cindex  IBM Packed Format
12913 @cindex  Packed Decimal
12914
12915 @noindent
12916 This package provides a set of routines for conversions to and
12917 from a packed decimal format compatible with that used on IBM
12918 mainframes.
12919
12920 @node Interfaces.VxWorks (i-vxwork.ads)
12921 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12922 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12923 @cindex Interfacing to VxWorks
12924 @cindex VxWorks, interfacing
12925
12926 @noindent
12927 This package provides a limited binding to the VxWorks API.
12928 In particular, it interfaces with the
12929 VxWorks hardware interrupt facilities.
12930
12931 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12932 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12933 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12934 @cindex Interfacing to VxWorks' I/O
12935 @cindex VxWorks, I/O interfacing
12936 @cindex VxWorks, Get_Immediate
12937 @cindex Get_Immediate, VxWorks
12938
12939 @noindent
12940 This package provides a binding to the ioctl (IO/Control)
12941 function of VxWorks, defining a set of option values and
12942 function codes. A particular use of this package is
12943 to enable the use of Get_Immediate under VxWorks.
12944
12945 @node System.Address_Image (s-addima.ads)
12946 @section @code{System.Address_Image} (@file{s-addima.ads})
12947 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12948 @cindex Address image
12949 @cindex Image, of an address
12950
12951 @noindent
12952 This function provides a useful debugging
12953 function that gives an (implementation dependent)
12954 string which identifies an address.
12955
12956 @node System.Assertions (s-assert.ads)
12957 @section @code{System.Assertions} (@file{s-assert.ads})
12958 @cindex @code{System.Assertions} (@file{s-assert.ads})
12959 @cindex Assertions
12960 @cindex Assert_Failure, exception
12961
12962 @noindent
12963 This package provides the declaration of the exception raised
12964 by an run-time assertion failure, as well as the routine that
12965 is used internally to raise this assertion.
12966
12967 @node System.Memory (s-memory.ads)
12968 @section @code{System.Memory} (@file{s-memory.ads})
12969 @cindex @code{System.Memory} (@file{s-memory.ads})
12970 @cindex Memory allocation
12971
12972 @noindent
12973 This package provides the interface to the low level routines used
12974 by the generated code for allocation and freeing storage for the
12975 default storage pool (analogous to the C routines malloc and free.
12976 It also provides a reallocation interface analogous to the C routine
12977 realloc. The body of this unit may be modified to provide alternative
12978 allocation mechanisms for the default pool, and in addition, direct
12979 calls to this unit may be made for low level allocation uses (for
12980 example see the body of @code{GNAT.Tables}).
12981
12982 @node System.Partition_Interface (s-parint.ads)
12983 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12984 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12985 @cindex Partition interfacing functions
12986
12987 @noindent
12988 This package provides facilities for partition interfacing.  It
12989 is used primarily in a distribution context when using Annex E
12990 with @code{GLADE}.
12991
12992 @node System.Restrictions (s-restri.ads)
12993 @section @code{System.Restrictions} (@file{s-restri.ads})
12994 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12995 @cindex Run-time restrictions access
12996
12997 @noindent
12998 This package provides facilities for accessing at run-time
12999 the status of restrictions specified at compile time for
13000 the partition. Information is available both with regard
13001 to actual restrictions specified, and with regard to
13002 compiler determined information on which restrictions
13003 are violated by one or more packages in the partition.
13004
13005 @node System.Rident (s-rident.ads)
13006 @section @code{System.Rident} (@file{s-rident.ads})
13007 @cindex @code{System.Rident} (@file{s-rident.ads})
13008 @cindex Restrictions definitions
13009
13010 @noindent
13011 This package provides definitions of the restrictions
13012 identifiers supported by GNAT, and also the format of
13013 the restrictions provided in package System.Restrictions.
13014 It is not normally necessary to @code{with} this generic package
13015 since the necessary instantiation is included in
13016 package System.Restrictions.
13017
13018 @node System.Task_Info (s-tasinf.ads)
13019 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13020 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13021 @cindex Task_Info pragma
13022
13023 @noindent
13024 This package provides target dependent functionality that is used
13025 to support the @code{Task_Info} pragma
13026
13027 @node System.Wch_Cnv (s-wchcnv.ads)
13028 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13029 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13030 @cindex Wide Character, Representation
13031 @cindex Wide String, Conversion
13032 @cindex Representation of wide characters
13033
13034 @noindent
13035 This package provides routines for converting between
13036 wide and wide wide characters and a representation as a value of type
13037 @code{Standard.String}, using a specified wide character
13038 encoding method.  It uses definitions in
13039 package @code{System.Wch_Con}.
13040
13041 @node System.Wch_Con (s-wchcon.ads)
13042 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13043 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13044
13045 @noindent
13046 This package provides definitions and descriptions of
13047 the various methods used for encoding wide characters
13048 in ordinary strings.  These definitions are used by
13049 the package @code{System.Wch_Cnv}.
13050
13051 @node Interfacing to Other Languages
13052 @chapter Interfacing to Other Languages
13053 @noindent
13054 The facilities in annex B of the Ada 95 Reference Manual are fully
13055 implemented in GNAT, and in addition, a full interface to C++ is
13056 provided.
13057
13058 @menu
13059 * Interfacing to C::
13060 * Interfacing to C++::
13061 * Interfacing to COBOL::
13062 * Interfacing to Fortran::
13063 * Interfacing to non-GNAT Ada code::
13064 @end menu
13065
13066 @node Interfacing to C
13067 @section Interfacing to C
13068
13069 @noindent
13070 Interfacing to C with GNAT can use one of two approaches:
13071
13072 @itemize @bullet
13073 @item
13074 The types in the package @code{Interfaces.C} may be used.
13075 @item
13076 Standard Ada types may be used directly.  This may be less portable to
13077 other compilers, but will work on all GNAT compilers, which guarantee
13078 correspondence between the C and Ada types.
13079 @end itemize
13080
13081 @noindent
13082 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13083 effect, since this is the default.  The following table shows the
13084 correspondence between Ada scalar types and the corresponding C types.
13085
13086 @table @code
13087 @item Integer
13088 @code{int}
13089 @item Short_Integer
13090 @code{short}
13091 @item Short_Short_Integer
13092 @code{signed char}
13093 @item Long_Integer
13094 @code{long}
13095 @item Long_Long_Integer
13096 @code{long long}
13097 @item Short_Float
13098 @code{float}
13099 @item Float
13100 @code{float}
13101 @item Long_Float
13102 @code{double}
13103 @item Long_Long_Float
13104 This is the longest floating-point type supported by the hardware.
13105 @end table
13106
13107 @noindent
13108 Additionally, there are the following general correspondences between Ada
13109 and C types:
13110 @itemize @bullet
13111 @item
13112 Ada enumeration types map to C enumeration types directly if pragma
13113 @code{Convention C} is specified, which causes them to have int
13114 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13115 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13116 @code{int}, respectively) depending on the number of values passed.
13117 This is the only case in which pragma @code{Convention C} affects the
13118 representation of an Ada type.
13119
13120 @item
13121 Ada access types map to C pointers, except for the case of pointers to
13122 unconstrained types in Ada, which have no direct C equivalent.
13123
13124 @item
13125 Ada arrays map directly to C arrays.
13126
13127 @item
13128 Ada records map directly to C structures.
13129
13130 @item
13131 Packed Ada records map to C structures where all members are bit fields
13132 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13133 @end itemize
13134
13135 @node Interfacing to C++
13136 @section Interfacing to C++
13137
13138 @noindent
13139 The interface to C++ makes use of the following pragmas, which are
13140 primarily intended to be constructed automatically using a binding generator
13141 tool, although it is possible to construct them by hand.  No suitable binding
13142 generator tool is supplied with GNAT though.
13143
13144 Using these pragmas it is possible to achieve complete
13145 inter-operability between Ada tagged types and C class definitions.
13146 See @ref{Implementation Defined Pragmas}, for more details.
13147
13148 @table @code
13149 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13150 The argument denotes an entity in the current declarative region that is
13151 declared as a tagged or untagged record type.  It indicates that the type
13152 corresponds to an externally declared C++ class type, and is to be laid
13153 out the same way that C++ would lay out the type.
13154
13155 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13156 This pragma identifies an imported function (imported in the usual way
13157 with pragma @code{Import}) as corresponding to a C++ constructor.
13158
13159 @item pragma CPP_Vtable @dots{}
13160 One @code{CPP_Vtable} pragma can be present for each component of type
13161 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13162 applies.
13163 @end table
13164
13165 @node Interfacing to COBOL
13166 @section Interfacing to COBOL
13167
13168 @noindent
13169 Interfacing to COBOL is achieved as described in section B.4 of
13170 the Ada 95 reference manual.
13171
13172 @node Interfacing to Fortran
13173 @section Interfacing to Fortran
13174
13175 @noindent
13176 Interfacing to Fortran is achieved as described in section B.5 of the
13177 reference manual.  The pragma @code{Convention Fortran}, applied to a
13178 multi-dimensional array causes the array to be stored in column-major
13179 order as required for convenient interface to Fortran.
13180
13181 @node Interfacing to non-GNAT Ada code
13182 @section Interfacing to non-GNAT Ada code
13183
13184 It is possible to specify the convention @code{Ada} in a pragma
13185 @code{Import} or pragma @code{Export}.  However this refers to
13186 the calling conventions used by GNAT, which may or may not be
13187 similar enough to those used by some other Ada 83 or Ada 95
13188 compiler to allow interoperation.
13189
13190 If arguments types are kept simple, and if the foreign compiler generally
13191 follows system calling conventions, then it may be possible to integrate
13192 files compiled by other Ada compilers, provided that the elaboration
13193 issues are adequately addressed (for example by eliminating the
13194 need for any load time elaboration).
13195
13196 In particular, GNAT running on VMS is designed to
13197 be highly compatible with the DEC Ada 83 compiler, so this is one
13198 case in which it is possible to import foreign units of this type,
13199 provided that the data items passed are restricted to simple scalar
13200 values or simple record types without variants, or simple array
13201 types with fixed bounds.
13202
13203 @node Specialized Needs Annexes
13204 @chapter Specialized Needs Annexes
13205
13206 @noindent
13207 Ada 95 defines a number of specialized needs annexes, which are not
13208 required in all implementations.  However, as described in this chapter,
13209 GNAT implements all of these special needs annexes:
13210
13211 @table @asis
13212 @item Systems Programming (Annex C)
13213 The Systems Programming Annex is fully implemented.
13214
13215 @item Real-Time Systems (Annex D)
13216 The Real-Time Systems Annex is fully implemented.
13217
13218 @item Distributed Systems (Annex E)
13219 Stub generation is fully implemented in the GNAT compiler.  In addition,
13220 a complete compatible PCS is available as part of the GLADE system,
13221 a separate product.  When the two
13222 products are used in conjunction, this annex is fully implemented.
13223
13224 @item Information Systems (Annex F)
13225 The Information Systems annex is fully implemented.
13226
13227 @item Numerics (Annex G)
13228 The Numerics Annex is fully implemented.
13229
13230 @item Safety and Security (Annex H)
13231 The Safety and Security annex is fully implemented.
13232 @end table
13233
13234 @node Implementation of Specific Ada Features
13235 @chapter Implementation of Specific Ada Features
13236
13237 @noindent
13238 This chapter describes the GNAT implementation of several Ada language
13239 facilities.
13240
13241 @menu
13242 * Machine Code Insertions::
13243 * GNAT Implementation of Tasking::
13244 * GNAT Implementation of Shared Passive Packages::
13245 * Code Generation for Array Aggregates::
13246 * The Size of Discriminated Records with Default Discriminants::
13247 @end menu
13248
13249 @node Machine Code Insertions
13250 @section Machine Code Insertions
13251
13252 @noindent
13253 Package @code{Machine_Code} provides machine code support as described
13254 in the Ada 95 Reference Manual in two separate forms:
13255 @itemize @bullet
13256 @item
13257 Machine code statements, consisting of qualified expressions that
13258 fit the requirements of RM section 13.8.
13259 @item
13260 An intrinsic callable procedure, providing an alternative mechanism of
13261 including machine instructions in a subprogram.
13262 @end itemize
13263
13264 @noindent
13265 The two features are similar, and both are closely related to the mechanism
13266 provided by the asm instruction in the GNU C compiler.  Full understanding
13267 and use of the facilities in this package requires understanding the asm
13268 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13269 by Richard Stallman. The relevant section is titled ``Extensions to the C
13270 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13271
13272 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13273 semantic restrictions and effects as described below.  Both are provided so
13274 that the procedure call can be used as a statement, and the function call
13275 can be used to form a code_statement.
13276
13277 The first example given in the GCC documentation is the C @code{asm}
13278 instruction:
13279 @smallexample
13280    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13281 @end smallexample
13282
13283 @noindent
13284 The equivalent can be written for GNAT as:
13285
13286 @smallexample @c ada
13287 Asm ("fsinx %1 %0",
13288      My_Float'Asm_Output ("=f", result),
13289      My_Float'Asm_Input  ("f",  angle));
13290 @end smallexample
13291
13292 @noindent
13293 The first argument to @code{Asm} is the assembler template, and is
13294 identical to what is used in GNU C@.  This string must be a static
13295 expression.  The second argument is the output operand list.  It is
13296 either a single @code{Asm_Output} attribute reference, or a list of such
13297 references enclosed in parentheses (technically an array aggregate of
13298 such references).
13299
13300 The @code{Asm_Output} attribute denotes a function that takes two
13301 parameters.  The first is a string, the second is the name of a variable
13302 of the type designated by the attribute prefix.  The first (string)
13303 argument is required to be a static expression and designates the
13304 constraint for the parameter (e.g.@: what kind of register is
13305 required).  The second argument is the variable to be updated with the
13306 result.  The possible values for constraint are the same as those used in
13307 the RTL, and are dependent on the configuration file used to build the
13308 GCC back end.  If there are no output operands, then this argument may
13309 either be omitted, or explicitly given as @code{No_Output_Operands}.
13310
13311 The second argument of @code{@var{my_float}'Asm_Output} functions as
13312 though it were an @code{out} parameter, which is a little curious, but
13313 all names have the form of expressions, so there is no syntactic
13314 irregularity, even though normally functions would not be permitted
13315 @code{out} parameters.  The third argument is the list of input
13316 operands.  It is either a single @code{Asm_Input} attribute reference, or
13317 a list of such references enclosed in parentheses (technically an array
13318 aggregate of such references).
13319
13320 The @code{Asm_Input} attribute denotes a function that takes two
13321 parameters.  The first is a string, the second is an expression of the
13322 type designated by the prefix.  The first (string) argument is required
13323 to be a static expression, and is the constraint for the parameter,
13324 (e.g.@: what kind of register is required).  The second argument is the
13325 value to be used as the input argument.  The possible values for the
13326 constant are the same as those used in the RTL, and are dependent on
13327 the configuration file used to built the GCC back end.
13328
13329 If there are no input operands, this argument may either be omitted, or
13330 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
13331 present in the above example, is a list of register names, called the
13332 @dfn{clobber} argument.  This argument, if given, must be a static string
13333 expression, and is a space or comma separated list of names of registers
13334 that must be considered destroyed as a result of the @code{Asm} call.  If
13335 this argument is the null string (the default value), then the code
13336 generator assumes that no additional registers are destroyed.
13337
13338 The fifth argument, not present in the above example, called the
13339 @dfn{volatile} argument, is by default @code{False}.  It can be set to
13340 the literal value @code{True} to indicate to the code generator that all
13341 optimizations with respect to the instruction specified should be
13342 suppressed, and that in particular, for an instruction that has outputs,
13343 the instruction will still be generated, even if none of the outputs are
13344 used.  See the full description in the GCC manual for further details.
13345
13346 The @code{Asm} subprograms may be used in two ways.  First the procedure
13347 forms can be used anywhere a procedure call would be valid, and
13348 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
13349 be used to intersperse machine instructions with other Ada statements.
13350 Second, the function forms, which return a dummy value of the limited
13351 private type @code{Asm_Insn}, can be used in code statements, and indeed
13352 this is the only context where such calls are allowed.  Code statements
13353 appear as aggregates of the form:
13354
13355 @smallexample @c ada
13356 Asm_Insn'(Asm (@dots{}));
13357 Asm_Insn'(Asm_Volatile (@dots{}));
13358 @end smallexample
13359
13360 @noindent
13361 In accordance with RM rules, such code statements are allowed only
13362 within subprograms whose entire body consists of such statements.  It is
13363 not permissible to intermix such statements with other Ada statements.
13364
13365 Typically the form using intrinsic procedure calls is more convenient
13366 and more flexible.  The code statement form is provided to meet the RM
13367 suggestion that such a facility should be made available.  The following
13368 is the exact syntax of the call to @code{Asm}. As usual, if named notation
13369 is used, the arguments may be given in arbitrary order, following the
13370 normal rules for use of positional and named arguments)
13371
13372 @smallexample
13373 ASM_CALL ::= Asm (
13374                  [Template =>] static_string_EXPRESSION
13375                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
13376                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
13377                [,[Clobber  =>] static_string_EXPRESSION ]
13378                [,[Volatile =>] static_boolean_EXPRESSION] )
13379
13380 OUTPUT_OPERAND_LIST ::=
13381   [PREFIX.]No_Output_Operands
13382 | OUTPUT_OPERAND_ATTRIBUTE
13383 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
13384
13385 OUTPUT_OPERAND_ATTRIBUTE ::=
13386   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
13387
13388 INPUT_OPERAND_LIST ::=
13389   [PREFIX.]No_Input_Operands
13390 | INPUT_OPERAND_ATTRIBUTE
13391 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
13392
13393 INPUT_OPERAND_ATTRIBUTE ::=
13394   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
13395 @end smallexample
13396
13397 @noindent
13398 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
13399 are declared in the package @code{Machine_Code} and must be referenced
13400 according to normal visibility rules. In particular if there is no
13401 @code{use} clause for this package, then appropriate package name
13402 qualification is required.
13403
13404 @node GNAT Implementation of Tasking
13405 @section GNAT Implementation of Tasking
13406
13407 @noindent
13408 This chapter outlines the basic GNAT approach to tasking (in particular,
13409 a multi-layered library for portability) and discusses issues related
13410 to compliance with the Real-Time Systems Annex.
13411
13412 @menu
13413 * Mapping Ada Tasks onto the Underlying Kernel Threads::
13414 * Ensuring Compliance with the Real-Time Annex::
13415 @end menu
13416
13417 @node Mapping Ada Tasks onto the Underlying Kernel Threads
13418 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
13419
13420 @noindent
13421 GNAT's run-time support comprises two layers:
13422
13423 @itemize @bullet
13424 @item GNARL (GNAT Run-time Layer)
13425 @item GNULL (GNAT Low-level Library)
13426 @end itemize
13427
13428 @noindent
13429 In GNAT, Ada's tasking services rely on a platform and OS independent
13430 layer known as GNARL@.  This code is responsible for implementing the
13431 correct semantics of Ada's task creation, rendezvous, protected
13432 operations etc.
13433
13434 GNARL decomposes Ada's tasking semantics into simpler lower level
13435 operations such as create a thread, set the priority of a thread,
13436 yield, create a lock, lock/unlock, etc.  The spec for these low-level
13437 operations constitutes GNULLI, the GNULL Interface.  This interface is
13438 directly inspired from the POSIX real-time API@.
13439
13440 If the underlying executive or OS implements the POSIX standard
13441 faithfully, the GNULL Interface maps as is to the services offered by
13442 the underlying kernel.  Otherwise, some target dependent glue code maps
13443 the services offered by the underlying kernel to the semantics expected
13444 by GNARL@.
13445
13446 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13447 key point is that each Ada task is mapped on a thread in the underlying
13448 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
13449
13450 In addition Ada task priorities map onto the underlying thread priorities.
13451 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13452
13453 @itemize @bullet
13454 @item
13455 The underlying scheduler is used to schedule the Ada tasks.  This
13456 makes Ada tasks as efficient as kernel threads from a scheduling
13457 standpoint.
13458
13459 @item
13460 Interaction with code written in C containing threads is eased
13461 since at the lowest level Ada tasks and C threads map onto the same
13462 underlying kernel concept.
13463
13464 @item
13465 When an Ada task is blocked during I/O the remaining Ada tasks are
13466 able to proceed.
13467
13468 @item
13469 On multiprocessor systems Ada tasks can execute in parallel.
13470 @end itemize
13471
13472 @noindent
13473 Some threads libraries offer a mechanism to fork a new process, with the
13474 child process duplicating the threads from the parent.
13475 GNAT does not
13476 support this functionality when the parent contains more than one task.
13477 @cindex Forking a new process
13478
13479 @node Ensuring Compliance with the Real-Time Annex
13480 @subsection Ensuring Compliance with the Real-Time Annex
13481 @cindex Real-Time Systems Annex compliance
13482
13483 @noindent
13484 Although mapping Ada tasks onto
13485 the underlying threads has significant advantages, it does create some
13486 complications when it comes to respecting the scheduling semantics
13487 specified in the real-time annex (Annex D).
13488
13489 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13490 scheduling policy states:
13491
13492 @quotation
13493 @emph{When the active priority of a ready task that is not running
13494 changes, or the setting of its base priority takes effect, the
13495 task is removed from the ready queue for its old active priority
13496 and is added at the tail of the ready queue for its new active
13497 priority, except in the case where the active priority is lowered
13498 due to the loss of inherited priority, in which case the task is
13499 added at the head of the ready queue for its new active priority.}
13500 @end quotation
13501
13502 @noindent
13503 While most kernels do put tasks at the end of the priority queue when
13504 a task changes its priority, (which respects the main
13505 FIFO_Within_Priorities requirement), almost none keep a thread at the
13506 beginning of its priority queue when its priority drops from the loss
13507 of inherited priority.
13508
13509 As a result most vendors have provided incomplete Annex D implementations.
13510
13511 The GNAT run-time, has a nice cooperative solution to this problem
13512 which ensures that accurate FIFO_Within_Priorities semantics are
13513 respected.
13514
13515 The principle is as follows.  When an Ada task T is about to start
13516 running, it checks whether some other Ada task R with the same
13517 priority as T has been suspended due to the loss of priority
13518 inheritance.  If this is the case, T yields and is placed at the end of
13519 its priority queue.  When R arrives at the front of the queue it
13520 executes.
13521
13522 Note that this simple scheme preserves the relative order of the tasks
13523 that were ready to execute in the priority queue where R has been
13524 placed at the end.
13525
13526 @node GNAT Implementation of Shared Passive Packages
13527 @section GNAT Implementation of Shared Passive Packages
13528 @cindex Shared passive packages
13529
13530 @noindent
13531 GNAT fully implements the pragma @code{Shared_Passive} for
13532 @cindex pragma @code{Shared_Passive}
13533 the purpose of designating shared passive packages.
13534 This allows the use of passive partitions in the
13535 context described in the Ada Reference Manual; i.e. for communication
13536 between separate partitions of a distributed application using the
13537 features in Annex E.
13538 @cindex Annex E
13539 @cindex Distribution Systems Annex
13540
13541 However, the implementation approach used by GNAT provides for more
13542 extensive usage as follows:
13543
13544 @table @emph
13545 @item Communication between separate programs
13546
13547 This allows separate programs to access the data in passive
13548 partitions, using protected objects for synchronization where
13549 needed. The only requirement is that the two programs have a
13550 common shared file system. It is even possible for programs
13551 running on different machines with different architectures
13552 (e.g. different endianness) to communicate via the data in
13553 a passive partition.
13554
13555 @item Persistence between program runs
13556
13557 The data in a passive package can persist from one run of a
13558 program to another, so that a later program sees the final
13559 values stored by a previous run of the same program.
13560
13561 @end table
13562
13563 @noindent
13564 The implementation approach used is to store the data in files. A
13565 separate stream file is created for each object in the package, and
13566 an access to an object causes the corresponding file to be read or
13567 written.
13568
13569 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13570 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13571 set to the directory to be used for these files.
13572 The files in this directory
13573 have names that correspond to their fully qualified names. For
13574 example, if we have the package
13575
13576 @smallexample @c ada
13577 package X is
13578   pragma Shared_Passive (X);
13579   Y : Integer;
13580   Z : Float;
13581 end X;
13582 @end smallexample
13583
13584 @noindent
13585 and the environment variable is set to @code{/stemp/}, then the files created
13586 will have the names:
13587
13588 @smallexample
13589 /stemp/x.y
13590 /stemp/x.z
13591 @end smallexample
13592
13593 @noindent
13594 These files are created when a value is initially written to the object, and
13595 the files are retained until manually deleted. This provides the persistence
13596 semantics. If no file exists, it means that no partition has assigned a value
13597 to the variable; in this case the initial value declared in the package
13598 will be used. This model ensures that there are no issues in synchronizing
13599 the elaboration process, since elaboration of passive packages elaborates the
13600 initial values, but does not create the files.
13601
13602 The files are written using normal @code{Stream_IO} access.
13603 If you want to be able
13604 to communicate between programs or partitions running on different
13605 architectures, then you should use the XDR versions of the stream attribute
13606 routines, since these are architecture independent.
13607
13608 If active synchronization is required for access to the variables in the
13609 shared passive package, then as described in the Ada Reference Manual, the
13610 package may contain protected objects used for this purpose. In this case
13611 a lock file (whose name is @file{___lock} (three underscores)
13612 is created in the shared memory directory.
13613 @cindex @file{___lock} file (for shared passive packages)
13614 This is used to provide the required locking
13615 semantics for proper protected object synchronization.
13616
13617 As of January 2003, GNAT supports shared passive packages on all platforms
13618 except for OpenVMS.
13619
13620 @node Code Generation for Array Aggregates
13621 @section Code Generation for Array Aggregates
13622
13623 @menu
13624 * Static constant aggregates with static bounds::
13625 * Constant aggregates with an unconstrained nominal types::
13626 * Aggregates with static bounds::
13627 * Aggregates with non-static bounds::
13628 * Aggregates in assignment statements::
13629 @end menu
13630
13631 @noindent
13632 Aggregate have a rich syntax and allow the user to specify the values of
13633 complex data structures by means of a single construct.  As a result, the
13634 code generated for aggregates can be quite complex and involve loops, case
13635 statements and multiple assignments.  In the simplest cases, however, the
13636 compiler will recognize aggregates whose components and constraints are
13637 fully static, and in those cases the compiler will generate little or no
13638 executable code.  The following is an outline of the code that GNAT generates
13639 for various aggregate constructs.  For further details, the user will find it
13640 useful to examine the output produced by the -gnatG flag to see the expanded
13641 source that is input to the code generator.  The user will also want to examine
13642 the assembly code generated at various levels of optimization.
13643
13644 The code generated for aggregates depends on the context, the component values,
13645 and the type.  In the context of an object declaration the code generated is
13646 generally simpler than in the case of an assignment.  As a general rule, static
13647 component values and static subtypes also lead to simpler code.
13648
13649 @node Static constant aggregates with static bounds
13650 @subsection Static constant aggregates with static bounds
13651
13652 @noindent
13653 For the declarations:
13654 @smallexample @c ada
13655     type One_Dim is array (1..10) of integer;
13656     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13657 @end smallexample
13658
13659 @noindent
13660 GNAT generates no executable code: the constant ar0 is placed in static memory.
13661 The same is true for constant aggregates with named associations:
13662
13663 @smallexample @c ada
13664     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13665     Cr3 : constant One_Dim := (others => 7777);
13666 @end smallexample
13667
13668 @noindent
13669 The same is true for multidimensional constant arrays such as:
13670
13671 @smallexample @c ada
13672     type two_dim is array (1..3, 1..3) of integer;
13673     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13674 @end smallexample
13675
13676 @noindent
13677 The same is true for arrays of one-dimensional arrays: the following are
13678 static:
13679
13680 @smallexample @c ada
13681 type ar1b  is array (1..3) of boolean;
13682 type ar_ar is array (1..3) of ar1b;
13683 None  : constant ar1b := (others => false);     --  fully static
13684 None2 : constant ar_ar := (1..3 => None);       --  fully static
13685 @end smallexample
13686
13687 @noindent
13688 However, for multidimensional aggregates with named associations, GNAT will
13689 generate assignments and loops, even if all associations are static.  The
13690 following two declarations generate a loop for the first dimension, and
13691 individual component assignments for the second dimension:
13692
13693 @smallexample @c ada
13694 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13695 Zero2: constant two_dim := (others => (others => 0));
13696 @end smallexample
13697
13698 @node Constant aggregates with an unconstrained nominal types
13699 @subsection Constant aggregates with an unconstrained nominal types
13700
13701 @noindent
13702 In such cases the aggregate itself establishes the subtype, so that
13703 associations with @code{others} cannot be used.  GNAT determines the
13704 bounds for the actual subtype of the aggregate, and allocates the
13705 aggregate statically as well.  No code is generated for the following:
13706
13707 @smallexample @c ada
13708     type One_Unc is array (natural range <>) of integer;
13709     Cr_Unc : constant One_Unc := (12,24,36);
13710 @end smallexample
13711
13712 @node Aggregates with static bounds
13713 @subsection Aggregates with static bounds
13714
13715 @noindent
13716 In all previous examples the aggregate was the initial (and immutable) value
13717 of a constant.  If the aggregate initializes a variable, then code is generated
13718 for it as a combination of individual assignments and loops over the target
13719 object.  The declarations
13720
13721 @smallexample @c ada
13722        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13723        Cr_Var2 : One_Dim := (others > -1);
13724 @end smallexample
13725
13726 @noindent
13727 generate the equivalent of
13728
13729 @smallexample @c ada
13730        Cr_Var1 (1) := 2;
13731        Cr_Var1 (2) := 3;
13732        Cr_Var1 (3) := 5;
13733        Cr_Var1 (4) := 11;
13734
13735        for I in Cr_Var2'range loop
13736           Cr_Var2 (I) := =-1;
13737        end loop;
13738 @end smallexample
13739
13740 @node Aggregates with non-static bounds
13741 @subsection Aggregates with non-static bounds
13742
13743 @noindent
13744 If the bounds of the aggregate are not statically compatible with the bounds
13745 of the nominal subtype  of the target, then constraint checks have to be
13746 generated on the bounds.  For a multidimensional array, constraint checks may
13747 have to be applied to sub-arrays individually, if they do not have statically
13748 compatible subtypes.
13749
13750 @node Aggregates in assignment statements
13751 @subsection Aggregates in assignment statements
13752
13753 @noindent
13754 In general, aggregate assignment requires the construction of a temporary,
13755 and a copy from the temporary to the target of the assignment.  This is because
13756 it is not always possible to convert the assignment into a series of individual
13757 component assignments.  For example, consider the simple case:
13758
13759 @smallexample @c ada
13760         A := (A(2), A(1));
13761 @end smallexample
13762
13763 @noindent
13764 This cannot be converted into:
13765
13766 @smallexample @c ada
13767         A(1) := A(2);
13768         A(2) := A(1);
13769 @end smallexample
13770
13771 @noindent
13772 So the aggregate has to be built first in a separate location, and then
13773 copied into the target.  GNAT recognizes simple cases where this intermediate
13774 step is not required, and the assignments can be performed in place, directly
13775 into the target.  The following sufficient criteria are applied:
13776
13777 @itemize @bullet
13778 @item
13779 The bounds of the aggregate are static, and the associations are static.
13780 @item
13781 The components of the aggregate are static constants, names of
13782 simple variables that are not renamings, or expressions not involving
13783 indexed components whose operands obey these rules.
13784 @end itemize
13785
13786 @noindent
13787 If any of these conditions are violated, the aggregate will be built in
13788 a temporary (created either by the front-end or the code generator) and then
13789 that temporary will be copied onto the target.
13790
13791
13792 @node The Size of Discriminated Records with Default Discriminants
13793 @section The Size of Discriminated Records with Default Discriminants
13794
13795 @noindent
13796 If a discriminated type @code{T} has discriminants with default values, it is
13797 possible to declare an object of this type without providing an explicit
13798 constraint:
13799
13800 @smallexample @c ada
13801 @group
13802 type Size is range 1..100;
13803
13804 type Rec (D : Size := 15) is record
13805    Name : String (1..D);
13806 end T;
13807
13808 Word : Rec;
13809 @end group
13810 @end smallexample
13811
13812 @noindent
13813 Such an object is said to be @emph{unconstrained}.
13814 The discriminant of the object
13815 can be modified by a full assignment to the object, as long as it preserves the
13816 relation between the value of the discriminant, and the value of the components
13817 that depend on it:
13818
13819 @smallexample @c ada
13820 @group
13821 Word := (3, "yes");
13822
13823 Word := (5, "maybe");
13824
13825 Word := (5, "no"); -- raises Constraint_Error
13826 @end group
13827 @end smallexample
13828
13829 @noindent
13830 In order to support this behavior efficiently, an unconstrained object is
13831 given the maximum size that any value of the type requires. In the case
13832 above, @code{Word} has storage for the discriminant and for
13833 a @code{String} of length 100.
13834 It is important to note that unconstrained objects do not require dynamic
13835 allocation. It would be an improper implementation to place on the heap those
13836 components whose size depends on discriminants. (This improper implementation
13837 was used by some Ada83 compilers, where the @code{Name} component above
13838 would have
13839 been stored as a pointer to a dynamic string). Following the principle that
13840 dynamic storage management should never be introduced implicitly,
13841 an Ada95 compiler should reserve the full size for an unconstrained declared
13842 object, and place it on the stack.
13843
13844 This maximum size approach
13845 has been a source of surprise to some users, who expect the default
13846 values of the discriminants to determine the size reserved for an
13847 unconstrained object: ``If the default is 15, why should the object occupy
13848 a larger size?''
13849 The answer, of course, is that the discriminant may be later modified,
13850 and its full range of values must be taken into account. This is why the
13851 declaration:
13852
13853 @smallexample
13854 @group
13855 type Rec (D : Positive := 15) is record
13856    Name : String (1..D);
13857 end record;
13858
13859 Too_Large : Rec;
13860 @end group
13861 @end smallexample
13862
13863 @noindent
13864 is flagged by the compiler with a warning:
13865 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
13866 because the required size includes @code{Positive'Last}
13867 bytes. As the first example indicates, the proper approach is to declare an
13868 index type of ``reasonable'' range so that unconstrained objects are not too
13869 large.
13870
13871 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
13872 created in the heap by means of an allocator, then it is @emph{not}
13873 unconstrained:
13874 it is constrained by the default values of the discriminants, and those values
13875 cannot be modified by full assignment. This is because in the presence of
13876 aliasing all views of the object (which may be manipulated by different tasks,
13877 say) must be consistent, so it is imperative that the object, once created,
13878 remain invariant.
13879
13880
13881
13882
13883 @node Project File Reference
13884 @chapter Project File Reference
13885
13886 @noindent
13887 This chapter describes the syntax and semantics of project files.
13888 Project files specify the options to be used when building a system.
13889 Project files can specify global settings for all tools,
13890 as well as tool-specific settings.
13891 See the chapter on project files in the GNAT Users guide for examples of use.
13892
13893 @menu
13894 * Reserved Words::
13895 * Lexical Elements::
13896 * Declarations::
13897 * Empty declarations::
13898 * Typed string declarations::
13899 * Variables::
13900 * Expressions::
13901 * Attributes::
13902 * Project Attributes::
13903 * Attribute References::
13904 * External Values::
13905 * Case Construction::
13906 * Packages::
13907 * Package Renamings::
13908 * Projects::
13909 * Project Extensions::
13910 * Project File Elaboration::
13911 @end menu
13912
13913 @node Reserved Words
13914 @section Reserved Words
13915
13916 @noindent
13917 All Ada95 reserved words are reserved in project files, and cannot be used
13918 as variable names or project names. In addition, the following are
13919 also reserved in project files:
13920
13921 @itemize
13922 @item @code{extends}
13923
13924 @item @code{external}
13925
13926 @item @code{project}
13927
13928 @end itemize
13929
13930 @node Lexical Elements
13931 @section Lexical Elements
13932
13933 @noindent
13934 Rules for identifiers are the same as in Ada95. Identifiers
13935 are case-insensitive.  Strings are case sensitive, except where noted.
13936 Comments have the same form as in Ada95.
13937
13938 @noindent
13939 Syntax:
13940
13941 @smallexample
13942 simple_name ::=
13943   identifier
13944
13945 name ::=
13946   simple_name @{. simple_name@}
13947 @end smallexample
13948
13949 @node Declarations
13950 @section Declarations
13951
13952 @noindent
13953 Declarations introduce new entities that denote types, variables, attributes,
13954 and packages. Some declarations can only appear immediately within a project
13955 declaration. Others can appear within a project or within a package.
13956
13957 Syntax:
13958 @smallexample
13959 declarative_item ::=
13960   simple_declarative_item |
13961   typed_string_declaration |
13962   package_declaration
13963
13964 simple_declarative_item ::=
13965   variable_declaration |
13966   typed_variable_declaration |
13967   attribute_declaration |
13968   case_construction |
13969   empty_declaration
13970 @end smallexample
13971
13972 @node Empty declarations
13973 @section Empty declarations
13974
13975 @smallexample
13976 empty_declaration ::=
13977   @b{null} ;
13978 @end smallexample
13979
13980 An empty declaration is allowed anywhere a declaration is allowed.
13981 It has no effect.
13982
13983 @node Typed string declarations
13984 @section Typed string declarations
13985
13986 @noindent
13987 Typed strings are sequences of string literals. Typed strings are the only
13988 named types in project files. They are used in case constructions, where they
13989 provide support for conditional attribute definitions.
13990
13991 Syntax:
13992 @smallexample
13993 typed_string_declaration ::=
13994   @b{type} <typed_string_>_simple_name @b{is}
13995    ( string_literal @{, string_literal@} );
13996 @end smallexample
13997
13998 @noindent
13999 A typed string declaration can only appear immediately within a project
14000 declaration.
14001
14002 All the string literals in a typed string declaration must be distinct.
14003
14004 @node Variables
14005 @section Variables
14006
14007 @noindent
14008 Variables denote values, and appear as constituents of expressions.
14009
14010 @smallexample
14011 typed_variable_declaration ::=
14012   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14013
14014 variable_declaration ::=
14015   <variable_>simple_name := expression;
14016 @end smallexample
14017
14018 @noindent
14019 The elaboration of a variable declaration introduces the variable and
14020 assigns to it the value of the expression. The name of the variable is
14021 available after the assignment symbol.
14022
14023 @noindent
14024 A typed_variable can only be declare once.
14025
14026 @noindent
14027 a non typed variable can be declared multiple times.
14028
14029 @noindent
14030 Before the completion of its first declaration, the value of variable
14031 is the null string.
14032
14033 @node Expressions
14034 @section Expressions
14035
14036 @noindent
14037 An expression is a formula that defines a computation or retrieval of a value.
14038 In a project file the value of an expression is either a string or a list
14039 of strings. A string value in an expression is either a literal, the current
14040 value of a variable, an external value, an attribute reference, or a
14041 concatenation operation.
14042
14043 Syntax:
14044
14045 @smallexample
14046 expression ::=
14047   term @{& term@}
14048
14049 term ::=
14050   string_literal |
14051   string_list |
14052   <variable_>name |
14053   external_value |
14054   attribute_reference
14055
14056 string_literal ::=
14057   (same as Ada)
14058
14059 string_list ::=
14060   ( <string_>expression @{ , <string_>expression @} )
14061 @end smallexample
14062
14063 @subsection Concatenation
14064 @noindent
14065 The following concatenation functions are defined:
14066
14067 @smallexample @c ada
14068   function "&" (X : String;      Y : String)      return String;
14069   function "&" (X : String_List; Y : String)      return String_List;
14070   function "&" (X : String_List; Y : String_List) return String_List;
14071 @end smallexample
14072
14073 @node Attributes
14074 @section Attributes
14075
14076 @noindent
14077 An attribute declaration defines a property of a project or package. This
14078 property can later be queried by means of an attribute reference.
14079 Attribute values are strings or string lists.
14080
14081 Some attributes are associative arrays. These attributes are mappings whose
14082 domain is a set of strings. These attributes are declared one association
14083 at a time, by specifying a point in the domain and the corresponding image
14084 of the attribute. They may also be declared as a full associative array,
14085 getting the same associations as the corresponding attribute in an imported
14086 or extended project.
14087
14088 Attributes that are not associative arrays are called simple attributes.
14089
14090 Syntax:
14091 @smallexample
14092 attribute_declaration ::=
14093   full_associative_array_declaration |
14094   @b{for} attribute_designator @b{use} expression ;
14095
14096 full_associative_array_declaration ::=
14097   @b{for} <associative_array_attribute_>simple_name @b{use}
14098   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14099
14100 attribute_designator ::=
14101   <simple_attribute_>simple_name |
14102   <associative_array_attribute_>simple_name ( string_literal )
14103 @end smallexample
14104
14105 @noindent
14106 Some attributes are project-specific, and can only appear immediately within
14107 a project declaration. Others are package-specific, and can only appear within
14108 the proper package.
14109
14110 The expression in an attribute definition must be a string or a string_list.
14111 The string literal appearing in the attribute_designator of an associative
14112 array attribute is case-insensitive.
14113
14114 @node Project Attributes
14115 @section Project Attributes
14116
14117 @noindent
14118 The following attributes apply to a project. All of them are simple
14119 attributes.
14120
14121 @table @code
14122 @item   Object_Dir
14123 Expression must be a path name. The attribute defines the
14124 directory in which the object files created by the build are to be placed. If
14125 not specified, object files are placed in the project directory.
14126
14127 @item   Exec_Dir
14128 Expression must be a path name. The attribute defines the
14129 directory in which the executables created by the build are to be placed.
14130 If not specified, executables are placed in the object directory.
14131
14132 @item  Source_Dirs
14133 Expression must be a list of path names. The attribute
14134 defines the directories in which the source files for the project are to be
14135 found. If not specified, source files are found in the project directory.
14136
14137 @item  Source_Files
14138 Expression must be a list of file names. The attribute
14139 defines the individual files, in the project directory, which are to be used
14140 as sources for the project. File names are path_names that contain no directory
14141 information. If the project has no sources the attribute must be declared
14142 explicitly with an empty list.
14143
14144 @item  Source_List_File
14145 Expression must a single path name. The attribute
14146 defines a text file that contains a list of source file names to be used
14147 as sources for the project
14148
14149 @item  Library_Dir
14150 Expression must be a path name. The attribute defines the
14151 directory in which a  library is to be built.  The directory must exist, must
14152 be distinct from the project's object directory, and must be writable.
14153
14154 @item  Library_Name
14155 Expression must be a string that is a legal file name,
14156 without extension. The attribute defines a string that is used to generate
14157 the name of the library to be built by the project.
14158
14159 @item  Library_Kind
14160 Argument must be a string value that must be one of the
14161 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14162 string is case-insensitive. If this attribute is not specified, the library is
14163 a static library. Otherwise, the library may be dynamic or relocatable. This
14164 distinction is operating-system dependent.
14165
14166 @item  Library_Version
14167 Expression must be a string value whose interpretation
14168 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14169 libraries as the internal name of the library (the @code{"soname"}). If the
14170 library file name (built from the @code{Library_Name}) is different from the
14171 @code{Library_Version}, then the library file will be a symbolic link to the
14172 actual file whose name will be @code{Library_Version}.
14173
14174 @item Library_Interface
14175 Expression must be a string list. Each element of the string list
14176 must designate a unit of the project.
14177 If this attribute is present in a Library Project File, then the project
14178 file is a Stand-alone Library_Project_File.
14179
14180 @item Library_Auto_Init
14181 Expression must be a single string "true" or "false", case-insensitive.
14182 If this attribute is present in a Stand-alone Library Project File,
14183 it indicates if initialization is automatic when the dynamic library
14184 is loaded.
14185
14186 @item Library_Options
14187 Expression must be a string list. Indicates additional switches that
14188 are to be used when building a shared library.
14189
14190 @item Library_GCC
14191 Expression must be a single string. Designates an alternative to "gcc"
14192 for building shared libraries.
14193
14194 @item  Library_Src_Dir
14195 Expression must be a path name. The attribute defines the
14196 directory in which the sources of the interfaces of a Stand-alone Library will
14197 be copied.  The directory must exist, must be distinct from the project's
14198 object directory and source directories, and must be writable.
14199
14200 @item  Main
14201 Expression must be a list of strings that are legal file names.
14202 These file names designate existing compilation units in the source directory
14203 that are legal main subprograms.
14204
14205 When a project file is elaborated, as part of the execution of a gnatmake
14206 command, one or several executables are built and placed in the Exec_Dir.
14207 If the gnatmake command does not include explicit file names, the executables
14208 that are built correspond to the files specified by this attribute.
14209
14210 @item Main_Language
14211 This is a simple attribute. Its value is a string that specifies the
14212 language of the main program.
14213
14214 @item  Languages
14215 Expression must be a string list. Each string designates
14216 a programming language that is known to GNAT. The strings are case-insensitive.
14217
14218 @item  Locally_Removed_Files
14219 This attribute is legal only in a project file that extends another.
14220 Expression must be a list of strings that are legal file names.
14221 Each file name must designate a source that would normally be inherited
14222 by the current project file. It cannot designate an immediate source that is
14223 not inherited. Each of the source files in the list are not considered to
14224 be sources of the project file: they are not inherited.
14225 @end table
14226
14227 @node Attribute References
14228 @section Attribute References
14229
14230 @noindent
14231 Attribute references are used to retrieve the value of previously defined
14232 attribute for a package or project.
14233 Syntax:
14234 @smallexample
14235 attribute_reference ::=
14236   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14237
14238 attribute_prefix ::=
14239   @b{project} |
14240   <project_simple_name | package_identifier |
14241   <project_>simple_name . package_identifier
14242 @end smallexample
14243
14244 @noindent
14245 If an attribute has not been specified for a given package or project, its
14246 value is the null string or the empty list.
14247
14248 @node External Values
14249 @section External Values
14250
14251 @noindent
14252 An external value is an expression whose value is obtained from the command
14253 that invoked the processing of the current project file (typically a
14254 gnatmake command).
14255
14256 Syntax:
14257 @smallexample
14258 external_value ::=
14259   @b{external} ( string_literal [, string_literal] )
14260 @end smallexample
14261
14262 @noindent
14263 The first string_literal is the string to be used on the command line or
14264 in the environment to specify the external value. The second string_literal,
14265 if present, is the default to use if there is no specification for this
14266 external value either on the command line or in the environment.
14267
14268 @node Case Construction
14269 @section Case Construction
14270
14271 @noindent
14272 A case construction supports attribute declarations that depend on the value of
14273 a previously declared variable.
14274
14275 Syntax:
14276 @smallexample
14277 case_construction ::=
14278   @b{case} <typed_variable_>name @b{is}
14279     @{case_item@}
14280   @b{end case} ;
14281
14282 case_item ::=
14283   @b{when} discrete_choice_list =>
14284     @{case_construction | attribute_declaration | empty_declaration@}
14285
14286 discrete_choice_list ::=
14287   string_literal @{| string_literal@} |
14288     @b{others}
14289 @end smallexample
14290
14291 @noindent
14292 All choices in a choice list must be distinct. The choice lists of two
14293 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
14294 alternatives do not need to include all values of the type. An @code{others}
14295 choice must appear last in the list of alternatives.
14296
14297 @node Packages
14298 @section Packages
14299
14300 @noindent
14301 A package provides a grouping of variable declarations and attribute
14302 declarations to be used when invoking various GNAT tools. The name of
14303 the package indicates the tool(s) to which it applies.
14304 Syntax:
14305
14306 @smallexample
14307 package_declaration ::=
14308   package_specification | package_renaming
14309
14310 package_specification ::=
14311   @b{package} package_identifier @b{is}
14312     @{simple_declarative_item@}
14313   @b{end} package_identifier ;
14314
14315 package_identifier ::=
14316   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
14317   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
14318   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
14319 @end smallexample
14320
14321 @subsection Package Naming
14322
14323 @noindent
14324 The attributes of a @code{Naming} package specifies the naming conventions
14325 that apply to the source files in a project. When invoking other GNAT tools,
14326 they will use the sources in the source directories that satisfy these
14327 naming conventions.
14328
14329 The following attributes apply to a @code{Naming} package:
14330
14331 @table @code
14332 @item Casing
14333 This is a simple attribute whose value is a string. Legal values of this
14334 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
14335 These strings are themselves case insensitive.
14336
14337 @noindent
14338 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
14339
14340 @item Dot_Replacement
14341 This is a simple attribute whose string value satisfies the following
14342 requirements:
14343
14344 @itemize @bullet
14345 @item It must not be empty
14346 @item It cannot start or end with an alphanumeric character
14347 @item It cannot be a single underscore
14348 @item It cannot start with an underscore followed by an alphanumeric
14349 @item It cannot contain a dot @code{'.'} if longer than one character
14350 @end itemize
14351
14352 @noindent
14353 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
14354
14355 @item Spec_Suffix
14356 This is an associative array attribute, defined on language names,
14357 whose image is a string that must satisfy the following
14358 conditions:
14359
14360 @itemize @bullet
14361 @item It must not be empty
14362 @item It cannot start with an alphanumeric character
14363 @item It cannot start with an underscore followed by an alphanumeric character
14364 @end itemize
14365
14366 @noindent
14367 For Ada, the attribute denotes the suffix used in file names that contain
14368 library unit declarations, that is to say units that are package and
14369 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
14370 specified, then the default is @code{".ads"}.
14371
14372 For C and C++, the attribute denotes the suffix used in file names that
14373 contain prototypes.
14374
14375 @item Body_Suffix
14376 This is an associative array attribute defined on language names,
14377 whose image is a string that must satisfy the following
14378 conditions:
14379
14380 @itemize @bullet
14381 @item It must not be empty
14382 @item It cannot start with an alphanumeric character
14383 @item It cannot start with an underscore followed by an alphanumeric character
14384 @item It cannot be a suffix of @code{Spec_Suffix}
14385 @end itemize
14386
14387 @noindent
14388 For Ada, the attribute denotes the suffix used in file names that contain
14389 library bodies, that is to say units that are package and subprogram bodies.
14390 If @code{Body_Suffix ("Ada")} is not specified, then the default is
14391 @code{".adb"}.
14392
14393 For C and C++, the attribute denotes the suffix used in file names that contain
14394 source code.
14395
14396 @item Separate_Suffix
14397 This is a simple attribute whose value satisfies the same conditions as
14398 @code{Body_Suffix}.
14399
14400 This attribute is specific to Ada. It denotes the suffix used in file names
14401 that contain separate bodies. If it is not specified, then it defaults to same
14402 value as @code{Body_Suffix ("Ada")}.
14403
14404 @item Spec
14405 This is an associative array attribute, specific to Ada, defined over
14406 compilation unit names. The image is a string that is the name of the file
14407 that contains that library unit. The file name is case sensitive if the
14408 conventions of the host operating system require it.
14409
14410 @item Body
14411 This is an associative array attribute, specific to Ada, defined over
14412 compilation unit names. The image is a string that is the name of the file
14413 that contains the library unit body for the named unit. The file name is case
14414 sensitive if the conventions of the host operating system require it.
14415
14416 @item Specification_Exceptions
14417 This is an associative array attribute defined on language names,
14418 whose value is a list of strings.
14419
14420 This attribute is not significant for Ada.
14421
14422 For C and C++, each string in the list denotes the name of a file that
14423 contains prototypes, but whose suffix is not necessarily the
14424 @code{Spec_Suffix} for the language.
14425
14426 @item Implementation_Exceptions
14427 This is an associative array attribute defined on language names,
14428 whose value is a list of strings.
14429
14430 This attribute is not significant for Ada.
14431
14432 For C and C++, each string in the list denotes the name of a file that
14433 contains source code, but whose suffix is not necessarily the
14434 @code{Body_Suffix} for the language.
14435 @end table
14436
14437 The following attributes of package @code{Naming} are obsolescent. They are
14438 kept as synonyms of other attributes for compatibility with previous versions
14439 of the Project Manager.
14440
14441 @table @code
14442 @item Specification_Suffix
14443 This is a synonym of @code{Spec_Suffix}.
14444
14445 @item Implementation_Suffix
14446 This is a synonym of @code{Body_Suffix}.
14447
14448 @item Specification
14449 This is a synonym of @code{Spec}.
14450
14451 @item Implementation
14452 This is a synonym of @code{Body}.
14453 @end table
14454
14455 @subsection package Compiler
14456
14457 @noindent
14458 The attributes of the @code{Compiler} package specify the compilation options
14459 to be used by the underlying compiler.
14460
14461 @table @code
14462 @item  Default_Switches
14463 This is an associative array attribute. Its
14464 domain is a set of language names. Its range is a string list that
14465 specifies the compilation options to be used when compiling a component
14466 written in that language, for which no file-specific switches have been
14467 specified..
14468
14469 @item  Switches
14470 This is an associative array attribute. Its domain is
14471 a set of file names. Its range is a string list that specifies the
14472 compilation options to be used when compiling the named file. If a file
14473 is not specified in the Switches attribute, it is compiled with the
14474 settings specified by Default_Switches.
14475
14476 @item  Local_Configuration_Pragmas.
14477 This is a simple attribute, whose
14478 value is a path name that designates a file containing configuration pragmas
14479 to be used for all invocations of the compiler for immediate sources of the
14480 project.
14481
14482 @item Executable
14483 This is an associative array attribute. Its domain is
14484 a set of main source file names. Its range is a simple string that specifies
14485 the executable file name to be used when linking the specified main source.
14486 If a main source is not specified in the Executable attribute, the executable
14487 file name is deducted from the main source file name.
14488 @end table
14489
14490 @subsection package Builder
14491
14492 @noindent
14493 The attributes of package @code{Builder} specify the compilation, binding, and
14494 linking options to be used when building an executable for a project. The
14495 following attributes apply to package @code{Builder}:
14496
14497 @table @code
14498 @item Default_Switches
14499 As above.
14500
14501 @item Switches
14502 As above.
14503
14504 @item Global_Configuration_Pragmas
14505 This is a simple attribute, whose
14506 value is a path name that designates a file that contains configuration pragmas
14507 to be used in every build of an executable. If both local and global
14508 configuration pragmas are specified, a compilation makes use of both sets.
14509
14510 @item Executable
14511 This is an associative array attribute, defined over
14512 compilation unit names. The image is a string that is the name of the
14513 executable file corresponding to the main source file index.
14514 This attribute has no effect if its value is the empty string.
14515
14516 @item Executable_Suffix
14517 This is a simple attribute whose value is a suffix to be added to
14518 the executables that don't have an attribute Executable specified.
14519 @end table
14520
14521 @subsection package Gnatls
14522
14523 @noindent
14524 The attributes of package @code{Gnatls} specify the tool options to be used
14525 when invoking the library browser @command{gnatls}.
14526 The following attributes apply to package @code{Gnatls}:
14527
14528 @table @code
14529 @item Switches
14530 As above.
14531 @end table
14532
14533 @subsection package Binder
14534
14535 @noindent
14536 The attributes of package @code{Binder} specify the options to be used
14537 when invoking the binder in the construction of an executable.
14538 The following attributes apply to package @code{Binder}:
14539
14540 @table @code
14541 @item     Default_Switches
14542 As above.
14543 @item     Switches
14544 As above.
14545 @end table
14546
14547 @subsection package Linker
14548
14549 @noindent
14550 The attributes of package @code{Linker} specify the options to be used when
14551 invoking the linker in the construction of an executable.
14552 The following attributes apply to package @code{Linker}:
14553
14554 @table @code
14555 @item     Default_Switches
14556 As above
14557 @item     Switches
14558 As above.
14559 @end table
14560
14561 @subsection package Cross_Reference
14562
14563 @noindent
14564 The attributes of package @code{Cross_Reference} specify the tool options
14565 to be used
14566 when invoking the library tool @command{gnatxref}.
14567 The following attributes apply to package @code{Cross_Reference}:
14568
14569 @table @code
14570 @item     Default_Switches
14571 As above.
14572 @item     Switches
14573 As above.
14574 @end table
14575
14576 @subsection package   Finder
14577
14578 @noindent
14579 The attributes of package @code{Finder} specify the tool options to be used
14580 when invoking the search tool @command{gnatfind}.
14581 The following attributes apply to package @code{Finder}:
14582
14583 @table @code
14584 @item     Default_Switches
14585 As above.
14586 @item     Switches
14587 As above.
14588 @end table
14589
14590 @subsection package Pretty_Printer
14591
14592 @noindent
14593 The attributes of package @code{Pretty_Printer}
14594 specify the tool options to be used
14595 when invoking the formatting tool @command{gnatpp}.
14596 The following attributes apply to package @code{Pretty_Printer}:
14597
14598 @table @code
14599 @item     Default_switches
14600 As above.
14601 @item     Switches
14602 As above.
14603 @end table
14604
14605 @subsection  package IDE
14606
14607 @noindent
14608 The attributes of package @code{IDE} specify the options to be used when using
14609 an Integrated Development Environment such as @command{GPS}.
14610
14611 @table @code
14612 @item Remote_Host
14613 This is a simple attribute. Its value is a string that designates the remote
14614 host in a cross-compilation environment, to be used for remote compilation and
14615 debugging. This field should not be specified when running on the local
14616 machine.
14617
14618 @item Program_Host
14619 This is a simple attribute. Its value is a string that specifies the
14620 name of IP address of the embedded target in a cross-compilation environment,
14621 on which the program should execute.
14622
14623 @item Communication_Protocol
14624 This is a simple string attribute. Its value is the name of the protocol
14625 to use to communicate with the target in a cross-compilation environment,
14626 e.g. @code{"wtx"} or @code{"vxworks"}.
14627
14628 @item Compiler_Command
14629 This is an associative array attribute, whose domain is a language name. Its
14630 value is  string that denotes the command to be used to invoke the compiler.
14631 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14632 gnatmake, in particular in the handling of switches.
14633
14634 @item Debugger_Command
14635 This is simple attribute, Its value is a string that specifies the name of
14636 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14637
14638 @item Default_Switches
14639 This is an associative array attribute. Its indexes are the name of the
14640 external tools that the GNAT Programming System (GPS) is supporting. Its
14641 value is a list of switches to use when invoking that tool.
14642
14643 @item  Gnatlist
14644 This is a simple attribute.  Its value is a string that specifies the name
14645 of the @command{gnatls} utility to be used to retrieve information about the
14646 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14647
14648 @item VCS_Kind
14649 This is a simple attribute. Its value is a string used to specify the
14650 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14651 ClearCase or Perforce.
14652
14653 @item VCS_File_Check
14654 This is a simple attribute. Its value is a string that specifies the
14655 command used by the VCS to check the validity of a file, either
14656 when the user explicitly asks for a check, or as a sanity check before
14657 doing the check-in.
14658
14659 @item VCS_Log_Check
14660 This is a simple attribute. Its value is a string that specifies
14661 the command used by the VCS to check the validity of a log file.
14662
14663 @end table
14664
14665 @node Package Renamings
14666 @section Package Renamings
14667
14668 @noindent
14669 A package can be defined by a renaming declaration. The new package renames
14670 a package declared in a different project file, and has the same attributes
14671 as the package it renames.
14672 Syntax:
14673 @smallexample
14674 package_renaming ::==
14675   @b{package} package_identifier @b{renames}
14676        <project_>simple_name.package_identifier ;
14677 @end smallexample
14678
14679 @noindent
14680 The package_identifier of the renamed package must be the same as the
14681 package_identifier. The project whose name is the prefix of the renamed
14682 package must contain a package declaration with this name. This project
14683 must appear in the context_clause of the enclosing project declaration,
14684 or be the parent project of the enclosing child project.
14685
14686 @node Projects
14687 @section Projects
14688
14689 @noindent
14690 A project file specifies a set of rules for constructing a software system.
14691 A project file can be self-contained, or depend on other project files.
14692 Dependencies are expressed through a context clause that names other projects.
14693
14694 Syntax:
14695
14696 @smallexample
14697 project ::=
14698   context_clause project_declaration
14699
14700 project_declaration ::=
14701   simple_project_declaration | project_extension
14702
14703 simple_project_declaration ::=
14704   @b{project} <project_>simple_name @b{is}
14705     @{declarative_item@}
14706   @b{end} <project_>simple_name;
14707
14708 context_clause ::=
14709   @{with_clause@}
14710
14711 with_clause ::=
14712   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14713
14714 path_name ::=
14715    string_literal
14716 @end smallexample
14717
14718 @noindent
14719 A path name denotes a project file. A path name can be absolute or relative.
14720 An absolute path name includes a sequence of directories, in the syntax of
14721 the host operating system, that identifies uniquely the project file in the
14722 file system. A relative path name identifies the project file, relative
14723 to the directory that contains the current project, or relative to a
14724 directory listed in the environment variable ADA_PROJECT_PATH.
14725 Path names are case sensitive if file names in the host operating system
14726 are case sensitive.
14727
14728 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14729 directory names separated by colons (semicolons on Windows).
14730
14731 A given project name can appear only once in a context_clause.
14732
14733 It is illegal for a project imported by a context clause to refer, directly
14734 or indirectly, to the project in which this context clause appears (the
14735 dependency graph cannot contain cycles), except when one of the with_clause
14736 in the cycle is a @code{limited with}.
14737
14738 @node Project Extensions
14739 @section Project Extensions
14740
14741 @noindent
14742 A project extension introduces a new project, which inherits the declarations
14743 of another project.
14744 Syntax:
14745 @smallexample
14746
14747 project_extension ::=
14748   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14749     @{declarative_item@}
14750   @b{end} <project_>simple_name;
14751 @end smallexample
14752
14753 @noindent
14754 The project extension declares a child project. The child project inherits
14755 all the declarations and all the files of the parent project, These inherited
14756 declaration can be overridden in the child project, by means of suitable
14757 declarations.
14758
14759 @node Project File Elaboration
14760 @section Project File Elaboration
14761
14762 @noindent
14763 A project file is processed as part of the invocation of a gnat tool that
14764 uses the project option. Elaboration of the process file consists in the
14765 sequential elaboration of all its declarations. The computed values of
14766 attributes and variables in the project are then used to establish the
14767 environment in which the gnat tool will execute.
14768
14769 @node Obsolescent Features
14770 @chapter Obsolescent Features
14771
14772 @noindent
14773 This chapter describes features that are provided by GNAT, but are
14774 considered obsolescent since there are preferred ways of achieving
14775 the same effect. These features are provided solely for historical
14776 compatibility purposes.
14777
14778 @menu
14779 * pragma No_Run_Time::
14780 * pragma Ravenscar::
14781 * pragma Restricted_Run_Time::
14782 @end menu
14783
14784 @node pragma No_Run_Time
14785 @section pragma No_Run_Time
14786
14787 The pragma @code{No_Run_Time} is used to achieve an affect similar
14788 to the use of the "Zero Foot Print" configurable run time, but without
14789 requiring a specially configured run time. The result of using this
14790 pragma, which must be used for all units in a partition, is to restrict
14791 the use of any language features requiring run-time support code. The
14792 preferred usage is to use an appropriately configured run-time that
14793 includes just those features that are to be made accessible.
14794
14795 @node pragma Ravenscar
14796 @section pragma Ravenscar
14797
14798 The pragma @code{Ravenscar} has exactly the same effect as pragma
14799 @code{Profile (Ravenscar)}. The latter usage is preferred since it
14800 is part of the new Ada 2005 standard.
14801
14802 @node pragma Restricted_Run_Time
14803 @section pragma Restricted_Run_Time
14804
14805 The pragma @code{Restricted_Run_Time} has exactly the same effect as
14806 pragma @code{Profile (Restricted)}. The latter usage is
14807 preferred since the Ada 2005 pragma @code{Profile} is intended for
14808 this kind of implementation dependent addition.
14809
14810 @include fdl.texi
14811 @c GNU Free Documentation License
14812
14813 @node Index,,GNU Free Documentation License, Top
14814 @unnumbered Index
14815
14816 @printindex cp
14817
14818 @contents
14819
14820 @bye