OSDN Git Service

fastjar:
[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-2002 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 @settitle GNAT Reference Manual
20 @setchapternewpage odd
21 @syncodeindex fn cp
22
23 @include gcc-common.texi
24
25 @dircategory GNU Ada tools
26 @direntry
27 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
28 @end direntry
29
30 @copying
31 Copyright @copyright{} 1995-2001, Free Software Foundation
32
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU Free Documentation License, Version 1.2
35 or any later version published by the Free Software Foundation;
36 with the Invariant Sections being ``GNU Free Documentation License'', with the
37 Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts.
38 A copy of the license is included in the section entitled ``GNU
39 Free Documentation License''.
40 @end copying
41
42 @titlepage
43
44
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada 95 Compiler
47 @subtitle GNAT Version for GCC @value{version-GCC}
48 @author Ada Core Technologies, Inc.
49
50 @page
51 @vskip 0pt plus 1filll
52
53 @insertcopying
54
55 @end titlepage
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60
61 GNAT Reference Manual
62
63 GNAT, The GNU Ada 95 Compiler
64
65 GNAT Version for GCC @value{version-GCC}
66
67 Ada Core Technologies, Inc.
68
69 @insertcopying
70
71
72 @menu
73 * About This Guide::            
74 * Implementation Defined Pragmas::  
75 * Implementation Defined Attributes::  
76 * Implementation Advice::       
77 * Implementation Defined Characteristics::  
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::   
81 * The Implementation of Standard I/O::  
82 * The GNAT Library::
83 * Interfacing to Other Languages::  
84 * Machine Code Insertions::
85 * GNAT Implementation of Tasking::
86 * Code generation for array aggregates::
87 * Specialized Needs Annexes::   
88 * Compatibility Guide::
89 * GNU Free Documentation License::
90 * Index::                       
91
92  --- The Detailed Node Listing ---
93
94 About This Guide
95
96 * What This Reference Manual Contains::  
97 * Related Information::         
98
99 The Implementation of Standard I/O
100
101 * Standard I/O Packages::       
102 * FORM Strings::                
103 * Direct_IO::                   
104 * Sequential_IO::               
105 * Text_IO::                     
106 * Wide_Text_IO::                
107 * Stream_IO::                   
108 * Shared Files::                
109 * Open Modes::                  
110 * Operations on C Streams::     
111 * Interfacing to C Streams::    
112
113 The GNAT Library
114
115 * Ada.Characters.Latin_9 (a-chlat9.ads)::
116 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
117 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
118 * Ada.Command_Line.Remove (a-colire.ads)::
119 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
120 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
121 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
122 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
123 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
124 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
125 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
126 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
127 * GNAT.AWK (g-awk.ads)::
128 * GNAT.Bubble_Sort_A (g-busora.ads)::
129 * GNAT.Bubble_Sort_G (g-busorg.ads)::
130 * GNAT.Calendar (g-calend.ads)::
131 * GNAT.Calendar.Time_IO (g-catiio.ads)::
132 * GNAT.Case_Util (g-casuti.ads)::
133 * GNAT.CGI (g-cgi.ads)::
134 * GNAT.CGI.Cookie (g-cgicoo.ads)::
135 * GNAT.CGI.Debug (g-cgideb.ads)::
136 * GNAT.Command_Line (g-comlin.ads)::
137 * GNAT.CRC32 (g-crc32.ads)::
138 * GNAT.Current_Exception (g-curexc.ads)::
139 * GNAT.Debug_Pools (g-debpoo.ads)::
140 * GNAT.Debug_Utilities (g-debuti.ads)::
141 * GNAT.Directory_Operations (g-dirope.ads)::
142 * GNAT.Dynamic_Tables (g-dyntab.ads)::
143 * GNAT.Exception_Traces (g-exctra.ads)::
144 * GNAT.Expect (g-expect.ads)::
145 * GNAT.Float_Control (g-flocon.ads)::
146 * GNAT.Heap_Sort_A (g-hesora.ads)::
147 * GNAT.Heap_Sort_G (g-hesorg.ads)::
148 * GNAT.HTable (g-htable.ads)::
149 * GNAT.IO (g-io.ads)::
150 * GNAT.IO_Aux (g-io_aux.ads)::
151 * GNAT.Lock_Files (g-locfil.ads)::
152 * GNAT.MD5 (g-md5.ads)::
153 * GNAT.Most_Recent_Exception (g-moreex.ads)::
154 * GNAT.OS_Lib (g-os_lib.ads)::
155 * GNAT.Regexp (g-regexp.ads)::
156 * GNAT.Registry (g-regist.ads)::
157 * GNAT.Regpat (g-regpat.ads)::
158 * GNAT.Sockets (g-socket.ads)::
159 * GNAT.Source_Info (g-souinf.ads)::
160 * GNAT.Spell_Checker (g-speche.ads)::
161 * GNAT.Spitbol.Patterns (g-spipat.ads)::
162 * GNAT.Spitbol (g-spitbo.ads)::
163 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
164 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
165 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
166 * GNAT.Table (g-table.ads)::
167 * GNAT.Task_Lock (g-tasloc.ads)::
168 * GNAT.Threads (g-thread.ads)::
169 * GNAT.Traceback (g-traceb.ads)::
170 * GNAT.Traceback.Symbolic (g-trasym.ads)::
171 * Interfaces.C.Extensions (i-cexten.ads)::
172 * Interfaces.C.Streams (i-cstrea.ads)::
173 * Interfaces.CPP (i-cpp.ads)::
174 * Interfaces.Os2lib (i-os2lib.ads)::
175 * Interfaces.Os2lib.Errors (i-os2err.ads)::
176 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
177 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
178 * Interfaces.Packed_Decimal (i-pacdec.ads)::
179 * Interfaces.VxWorks (i-vxwork.ads)::
180 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
181 * System.Address_Image (s-addima.ads)::
182 * System.Assertions (s-assert.ads)::
183 * System.Partition_Interface (s-parint.ads)::
184 * System.Task_Info (s-tasinf.ads)::
185 * System.Wch_Cnv (s-wchcnv.ads)::
186 * System.Wch_Con (s-wchcon.ads)::
187
188 Text_IO
189
190 * Text_IO Stream Pointer Positioning::  
191 * Text_IO Reading and Writing Non-Regular Files::  
192 * Get_Immediate::               
193 * Treating Text_IO Files as Streams::
194 * Text_IO Extensions::
195 * Text_IO Facilities for Unbounded Strings::
196
197 Wide_Text_IO
198
199 * Wide_Text_IO Stream Pointer Positioning::  
200 * Wide_Text_IO Reading and Writing Non-Regular Files::  
201
202 Interfacing to Other Languages
203
204 * Interfacing to C::
205 * Interfacing to C++::          
206 * Interfacing to COBOL::        
207 * Interfacing to Fortran::      
208 * Interfacing to non-GNAT Ada code::
209
210 GNAT Implementation of Tasking
211
212 * Mapping Ada Tasks onto the Underlying Kernel Threads::
213 * Ensuring Compliance with the Real-Time Annex::
214 @end menu
215
216 @end ifnottex
217
218 @node About This Guide
219 @unnumbered About This Guide
220
221 @noindent
222 This manual contains useful information in writing programs using the
223 GNAT compiler.  It includes information on implementation dependent
224 characteristics of GNAT, including all the information required by Annex
225 M of the standard.
226
227 Ada 95 is designed to be highly portable,and guarantees that, for most
228 programs, Ada 95 compilers behave in exactly the same manner on
229 different machines.  However, since Ada 95 is designed to be used in a
230 wide variety of applications, it also contains a number of system
231 dependent features to Functbe used in interfacing to the external world. 
232
233 @c Maybe put the following in platform-specific section
234 @ignore
235 @cindex ProDev Ada
236 This reference manual discusses how these features are implemented for
237 use in ProDev Ada running on the IRIX 5.3 or greater operating systems.
238 @end ignore
239
240 @cindex Implementation-dependent features
241 @cindex Portability
242 Note: Any program that makes use of implementation-dependent features
243 may be non-portable.  You should follow good programming practice and
244 isolate and clearly document any sections of your program that make use
245 of these features in a non-portable manner.
246
247 @menu
248 * What This Reference Manual Contains::  
249 * Conventions::
250 * Related Information::         
251 @end menu
252
253 @node What This Reference Manual Contains
254 @unnumberedsec What This Reference Manual Contains
255
256 This reference manual contains the following chapters:
257
258 @itemize @bullet
259 @item
260 @ref{Implementation Defined Pragmas} lists GNAT implementation-dependent
261 pragmas, which can be used to extend and enhance the functionality of the
262 compiler.
263
264 @item
265 @ref{Implementation Defined Attributes} lists GNAT
266 implementation-dependent attributes which can be used to extend and
267 enhance the functionality of the compiler.
268
269 @item
270 @ref{Implementation Advice} provides information on generally
271 desirable behavior which are not requirements that all compilers must
272 follow since it cannot be provided on all systems, or which may be
273 undesirable on some systems.
274
275 @item
276 @ref{Implementation Defined Characteristics} provides a guide to
277 minimizing implementation dependent features.
278
279 @item
280 @ref{Intrinsic Subprograms} describes the intrinsic subprograms
281 implemented by GNAT, and how they can be imported into user
282 application programs.
283
284 @item
285 @ref{Representation Clauses and Pragmas} describes in detail the
286 way that GNAT represents data, and in particular the exact set
287 of representation clauses and pragmas that is accepted.
288
289 @item
290 @ref{Standard Library Routines} provides a listing of packages and a
291 brief description of the functionality that is provided by Ada's
292 extensive set of standard library routines as implemented by GNAT@.
293
294 @item
295 @ref{The Implementation of Standard I/O} details how the GNAT
296 implementation of the input-output facilities.
297
298 @item
299 @ref{Interfacing to Other Languages} describes how programs
300 written in Ada using GNAT can be interfaced to other programming
301 languages.
302
303 @item
304 @ref{Specialized Needs Annexes} describes the GNAT implementation of all
305 of the special needs annexes.
306
307 @item
308 @ref{Compatibility Guide} includes sections on compatibility of GNAT with
309 other Ada 83 and Ada 95 compilation systems, to assist in porting code
310 from other environments.
311 @end itemize
312
313 @cindex Ada 95 ISO/ANSI Standard
314 This reference manual assumes that you are familiar with Ada 95
315 language, as described in the International Standard
316 ANSI/ISO/IEC-8652:1995, Jan 1995.
317
318 @node Conventions
319 @unnumberedsec Conventions
320 @cindex Conventions, typographical
321 @cindex Typographical conventions
322
323 @noindent
324 Following are examples of the typographical and graphic conventions used
325 in this guide:
326
327 @itemize @bullet
328 @item
329 @code{Functions}, @code{utility program names}, @code{standard names},
330 and @code{classes}.
331
332 @item
333 @code{Option flags}
334
335 @item
336 @file{File Names}, @samp{button names}, and @samp{field names}.
337
338 @item
339 @code{Variables}.
340
341 @item
342 @emph{Emphasis}.
343
344 @item
345 [optional information or parameters]
346
347 @item
348 Examples are described by text
349 @smallexample
350 and then shown this way.
351 @end smallexample
352 @end itemize
353
354 @noindent
355 Commands that are entered by the user are preceded in this manual by the
356 characters @samp{$ } (dollar sign followed by space).  If your system uses this
357 sequence as a prompt, then the commands will appear exactly as you see them
358 in the manual.  If your system uses some other prompt, then the command will
359 appear with the @samp{$} replaced by whatever prompt character you are using.
360
361 @node Related Information
362 @unnumberedsec Related Information
363 See the following documents for further information on GNAT:
364
365 @itemize @bullet
366 @item
367 @cite{GNAT User's Guide}, which provides information on how to use
368 the GNAT compiler system.
369
370 @item
371 @cite{Ada 95 Reference Manual}, which contains all reference
372 material for the Ada 95 programming language.
373
374 @item
375 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
376 of the standard reference manual cited above.  The annotations describe
377 detailed aspects of the design decision, and in particular contain useful
378 sections on Ada 83 compatibility.
379
380 @item
381 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
382 which contains specific information on compatibility between GNAT and
383 DEC Ada 83 systems.
384
385 @item
386 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
387 describes in detail the pragmas and attributes provided by the DEC Ada 83
388 compiler system.
389
390 @end itemize
391
392 @node Implementation Defined Pragmas
393 @chapter Implementation Defined Pragmas
394
395 @noindent
396 Ada 95 defines a set of pragmas that can be used to supply additional
397 information to the compiler.  These language defined pragmas are
398 implemented in GNAT and work as described in the Ada 95 Reference
399 Manual.
400
401 In addition, Ada 95 allows implementations to define additional pragmas
402 whose meaning is defined by the implementation.  GNAT provides a number
403 of these implementation-dependent pragmas which can be used to extend
404 and enhance the functionality of the compiler.  This section of the GNAT
405 Reference Manual describes these additional pragmas.
406
407 Note that any program using these pragmas may not be portable to other
408 compilers (although GNAT implements this set of pragmas on all
409 platforms).  Therefore if portability to other compilers is an important
410 consideration, the use of these pragmas should be minimized.
411
412 @table @code
413
414 @findex Abort_Defer
415 @cindex Deferring aborts
416 @item pragma Abort_Defer
417 @noindent
418 Syntax:
419
420 @smallexample
421 pragma Abort_Defer;
422 @end smallexample
423
424 @noindent
425 This pragma must appear at the start of the statement sequence of a
426 handled sequence of statements (right after the @code{begin}).  It has
427 the effect of deferring aborts for the sequence of statements (but not
428 for the declarations or handlers, if any, associated with this statement
429 sequence).
430
431 @item pragma Ada_83
432 @findex Ada_83
433 @noindent
434 Syntax:
435
436 @smallexample
437 pragma Ada_83;
438 @end smallexample
439
440 @noindent
441 A configuration pragma that establishes Ada 83 mode for the unit to
442 which it applies, regardless of the mode set by the command line
443 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
444 the syntax and semantics of Ada 83, as defined in the original Ada
445 83 Reference Manual as possible.  In particular, the new Ada 95
446 keywords are not recognized, optional package bodies are allowed,
447 and generics may name types with unknown discriminants without using
448 the @code{(<>)} notation.  In addition, some but not all of the additional
449 restrictions of Ada 83 are enforced.
450
451 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
452 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
453 Secondly, it aids in keeping code backwards compatible with Ada 83. 
454 However, there is no guarantee that code that is processed correctly
455 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
456 83 compiler, since GNAT does not enforce all the additional checks
457 required by Ada 83.
458
459 @findex Ada_95
460 @item pragma Ada_95
461 @noindent
462 Syntax:
463
464 @smallexample
465 pragma Ada_95;
466 @end smallexample
467
468 @noindent
469 A configuration pragma that establishes Ada 95 mode for the unit to which
470 it applies, regardless of the mode set by the command line switches.
471 This mode is set automatically for the @code{Ada} and @code{System}
472 packages and their children, so you need not specify it in these
473 contexts.  This pragma is useful when writing a reusable component that
474 itself uses Ada 95 features, but which is intended to be usable from
475 either Ada 83 or Ada 95 programs.
476
477 @findex Annotate
478 @item pragma Annotate
479 @noindent
480 Syntax:
481
482 @smallexample
483 pragma Annotate (IDENTIFIER @{, ARG@});
484
485 ARG ::= NAME | EXPRESSION
486 @end smallexample
487
488 @noindent
489 This pragma is used to annotate programs.  @var{identifier} identifies
490 the type of annotation.  GNAT verifies this is an identifier, but does
491 not otherwise analyze it.  The @var{arg} argument
492 can be either a string literal or an
493 expression.  String literals are assumed to be of type
494 @code{Standard.String}.  Names of entities are simply analyzed as entity
495 names.  All other expressions are analyzed as expressions, and must be
496 unambiguous.
497
498 The analyzed pragma is retained in the tree, but not otherwise processed
499 by any part of the GNAT compiler.  This pragma is intended for use by
500 external tools, including ASIS@.
501
502 @findex Assert
503 @item pragma Assert
504 @noindent
505 Syntax:
506
507 @smallexample
508 pragma Assert (
509   boolean_EXPRESSION
510   [, static_string_EXPRESSION])
511 @end smallexample
512
513 @noindent
514 The effect of this pragma depends on whether the corresponding command
515 line switch is set to activate assertions.  The pragma expands into code
516 equivalent to the following:
517
518 @smallexample
519 if assertions-enabled then
520    if not boolean_EXPRESSION then
521       System.Assertions.Raise_Assert_Failure
522         (string_EXPRESSION); 
523    end if;
524 end if;
525 @end smallexample
526
527 @noindent
528 The string argument, if given, is the message that will be associated
529 with the exception occurrence if the exception is raised.  If no second
530 argument is given, the default message is @samp{@var{file}:@var{nnn}},
531 where @var{file} is the name of the source file containing the assert,
532 and @var{nnn} is the line number of the assert.  A pragma is not a
533 statement, so if a statement sequence contains nothing but a pragma
534 assert, then a null statement is required in addition, as in:
535
536 @smallexample
537 @dots{}
538 if J > 3 then
539    pragma Assert (K > 3, "Bad value for K");
540    null;
541 end if;
542 @end smallexample
543
544 @noindent
545 Note that, as with the @code{if} statement to which it is equivalent, the
546 type of the expression is either @code{Standard.Boolean}, or any type derived
547 from this standard type.
548
549 If assertions are disabled (switch @code{-gnata} not used), then there
550 is no effect (and in particular, any side effects from the expression
551 are suppressed).  More precisely it is not quite true that the pragma
552 has no effect, since the expression is analyzed, and may cause types
553 to be frozen if they are mentioned here for the first time.
554
555 If assertions are enabled, then the given expression is tested, and if
556 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
557 which results in the raising of @code{Assert_Failure} with the given message.
558
559 If the boolean expression has side effects, these side effects will turn
560 on and off with the setting of the assertions mode, resulting in
561 assertions that have an effect on the program.  You should generally 
562 avoid side effects in the expression arguments of this pragma.  However,
563 the expressions are analyzed for semantic correctness whether or not
564 assertions are enabled, so turning assertions on and off cannot affect
565 the legality of a program.
566
567 @cindex OpenVMS
568 @findex Ast_Entry
569 @item pragma Ast_Entry
570 @noindent
571 Syntax:
572
573 @smallexample
574 pragma AST_Entry (entry_IDENTIFIER);
575 @end smallexample
576
577 @noindent
578 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
579 argument is the simple name of a single entry; at most one @code{AST_Entry}
580 pragma is allowed for any given entry.  This pragma must be used in 
581 conjunction with the @code{AST_Entry} attribute, and is only allowed after
582 the entry declaration and in the same task type specification or single task
583 as the entry to which it applies.  This pragma specifies that the given entry
584 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
585 resulting from an OpenVMS system service call.  The pragma does not affect
586 normal use of the entry.  For further details on this pragma, see the 
587 DEC Ada Language Reference Manual, section 9.12a.
588
589 @cindex Passing by copy
590 @findex C_Pass_By_Copy
591 @item pragma C_Pass_By_Copy
592 @noindent
593 Syntax:
594
595 @smallexample
596 pragma C_Pass_By_Copy
597   ([Max_Size =>] static_integer_EXPRESSION);
598 @end smallexample
599
600 @noindent
601 Normally the default mechanism for passing C convention records to C
602 convention subprograms is to pass them by reference, as suggested by RM
603 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
604 this default, by requiring that record formal parameters be passed by
605 copy if all of the following conditions are met:
606
607 @itemize @bullet
608 @item
609 The size of the record type does not exceed@*@var{static_integer_expression}.
610 @item
611 The record type has @code{Convention C}.
612 @item
613 The formal parameter has this record type, and the subprogram has a
614 foreign (non-Ada) convention.
615 @end itemize
616
617 @noindent
618 If these conditions are met the argument is passed by copy, i.e.@: in a
619 manner consistent with what C expects if the corresponding formal in the
620 C prototype is a struct (rather than a pointer to a struct).
621
622 You can also pass records by copy by specifying the convention
623 @code{C_Pass_By_Copy} for the record type, or by using the extended
624 @code{Import} and @code{Export} pragmas, which allow specification of
625 passing mechanisms on a parameter by parameter basis.
626
627 @findex Comment
628 @item pragma Comment
629 @noindent
630 Syntax:
631
632 @smallexample
633 pragma Comment (static_string_EXPRESSION);
634 @end smallexample
635
636 @noindent
637 This is almost identical in effect to pragma @code{Ident}.  It allows the
638 placement of a comment into the object file and hence into the
639 executable file if the operating system permits such usage.  The
640 difference is that @code{Comment}, unlike @code{Ident}, has no limit on the
641 length of the string argument, and no limitations on placement
642 of the pragma (it can be placed anywhere in the main source unit).
643
644 @findex Common_Object
645 @item pragma Common_Object
646 @noindent
647 Syntax:
648
649 @smallexample
650 pragma Common_Object (
651      [Internal =>] LOCAL_NAME,
652   [, [External =>] EXTERNAL_SYMBOL]
653   [, [Size     =>] EXTERNAL_SYMBOL] )
654
655 EXTERNAL_SYMBOL ::=
656   IDENTIFIER
657 | static_string_EXPRESSION
658 @end smallexample
659
660 @noindent
661 This pragma enables the shared use of variables stored in overlaid
662 linker areas corresponding to the use of @code{COMMON}
663 in Fortran.  The single
664 object @var{local_name} is assigned to the area designated by
665 the @var{External} argument.
666 You may define a record to correspond to a series
667 of fields.  The @var{size} argument
668 is syntax checked in GNAT, but otherwise ignored.
669
670 @code{Common_Object} is not supported on all platforms.  If no
671 support is available, then the code generator will issue a message
672 indicating that the necessary attribute for implementation of this
673 pragma is not available.
674
675 @findex Complex_Representation
676 @item pragma Complex_Representation
677 @noindent
678 Syntax:
679
680 @smallexample
681 pragma Complex_Representation
682         ([Entity =>] LOCAL_NAME);
683 @end smallexample
684
685 @noindent
686 The @var{Entity} argument must be the name of a record type which has
687 two fields of the same floating-point type.  The effect of this pragma is
688 to force gcc to use the special internal complex representation form for
689 this record, which may be more efficient.  Note that this may result in
690 the code for this type not conforming to standard ABI (application
691 binary interface) requirements for the handling of record types.  For
692 example, in some environments, there is a requirement for passing
693 records by pointer, and the use of this pragma may result in passing
694 this type in floating-point registers.
695
696 @cindex Alignments of components
697 @findex Component_Alignment
698 @item pragma Component_Alignment
699 @noindent
700 Syntax:
701
702 @smallexample
703 pragma Component_Alignment (
704      [Form =>] ALIGNMENT_CHOICE
705   [, [Name =>] type_LOCAL_NAME]);
706
707 ALIGNMENT_CHOICE ::=
708   Component_Size
709 | Component_Size_4
710 | Storage_Unit
711 | Default
712 @end smallexample
713
714 @noindent
715 Specifies the alignment of components in array or record types.
716 The meaning of the @var{Form} argument is as follows:
717
718 @table @code
719 @findex Component_Size
720 @item Component_Size
721 Aligns scalar components and subcomponents of the array or record type
722 on boundaries appropriate to their inherent size (naturally
723 aligned).  For example, 1-byte components are aligned on byte boundaries,
724 2-byte integer components are aligned on 2-byte boundaries, 4-byte
725 integer components are aligned on 4-byte boundaries and so on.  These
726 alignment rules correspond to the normal rules for C compilers on all
727 machines except the VAX@.
728
729 @findex Component_Size_4
730 @item Component_Size_4
731 Naturally aligns components with a size of four or fewer
732 bytes.  Components that are larger than 4 bytes are placed on the next
733 4-byte boundary.
734
735 @findex Storage_Unit
736 @item Storage_Unit
737 Specifies that array or record components are byte aligned, i.e.@:
738 aligned on boundaries determined by the value of the constant
739 @code{System.Storage_Unit}.
740
741 @cindex OpenVMS
742 @item Default
743 Specifies that array or record components are aligned on default
744 boundaries, appropriate to the underlying hardware or operating system or
745 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
746 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
747 the @code{Default} choice is the same as @code{Component_Size} (natural
748 alignment).
749 @end table
750
751 If the @code{Name} parameter is present, @var{type_local_name} must
752 refer to a local record or array type, and the specified alignment
753 choice applies to the specified type.  The use of
754 @code{Component_Alignment} together with a pragma @code{Pack} causes the
755 @code{Component_Alignment} pragma to be ignored.  The use of
756 @code{Component_Alignment} together with a record representation clause
757 is only effective for fields not specified by the representation clause.
758
759 If the @code{Name} parameter is absent, the pragma can be used as either
760 a configuration pragma, in which case it applies to one or more units in
761 accordance with the normal rules for configuration pragmas, or it can be
762 used within a declarative part, in which case it applies to types that
763 are declared within this declarative part, or within any nested scope
764 within this declarative part.  In either case it specifies the alignment
765 to be applied to any record or array type which has otherwise standard
766 representation.
767
768 If the alignment for a record or array type is not specified (using
769 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
770 clause), the GNAT uses the default alignment as described previously.
771
772 @findex Convention_Identifier
773 @cindex Conventions, synonyms
774 @item pragma Convention_Identifier
775 @noindent
776 Syntax:
777
778 @smallexample
779 pragma Convention_Identifier (
780          [Name =>]       IDENTIFIER,
781          [Convention =>] convention_IDENTIFIER);
782 @end smallexample
783
784 @noindent
785 This pragma provides a mechanism for supplying synonyms for existing
786 convention identifiers. The @code{Name} identifier can subsequently
787 be used as a synonym for the given convention in other pragmas (including
788 for example pragma @code{Import} or another @code{Convention_Identifier}
789 pragma). As an example of the use of this, suppose you had legacy code
790 which used Fortran77 as the identifier for Fortran. Then the pragma:
791
792 @smallexample
793 pragma Convention_Indentifier (Fortran77, Fortran);
794 @end smallexample
795
796 @noindent
797 would allow the use of the convention identifier @code{Fortran77} in
798 subsequent code, avoiding the need to modify the sources. As another
799 example, you could use this to parametrize convention requirements
800 according to systems. Suppose you needed to use @code{Stdcall} on
801 windows systems, and @code{C} on some other system, then you could
802 define a convention identifier @code{Library} and use a single
803 @code{Convention_Identifier} pragma to specify which convention
804 would be used system-wide.
805   
806 @findex CPP_Class
807 @cindex Interfacing with C++
808 @item pragma CPP_Class
809 @noindent
810 Syntax:
811
812 @smallexample
813 pragma CPP_Class ([Entity =>] LOCAL_NAME);
814 @end smallexample
815
816 @noindent
817 The argument denotes an entity in the current declarative region
818 that is declared as a tagged or untagged record type.  It indicates that
819 the type corresponds to an externally declared C++ class type, and is to
820 be laid out the same way that C++ would lay out the type.
821
822 If (and only if) the type is tagged, at least one component in the
823 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
824 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
825 for dispatching.
826
827 Types for which @code{CPP_Class} is specified do not have assignment or
828 equality operators defined (such operations can be imported or declared
829 as subprograms as required).  Initialization is allowed only by
830 constructor functions (see pragma @code{CPP_Constructor}).
831
832 Pragma @code{CPP_Class} is intended primarily for automatic generation
833 using an automatic binding generator tool.  
834 See @ref{Interfacing to C++} for related information.
835
836 @cindex Interfacing with C++
837 @findex CPP_Constructor
838 @item pragma CPP_Constructor
839 @noindent
840 Syntax:
841
842 @smallexample
843 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
844 @end smallexample
845
846 @noindent
847 This pragma identifies an imported function (imported in the usual way
848 with pragma @code{Import}) as corresponding to a C++
849 constructor.  The argument is a name that must have been
850 previously mentioned in a pragma @code{Import} 
851 with @code{Convention} = @code{CPP}, and must be of one of the following
852 forms:
853
854 @itemize @bullet
855 @item
856 @code{function @var{Fname} return @var{T}'Class}
857
858 @item
859 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
860 @end itemize
861
862 @noindent
863 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
864
865 The first form is the default constructor, used when an object of type
866 @var{T} is created on the Ada side with no explicit constructor.  Other
867 constructors (including the copy constructor, which is simply a special
868 case of the second form in which the one and only argument is of type
869 @var{T}), can only appear in two contexts:
870
871 @itemize @bullet
872 @item
873 On the right side of an initialization of an object of type @var{T}.
874 @item
875 In an extension aggregate for an object of a type derived from @var{T}.
876 @end itemize
877
878 Although the constructor is described as a function that returns a value
879 on the Ada side, it is typically a procedure with an extra implicit
880 argument (the object being initialized) at the implementation
881 level.  GNAT issues the appropriate call, whatever it is, to get the
882 object properly initialized.
883
884 In the case of derived objects, you may use one of two possible forms
885 for declaring and creating an object:
886
887 @itemize @bullet
888 @item @code{New_Object : Derived_T}
889 @item @code{New_Object : Derived_T := (@var{constructor-function-call with} @dots{})}
890 @end itemize
891
892 In the first case the default constructor is called and extension fields
893 if any are initialized according to the default initialization
894 expressions in the Ada declaration.  In the second case, the given
895 constructor is called and the extension aggregate indicates the explicit
896 values of the extension fields.
897
898 If no constructors are imported, it is impossible to create any objects
899 on the Ada side.  If no default constructor is imported, only the
900 initialization forms using an explicit call to a constructor are
901 permitted.
902
903 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
904 using an automatic binding generator tool.  
905 See @ref{Interfacing to C++} for more related information.
906
907 @cindex Interfacing to C++
908 @findex CPP_Virtual
909 @item pragma CPP_Virtual
910 @noindent
911 Syntax:
912
913 @smallexample
914 pragma CPP_Virtual
915      [Entity     =>] ENTITY,
916   [, [Vtable_Ptr =>] vtable_ENTITY,]
917   [, [Position   =>] static_integer_EXPRESSION])
918 @end smallexample
919
920 This pragma serves the same function as pragma @code{Import} in that
921 case of a virtual function imported from C++.  The @var{Entity} argument
922 must be a
923 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
924 applies.  The @var{Vtable_Ptr} argument specifies
925 the Vtable_Ptr component which contains the
926 entry for this virtual function.  The @var{Position} argument
927 is the sequential number
928 counting virtual functions for this Vtable starting at 1.
929
930 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
931 there is one Vtable_Ptr present (single inheritance case) and all
932 virtual functions are imported.  In that case the compiler can deduce both
933 these values.
934
935 No @code{External_Name} or @code{Link_Name} arguments are required for a
936 virtual function, since it is always accessed indirectly via the
937 appropriate Vtable entry.
938
939 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
940 using an automatic binding generator tool.  
941 See @ref{Interfacing to C++} for related information.
942
943 @cindex Interfacing with C++
944 @findex CPP_Vtable
945 @item pragma CPP_Vtable
946 @noindent
947 Syntax:
948
949 @smallexample
950 pragma CPP_Vtable (
951   [Entity      =>] ENTITY,
952   [Vtable_Ptr  =>] vtable_ENTITY,
953   [Entry_Count =>] static_integer_EXPRESSION);
954 @end smallexample
955
956 @noindent
957 Given a record to which the pragma @code{CPP_Class} applies,
958 this pragma can be specified for each component of type
959 @code{CPP.Interfaces.Vtable_Ptr}.
960 @var{Entity} is the tagged type, @var{Vtable_Ptr}
961 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
962 the number of virtual functions on the C++ side.  Not all of these
963 functions need to be imported on the Ada side.
964
965 You may omit the @code{CPP_Vtable} pragma if there is only one
966 @code{Vtable_Ptr} component in the record and all virtual functions are
967 imported on the Ada side (the default value for the entry count in this
968 case is simply the total number of virtual functions).
969
970 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
971 using an automatic binding generator tool.  
972 See @ref{Interfacing to C++} for related information.
973
974 @findex Debug
975 @item pragma Debug
976 @noindent
977 Syntax:
978
979 @smallexample
980 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
981
982 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
983   PROCEDURE_NAME
984 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
985 @end smallexample
986
987 @noindent
988 The argument has the syntactic form of an expression, meeting the
989 syntactic requirements for pragmas. 
990
991 If assertions are not enabled on the command line, this pragma has no
992 effect.  If asserts are enabled, the semantics of the pragma is exactly
993 equivalent to the procedure call statement corresponding to the argument
994 with a terminating semicolon.  Pragmas are permitted in sequences of
995 declarations, so you can use pragma @code{Debug} to intersperse calls to
996 debug procedures in the middle of declarations.
997
998 @cindex Elaboration control
999 @findex Elaboration_Checks
1000 @item pragma Elaboration_Checks
1001 @noindent
1002 Syntax:
1003
1004 @smallexample
1005 pragma Elaboration_Checks (RM | Static);
1006 @end smallexample
1007
1008 @noindent
1009 This is a configuration pragma that provides control over the
1010 elaboration model used by the compilation affected by the
1011 pragma.  If the parameter is RM, then the dynamic elaboration
1012 model described in the Ada Reference Manual is used, as though
1013 the @code{-gnatE} switch had been specified on the command
1014 line.  If the parameter is Static, then the default GNAT static
1015 model is used.  This configuration pragma overrides the setting
1016 of the command line.  For full details on the elaboration models
1017 used by the GNAT compiler, see section ``Elaboration Order
1018 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1019
1020 @cindex Elimination of unused subprograms
1021 @findex Eliminate
1022 @item pragma Eliminate
1023 @noindent
1024 Syntax:
1025
1026 @smallexample
1027 pragma Eliminate (
1028     [Unit_Name =>] IDENTIFIER |
1029                    SELECTED_COMPONENT);
1030
1031 pragma Eliminate (
1032     [Unit_Name       =>]  IDENTIFIER |
1033                           SELECTED_COMPONENT,
1034     [Entity          =>]  IDENTIFIER |
1035                           SELECTED_COMPONENT |
1036                           STRING_LITERAL
1037   [,[Parameter_Types =>]  PARAMETER_TYPES]
1038   [,[Result_Type     =>]  result_SUBTYPE_NAME]
1039   [,[Homonym_Number  =>]  INTEGER_LITERAL]);
1040
1041 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1042 SUBTYPE_NAME    ::= STRING_LITERAL
1043 @end smallexample
1044
1045 @noindent
1046 This pragma indicates that the given entity is not used outside the
1047 compilation unit it is defined in.  The entity may be either a subprogram 
1048 or a variable.
1049
1050 If the entity to be eliminated is a library level subprogram, then
1051 the first form of pragma @code{Eliminate} is used with only a single argument.
1052 In this form, the @code{Unit_Name} argument specifies the name of the
1053 library  level unit to be eliminated.
1054
1055 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1056 are required.  item is an entity of a library package, then the first
1057 argument specifies the unit name, and the second argument specifies
1058 the particular entity.  If the second argument is in string form, it must
1059 correspond to the internal manner in which GNAT stores entity names (see
1060 compilation unit Namet in the compiler sources for details).
1061
1062 The remaining parameters are optionally used to distinguish
1063 between overloaded subprograms.  There are two ways of doing this.
1064
1065 Use @code{Parameter_Types} and @code{Result_Type} to specify the
1066 profile of the subprogram to be eliminated in a manner similar to that
1067 used for
1068 the extended @code{Import} and @code{Export} pragmas, except that the
1069 subtype names are always given as string literals, again corresponding
1070 to the internal manner in which GNAT stores entity names.
1071
1072 Alternatively, the @code{Homonym_Number} parameter is used to specify
1073 which overloaded alternative is to be eliminated.  A value of 1 indicates
1074 the first subprogram (in lexical order), 2 indicates the second etc.
1075
1076 The effect of the pragma is to allow the compiler to eliminate
1077 the code or data associated with the named entity.  Any reference to 
1078 an eliminated entity outside the compilation unit it is defined in,
1079 causes a compile time or link time error.
1080
1081 The parameters of this pragma may be given in any order, as long as
1082 the usual rules for use of named parameters and position parameters
1083 are used.
1084
1085 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1086 in a system independent manner, with unused entities eliminated, without
1087 the requirement of modifying the source text.  Normally the required set
1088 of @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1089 Elimination of unused entities local to a compilation unit is automatic,
1090 without requiring the use of pragma @code{Eliminate}.
1091
1092 Note that the reason this pragma takes string literals where names might
1093 be expected is that a pragma @code{Eliminate} can appear in a context where the
1094 relevant names are not visible.
1095
1096 @cindex OpenVMS
1097 @findex Export_Exception
1098 @item pragma Export_Exception
1099 @noindent
1100 Syntax:
1101
1102 @smallexample
1103 pragma Export_Exception (
1104      [Internal =>] LOCAL_NAME,
1105   [, [External =>] EXTERNAL_SYMBOL,]
1106   [, [Form     =>] Ada | VMS]
1107   [, [Code     =>] static_integer_EXPRESSION]);
1108
1109 EXTERNAL_SYMBOL ::=
1110   IDENTIFIER
1111 | static_string_EXPRESSION
1112 @end smallexample
1113
1114 @noindent
1115 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1116 causes the specified exception to be propagated outside of the Ada program,
1117 so that it can be handled by programs written in other OpenVMS languages.
1118 This pragma establishes an external name for an Ada exception and makes the
1119 name available to the OpenVMS Linker as a global symbol.  For further details
1120 on this pragma, see the
1121 DEC Ada Language Reference Manual, section 13.9a3.2.
1122
1123 @cindex Argument passing mechanisms
1124 @findex Export_Function
1125 @item pragma Export_Function @dots{}
1126
1127 @noindent
1128 Syntax:
1129
1130 @smallexample
1131 pragma Export_Function (
1132      [Internal         =>] LOCAL_NAME,      
1133   [, [External         =>] EXTERNAL_SYMBOL]
1134   [, [Parameter_Types  =>] PARAMETER_TYPES]
1135   [, [Result_Type      =>] result_SUBTYPE_MARK]
1136   [, [Mechanism        =>] MECHANISM]
1137   [, [Result_Mechanism =>] MECHANISM_NAME]);
1138
1139 EXTERNAL_SYMBOL ::=
1140   IDENTIFIER
1141 | static_string_EXPRESSION
1142
1143 PARAMETER_TYPES ::=
1144   null
1145 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1146
1147 MECHANISM ::=
1148   MECHANISM_NAME
1149 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1150
1151 MECHANISM_ASSOCIATION ::=
1152   [formal_parameter_NAME =>] MECHANISM_NAME
1153
1154 MECHANISM_NAME ::=
1155   Value
1156 | Reference
1157 | Descriptor [([Class =>] CLASS_NAME)]
1158
1159 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1160 @end smallexample
1161
1162 Use this pragma to make a function externally callable and optionally
1163 provide information on mechanisms to be used for passing parameter and
1164 result values.  We recommend, for the purposes of improving portability,
1165 this pragma always be used in conjunction with a separate pragma
1166 @code{Export}, which must precede the pragma @code{Export_Function}.
1167 GNAT does not require a separate pragma @code{Export}, but if none is
1168 present, @code{Convention Ada} is assumed, which is usually
1169 not what is wanted, so it is usually appropriate to use this
1170 pragma in conjunction with a @code{Export} or @code{Convention}
1171 pragma that specifies the desired foreign convention.
1172 Pragma @code{Export_Function}
1173 (and @code{Export}, if present) must appear in the same declarative
1174 region as the function to which they apply.
1175
1176 @var{internal_name} must uniquely designate the function to which the
1177 pragma applies.  If more than one function name exists of this name in
1178 the declarative part you must use the @code{Parameter_Types} and
1179 @code{Result_Type} parameters is mandatory to achieve the required
1180 unique designation.  @var{subtype_ mark}s in these parameters must
1181 exactly match the subtypes in the corresponding function specification,
1182 using positional notation to match parameters with subtype marks.
1183 @cindex OpenVMS
1184 @cindex Passing by descriptor
1185 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1186
1187 @findex Export_Object
1188 @item pragma Export_Object @dots{}
1189 @noindent
1190 Syntax:
1191
1192 @smallexample
1193 pragma Export_Object
1194       [Internal =>] LOCAL_NAME,
1195    [, [External =>] EXTERNAL_SYMBOL]
1196    [, [Size     =>] EXTERNAL_SYMBOL]
1197
1198 EXTERNAL_SYMBOL ::=
1199   IDENTIFIER
1200 | static_string_EXPRESSION
1201 @end smallexample
1202
1203 This pragma designates an object as exported, and apart from the
1204 extended rules for external symbols, is identical in effect to the use of
1205 the normal @code{Export} pragma applied to an object.  You may use a
1206 separate Export pragma (and you probably should from the point of view
1207 of portability), but it is not required.  @var{Size} is syntax checked,
1208 but otherwise ignored by GNAT@.
1209
1210 @findex Export_Procedure
1211 @item pragma Export_Procedure @dots{}
1212 @noindent
1213 Syntax:
1214
1215 @smallexample
1216 pragma Export_Procedure (
1217      [Internal        =>] LOCAL_NAME
1218   [, [External        =>] EXTERNAL_SYMBOL]
1219   [, [Parameter_Types =>] PARAMETER_TYPES]
1220   [, [Mechanism       =>] MECHANISM]);
1221
1222 EXTERNAL_SYMBOL ::=
1223   IDENTIFIER
1224 | static_string_EXPRESSION
1225
1226 PARAMETER_TYPES ::=
1227   null
1228 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1229
1230 MECHANISM ::=
1231   MECHANISM_NAME
1232 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1233
1234 MECHANISM_ASSOCIATION ::=
1235   [formal_parameter_NAME =>] MECHANISM_NAME
1236
1237 MECHANISM_NAME ::=
1238   Value
1239 | Reference
1240 | Descriptor [([Class =>] CLASS_NAME)]
1241
1242 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1243 @end smallexample
1244
1245 @noindent
1246 This pragma is identical to @code{Export_Function} except that it
1247 applies to a procedure rather than a function and the parameters
1248 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1249 GNAT does not require a separate pragma @code{Export}, but if none is
1250 present, @code{Convention Ada} is assumed, which is usually
1251 not what is wanted, so it is usually appropriate to use this
1252 pragma in conjunction with a @code{Export} or @code{Convention}
1253 pragma that specifies the desired foreign convention.
1254
1255 @findex Export_Valued_Procedure
1256 @item pragma Export_Valued_Procedure
1257 @noindent
1258 Syntax:
1259
1260 @smallexample
1261 pragma Export_Valued_Procedure (
1262      [Internal        =>] LOCAL_NAME
1263   [, [External        =>] EXTERNAL_SYMBOL]
1264   [, [Parameter_Types =>] PARAMETER_TYPES]
1265   [, [Mechanism       =>] MECHANISM]);
1266
1267 EXTERNAL_SYMBOL ::=
1268   IDENTIFIER
1269 | static_string_EXPRESSION
1270
1271 PARAMETER_TYPES ::=
1272   null
1273 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1274
1275 MECHANISM ::=
1276   MECHANISM_NAME
1277 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1278
1279 MECHANISM_ASSOCIATION ::=
1280   [formal_parameter_NAME =>] MECHANISM_NAME
1281
1282 MECHANISM_NAME ::=
1283   Value
1284 | Reference
1285 | Descriptor [([Class =>] CLASS_NAME)]
1286
1287 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1288 @end smallexample
1289
1290 This pragma is identical to @code{Export_Procedure} except that the
1291 first parameter of @var{local_name}, which must be present, must be of
1292 mode @code{OUT}, and externally the subprogram is treated as a function
1293 with this parameter as the result of the function.  GNAT provides for
1294 this capability to allow the use of @code{OUT} and @code{IN OUT}
1295 parameters in interfacing to external functions (which are not permitted
1296 in Ada functions).
1297 GNAT does not require a separate pragma @code{Export}, but if none is
1298 present, @code{Convention Ada} is assumed, which is almost certainly
1299 not what is wanted since the whole point of this pragma is to interface
1300 with foreign language functions, so it is usually appropriate to use this
1301 pragma in conjunction with a @code{Export} or @code{Convention}
1302 pragma that specifies the desired foreign convention.
1303
1304 @cindex @code{system}, extending
1305 @cindex Dec Ada 83
1306 @findex Extend_System
1307 @item pragma Extend_System
1308 @noindent
1309 Syntax:
1310
1311 @smallexample
1312 pragma Extend_System ([Name =>] IDENTIFIER);
1313 @end smallexample
1314
1315 @noindent
1316 This pragma is used to provide backwards compatibility with other
1317 implementations that extend the facilities of package @code{System}.  In
1318 GNAT, @code{System} contains only the definitions that are present in
1319 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1320 implementation, provide many extensions to package @code{System}.
1321
1322 For each such implementation accommodated by this pragma, GNAT provides a
1323 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1324 implementation, which provides the required additional definitions.  You
1325 can use this package in two ways.  You can @code{with} it in the normal
1326 way and access entities either by selection or using a @code{use}
1327 clause.  In this case no special processing is required.
1328
1329 However, if existing code contains references such as
1330 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1331 definitions provided in package @code{System}, you may use this pragma
1332 to extend visibility in @code{System} in a non-standard way that
1333 provides greater compatibility with the existing code.  Pragma
1334 @code{Extend_System} is a configuration pragma whose single argument is
1335 the name of the package containing the extended definition
1336 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1337 control of this pragma will be processed using special visibility
1338 processing that looks in package @code{System.Aux_@var{xxx}} where
1339 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1340 package @code{System}, but not found in package @code{System}.
1341
1342 You can use this pragma either to access a predefined @code{System}
1343 extension supplied with the compiler, for example @code{Aux_DEC} or
1344 you can construct your own extension unit following the above
1345 definition.  Note that such a package is a child of @code{System}
1346 and thus is considered part of the implementation.  To compile
1347 it you will have to use the appropriate switch for compiling
1348 system units.  See the GNAT User's Guide for details.
1349
1350 @findex External
1351 @item pragma External
1352 @noindent
1353 Syntax:
1354
1355 @smallexample
1356 pragma External (
1357   [   Convention    =>] convention_IDENTIFIER,
1358   [   Entity        =>] local_NAME
1359   [, [External_Name =>] static_string_EXPRESSION ]
1360   [, [Link_Name     =>] static_string_EXPRESSION ]);
1361 @end smallexample
1362
1363 @noindent
1364 This pragma is identical in syntax and semantics to pragma
1365 @code{Export} as defined in the Ada Reference Manual.  It is
1366 provided for compatibility with some Ada 83 compilers that
1367 used this pragma for exactly the same purposes as pragma
1368 @code{Export} before the latter was standardized.
1369
1370 @cindex Dec Ada 83 casing compatibility
1371 @cindex External Names, casing
1372 @cindex Casing of External names
1373 @findex External_Name_Casing
1374 @item pragma External_Name_Casing
1375 @noindent
1376 Syntax:
1377
1378 @smallexample
1379 pragma External_Name_Casing (
1380   Uppercase | Lowercase
1381   [, Uppercase | Lowercase | As_Is]);
1382 @end smallexample
1383
1384 @noindent
1385 This pragma provides control over the casing of external names associated
1386 with Import and Export pragmas.  There are two cases to consider:
1387
1388 @table @asis
1389 @item Implicit external names
1390 Implicit external names are derived from identifiers.  The most common case
1391 arises when a standard Ada 95 Import or Export pragma is used with only two
1392 arguments, as in:
1393
1394 @smallexample
1395    pragma Import (C, C_Routine);
1396 @end smallexample
1397
1398 @noindent
1399 Since Ada is a case insensitive language, the spelling of the identifier in
1400 the Ada source program does not provide any information on the desired
1401 casing of the external name, and so a convention is needed.  In GNAT the
1402 default treatment is that such names are converted to all lower case
1403 letters.  This corresponds to the normal C style in many environments.
1404 The first argument of pragma @code{External_Name_Casing} can be used to
1405 control this treatment.  If @code{Uppercase} is specified, then the name
1406 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1407 then the normal default of all lower case letters will be used.
1408
1409 This same implicit treatment is also used in the case of extended DEC Ada 83
1410 compatible Import and Export pragmas where an external name is explicitly
1411 specified using an identifier rather than a string.
1412
1413 @item Explicit external names
1414 Explicit external names are given as string literals.  The most common case
1415 arises when a standard Ada 95 Import or Export pragma is used with three
1416 arguments, as in:
1417
1418 @smallexample
1419 pragma Import (C, C_Routine, "C_routine");
1420 @end smallexample
1421
1422 @noindent
1423 In this case, the string literal normally provides the exact casing required
1424 for the external name.  The second argument of pragma 
1425 @code{External_Name_Casing} may be used to modify this behavior. 
1426 If @code{Uppercase} is specified, then the name
1427 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1428 then the name will be forced to all lowercase letters.  A specification of
1429 @code{As_Is} provides the normal default behavior in which the casing is
1430 taken from the string provided.
1431 @end table
1432
1433 @noindent
1434 This pragma may appear anywhere that a pragma is valid.  In particular, it
1435 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1436 case it applies to all subsequent compilations, or it can be used as a program
1437 unit pragma, in which case it only applies to the current unit, or it can
1438 be used more locally to control individual Import/Export pragmas.
1439
1440 It is primarily intended for use with OpenVMS systems, where many
1441 compilers convert all symbols to upper case by default.  For interfacing to
1442 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1443 the pragma:
1444
1445 @smallexample
1446 pragma External_Name_Casing (Uppercase, Uppercase);
1447 @end smallexample
1448
1449 @noindent
1450 to enforce the upper casing of all external symbols. 
1451
1452 @findex Finalize_Storage_Only
1453 @item pragma Finalize_Storage_Only
1454 @noindent
1455 Syntax:
1456
1457 @smallexample
1458 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1459 @end smallexample
1460
1461 @noindent
1462 This pragma allows the compiler not to emit a Finalize call for objects
1463 defined at the library level.  This is mostly useful for types where
1464 finalization is only used to deal with storage reclamation since in most
1465 environments it is not necessary to reclaim memory just before terminating
1466 execution, hence the name.
1467
1468 @cindex OpenVMS
1469 @findex Float_Representation
1470 @item pragma Float_Representation
1471 @noindent
1472 Syntax:
1473
1474 @smallexample
1475 pragma Float_Representation (FLOAT_REP);
1476
1477 FLOAT_REP ::= VAX_Float | IEEE_Float
1478 @end smallexample
1479
1480 @noindent
1481 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1482 It allows control over the internal representation chosen for the predefined
1483 floating point types declared in the packages @code{Standard} and
1484 @code{System}.  For further details on this pragma, see the
1485 DEC Ada Language Reference Manual, section 3.5.7a.  Note that to use this
1486 pragma, the standard runtime libraries must be recompiled.  See the
1487 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1488 of the GNAT Users Guide for details on the use of this command.
1489
1490 @findex Ident
1491 @item pragma Ident
1492 @noindent
1493 Syntax:
1494
1495 @smallexample
1496 pragma Ident (static_string_EXPRESSION);
1497 @end smallexample
1498
1499 @noindent
1500 This pragma provides a string identification in the generated object file,
1501 if the system supports the concept of this kind of identification string.
1502 The maximum permitted length of the string literal is 31 characters.
1503 This pragma is allowed only in the outermost declarative part or
1504 declarative items of a compilation unit.
1505 @cindex OpenVMS
1506 On OpenVMS systems, the effect of the pragma is identical to the effect of
1507 the DEC Ada 83 pragma of the same name. 
1508
1509 @cindex OpenVMS
1510 @findex Import_Exception
1511 @item pragma Import_Exception
1512 @noindent
1513 Syntax:
1514
1515 @smallexample
1516 pragma Import_Exception (
1517      [Internal =>] LOCAL_NAME,
1518   [, [External =>] EXTERNAL_SYMBOL,]
1519   [, [Form     =>] Ada | VMS]
1520   [, [Code     =>] static_integer_EXPRESSION]);
1521
1522 EXTERNAL_SYMBOL ::=
1523   IDENTIFIER
1524 | static_string_EXPRESSION
1525 @end smallexample
1526
1527 @noindent
1528 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1529 It allows OpenVMS conditions (for example, from OpenVMS system services or
1530 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1531 The pragma specifies that the exception associated with an exception
1532 declaration in an Ada program be defined externally (in non-Ada code).
1533 For further details on this pragma, see the
1534 DEC Ada Language Reference Manual, section 13.9a.3.1.
1535
1536 @findex Import_Function
1537 @item pragma Import_Function @dots{}
1538 @noindent
1539 Syntax:
1540
1541 @smallexample
1542 pragma Import_Function (
1543      [Internal                 =>] LOCAL_NAME,
1544   [, [External                 =>] EXTERNAL_SYMBOL]
1545   [, [Parameter_Types          =>] PARAMETER_TYPES]
1546   [, [Result_Type              =>] SUBTYPE_MARK]
1547   [, [Mechanism                =>] MECHANISM]
1548   [, [Result_Mechanism         =>] MECHANISM_NAME]
1549   [, [First_Optional_Parameter =>] IDENTIFIER]);
1550
1551 EXTERNAL_SYMBOL ::=
1552   IDENTIFIER
1553 | static_string_EXPRESSION
1554
1555 PARAMETER_TYPES ::=
1556   null
1557 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1558
1559 MECHANISM ::=
1560   MECHANISM_NAME
1561 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1562
1563 MECHANISM_ASSOCIATION ::=
1564   [formal_parameter_NAME =>] MECHANISM_NAME
1565
1566 MECHANISM_NAME ::=
1567   Value
1568 | Reference
1569 | Descriptor [([Class =>] CLASS_NAME)]
1570
1571 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1572 @end smallexample
1573
1574 This pragma is used in conjunction with a pragma @code{Import} to
1575 specify additional information for an imported function.  The pragma
1576 @code{Import} (or equivalent pragma @code{Interface}) must precede the
1577 @code{Import_Function} pragma and both must appear in the same
1578 declarative part as the function specification.
1579
1580 The @var{Internal_Name} argument must uniquely designate
1581 the function to which the
1582 pragma applies.  If more than one function name exists of this name in
1583 the declarative part you must use the @code{Parameter_Types} and
1584 @var{Result_Type} parameters to achieve the required unique
1585 designation.  Subtype marks in these parameters must exactly match the
1586 subtypes in the corresponding function specification, using positional
1587 notation to match parameters with subtype marks.
1588
1589 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
1590 parameters to specify passing mechanisms for the
1591 parameters and result.  If you specify a single mechanism name, it
1592 applies to all parameters.  Otherwise you may specify a mechanism on a
1593 parameter by parameter basis using either positional or named
1594 notation.  If the mechanism is not specified, the default mechanism
1595 is used.
1596
1597 @cindex OpenVMS
1598 @cindex Passing by descriptor
1599 Passing by descriptor is supported only on the to OpenVMS ports of GNAT@.
1600
1601 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
1602 It specifies that the designated parameter and all following parameters
1603 are optional, meaning that they are not passed at the generated code
1604 level (this is distinct from the notion of optional parameters in Ada
1605 where the parameters are passed anyway with the designated optional
1606 parameters).  All optional parameters must be of mode @code{IN} and have
1607 default parameter values that are either known at compile time
1608 expressions, or uses of the @code{'Null_Parameter} attribute.
1609
1610 @findex Import_Object
1611 @item pragma Import_Object
1612 @noindent
1613 Syntax:
1614
1615 @smallexample
1616 pragma Import_Object
1617      [Internal =>] LOCAL_NAME,
1618   [, [External =>] EXTERNAL_SYMBOL],
1619   [, [Size     =>] EXTERNAL_SYMBOL])
1620
1621 EXTERNAL_SYMBOL ::=
1622   IDENTIFIER
1623 | static_string_EXPRESSION
1624 @end smallexample
1625
1626 @noindent
1627 This pragma designates an object as imported, and apart from the
1628 extended rules for external symbols, is identical in effect to the use of
1629 the normal @code{Import} pragma applied to an object.  Unlike the
1630 subprogram case, you need not use a separate @code{Import} pragma,
1631 although you may do so (and probably should do so from a portability
1632 point of view).  @var{size} is syntax checked, but otherwise ignored by
1633 GNAT@.
1634
1635 @findex Import_Procedure
1636 @item pragma Import_Procedure
1637 @noindent
1638 Syntax:
1639
1640 @smallexample
1641 pragma Import_Procedure (
1642      [Internal                 =>] LOCAL_NAME,
1643   [, [External                 =>] EXTERNAL_SYMBOL]
1644   [, [Parameter_Types          =>] PARAMETER_TYPES]
1645   [, [Mechanism                =>] MECHANISM]
1646   [, [First_Optional_Parameter =>] IDENTIFIER]);
1647
1648 EXTERNAL_SYMBOL ::=
1649   IDENTIFIER
1650 | static_string_EXPRESSION
1651
1652 PARAMETER_TYPES ::=
1653   null
1654 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1655
1656 MECHANISM ::=
1657   MECHANISM_NAME
1658 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1659
1660 MECHANISM_ASSOCIATION ::=
1661   [formal_parameter_NAME =>] MECHANISM_NAME
1662
1663 MECHANISM_NAME ::=
1664   Value
1665 | Reference
1666 | Descriptor [([Class =>] CLASS_NAME)]
1667
1668 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1669 @end smallexample
1670
1671 @noindent
1672 This pragma is identical to @code{Import_Function} except that it
1673 applies to a procedure rather than a function and the parameters
1674 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1675
1676 @findex Import_Valued_Procedure
1677 @item pragma Import_Valued_Procedure @dots{}
1678 @noindent
1679 Syntax:
1680
1681 @smallexample
1682 pragma Import_Valued_Procedure (
1683      [Internal                 =>] LOCAL_NAME,
1684   [, [External                 =>] EXTERNAL_SYMBOL]
1685   [, [Parameter_Types          =>] PARAMETER_TYPES]
1686   [, [Mechanism                =>] MECHANISM]
1687   [, [First_Optional_Parameter =>] IDENTIFIER]);
1688
1689 EXTERNAL_SYMBOL ::=
1690   IDENTIFIER
1691 | static_string_EXPRESSION
1692
1693 PARAMETER_TYPES ::=
1694   null
1695 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1696
1697 MECHANISM ::=
1698   MECHANISM_NAME
1699 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1700
1701 MECHANISM_ASSOCIATION ::=
1702   [formal_parameter_NAME =>] MECHANISM_NAME
1703
1704 MECHANISM_NAME ::=
1705   Value
1706 | Reference
1707 | Descriptor [([Class =>] CLASS_NAME)]
1708
1709 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1710 @end smallexample
1711
1712 @noindent
1713 This pragma is identical to @code{Import_Procedure} except that the
1714 first parameter of @var{local_name}, which must be present, must be of
1715 mode @code{OUT}, and externally the subprogram is treated as a function
1716 with this parameter as the result of the function.  The purpose of this
1717 capability is to allow the use of @code{OUT} and @code{IN OUT}
1718 parameters in interfacing to external functions (which are not permitted
1719 in Ada functions).  You may optionally use the @code{Mechanism}
1720 parameters to specify passing mechanisms for the parameters.
1721 If you specify a single mechanism name, it applies to all parameters.
1722 Otherwise you may specify a mechanism on a parameter by parameter
1723 basis using either positional or named notation.  If the mechanism is not
1724 specified, the default mechanism is used.
1725
1726 Note that it is important to use this pragma in conjunction with a separate
1727 pragma Import that specifies the desired convention, since otherwise the
1728 default convention is Ada, which is almost certainly not what is required.
1729
1730 @findex Initialize_Scalars
1731 @cindex debugging with Initialize_Scalars
1732 @item pragma Initialize_Scalars
1733 @noindent
1734 Syntax:
1735
1736 @smallexample
1737 pragma Initialize_Scalars;
1738 @end smallexample
1739
1740 @noindent
1741 This pragma is similar to @code{Normalize_Scalars} conceptually but has 
1742 two important differences.  First, there is no requirement for the pragma
1743 to be used uniformly in all units of a partition, in particular, it is fine
1744 to use this just for some or all of the application units of a partition,
1745 without needing to recompile the run-time library.
1746
1747 In the case where some units are compiled with the pragma, and some without,
1748 then a declaration of a variable where the type is defined in package
1749 Standard or is locally declared will always be subject to initialization,
1750 as will any declaration of a scalar variable.  For composite variables,
1751 whether the variable is initialized may also depend on whether the package
1752 in which the type of the variable is declared is compiled with the pragma.
1753
1754 The other important difference is that there is control over the value used
1755 for initializing scalar objects.  At bind time, you can select whether to
1756 initialize with invalid values (like Normalize_Scalars), or with high or
1757 low values, or with a specified bit pattern.  See the users guide for binder
1758 options for specifying these cases.
1759
1760 This means that you can compile a program, and then without having to
1761 recompile the program, you can run it with different values being used
1762 for initializing otherwise uninitialized values, to test if your program
1763 behavior depends on the choice.  Of course the behavior should not change,
1764 and if it does, then most likely you have an erroneous reference to an
1765 uninitialized value.
1766
1767 Note that pragma @code{Initialize_Scalars} is particularly useful in
1768 conjunction with the enhanced validity checking that is now provided
1769 in GNAT, which checks for invalid values under more conditions.
1770 Using this feature (see description of the @code{-gnatv} flag in the
1771 users guide) in conjunction with pragma @code{Initialize_Scalars}
1772 provides a powerful new tool to assist in the detection of problems
1773 caused by uninitialized variables.
1774
1775 @findex Inline_Always
1776 @item pragma Inline_Always
1777 @noindent
1778 Syntax:
1779
1780 @smallexample
1781 pragma Inline_Always (NAME [, NAME]);
1782 @end smallexample
1783
1784 @noindent
1785 Similar to pragma @code{Inline} except that inlining is not subject to
1786 the use of option @code{-gnatn} for inter-unit inlining.
1787
1788 @findex Inline_Generic
1789 @item pragma Inline_Generic
1790 @noindent
1791 Syntax:
1792
1793 @smallexample
1794 pragma Inline_Generic (generic_package_NAME)
1795 @end smallexample
1796
1797 @noindent
1798 This is implemented for compatibility with DEC Ada 83 and is recognized,
1799 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
1800 by default when using GNAT@.
1801
1802 @findex Interface
1803 @item pragma Interface
1804 @noindent
1805 Syntax:
1806
1807 @smallexample
1808 pragma Interface (
1809      [Convention    =>] convention_identifier,
1810      [Entity =>] local_name
1811   [, [External_Name =>] static_string_expression],
1812   [, [Link_Name     =>] static_string_expression]);
1813 @end smallexample
1814
1815 @noindent
1816 This pragma is identical in syntax and semantics to
1817 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
1818 with Ada 83.  The definition is upwards compatible both with pragma
1819 @code{Interface} as defined in the Ada 83 Reference Manual, and also
1820 with some extended implementations of this pragma in certain Ada 83
1821 implementations.
1822
1823 @findex Interface_Name
1824 @item pragma Interface_Name
1825 @noindent
1826 Syntax:
1827
1828 @smallexample
1829 pragma Interface_Name ( 
1830      [Entity        =>] LOCAL_NAME
1831   [, [External_Name =>] static_string_EXPRESSION]
1832   [, [Link_Name     =>] static_string_EXPRESSION]);
1833 @end smallexample
1834
1835 @noindent
1836 This pragma provides an alternative way of specifying the interface name
1837 for an interfaced subprogram, and is provided for compatibility with Ada
1838 83 compilers that use the pragma for this purpose.  You must provide at
1839 least one of @var{External_Name} or @var{Link_Name}.
1840
1841 @findex License
1842 @item pragma License
1843 @cindex License checking
1844 @noindent
1845 Syntax:
1846
1847 @smallexample
1848 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
1849 @end smallexample
1850
1851 @noindent
1852 This pragma is provided to allow automated checking for appropriate license
1853 conditions with respect to the standard and modified GPL@.  A pragma @code{License},
1854 which is a configuration pragma that typically appears at the start of a
1855 source file or in a separate @file{gnat.adc} file, specifies the licensing
1856 conditions of a unit as follows:
1857
1858 @itemize @bullet
1859 @item Unrestricted
1860 This is used for a unit that can be freely used with no license restrictions.
1861 Examples of such units are public domain units, and units from the Ada
1862 Reference Manual.
1863
1864 @item GPL
1865 This is used for a unit that is licensed under the unmodified GPL, and which
1866 therefore cannot be @code{with}'ed by a restricted unit.
1867
1868 @item Modified_GPL
1869 This is used for a unit licensed under the GNAT modified GPL that includes
1870 a special exception paragraph that specifically permits the inclusion of
1871 the unit in programs without requiring the entire program to be released
1872 under the GPL@.  This is the license used for the GNAT run-time which ensures
1873 that the run-time can be used freely in any program without GPL concerns.
1874
1875 @item Restricted
1876 This is used for a unit that is restricted in that it is not permitted to
1877 depend on units that are licensed under the GPL@.  Typical examples are
1878 proprietary code that is to be released under more restrictive license
1879 conditions.  Note that restricted units are permitted to @code{with} units
1880 which are licensed under the modified GPL (this is the whole point of the
1881 modified GPL).
1882
1883 @end itemize
1884
1885 @noindent
1886 Normally a unit with no @code{License} pragma is considered to have an
1887 unknown license, and no checking is done.  However, standard GNAT headers
1888 are recognized, and license information is derived from them as follows.
1889
1890 @itemize @bullet
1891
1892 A GNAT license header starts with a line containing 78 hyphens.  The following
1893 comment text is searched for the appearence of any of the following strings.
1894
1895 If the string ``GNU General Public License'' is found, then the unit is assumed
1896 to have GPL license, unless the string ``As a special exception'' follows, in
1897 which case the license is assumed to be modified GPL@.
1898
1899 If one of the strings
1900 ``This specification is adapated from the Ada Semantic Interface'' or
1901 ``This specification is derived from the Ada Reference Manual'' is found
1902 then the unit is assumed to be unrestricted.
1903 @end itemize
1904
1905 @noindent
1906 These default actions means that a program with a restricted license pragma
1907 will automatically get warnings if a GPL unit is inappropriately
1908 @code{with}'ed.  For example, the program:
1909
1910 @smallexample
1911 with Sem_Ch3;
1912 with GNAT.Sockets;
1913 procedure Secret_Stuff is
1914 @dots{}
1915 end Secret_Stuff
1916 @end smallexample
1917
1918 @noindent
1919 if compiled with pragma @code{License} (@code{Restricted}) in a
1920 @file{gnat.adc} file will generate the warning:
1921
1922 @smallexample
1923 1.  with Sem_Ch3;
1924         |
1925    >>> license of withed unit "Sem_Ch3" is incompatible
1926
1927 2.  with GNAT.Sockets;
1928 3.  procedure Secret_Stuff is
1929 @end smallexample
1930 @noindent
1931 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
1932 compiler and is licensed under the
1933 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT 
1934 run time, and is therefore licensed under the modified GPL@.
1935
1936 @findex Link_With
1937 @item pragma Link_With
1938 @noindent
1939 Syntax:
1940
1941 @smallexample
1942 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
1943 @end smallexample
1944
1945 @noindent
1946 This pragma is provided for compatibility with certain Ada 83 compilers.
1947 It has exactly the same effect as pragma @code{Linker_Options} except
1948 that spaces occurring within one of the string expressions are treated
1949 as separators. For example, in the following case:
1950
1951 @smallexample
1952 pragma Link_With ("-labc -ldef");
1953 @end smallexample
1954
1955 @noindent
1956 results in passing the strings @code{-labc} and @code{-ldef} as two
1957 separate arguments to the linker. In addition pragma Link_With allows
1958 multiple arguments, with the same effect as successive pragmas.
1959
1960 @findex Linker_Alias
1961 @item pragma Linker_Alias
1962 @noindent
1963 Syntax:
1964
1965 @smallexample
1966 pragma Linker_Alias (
1967   [Entity =>] LOCAL_NAME
1968   [Alias  =>] static_string_EXPRESSION);
1969 @end smallexample
1970
1971 @noindent
1972 This pragma establishes a linker alias for the given named entity.  For
1973 further details on the exact effect, consult the GCC manual.
1974
1975 @findex Linker_Section
1976 @item pragma Linker_Section
1977 @noindent
1978 Syntax:
1979
1980 @smallexample
1981 pragma Linker_Section (
1982   [Entity  =>] LOCAL_NAME
1983   [Section =>] static_string_EXPRESSION);
1984 @end smallexample
1985
1986 @noindent
1987 This pragma specifies the name of the linker section for the given entity.
1988 For further details on the exact effect, consult the GCC manual.
1989
1990 @findex No_Run_Time
1991 @item pragma No_Run_Time
1992 @noindent
1993 Syntax:
1994
1995 @smallexample
1996 pragma No_Run_Time;
1997 @end smallexample
1998
1999 @noindent
2000 This is a configuration pragma that makes sure the user code does not
2001 use nor need anything from the GNAT run time.  This is mostly useful in
2002 context where code certification is required.  Please consult the 
2003 @cite{GNAT Pro High-Integrity Edition User's Guide} for additional information.
2004
2005 @findex Normalize_Scalars
2006 @item pragma Normalize_Scalars
2007 @noindent
2008 Syntax:
2009
2010 @smallexample
2011 pragma Normalize_Scalars;
2012 @end smallexample
2013
2014 @noindent
2015 This is a language defined pragma which is fully implemented in GNAT@.  The
2016 effect is to cause all scalar objects that are not otherwise initialized
2017 to be initialized.  The initial values are implementation dependent and
2018 are as follows:
2019
2020 @table @code
2021 @item Standard.Character
2022 @noindent
2023 Objects whose root type is Standard.Character are initialized to
2024 Character'Last.  This will be out of range of the subtype only if
2025 the subtype range excludes this value.
2026
2027 @item Standard.Wide_Character
2028 @noindent
2029 Objects whose root type is Standard.Wide_Character are initialized to
2030 Wide_Character'Last.  This will be out of range of the subtype only if
2031 the subtype range excludes this value.
2032
2033 @item Integer types
2034 @noindent
2035 Objects of an integer type are initialized to base_type'First, where
2036 base_type is the base type of the object type.  This will be out of range
2037 of the subtype only if the subtype range excludes this value.  For example,
2038 if you declare the subtype:
2039
2040 @smallexample
2041 subtype Ityp is integer range 1 .. 10;
2042 @end smallexample
2043
2044 @noindent
2045 then objects of type x will be initialized to Integer'First, a negative
2046 number that is certainly outside the range of subtype @code{Ityp}.
2047
2048 @item Real types
2049 Objects of all real types (fixed and floating) are initialized to
2050 base_type'First, where base_Type is the base type of the object type.
2051 This will be out of range of the subtype only if the subtype range
2052 excludes this value.
2053
2054 @item Modular types
2055 Objects of a modular type are initialized to typ'Last.  This will be out
2056 of range of the subtype only if the subtype excludes this value.
2057
2058 @item Enumeration types
2059 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2060 the value @code{2 ** typ'Size - 1}.  This will be out of range of the enumeration
2061 subtype in all cases except where the subtype contains exactly
2062 2**8, 2**16, or 2**32 elements.
2063
2064 @end table
2065
2066 @cindex OpenVMS
2067 @findex Long_Float
2068 @item pragma Long_Float
2069 @noindent
2070 Syntax:
2071
2072 @smallexample
2073 pragma Long_Float (FLOAT_FORMAT);
2074
2075 FLOAT_FORMAT ::= D_Float | G_Float
2076 @end smallexample
2077
2078 @noindent
2079 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2080 It allows control over the internal representation chosen for the predefined
2081 type @code{Long_Float} and for floating point type representations with
2082 @code{digits} specified in the range 7 through 15.
2083 For further details on this pragma, see the
2084 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use this
2085 pragma, the standard runtime libraries must be recompiled.  See the
2086 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2087 of the GNAT User's Guide for details on the use of this command.
2088
2089 @findex Machine_Attribute
2090 @item pragma Machine_Attribute @dots{}
2091 @noindent
2092 Syntax:
2093
2094 @smallexample
2095 pragma Machine_Attribute (
2096   [Attribute_Name =>] string_EXPRESSION,
2097   [Entity         =>] LOCAL_NAME);
2098 @end smallexample
2099
2100 Machine dependent attributes can be specified for types and/or
2101 declarations.  Currently only subprogram entities are supported.  This
2102 pragma is semantically equivalent to 
2103 @code{__attribute__((@var{string_expression}))} in GNU C, 
2104 where @code{@var{string_expression}} is
2105 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2106 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2107 configuration header file @file{tm.h} for each machine.  See the GCC
2108 manual for further information.
2109
2110 @cindex OpenVMS
2111 @findex Main_Storage
2112 @item pragma Main_Storage
2113 @noindent
2114 Syntax:
2115
2116 @smallexample
2117 pragma Main_Storage
2118   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2119
2120 MAIN_STORAGE_OPTION ::=
2121   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2122 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2123
2124 @end smallexample
2125
2126 @noindent
2127 This pragma is provided for compatibility with OpenVMS Vax Systems.  It has
2128 no effect in GNAT, other than being syntax checked.  Note that the pragma
2129 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2130
2131 @findex No_Return
2132 @item pragma No_Return
2133 @noindent
2134 Syntax:
2135
2136 @smallexample
2137 pragma No_Return (procedure_LOCAL_NAME);
2138 @end smallexample
2139
2140 @noindent
2141 @var{procedure_local_NAME} must refer to one or more procedure
2142 declarations in the current declarative part.  A procedure to which this
2143 pragma is applied may not contain any explicit @code{return} statements,
2144 and also may not contain any implicit return statements from falling off
2145 the end of a statement sequence.  One use of this pragma is to identify
2146 procedures whose only purpose is to raise an exception.
2147
2148 Another use of this pragma is to suppress incorrect warnings about
2149 missing returns in functions, where the last statement of a function
2150 statement sequence is a call to such a procedure.
2151
2152 @findex Passive
2153 @item pragma Passive
2154 @noindent
2155 Syntax:
2156
2157 @smallexample
2158 pragma Passive ([Semaphore | No]);
2159 @end smallexample
2160
2161 @noindent
2162 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2163 compatibility with DEC Ada 83 implementations, where it is used within a
2164 task definition to request that a task be made passive.  If the argument
2165 @code{Semaphore} is present, or no argument is omitted, then DEC Ada 83
2166 treats the pragma as an assertion that the containing task is passive
2167 and that optimization of context switch with this task is permitted and
2168 desired.  If the argument @code{No} is present, the task must not be
2169 optimized.  GNAT does not attempt to optimize any tasks in this manner
2170 (since protected objects are available in place of passive tasks).
2171
2172 @findex Polling 
2173 @item pragma Polling
2174 @noindent
2175 Syntax:
2176
2177 @smallexample
2178 pragma Polling (ON | OFF);
2179 @end smallexample
2180
2181 @noindent
2182 This pragma controls the generation of polling code.  This is normally off.
2183 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2184 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2185 runtime library, and can be found in file @file{a-excpol.adb}.
2186
2187 Pragma @code{Polling} can appear as a configuration pragma (for example it can be
2188 placed in the @file{gnat.adc} file) to enable polling globally, or it can be used
2189 in the statement or declaration sequence to control polling more locally.
2190
2191 A call to the polling routine is generated at the start of every loop and
2192 at the start of every subprogram call.  This guarantees that the @code{Poll}
2193 routine is called frequently, and places an upper bound (determined by
2194 the complexity of the code) on the period between two @code{Poll} calls.
2195
2196 The primary purpose of the polling interface is to enable asynchronous 
2197 aborts on targets that cannot otherwise support it (for example Windows
2198 NT), but it may be used for any other purpose requiring periodic polling.
2199 The standard version is null, and can be replaced by a user program.  This
2200 will require re-compilation of the @code{Ada.Exceptions} package that can be found
2201 in files @file{a-except.ads} and @file{a-except.adb}.
2202
2203 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2204 distribution) is used to enable the asynchronous abort capability on
2205 targets that do not normally support the capability.  The version of @code{Poll}
2206 in this file makes a call to the appropriate runtime routine to test for
2207 an abort condition.
2208
2209 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2210 the @cite{GNAT User's Guide} for details.
2211
2212 @findex Propagate_Exceptions
2213 @cindex Zero Cost Exceptions
2214 @item pragma Propagate_Exceptions
2215 @noindent
2216 Syntax:
2217
2218 @smallexample
2219 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2220 @end smallexample
2221
2222 @noindent
2223 This pragma indicates that the given entity, which is the name of an
2224 imported foreign-language subprogram may receive an Ada exception, 
2225 and that the exception should be propagated.  It is relevant only if
2226 zero cost exception handling is in use, and is thus never needed if
2227 the alternative @code{longjmp} / @code{setjmp} implementation of exceptions is used
2228 (although it is harmless to use it in such cases).
2229
2230 The implementation of fast exceptions always properly propagates
2231 exceptions through Ada code, as described in the Ada Reference Manual.
2232 However, this manual is silent about the propagation of exceptions
2233 through foreign code.  For example, consider the
2234 situation where @code{P1} calls
2235 @code{P2}, and @code{P2} calls @code{P3}, where
2236 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2237 @code{P3} raises an Ada exception.  The question is whether or not
2238 it will be propagated through @code{P2} and can be handled in 
2239 @code{P1}.
2240
2241 For the @code{longjmp} / @code{setjmp} implementation of exceptions, the answer is
2242 always yes.  For some targets on which zero cost exception handling
2243 is implemented, the answer is also always yes.  However, there are
2244 some targets, notably in the current version all x86 architecture
2245 targets, in which the answer is that such propagation does not
2246 happen automatically.  If such propagation is required on these
2247 targets, it is mandatory to use @code{Propagate_Exceptions} to 
2248 name all foreign language routines through which Ada exceptions
2249 may be propagated.
2250
2251 @findex Psect_Object
2252 @item pragma Psect_Object
2253 @noindent
2254 Syntax:
2255
2256 @smallexample
2257 pragma Psect_Object
2258      [Internal =>] LOCAL_NAME,
2259   [, [External =>] EXTERNAL_SYMBOL]
2260   [, [Size     =>] EXTERNAL_SYMBOL]
2261
2262 EXTERNAL_SYMBOL ::=
2263   IDENTIFIER
2264 | static_string_EXPRESSION
2265 @end smallexample
2266
2267 @noindent
2268 This pragma is identical in effect to pragma @code{Common_Object}.
2269
2270 @findex Pure_Function
2271 @item pragma Pure_Function
2272 @noindent
2273 Syntax:
2274
2275 @smallexample
2276 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2277 @end smallexample
2278
2279 This pragma appears in the same declarative part as a function
2280 declaration (or a set of function declarations if more than one
2281 overloaded declaration exists, in which case the pragma applies
2282 to all entities).  If specifies that the function @code{Entity} is
2283 to be considered pure for the purposes of code generation.  This means
2284 that the compiler can assume that there are no side effects, and
2285 in particular that two calls with identical arguments produce the
2286 same result.  It also means that the function can be used in an
2287 address clause.
2288
2289 Note that, quite deliberately, there are no static checks to try
2290 to ensure that this promise is met, so @code{Pure_Function} can be used
2291 with functions that are conceptually pure, even if they do modify
2292 global variables.  For example, a square root function that is
2293 instrumented to count the number of times it is called is still
2294 conceptually pure, and can still be optimized, even though it
2295 modifies a global variable (the count).  Memo functions are another
2296 example (where a table of previous calls is kept and consulted to
2297 avoid re-computation).
2298
2299 @findex Pure
2300 Note: Most functions in a @code{Pure} package are automatically pure, and
2301 there is no need to use pragma @code{Pure_Function} for such functions.  An
2302 exception is any function that has at least one formal of type
2303 @code{System.Address} or a type derived from it.  Such functions are not
2304 considered pure by default, since the compiler assumes that the
2305 @code{Address} parameter may be functioning as a pointer and that the
2306 referenced data may change even if the address value does not.  The use
2307 of pragma @code{Pure_Function} for such a function will override this default
2308 assumption, and cause the compiler to treat such a function as pure.
2309
2310 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2311 applies to the underlying renamed function.  This can be used to
2312 disambiguate cases of overloading where some but not all functions
2313 in a set of overloaded functions are to be designated as pure.
2314
2315 @findex Ravenscar
2316 @item pragma Ravenscar
2317 @noindent
2318 Syntax:
2319
2320 @smallexample
2321 pragma Ravenscar
2322 @end smallexample
2323
2324 @noindent
2325 A configuration pragma that establishes the following set of restrictions:
2326
2327 @table @code
2328 @item No_Abort_Statements
2329 [RM D.7] There are no abort_statements, and there are 
2330 no calls to Task_Identification.Abort_Task.
2331
2332 @item No_Select_Statements
2333 There are no select_statements.
2334
2335 @item No_Task_Hierarchy
2336 [RM D.7] All (non-environment) tasks depend 
2337 directly on the environment task of the partition.  
2338
2339 @item No_Task_Allocators
2340 [RM D.7] There are no allocators for task types
2341 or types containing task subcomponents.
2342
2343 @item No_Dynamic_Priorities
2344 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2345
2346 @item No_Terminate_Alternatives
2347 [RM D.7] There are no selective_accepts with terminate_alternatives
2348
2349 @item No_Dynamic_Interrupts
2350 There are no semantic dependencies on Ada.Interrupts.
2351
2352 @item No_Protected_Type_Allocators
2353 There are no allocators for protected types or
2354 types containing protected subcomponents.
2355
2356 @item No_Local_Protected_Objects
2357 Protected objects and access types that designate 
2358 such objects shall be declared only at library level.
2359
2360 @item No_Requeue
2361 Requeue statements are not allowed.
2362
2363 @item No_Calendar
2364 There are no semantic dependencies on the package Ada.Calendar.
2365
2366 @item No_Relative_Delay
2367 There are no delay_relative_statements.
2368
2369 @item No_Task_Attributes
2370 There are no semantic dependencies on the Ada.Task_Attributes package and
2371 there are no references to the attributes Callable and Terminated [RM 9.9].
2372
2373 @item Static_Storage_Size
2374 The expression for pragma Storage_Size is static.
2375
2376 @item Boolean_Entry_Barriers
2377 Entry barrier condition expressions shall be boolean 
2378 objects which are declared in the protected type 
2379 which contains the entry.
2380
2381 @item Max_Asynchronous_Select_Nesting = 0
2382 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2383 A value of zero prevents the use of any asynchronous_select.
2384
2385 @item Max_Task_Entries = 0
2386 [RM D.7] Specifies the maximum number of entries
2387 per task.  The bounds of every entry family
2388 of a task unit shall be static, or shall be
2389 defined by a discriminant of a subtype whose
2390 corresponding bound is static.  A value of zero
2391 indicates that no rendezvous are possible.  For
2392 the Ravenscar pragma, the value of Max_Task_Entries is always
2393 0 (zero).
2394
2395 @item Max_Protected_Entries = 1
2396 [RM D.7] Specifies the maximum number of entries per 
2397 protected type.  The bounds of every entry family of 
2398 a protected unit shall be static, or shall be defined 
2399 by a discriminant of a subtype whose corresponding 
2400 bound is static.  For the Ravenscar pragma the value of 
2401 Max_Protected_Entries is always 1.
2402
2403 @item Max_Select_Alternatives = 0
2404 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
2405 For the Ravenscar pragma the value if always 0.
2406
2407 @item No_Task_Termination
2408 Tasks which terminate are erroneous.
2409
2410 @item No_Entry_Queue
2411 No task can be queued on a protected entry.  Note that this restrictions is
2412 checked at run time.  The violation of this restriction generates a
2413 Program_Error exception.
2414 @end table
2415
2416 @noindent
2417 This set of restrictions corresponds to the definition of the ``Ravenscar
2418 Profile'' for limited tasking, devised and published by the @cite{International
2419 Real-Time Ada Workshop}, 1997. 
2420
2421 The above set is a superset of the restrictions provided by pragma
2422 @code{Restricted_Run_Time}, it includes six additional restrictions
2423 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
2424 @code{No_Calendar}, @code{Static_Storage_Size},
2425 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2426 that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time}, automatically
2427 causes the use of a simplified, more efficient version of the tasking
2428 run-time system.
2429
2430 @findex Restricted_Run_Time
2431 @item pragma Restricted_Run_Time
2432 @noindent
2433 Syntax:
2434
2435 @smallexample
2436 pragma Restricted_Run_Time
2437 @end smallexample
2438
2439 @noindent
2440 A configuration pragma that establishes the following set of restrictions:
2441
2442 @itemize @bullet
2443 @item No_Abort_Statements
2444 @item No_Asynchronous_Control
2445 @item No_Entry_Queue
2446 @item No_Task_Hierarchy
2447 @item No_Task_Allocators
2448 @item No_Dynamic_Priorities
2449 @item No_Terminate_Alternatives
2450 @item No_Dynamic_Interrupts
2451 @item No_Protected_Type_Allocators
2452 @item No_Local_Protected_Objects
2453 @item No_Requeue
2454 @item No_Task_Attributes
2455 @item Max_Asynchronous_Select_Nesting =  0
2456 @item Max_Task_Entries =  0
2457 @item Max_Protected_Entries = 1
2458 @item Max_Select_Alternatives = 0
2459 @end itemize
2460
2461 @noindent
2462 This set of restrictions causes the automatic selection of a simplified
2463 version of the run time that provides improved performance for the
2464 limited set of tasking functionality permitted by this set of restrictions.
2465
2466 @findex Share_Generic
2467 @item pragma Share_Generic
2468 @noindent
2469 Syntax:
2470
2471 @smallexample
2472 pragma Share_Generic (NAME @{, NAME@});
2473 @end smallexample
2474
2475 @noindent
2476 This pragma is recognized for compatibility with other Ada compilers
2477 but is ignored by GNAT@.  GNAT does not provide the capability for
2478 sharing of generic code.  All generic instantiations result in making
2479 an inlined copy of the template with appropriate substitutions.
2480
2481 @findex Source_File_Name
2482 @item pragma Source_File_Name
2483 @noindent
2484 Syntax:
2485
2486 @smallexample
2487 pragma Source_File_Name (
2488   [Unit_Name   =>] unit_NAME,
2489   Spec_File_Name =>  STRING_LITERAL);
2490
2491 pragma Source_File_Name (
2492   [Unit_Name   =>] unit_NAME,
2493   Body_File_Name =>  STRING_LITERAL);
2494 @end smallexample
2495
2496 @noindent
2497 Use this to override the normal naming convention.  It is a configuration
2498 pragma, and so has the usual applicability of configuration pragmas
2499 (i.e.@: it applies to either an entire partition, or to all units in a
2500 compilation, or to a single unit, depending on how it is used.
2501 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
2502 the second argument is required, and indicates whether this is the file
2503 name for the spec or for the body.
2504
2505 Another form of the @code{Source_File_Name} pragma allows
2506 the specification of patterns defining alternative file naming schemes
2507 to apply to all files. 
2508
2509 @smallexample
2510 pragma Source_File_Name
2511   (Spec_File_Name => STRING_LITERAL
2512    [,Casing => CASING_SPEC]
2513    [,Dot_Replacement => STRING_LITERAL]);
2514
2515 pragma Source_File_Name
2516   (Body_File_Name => STRING_LITERAL
2517    [,Casing => CASING_SPEC]
2518    [,Dot_Replacement => STRING_LITERAL]);
2519
2520 pragma Source_File_Name
2521   (Subunit_File_Name => STRING_LITERAL
2522    [,Casing => CASING_SPEC]
2523    [,Dot_Replacement => STRING_LITERAL]);
2524
2525 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
2526 @end smallexample
2527
2528 @noindent
2529 The first argument is a pattern that contains a single asterisk indicating
2530 the point at which the unit name is to be inserted in the pattern string
2531 to form the file name.  The second argument is optional.  If present it
2532 specifies the casing of the unit name in the resulting file name string.
2533 The default is lower case.  Finally the third argument allows for systematic
2534 replacement of any dots in the unit name by the specified string literal.
2535
2536 For more details on the use of the @code{Source_File_Name} pragma,
2537 see the sections ``Using Other File Names'' and 
2538 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
2539
2540 @findex Source_Reference
2541 @item pragma Source_Reference
2542 @noindent
2543 Syntax:
2544
2545 @smallexample
2546 pragma Source_Reference (INTEGER_LITERAL,
2547                          STRING_LITERAL);
2548 @end smallexample
2549
2550 @noindent
2551 This pragma must appear as the first line of a source file.
2552 @var{integer_literal} is the logical line number of the line following
2553 the pragma line (for use in error messages and debugging
2554 information).  @var{string_literal} is a static string constant that
2555 specifies the file name to be used in error messages and debugging
2556 information.  This is most notably used for the output of @code{gnatchop}
2557 with the @code{-r} switch, to make sure that the original unchopped
2558 source file is the one referred to.
2559
2560 The second argument must be a string literal, it cannot be a static
2561 string expression other than a string literal.  This is because its value
2562 is needed for error messages issued by all phases of the compiler.
2563
2564 @findex Stream_Convert
2565 @item pragma Stream_Convert
2566 @noindent
2567 Syntax:
2568
2569 @smallexample
2570 pragma Stream_Convert (
2571   [Entity =>] type_LOCAL_NAME,
2572   [Read   =>] function_NAME,
2573   [Write  =>] function NAME);
2574 @end smallexample
2575
2576 @noindent
2577 This pragma provides an efficient way of providing stream functions for
2578 types defined in packages.  Not only is it simpler to use than declaring
2579 the necessary functions with attribute representation clauses, but more
2580 significantly, it allows the declaration to made in such a way that the
2581 stream packages are not loaded unless they are needed.  The use of
2582 the Stream_Convert pragma adds no overhead at all, unless the stream
2583 attributes are actually used on the designated type.
2584
2585 The first argument specifies the type for which stream functions are
2586 provided.  The second parameter provides a function used to read values
2587 of this type.  It must name a function whose argument type may be any
2588 subtype, and whose returned type must be the type given as the first
2589 argument to the pragma.
2590
2591 The meaning of the @var{Read}
2592 parameter is that if a stream attribute directly
2593 or indirectly specifies reading of the type given as the first parameter,
2594 then a value of the type given as the argument to the Read function is
2595 read from the stream, and then the Read function is used to convert this
2596 to the required target type.
2597
2598 Similarly the @var{Write} parameter specifies how to treat write attributes
2599 that directly or indirectly apply to the type given as the first parameter.
2600 It must have an input parameter of the type specified by the first parameter,
2601 and the return type must be the same as the input type of the Read function.
2602 The effect is to first call the Write function to convert to the given stream
2603 type, and then write the result type to the stream.
2604
2605 The Read and Write functions must not be overloaded subprograms.  If necessary
2606 renamings can be supplied to meet this requirement.
2607 The usage of this attribute is best illustrated by a simple example, taken
2608 from the GNAT implementation of package Ada.Strings.Unbounded:
2609
2610 @smallexample
2611 function To_Unbounded (S : String)
2612            return Unbounded_String
2613   renames To_Unbounded_String;
2614
2615 pragma Stream_Convert
2616   (Unbounded_String, To_Unbounded, To_String);
2617 @end smallexample
2618
2619 @noindent
2620 The specifications of the referenced functions, as given in the Ada 95
2621 Reference Manual are:
2622
2623 @smallexample
2624 function To_Unbounded_String (Source : String)
2625   return Unbounded_String;
2626
2627 function To_String (Source : Unbounded_String)
2628   return String;
2629 @end smallexample
2630
2631 @noindent
2632 The effect is that if the value of an unbounded string is written to a
2633 stream, then the representation of the item in the stream is in the same
2634 format used for @code{Standard.String}, and this same representation is
2635 expected when a value of this type is read from the stream.
2636
2637 @findex Style_Checks
2638 @item pragma Style_Checks
2639 @noindent
2640 Syntax:
2641
2642 @smallexample
2643 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
2644                      On | Off [, LOCAL_NAME]);
2645 @end smallexample
2646
2647 @noindent
2648 This pragma is used in conjunction with compiler switches to control the
2649 built in style checking provided by GNAT@.  The compiler switches, if set
2650 provide an initial setting for the switches, and this pragma may be used
2651 to modify these settings, or the settings may be provided entirely by
2652 the use of the pragma.  This pragma can be used anywhere that a pragma
2653 is legal, including use as a configuration pragma (including use in
2654 the @file{gnat.adc} file).
2655
2656 The form with a string literal specifies which style options are to be
2657 activated.  These are additive, so they apply in addition to any previously
2658 set style check options.  The codes for the options are the same as those
2659 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
2660 For example the following two methods can be used to enable
2661 layout checking:
2662
2663 @smallexample
2664 pragma Style_Checks ("l");
2665 gcc -c -gnatyl @dots{}
2666 @end smallexample
2667
2668 @noindent
2669 The form ALL_CHECKS activates all standard checks (its use is equivalent
2670 to the use of the @code{gnaty} switch with no options.  See GNAT User's
2671 Guide for details.
2672
2673 The forms with @code{Off} and @code{On}
2674 can be used to temporarily disable style checks
2675 as shown in the following example:
2676
2677 @smallexample
2678 @iftex
2679 @leftskip=0cm
2680 @end iftex
2681 pragma Style_Checks ("k"); -- requires keywords in lower case
2682 pragma Style_Checks (Off); -- turn off style checks
2683 NULL;                      -- this will not generate an error message
2684 pragma Style_Checks (On);  -- turn style checks back on
2685 NULL;                      -- this will generate an error message
2686 @end smallexample
2687
2688 @noindent
2689 Finally the two argument form is allowed only if the first argument is
2690 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
2691 for the specified entity, as shown in the following example:
2692
2693 @smallexample
2694 @iftex
2695 @leftskip=0cm
2696 @end iftex
2697 pragma Style_Checks ("r"); -- require consistency of identifier casing
2698 Arg : Integer;
2699 Rf1 : Integer := ARG;      -- incorrect, wrong case
2700 pragma Style_Checks (Off, Arg);
2701 Rf2 : Integer := ARG;      -- OK, no error
2702 @end smallexample
2703
2704 @findex Subtitle
2705 @item pragma Subtitle
2706 @noindent
2707 Syntax:
2708
2709 @smallexample
2710 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
2711 @end smallexample
2712
2713 @noindent
2714 This pragma is recognized for compatibility with other Ada compilers
2715 but is ignored by GNAT@.
2716
2717 @findex Suppress_All
2718 @item pragma Suppress_All
2719 @noindent
2720 Syntax:
2721
2722 @smallexample
2723 pragma Suppress_All;
2724 @end smallexample
2725
2726 @noindent
2727 This pragma can only appear immediately following a compilation
2728 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
2729 which it follows.  This pragma is implemented for compatibility with DEC
2730 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
2731 configuration pragma is the preferred usage in GNAT@.
2732
2733 @findex Suppress_Initialization
2734 @cindex Suppressing initialization
2735 @cindex Initialization, suppression of
2736 @item pragma Suppress_Initialization
2737 @noindent
2738 Syntax:
2739
2740 @smallexample
2741 pragma Suppress_Initialization ([Entity =>] type_Name);
2742 @end smallexample
2743
2744 @noindent
2745 This pragma suppresses any implicit or explicit initialization
2746 associated with the given type name for all variables of this type.
2747
2748 @findex Task_Info
2749 @item pragma Task_Info
2750 @noindent
2751 Syntax
2752
2753 @smallexample
2754 pragma Task_Info (EXPRESSION);
2755 @end smallexample
2756
2757 @noindent
2758 This pragma appears within a task definition (like pragma
2759 @code{Priority}) and applies to the task in which it appears.  The
2760 argument must be of type @code{System.Task_Info.Task_Info_Type}.
2761 The @code{Task_Info} pragma provides system dependent control over
2762 aspect of tasking implementation, for example, the ability to map
2763 tasks to specific processors.  For details on the facilities available
2764 for the version of GNAT that you are using, see the documentation
2765 in the specification of package System.Task_Info in the runtime
2766 library.
2767
2768 @findex Task_Name
2769 @item pragma Task_Name
2770 @noindent
2771 Syntax
2772
2773 @smallexample
2774 pragma Task_Name (string_EXPRESSION);
2775 @end smallexample
2776
2777 @noindent
2778 This pragma appears within a task definition (like pragma
2779 @code{Priority}) and applies to the task in which it appears.  The
2780 argument must be of type String, and provides a name to be used for
2781 the task instance when the task is created.  Note that this expression
2782 is not required to be static, and in particular, it can contain
2783 references to task discriminants.  This facility can be used to
2784 provide different names for different tasks as they are created,
2785 as illustrated in the example below.
2786
2787 The task name is recorded internally in the run-time structures
2788 and is accessible to tools like the debugger.  In addition the
2789 routine @code{Ada.Task_Identification.Image} will return this
2790 string, with a unique task address appended.
2791
2792 @smallexample
2793 --  Example of the use of pragma Task_Name
2794
2795 with Ada.Task_Identification;
2796 use Ada.Task_Identification;
2797 with Text_IO; use Text_IO;
2798 procedure t3 is
2799
2800    type Astring is access String;
2801
2802    task type Task_Typ (Name : access String) is
2803       pragma Task_Name (Name.all);
2804    end Task_Typ;
2805    
2806    task body Task_Typ is
2807       Nam : constant String := Image (Current_Task);
2808    begin
2809       Put_Line ("-->" & Nam (1 .. 14) & "<--");
2810    end Task_Typ;
2811    
2812    type Ptr_Task is access Task_Typ;
2813    Task_Var : Ptr_Task;
2814
2815 begin
2816    Task_Var :=
2817      new Task_Typ (new String'("This is task 1"));
2818    Task_Var :=
2819      new Task_Typ (new String'("This is task 2"));
2820 end;
2821 @end smallexample
2822
2823 @findex Task_Storage
2824 @item pragma Task_Storage
2825 Syntax:
2826
2827 @smallexample
2828 pragma Task_Storage
2829   [Task_Type =>] LOCAL_NAME,
2830   [Top_Guard =>] static_integer_EXPRESSION);
2831 @end smallexample
2832
2833 This pragma specifies the length of the guard area for tasks.  The guard
2834 area is an additional storage area allocated to a task.  A value of zero
2835 means that either no guard area is created or a minimal guard area is
2836 created, depending on the target.  This pragma can appear anywhere a
2837 @code{Storage_Size} attribute definition clause is allowed for a task
2838 type.
2839
2840 @findex Time_Slice
2841 @item pragma Time_Slice
2842 @noindent
2843 Syntax:
2844
2845 @smallexample
2846 pragma Time_Slice (static_duration_EXPRESSION);
2847 @end smallexample
2848
2849 @noindent
2850 For implementations of GNAT on operating systems where it is possible
2851 to supply a time slice value, this pragma may be used for this purpose.
2852 It is ignored if it is used in a system that does not allow this control,
2853 or if it appears in other than the main program unit.
2854 @cindex OpenVMS
2855 Note that the effect of this pragma is identical to the effect of the
2856 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
2857
2858 @findex Title
2859 @item pragma Title
2860 @noindent
2861 Syntax:
2862
2863 @smallexample
2864 pragma Title (TITLING_OPTION [, TITLING OPTION]);
2865
2866 TITLING_OPTION ::=
2867   [Title    =>] STRING_LITERAL,
2868 | [Subtitle =>] STRING_LITERAL
2869 @end smallexample
2870
2871 @noindent
2872 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
2873 pragma used in DEC Ada 83 implementations to provide a title and/or
2874 subtitle for the program listing.  The program listing generated by GNAT
2875 does not have titles or subtitles.
2876
2877 Unlike other pragmas, the full flexibility of named notation is allowed
2878 for this pragma, i.e.@: the parameters may be given in any order if named
2879 notation is used, and named and positional notation can be mixed
2880 following the normal rules for procedure calls in Ada.
2881
2882 @cindex Unions in C
2883 @findex Unchecked_Union
2884 @item pragma Unchecked_Union
2885 @noindent
2886 Syntax:
2887
2888 @smallexample
2889 pragma Unchecked_Union (first_subtype_LOCAL_NAME)
2890 @end smallexample
2891
2892 @noindent
2893 This pragma is used to declare that the specified type should be represented
2894 in a manner
2895 equivalent to a C union type, and is intended only for use in
2896 interfacing with C code that uses union types.  In Ada terms, the named
2897 type must obey the following rules:
2898
2899 @itemize @bullet
2900 @item
2901 It is a non-tagged non-limited record type.
2902 @item
2903 It has a single discrete discriminant with a default value.
2904 @item
2905 The component list consists of a single variant part.
2906 @item
2907 Each variant has a component list with a single component.
2908 @item
2909 No nested variants are allowed.
2910 @item
2911 No component has an explicit default value.
2912 @item
2913 No component has a non-static constraint.
2914 @end itemize
2915
2916 In addition, given a type that meets the above requirements, the
2917 following restrictions apply to its use throughout the program:
2918
2919 @itemize @bullet
2920 @item
2921 The discriminant name can be mentioned only in an aggregate.
2922 @item
2923 No subtypes may be created of this type.
2924 @item
2925 The type may not be constrained by giving a discriminant value.
2926 @item
2927 The type cannot be passed as the actual for a generic formal with a
2928 discriminant.
2929 @end itemize
2930
2931 Equality and inequality operations on @code{unchecked_unions} are not
2932 available, since there is no discriminant to compare and the compiler
2933 does not even know how many bits to compare.  It is implementation
2934 dependent whether this is detected at compile time as an illegality or
2935 whether it is undetected and considered to be an erroneous construct.  In
2936 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
2937 the composite case (where two composites are compared that contain an
2938 unchecked union component), so such comparisons are simply considered
2939 erroneous.
2940
2941 The layout of the resulting type corresponds exactly to a C union, where
2942 each branch of the union corresponds to a single variant in the Ada
2943 record.  The semantics of the Ada program is not changed in any way by
2944 the pragma, i.e.@: provided the above restrictions are followed, and no
2945 erroneous incorrect references to fields or erroneous comparisons occur,
2946 the semantics is exactly as described by the Ada reference manual.
2947 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
2948 type and the default convention is C
2949
2950 @findex Unimplemented_Unit
2951 @item pragma Unimplemented_Unit
2952 @noindent
2953 Syntax:
2954
2955 @smallexample
2956 pragma Unimplemented_Unit;
2957 @end smallexample
2958
2959 @noindent
2960 If this pragma occurs in a unit that is processed by the compiler, GNAT
2961 aborts with the message @samp{@var{xxx} not implemented}, where
2962 @var{xxx} is the name of the current compilation unit.  This pragma is
2963 intended to allow the compiler to handle unimplemented library units in
2964 a clean manner.
2965
2966 The abort only happens if code is being generated.  Thus you can use
2967 specs of unimplemented packages in syntax or semantic checking mode.
2968
2969 @findex Unreferenced
2970 @item pragma Unreferenced
2971 @cindex Warnings, unreferenced
2972 @noindent
2973 Syntax:
2974
2975 @smallexample
2976 pragma Unreferenced (local_Name @{, local_Name@});
2977 @end smallexample
2978
2979 @noindent
2980 This pragma signals that the entities whose names are listed are
2981 deliberately not referenced. This suppresses warnings about the
2982 entities being unreferenced, and in addition a warning will be
2983 generated if one of these entities is in fact referenced.
2984
2985 This is particularly useful for clearly signalling that a particular
2986 parameter is not referenced in some particular subprogram implementation
2987 and that this is deliberate. It can also be useful in the case of
2988 objects declared only for their initialization or finalization side
2989 effects.
2990
2991 If @code{local_Name} identifies more than one matching homonym in the
2992 current scope, then the entity most recently declared is the one to which
2993 the pragma applies.
2994
2995 @findex Unreserve_All_Interrupts
2996 @item pragma Unreserve_All_Interrupts
2997 @noindent
2998 Syntax:
2999
3000 @smallexample
3001 pragma Unreserve_All_Interrupts;
3002 @end smallexample
3003
3004 @noindent
3005 Normally certain interrupts are reserved to the implementation.  Any attempt
3006 to attach an interrupt causes Program_Error to be raised, as described in
3007 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3008 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3009 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3010 interrupt execution.
3011
3012 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3013 a program, then all such interrupts are unreserved.  This allows the
3014 program to handle these interrupts, but disables their standard
3015 functions.  For example, if this pragma is used, then pressing
3016 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3017 a program can then handle the @code{SIGINT} interrupt as it chooses.
3018
3019 For a full list of the interrupts handled in a specific implementation,
3020 see the source code for the specification of @code{Ada.Interrupts.Names} in
3021 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3022 list of interrupts recognized for a given target.  The documentation in
3023 this file also specifies what interrupts are affected by the use of
3024 the @code{Unreserve_All_Interrupts} pragma.
3025
3026 @findex Unsuppress
3027 @item pragma Unsuppress
3028 @noindent
3029 Syntax:
3030
3031 @smallexample
3032 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3033 @end smallexample
3034
3035 @noindent
3036 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3037 there is no corresponding pragma @code{Suppress} in effect, it has no
3038 effect.  The range of the effect is the same as for pragma
3039 @code{Suppress}.  The meaning of the arguments is identical to that used
3040 in pragma @code{Suppress}.
3041
3042 One important application is to ensure that checks are on in cases where
3043 code depends on the checks for its correct functioning, so that the code
3044 will compile correctly even if the compiler switches are set to suppress
3045 checks.
3046
3047 @cindex @code{Size}, VADS compatibility
3048 @findex Use_VADS_Size
3049 @item pragma Use_VADS_Size
3050 @noindent
3051 Syntax:
3052
3053 @smallexample
3054 pragma Use_VADS_Size;
3055 @end smallexample
3056
3057 @noindent
3058 This is a configuration pragma.  In a unit to which it applies, any use
3059 of the 'Size attribute is automatically interpreted as a use of the
3060 'VADS_Size attribute.  Note that this may result in incorrect semantic
3061 processing of valid Ada 95 programs.  This is intended to aid in the
3062 handling of legacy code which depends on the interpretation of Size
3063 as implemented in the VADS compiler.  See description of the VADS_Size
3064 attribute for further details.
3065
3066 @findex Validity_Checks
3067 @item pragma Validity_Checks
3068 @noindent
3069 Syntax:
3070
3071 @smallexample
3072 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3073 @end smallexample
3074
3075 @noindent
3076 This pragma is used in conjunction with compiler switches to control the
3077 built in validity checking provided by GNAT@.  The compiler switches, if set
3078 provide an initial setting for the switches, and this pragma may be used
3079 to modify these settings, or the settings may be provided entirely by
3080 the use of the pragma.  This pragma can be used anywhere that a pragma
3081 is legal, including use as a configuration pragma (including use in
3082 the @file{gnat.adc} file).
3083
3084 The form with a string literal specifies which validity options are to be
3085 activated.  The validity checks are first set to include only the default
3086 reference manual settings, and then a string of letters in the string
3087 specifies the exact set of options required.  The form of this string
3088 is exactly as described for the @code{-gnatVx} compiler switch (see the
3089 GNAT users guide for details).  For example the following two methods
3090 can be used to enable validity checking for mode @code{in} and
3091 @code{in out} subprogram parameters:
3092
3093 @smallexample
3094 pragma Validity_Checks ("im");
3095 gcc -c -gnatVim @dots{}
3096 @end smallexample
3097
3098 @noindent
3099 The form ALL_CHECKS activates all standard checks (its use is equivalent
3100 to the use of the @code{gnatva} switch.
3101
3102 The forms with @code{Off} and @code{On}
3103 can be used to temporarily disable validity checks
3104 as shown in the following example:
3105
3106 @smallexample
3107 @iftex
3108 @leftskip=0cm
3109 @end iftex
3110 pragma Validity_Checks ("c"); -- validity checks for copies
3111 pragma Validity_Checks (Off); -- turn off validity checks
3112 A := B;                       -- B will not be validity checked
3113 pragma Validity_Checks (On);  -- turn validity checks back on
3114 A := C;                       -- C will be validity checked
3115 @end smallexample
3116
3117 @findex Volatile
3118 @item pragma Volatile
3119 @noindent
3120 Syntax:
3121
3122 @smallexample
3123 pragma Volatile (local_NAME)
3124 @end smallexample
3125
3126 @noindent
3127 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3128 implementation is fully conformant with this definition.  The reason it
3129 is mentioned in this section is that a pragma of the same name was supplied
3130 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3131 of pragma Volatile is upwards compatible with the implementation in
3132 Dec Ada 83.
3133
3134 @findex Warnings
3135 @item pragma Warnings
3136 @noindent
3137 Syntax:
3138
3139 @smallexample
3140 pragma Warnings (On | Off [, LOCAL_NAME]);
3141 @end smallexample
3142
3143 @noindent
3144 Normally warnings are enabled, with the output being controlled by
3145 the command line switch.  Warnings (@code{Off}) turns off generation of
3146 warnings until a Warnings (@code{On}) is encountered or the end of the
3147 current unit.  If generation of warnings is turned off using this
3148 pragma, then no warning messages are output, regardless of the
3149 setting of the command line switches.
3150
3151 The form with a single argument is a configuration pragma.
3152
3153 If the @var{local_name} parameter is present, warnings are suppressed for
3154 the specified entity.  This suppression is effective from the point where
3155 it occurs till the end of the extended scope of the variable (similar to
3156 the scope of @code{Suppress}).
3157
3158 @findex Weak_External
3159 @item pragma Weak_External
3160 @noindent
3161 Syntax:
3162
3163 @smallexample
3164 pragma Weak_External ([Entity =>] LOCAL_NAME);
3165 @end smallexample
3166
3167 @noindent
3168 This pragma specifies that the given entity should be marked as a weak
3169 external (one that does not have to be resolved) for the linker.  For
3170 further details, consult the GCC manual.
3171 @end table
3172
3173 @node Implementation Defined Attributes
3174 @chapter Implementation Defined Attributes
3175 Ada 95 defines (throughout the Ada 95 reference manual,
3176 summarized in annex K),
3177 a set of attributes that provide useful additional functionality in all
3178 areas of the language.  These language defined attributes are implemented
3179 in GNAT and work as described in the Ada 95 Reference Manual.
3180
3181 In addition, Ada 95 allows implementations to define additional
3182 attributes whose meaning is defined by the implementation.  GNAT provides
3183 a number of these implementation-dependent attributes which can be used
3184 to extend and enhance the functionality of the compiler.  This section of
3185 the GNAT reference manual describes these additional attributes.
3186
3187 Note that any program using these attributes may not be portable to
3188 other compilers (although GNAT implements this set of attributes on all
3189 platforms).  Therefore if portability to other compilers is an important
3190 consideration, you should minimize the use of these attributes.
3191
3192 @table @code
3193 @findex Abort_Signal
3194 @item Abort_Signal
3195 @noindent
3196 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
3197 prefix) provides the entity for the special exception used to signal
3198 task abort or asynchronous transfer of control.  Normally this attribute
3199 should only be used in the tasking runtime (it is highly peculiar, and
3200 completely outside the normal semantics of Ada, for a user program to
3201 intercept the abort exception).
3202
3203 @cindex Size of @code{Address}
3204 @findex Address_Size
3205 @item Address_Size
3206 @noindent
3207 @code{Standard'Address_Size} (@code{Standard} is the only allowed
3208 prefix) is a static constant giving the number of bits in an
3209 @code{Address}.  It is used primarily for constructing the definition of
3210 @code{Memory_Size} in package @code{Standard}, but may be freely used in user
3211 programs and has the advantage of being static, while a direct
3212 reference to System.Address'Size is non-static because Address
3213 is a private type.
3214
3215 @findex Asm_Input
3216 @item Asm_Input
3217 @noindent
3218 The @code{Asm_Input} attribute denotes a function that takes two
3219 parameters.  The first is a string, the second is an expression of the
3220 type designated by the prefix.  The first (string) argument is required
3221 to be a static expression, and is the constraint for the parameter,
3222 (e.g.@: what kind of register is required).  The second argument is the
3223 value to be used as the input argument.  The possible values for the
3224 constant are the same as those used in the RTL, and are dependent on
3225 the configuration file used to built the GCC back end.
3226 @ref{Machine Code Insertions}
3227
3228 @findex Asm_Output
3229 @item Asm_Output
3230 @noindent
3231 The @code{Asm_Output} attribute denotes a function that takes two
3232 parameters.  The first is a string, the second is the name of a variable
3233 of the type designated by the attribute prefix.  The first (string)
3234 argument is required to be a static expression and designates the
3235 constraint for the parameter (e.g.@: what kind of register is
3236 required).  The second argument is the variable to be updated with the
3237 result.  The possible values for constraint are the same as those used in
3238 the RTL, and are dependent on the configuration file used to build the
3239 GCC back end.  If there are no output operands, then this argument may
3240 either be omitted, or explicitly given as @code{No_Output_Operands}.
3241 @ref{Machine Code Insertions}
3242
3243 @cindex OpenVMS
3244 @findex AST_Entry
3245 @item AST_Entry
3246 @noindent
3247 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
3248 the name of an entry, it yields a value of the predefined type AST_Handler
3249 (declared in the predefined package System, as extended by the use of
3250 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
3251 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
3252 Language Reference Manual}, section 9.12a.
3253
3254 @findex Bit
3255 @item Bit
3256 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
3257 offset within the storage unit (byte) that contains the first bit of
3258 storage allocated for the object.  The value of this attribute is of the
3259 type @code{Universal_Integer}, and is always a non-negative number not
3260 exceeding the value of @code{System.Storage_Unit}.
3261
3262 For an object that is a variable or a constant allocated in a register,
3263 the value is zero.  (The use of this attribute does not force the
3264 allocation of a variable to memory).
3265
3266 For an object that is a formal parameter, this attribute applies
3267 to either the matching actual parameter or to a copy of the
3268 matching actual parameter.
3269
3270 For an access object the value is zero.  Note that
3271 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
3272 designated object.  Similarly for a record component
3273 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
3274 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
3275 are subject to index checks.
3276
3277 This attribute is designed to be compatible with the DEC Ada 83 definition
3278 and implementation of the @code{Bit} attribute.
3279
3280 @findex Bit_Position
3281 @item Bit_Position
3282 @noindent
3283 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
3284 of the fields of the record type, yields the bit
3285 offset within the record contains the first bit of
3286 storage allocated for the object.  The value of this attribute is of the
3287 type @code{Universal_Integer}.  The value depends only on the field
3288 @var{C} and is independent of the alignment of
3289 the containing record @var{R}.
3290
3291 @findex Code_Address
3292 @cindex Subprogram address
3293 @cindex Address of subprogram code
3294 @item Code_Address
3295 @noindent
3296 The @code{'Address}
3297 attribute may be applied to subprograms in Ada 95, but the
3298 intended effect from the Ada 95 reference manual seems to be to provide
3299 an address value which can be used to call the subprogram by means of
3300 an address clause as in the following example:
3301
3302 @smallexample
3303 procedure K is @dots{}
3304
3305 procedure L;
3306 for L'Address use K'Address;
3307 pragma Import (Ada, L);
3308 @end smallexample
3309
3310 @noindent
3311 A call to @code{L} is then expected to result in a call to @code{K}@.  In Ada 83, where
3312 there were no access-to-subprogram values, this was a common work around
3313 for getting the effect of an indirect call.
3314 GNAT implements the above use of @code{Address} and the technique illustrated
3315 by the example code works correctly.
3316
3317 However, for some purposes, it is useful to have the address of the start
3318 of the generated code for the subprogram.  On some architectures, this is
3319 not necessarily the same as the @code{Address} value described above.  For example,
3320 the @code{Address} value may reference a subprogram descriptor rather than the
3321 subprogram itself.
3322
3323 The @code{'Code_Address} attribute, which can only be applied to 
3324 subprogram entities, always returns the address of the start of the 
3325 generated code of the specified subprogram, which may or may not be
3326 the same value as is returned by the corresponding @code{'Address}
3327 attribute.
3328
3329 @cindex Big endian
3330 @cindex Little endian
3331 @findex Default_Bit_Order
3332 @item Default_Bit_Order
3333 @noindent
3334 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
3335 permissible prefix), provides the value @code{System.Default_Bit_Order}
3336 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
3337 @code{Low_Order_First}).  This is used to construct the definition of
3338 @code{Default_Bit_Order} in package @code{System}.
3339
3340 @findex Elaborated
3341 @item Elaborated
3342 @noindent
3343 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
3344 value is a Boolean which indicates whether or not the given unit has been
3345 elaborated.  This attribute is primarily intended for internal use by the
3346 generated code for dynamic elaboration checking, but it can also be used
3347 in user programs.  The value will always be True once elaboration of all
3348 units has been completed.
3349
3350 @findex Elab_Body
3351 @item Elab_Body
3352 @noindent
3353 This attribute can only be applied to a program unit name.  It returns
3354 the entity for the corresponding elaboration procedure for elaborating
3355 the body of the referenced unit.  This is used in the main generated
3356 elaboration procedure by the binder and is not normally used in any
3357 other context.  However, there may be specialized situations in which it
3358 is useful to be able to call this elaboration procedure from Ada code,
3359 e.g.@: if it is necessary to do selective re-elaboration to fix some
3360 error.
3361
3362 @findex Elab_Spec
3363 @item Elab_Spec
3364 @noindent
3365 This attribute can only be applied to a program unit name.  It returns
3366 the entity for the corresponding elaboration procedure for elaborating
3367 the specification of the referenced unit.  This is used in the main
3368 generated elaboration procedure by the binder and is not normally used
3369 in any other context.  However, there may be specialized situations in
3370 which it is useful to be able to call this elaboration procedure from
3371 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
3372 some error.
3373
3374 @cindex Ada 83 attributes
3375 @findex Emax
3376 @item Emax
3377 @noindent
3378 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
3379 the Ada 83 reference manual for an exact description of the semantics of
3380 this attribute.
3381
3382 @cindex Representation of enums
3383 @findex Enum_Rep
3384 @item Enum_Rep
3385 @noindent
3386 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
3387 function with the following specification:
3388
3389 @smallexample
3390 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
3391   return Universal_Integer;
3392 @end smallexample
3393
3394 @noindent
3395 It is also allowable to apply @code{Enum_Rep} directly to an object of an
3396 enumeration type or to a non-overloaded enumeration
3397 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to 
3398 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
3399 enumeration literal or object.
3400
3401 The function returns the representation value for the given enumeration
3402 value.  This will be equal to value of the @code{Pos} attribute in the
3403 absence of an enumeration representation clause.  This is a static
3404 attribute (i.e.@: the result is static if the argument is static).
3405
3406 @code{@var{S}'Enum_Rep} can also be used with integer types and objects, in which
3407 case it simply returns the integer value.  The reason for this is to allow
3408 it to be used for @code{(<>)} discrete formal arguments in a generic unit that
3409 can be instantiated with either enumeration types or integer types.  Note
3410 that if @code{Enum_Rep} is used on a modular type whose upper bound exceeds the
3411 upper bound of the largest signed integer type, and the argument is a
3412 variable, so that the universal integer calculation is done at run-time,
3413 then the call to @code{Enum_Rep} may raise @code{Constraint_Error}.
3414
3415 @cindex Ada 83 attributes
3416 @findex Epsilon
3417 @item Epsilon
3418 @noindent
3419 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
3420 the Ada 83 reference manual for an exact description of the semantics of
3421 this attribute.
3422
3423 @findex Fixed_Value
3424 @item Fixed_Value
3425 @noindent
3426 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
3427 function with the following specification:
3428
3429 @smallexample
3430 function @var{S}'Fixed_Value (Arg : Universal_Integer)
3431   return @var{S};
3432 @end smallexample
3433
3434 @noindent
3435 The value returned is the fixed-point value @var{V} such that
3436
3437 @smallexample
3438 @var{V} = Arg * @var{S}'Small
3439 @end smallexample
3440
3441 @noindent
3442 The effect is thus equivalent to first converting the argument to the
3443 integer type used to represent @var{S}, and then doing an unchecked
3444 conversion to the fixed-point type.  This attribute is primarily intended
3445 for use in implementation of the input-output functions for fixed-point
3446 values.
3447
3448 @cindex Discriminants, testing for
3449 @findex Has_Discriminants
3450 @item Has_Discriminants
3451 @noindent
3452 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
3453 is a Boolean value which is True if the type has discriminants, and False
3454 otherwise.  The intended use of this attribute is in conjunction with generic
3455 definitions.  If the attribute is applied to a generic private type, it
3456 indicates whether or not the corresponding actual type has discriminants.
3457
3458 @findex Img
3459 @item Img
3460 @noindent
3461 The @code{Img} attribute differs from @code{Image} in that it may be
3462 applied to objects as well as types, in which case it gives the
3463 @code{Image} for the subtype of the object.  This is convenient for
3464 debugging:
3465
3466 @smallexample
3467 Put_Line ("X = " & X'Img);
3468 @end smallexample
3469
3470 @noindent
3471 has the same meaning as the more verbose:
3472
3473 @smallexample
3474 Put_Line ("X = " & @var{type}'Image (X));
3475 @end smallexample
3476
3477 where @var{type} is the subtype of the object X@.
3478
3479 @findex Integer_Value
3480 @item Integer_Value
3481 @noindent
3482 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
3483 function with the following specification:
3484
3485 @smallexample
3486 function @var{S}'Integer_Value (Arg : Universal_Fixed)
3487   return @var{S};
3488 @end smallexample
3489
3490 @noindent
3491 The value returned is the integer value @var{V}, such that
3492
3493 @smallexample
3494 Arg = @var{V} * @var{type}'Small
3495 @end smallexample
3496
3497 @noindent
3498 The effect is thus equivalent to first doing an unchecked convert from
3499 the fixed-point type to its corresponding implementation type, and then
3500 converting the result to the target integer type.  This attribute is
3501 primarily intended for use in implementation of the standard
3502 input-output functions for fixed-point values.
3503
3504 @cindex Ada 83 attributes
3505 @findex Large
3506 @item Large
3507 @noindent
3508 The @code{Large} attribute is provided for compatibility with Ada 83.  See
3509 the Ada 83 reference manual for an exact description of the semantics of
3510 this attribute.
3511
3512 @findex Machine_Size
3513 @item Machine_Size
3514 @noindent
3515 This attribute is identical to the @code{Object_Size} attribute.  It is
3516 provided for compatibility with the DEC Ada 83 attribute of this name.
3517    
3518 @cindex Ada 83 attributes
3519 @findex Mantissa
3520 @item Mantissa
3521 @noindent
3522 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
3523 the Ada 83 reference manual for an exact description of the semantics of
3524 this attribute.
3525
3526 @cindex Interrupt priority, maximum
3527 @findex Max_Interrupt_Priority
3528 @item Max_Interrupt_Priority
3529 @noindent
3530 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
3531 permissible prefix), provides the value
3532 @code{System.Max_Interrupt_Priority} and is intended primarily for
3533 constructing this definition in package @code{System}.
3534
3535 @cindex Priority, maximum
3536 @findex Max_Priority
3537 @item Max_Priority
3538 @noindent
3539 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
3540 prefix) provides the value @code{System.Max_Priority} and is intended
3541 primarily for constructing this definition in package @code{System}.
3542
3543 @cindex Alignment, maximum
3544 @findex Maximum_Alignment
3545 @item Maximum_Alignment
3546 @noindent
3547 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
3548 permissible prefix) provides the maximum useful alignment value for the
3549 target.  This is a static value that can be used to specify the alignment
3550 for an object, guaranteeing that it is properly aligned in all
3551 cases.  This is useful when an external object is imported and its
3552 alignment requirements are unknown.
3553
3554 @cindex Return values, passing mechanism
3555 @cindex Parameters, passing mechanism
3556 @findex Mechanism_Code
3557 @item Mechanism_Code
3558 @noindent
3559 @code{@var{function}'Mechanism_Code} yields an integer code for the
3560 mechanism used for the result of function, and
3561 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
3562 used for formal parameter number @var{n} (a static integer value with 1
3563 meaning the first parameter) of @var{subprogram}.  The code returned is:
3564
3565 @table @asis
3566 @item 1
3567 by copy (value)
3568 @item 2
3569 by reference
3570 @item 3
3571 by descriptor (default descriptor class)
3572 @item 4
3573 by descriptor (UBS: unaligned bit string)
3574 @item 5
3575 by descriptor (UBSB: aligned bit string with arbitrary bounds)
3576 @item 6
3577 by descriptor (UBA: unaligned bit array)
3578 @item 7
3579 by descriptor (S: string, also scalar access type parameter)
3580 @item 8
3581 by descriptor (SB: string with arbitrary bounds)
3582 @item 9
3583 by descriptor (A: contiguous array)
3584 @item 10
3585 by descriptor (NCA: non-contiguous array)
3586 @end table
3587
3588 @cindex OpenVMS
3589 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
3590
3591 @cindex Zero address, passing
3592 @findex Null_Parameter
3593 @item Null_Parameter
3594 @noindent
3595 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
3596 type or subtype @var{T} allocated at machine address zero.  The attribute
3597 is allowed only as the default expression of a formal parameter, or as
3598 an actual expression of a subprogram call.  In either case, the
3599 subprogram must be imported.
3600
3601 The identity of the object is represented by the address zero in the
3602 argument list, independent of the passing mechanism (explicit or
3603 default).
3604
3605 This capability is needed to specify that a zero address should be
3606 passed for a record or other composite object passed by reference.
3607 There is no way of indicating this without the @code{Null_Parameter}
3608 attribute.
3609
3610 @cindex Size, used for objects
3611 @findex Object_Size
3612 @item Object_Size
3613 @noindent
3614 The size of an object is not necessarily the same as the size of the type
3615 of an object.  This is because by default object sizes are increased to be
3616 a multiple of the alignment of the object.  For example, 
3617 @code{Natural'Size} is
3618 31, but by default objects of type @code{Natural} will have a size of 32 bits.
3619 Similarly, a record containing an integer and a character:
3620
3621 @smallexample
3622 type Rec is record
3623    I : Integer;
3624    C : Character;
3625 end record;
3626 @end smallexample
3627
3628 @noindent
3629 will have a size of 40 (that is @code{Rec'Size} will be 40.  The 
3630 alignment will be 4, because of the
3631 integer field, and so the default size of record objects for this type
3632 will be 64 (8 bytes).
3633
3634 The @code{@var{type}'Object_Size} attribute
3635 has been added to GNAT to allow the
3636 default object size of a type to be easily determined.  For example,
3637 @code{Natural'Object_Size} is 32, and
3638 @code{Rec'Object_Size} (for the record type in the above example) will be
3639 64.  Note also that, unlike the situation with the
3640 @code{Size} attribute as defined in the Ada RM, the 
3641 @code{Object_Size} attribute can be specified individually
3642 for different subtypes.  For example:
3643
3644 @smallexample
3645 type R is new Integer;
3646 subtype R1 is R range 1 .. 10;
3647 subtype R2 is R range 1 .. 10;
3648 for R2'Object_Size use 8;
3649 @end smallexample
3650
3651 @noindent
3652 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
3653 32 since the default object size for a subtype is the same as the object size
3654 for the parent subtype.  This means that objects of type @code{R}
3655 or @code{R1} will
3656 by default be 32 bits (four bytes).  But objects of type
3657 @code{R2} will be only
3658 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
3659
3660 @cindex Parameters, when passed by reference
3661 @findex Passed_By_Reference
3662 @item Passed_By_Reference
3663 @noindent
3664 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
3665 a value of type @code{Boolean} value that is @code{True} if the type is
3666 normally passed by reference and @code{False} if the type is normally
3667 passed by copy in calls.  For scalar types, the result is always @code{False}
3668 and is static.  For non-scalar types, the result is non-static.
3669
3670 @findex Range_Length
3671 @item Range_Length
3672 @noindent
3673 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
3674 the number of values represented by the subtype (zero for a null
3675 range).  The result is static for static subtypes.  @code{Range_Length}
3676 applied to the index subtype of a one dimensional array always gives the
3677 same result as @code{Range} applied to the array itself.
3678
3679 @cindex Ada 83 attributes
3680 @findex Safe_Emax
3681 @item Safe_Emax
3682 @noindent
3683 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
3684 the Ada 83 reference manual for an exact description of the semantics of
3685 this attribute.
3686
3687 @cindex Ada 83 attributes
3688 @findex Safe_Large
3689 @item Safe_Large
3690 @noindent
3691 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
3692 the Ada 83 reference manual for an exact description of the semantics of
3693 this attribute.
3694
3695 @cindex Ada 83 attributes
3696 @findex Safe_Large
3697 @item Safe_Large
3698 @noindent
3699 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
3700 the Ada 83 reference manual for an exact description of the semantics of
3701 this attribute.
3702
3703 @cindex Ada 83 attributes
3704 @findex Small
3705 @item Small
3706 @noindent
3707 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
3708 GNAT also allows this attribute to be applied to floating-point types
3709 for compatibility with Ada 83.  See
3710 the Ada 83 reference manual for an exact description of the semantics of
3711 this attribute when applied to floating-point types.
3712
3713 @findex Storage_Unit
3714 @item Storage_Unit
3715 @noindent
3716 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
3717 prefix) provides the value @code{System.Storage_Unit} and is intended
3718 primarily for constructing this definition in package @code{System}.
3719
3720 @findex Tick
3721 @item Tick
3722 @noindent
3723 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
3724 provides the value of @code{System.Tick} and is intended primarily for
3725 constructing this definition in package @code{System}.
3726
3727 @findex To_Address
3728 @item To_Address
3729 @noindent
3730 The @code{System'To_Address}
3731 (@code{System} is the only permissible prefix)
3732 denotes a function identical to 
3733 @code{System.Storage_Elements.To_Address} except that
3734 it is a static attribute.  This means that if its argument is
3735 a static expression, then the result of the attribute is a
3736 static expression.  The result is that such an expression can be
3737 used in contexts (e.g.@: preelaborable packages) which require a
3738 static expression and where the function call could not be used
3739 (since the function call is always non-static, even if its 
3740 argument is static).
3741
3742 @findex Type_Class
3743 @item Type_Class
3744 @noindent
3745 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
3746 the value of the type class for the full type of @var{type}.  If
3747 @var{type} is a generic formal type, the value is the value for the
3748 corresponding actual subtype.  The value of this attribute is of type
3749 @code{System.Aux_DEC.Type_Class}, which has the following definition:
3750
3751 @smallexample
3752   type Type_Class is
3753     (Type_Class_Enumeration,
3754      Type_Class_Integer,
3755      Type_Class_Fixed_Point,
3756      Type_Class_Floating_Point,
3757      Type_Class_Array,
3758      Type_Class_Record,
3759      Type_Class_Access,
3760      Type_Class_Task,
3761      Type_Class_Address);
3762 @end smallexample
3763
3764 @noindent
3765 Protected types yield the value @code{Type_Class_Task}, which thus
3766 applies to all concurrent types.  This attribute is designed to
3767 be compatible with the DEC Ada 83 attribute of the same name.
3768
3769 @findex UET_Address
3770 @item UET_Address
3771 @noindent
3772 The @code{UET_Address} attribute can only be used for a prefix which
3773 denotes a library package.  It yields the address of the unit exception
3774 table when zero cost exception handling is used.  This attribute is
3775 intended only for use within the GNAT implementation.  See the unit
3776 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
3777 for details on how this attribute is used in the implementation.
3778
3779 @cindex Named numbers, representation of
3780 @findex Universal_Literal_String
3781 @item Universal_Literal_String
3782 @noindent
3783 The prefix of @code{Universal_Literal_String} must be a named
3784 number.  The static result is the string consisting of the characters of
3785 the number as defined in the original source.  This allows the user
3786 program to access the actual text of named numbers without intermediate
3787 conversions and without the need to enclose the strings in quotes (which
3788 would preclude their use as numbers).  This is used internally for the
3789 construction of values of the floating-point attributes from the file
3790 @file{ttypef.ads}, but may also be used by user programs.
3791
3792 @cindex @code{Access}, unrestricted
3793 @findex Unrestricted_Access
3794 @item Unrestricted_Access
3795 @noindent
3796 The @code{Unrestricted_Access} attribute is similar to @code{Access}
3797 except that all accessibility and aliased view checks are omitted.  This
3798 is a user-beware attribute.  It is similar to
3799 @code{Address}, for which it is a desirable replacement where the value
3800 desired is an access type.  In other words, its effect is identical to
3801 first applying the @code{Address} attribute and then doing an unchecked
3802 conversion to a desired access type.  In GNAT, but not necessarily in
3803 other implementations, the use of static chains for inner level
3804 subprograms means that @code{Unrestricted_Access} applied to a
3805 subprogram yields a value that can be called as long as the subprogram
3806 is in scope (normal Ada 95 accessibility rules restrict this usage).
3807
3808 @cindex @code{Size}, VADS compatibility
3809 @findex VADS_Size
3810 @item VADS_Size
3811 @noindent
3812 The @code{'VADS_Size} attribute is intended to make it easier to port
3813 legacy code which relies on the semantics of @code{'Size} as implemented
3814 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
3815 same semantic interpretation.  In particular, @code{'VADS_Size} applied
3816 to a predefined or other primitive type with no Size clause yields the
3817 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
3818 typical machines).  In addition @code{'VADS_Size} applied to an object
3819 gives the result that would be obtained by applying the attribute to
3820 the corresponding type.
3821
3822 @cindex @code{Size}, setting for not-first subtype
3823 @findex Value_Size
3824 @item Value_Size
3825 @code{@var{type}'Value_Size} is the number of bits required to represent
3826 a value of the given subtype.  It is the same as @code{@var{type}'Size},
3827 but, unlike @code{Size}, may be set for non-first subtypes.
3828
3829 @findex Wchar_T_Size
3830 @item Wchar_T_Size
3831 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
3832 prefix) provides the size in bits of the C @code{wchar_t} type 
3833 primarily for constructing the definition of this type in 
3834 package @code{Interfaces.C}.
3835
3836 @findex Word_Size
3837 @item Word_Size
3838 @code{Standard'Word_Size} (@code{Standard} is the only permissible
3839 prefix) provides the value @code{System.Word_Size} and is intended
3840 primarily for constructing this definition in package @code{System}.
3841 @end table
3842 @node Implementation Advice
3843 @chapter Implementation Advice
3844 The main text of the Ada 95 Reference Manual describes the required
3845 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
3846 these requirements.
3847
3848 In addition, there are sections throughout the Ada 95
3849 reference manual headed
3850 by the phrase ``implementation advice''.  These sections are not normative,
3851 i.e.@: they do not specify requirements that all compilers must
3852 follow.  Rather they provide advice on generally desirable behavior.  You
3853 may wonder why they are not requirements.  The most typical answer is
3854 that they describe behavior that seems generally desirable, but cannot
3855 be provided on all systems, or which may be undesirable on some systems.
3856
3857 As far as practical, GNAT follows the implementation advice sections in
3858 the Ada 95 Reference Manual.  This chapter contains a table giving the
3859 reference manual section number, paragraph number and several keywords
3860 for each advice.  Each entry consists of the text of the advice followed
3861 by the GNAT interpretation of this advice.  Most often, this simply says
3862 ``followed'', which means that GNAT follows the advice.  However, in a
3863 number of cases, GNAT deliberately deviates from this advice, in which
3864 case the text describes what GNAT does and why.
3865
3866 @table @strong
3867 @cindex Error detection
3868 @item 1.1.3(20): Error Detection
3869 @sp 1
3870 @cartouche
3871 If an implementation detects the use of an unsupported Specialized Needs
3872 Annex feature at run time, it should raise @code{Program_Error} if
3873 feasible.
3874 @end cartouche
3875 Not relevant.  All specialized needs annex features are either supported,
3876 or diagnosed at compile time.
3877
3878 @cindex Child Units
3879 @item 1.1.3(31): Child Units
3880 @sp 1
3881 @cartouche
3882 If an implementation wishes to provide implementation-defined
3883 extensions to the functionality of a language-defined library unit, it
3884 should normally do so by adding children to the library unit.
3885 @end cartouche
3886 Followed.
3887
3888 @cindex Bounded errors
3889 @item 1.1.5(12): Bounded Errors
3890 @sp 1
3891 @cartouche
3892 If an implementation detects a bounded error or erroneous
3893 execution, it should raise @code{Program_Error}.
3894 @end cartouche
3895 Followed in all cases in which the implementation detects a bounded
3896 error or erroneous execution.  Not all such situations are detected at
3897 runtime.
3898
3899 @cindex Pragmas
3900 @item 2.8(16): Pragmas
3901 @sp 1
3902 @cartouche
3903 Normally, implementation-defined pragmas should have no semantic effect
3904 for error-free programs; that is, if the implementation-defined pragmas
3905 are removed from a working program, the program should still be legal,
3906 and should still have the same semantics.
3907 @end cartouche
3908 The following implementation defined pragmas are exceptions to this
3909 rule:
3910
3911 @table @code
3912 @item Abort_Defer
3913 Affects semantics
3914 @item Ada_83
3915 Affects legality
3916 @item Assert
3917 Affects semantics
3918 @item CPP_Class
3919 Affects semantics
3920 @item CPP_Constructor
3921 Affects semantics
3922 @item CPP_Virtual
3923 Affects semantics
3924 @item CPP_Vtable
3925 Affects semantics
3926 @item Debug
3927 Affects semantics
3928 @item Interface_Name
3929 Affects semantics
3930 @item Machine_Attribute
3931 Affects semantics
3932 @item Unimplemented_Unit
3933 Affects legality
3934 @item Unchecked_Union
3935 Affects semantics
3936 @end table
3937
3938 In each of the above cases, it is essential to the purpose of the pragma
3939 that this advice not be followed.  For details see the separate section
3940 on implementation defined pragmas.
3941
3942 @item 2.8(17-19): Pragmas
3943 @sp 1
3944 @cartouche
3945 Normally, an implementation should not define pragmas that can
3946 make an illegal program legal, except as follows:
3947 @end cartouche
3948 @sp 1
3949 @cartouche
3950 A pragma used to complete a declaration, such as a pragma @code{Import};
3951 @end cartouche
3952 @sp 1
3953 @cartouche
3954 A pragma used to configure the environment by adding, removing, or
3955 replacing @code{library_items}.
3956 @end cartouche
3957 See response to paragraph 16 of this same section.
3958
3959 @cindex Character Sets
3960 @cindex Alternative Character Sets
3961 @item 3.5.2(5): Alternative Character Sets
3962 @sp 1
3963 @cartouche
3964 If an implementation supports a mode with alternative interpretations
3965 for @code{Character} and @code{Wide_Character}, the set of graphic
3966 characters of @code{Character} should nevertheless remain a proper
3967 subset of the set of graphic characters of @code{Wide_Character}.  Any
3968 character set ``localizations'' should be reflected in the results of
3969 the subprograms defined in the language-defined package
3970 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
3971 an alternative interpretation of @code{Character}, the implementation should
3972 also support a corresponding change in what is a legal
3973 @code{identifier_letter}.
3974 @end cartouche
3975 Not all wide character modes follow this advice, in particular the JIS
3976 and IEC modes reflect standard usage in Japan, and in these encoding,
3977 the upper half of the Latin-1 set is not part of the wide-character
3978 subset, since the most significant bit is used for wide character
3979 encoding.  However, this only applies to the external forms.  Internally
3980 there is no such restriction.
3981
3982 @cindex Integer types
3983 @item 3.5.4(28): Integer Types
3984
3985 @sp 1
3986 @cartouche
3987 An implementation should support @code{Long_Integer} in addition to
3988 @code{Integer} if the target machine supports 32-bit (or longer)
3989 arithmetic.  No other named integer subtypes are recommended for package
3990 @code{Standard}.  Instead, appropriate named integer subtypes should be
3991 provided in the library package @code{Interfaces} (see B.2).
3992 @end cartouche
3993 @code{Long_Integer} is supported.  Other standard integer types are supported
3994 so this advice is not fully followed.  These types
3995 are supported for convenient interface to C, and so that all hardware
3996 types of the machine are easily available.
3997 @item 3.5.4(29): Integer Types
3998
3999 @sp 1
4000 @cartouche
4001 An implementation for a two's complement machine should support
4002 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4003 implementation should support a non-binary modules up to @code{Integer'Last}.
4004 @end cartouche
4005 Followed.
4006
4007 @cindex Enumeration values
4008 @item 3.5.5(8): Enumeration Values
4009 @sp 1
4010 @cartouche
4011 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4012 subtype, if the value of the operand does not correspond to the internal
4013 code for any enumeration literal of its type (perhaps due to an
4014 un-initialized variable), then the implementation should raise
4015 @code{Program_Error}.  This is particularly important for enumeration
4016 types with noncontiguous internal codes specified by an
4017 enumeration_representation_clause.
4018 @end cartouche
4019 Followed.
4020
4021 @cindex Float types
4022 @item 3.5.7(17): Float Types
4023 @sp 1
4024 @cartouche
4025 An implementation should support @code{Long_Float} in addition to
4026 @code{Float} if the target machine supports 11 or more digits of
4027 precision.  No other named floating point subtypes are recommended for
4028 package @code{Standard}.  Instead, appropriate named floating point subtypes
4029 should be provided in the library package @code{Interfaces} (see B.2).
4030 @end cartouche
4031 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4032 former provides improved compatibility with other implementations
4033 supporting this type.  The latter corresponds to the highest precision
4034 floating-point type supported by the hardware.  On most machines, this
4035 will be the same as @code{Long_Float}, but on some machines, it will
4036 correspond to the IEEE extended form.  The notable case is all ia32
4037 (x86) implementations, where @code{Long_Long_Float} corresponds to
4038 the 80-bit extended precision format supported in hardware on this
4039 processor.  Note that the 128-bit format on SPARC is not supported,
4040 since this is a software rather than a hardware format.
4041
4042 @cindex Multidimensional arrays
4043 @cindex Arrays, multidimensional
4044 @item 3.6.2(11): Multidimensional Arrays
4045 @sp 1
4046 @cartouche
4047 An implementation should normally represent multidimensional arrays in
4048 row-major order, consistent with the notation used for multidimensional
4049 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4050 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4051 column-major order should be used instead (see B.5, ``Interfacing with
4052 Fortran'').
4053 @end cartouche
4054 Followed.
4055
4056 @findex Duration'Small
4057 @item 9.6(30-31): Duration'Small
4058 @sp 1
4059 @cartouche
4060 Whenever possible in an implementation, the value of @code{Duration'Small}
4061 should be no greater than 100 microseconds.
4062 @end cartouche
4063 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4064
4065 @sp 1
4066 @cartouche
4067 The time base for @code{delay_relative_statements} should be monotonic;
4068 it need not be the same time base as used for @code{Calendar.Clock}.
4069 @end cartouche
4070 Followed.
4071
4072 @item 10.2.1(12): Consistent Representation
4073 @sp 1
4074 @cartouche
4075 In an implementation, a type declared in a pre-elaborated package should
4076 have the same representation in every elaboration of a given version of
4077 the package, whether the elaborations occur in distinct executions of
4078 the same program, or in executions of distinct programs or partitions
4079 that include the given version.
4080 @end cartouche
4081 Followed, except in the case of tagged types.  Tagged types involve
4082 implicit pointers to a local copy of a dispatch table, and these pointers
4083 have representations which thus depend on a particular elaboration of the
4084 package.  It is not easy to see how it would be possible to follow this
4085 advice without severely impacting efficiency of execution.
4086
4087 @cindex Exception information
4088 @item 11.4.1(19): Exception Information
4089 @sp 1
4090 @cartouche
4091 @code{Exception_Message} by default and @code{Exception_Information}
4092 should produce information useful for
4093 debugging.  @code{Exception_Message} should be short, about one
4094 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
4095 should not include the
4096 @code{Exception_Name}.  @code{Exception_Information} should include both
4097 the @code{Exception_Name} and the @code{Exception_Message}.
4098 @end cartouche
4099 Followed.  For each exception that doesn't have a specified
4100 @code{Exception_Message}, the compiler generates one containing the location
4101 of the raise statement.  This location has the form ``file:line'', where
4102 file is the short file name (without path information) and line is the line
4103 number in the file.  Note that in the case of the Zero Cost Exception
4104 mechanism, these messages become redundant with the Exception_Information that
4105 contains a full backtrace of the calling sequence, so they are disabled.
4106 To disable explicitly the generation of the source location message, use the
4107 Pragma @code{Discard_Names}.
4108
4109 @cindex Suppression of checks
4110 @cindex Checks, suppression of
4111 @item 11.5(28): Suppression of Checks
4112 @sp 1
4113 @cartouche
4114 The implementation should minimize the code executed for checks that
4115 have been suppressed.
4116 @end cartouche
4117 Followed.
4118
4119 @cindex Representation clauses
4120 @item 13.1 (21-24): Representation Clauses
4121 @sp 1
4122 @cartouche
4123 The recommended level of support for all representation items is
4124 qualified as follows:
4125 @end cartouche
4126 @sp 1
4127 @cartouche
4128 An implementation need not support representation items containing
4129 non-static expressions, except that an implementation should support a
4130 representation item for a given entity if each non-static expression in
4131 the representation item is a name that statically denotes a constant
4132 declared before the entity.
4133 @end cartouche
4134 Followed.  GNAT does not support non-static expressions in representation
4135 clauses unless they are constants declared before the entity.  For
4136 example:
4137
4138 @smallexample
4139 X : typ;
4140 for X'Address use To_address (16#2000#); 
4141 @end smallexample
4142
4143 @noindent
4144 will be rejected, since the To_Address expression is non-static.  Instead
4145 write: 
4146
4147 @smallexample
4148 X_Address : constant Address : = 
4149 To_Address    ((16#2000#); 
4150 X : typ;
4151 for X'Address use X_Address;
4152 @end smallexample
4153
4154 @sp 1
4155 @cartouche
4156 An implementation need not support a specification for the @code{Size}
4157 for a given composite subtype, nor the size or storage place for an
4158 object (including a component) of a given composite subtype, unless the
4159 constraints on the subtype and its composite subcomponents (if any) are
4160 all static constraints.
4161 @end cartouche
4162 Followed.  Size Clauses are not permitted on non-static components, as
4163 described above.
4164
4165 @sp 1
4166 @cartouche
4167 An aliased component, or a component whose type is by-reference, should
4168 always be allocated at an addressable location.
4169 @end cartouche
4170 Followed.
4171
4172 @cindex Packed types
4173 @item 13.2(6-8): Packed Types
4174 @sp 1
4175 @cartouche
4176 If a type is packed, then the implementation should try to minimize
4177 storage allocated to objects of the type, possibly at the expense of
4178 speed of accessing components, subject to reasonable complexity in
4179 addressing calculations.
4180 @end cartouche
4181 @sp 1
4182 @cartouche
4183 The recommended level of support pragma @code{Pack} is:
4184
4185 For a packed record type, the components should be packed as tightly as
4186 possible subject to the Sizes of the component subtypes, and subject to
4187 any @code{record_representation_clause} that applies to the type; the
4188 implementation may, but need not, reorder components or cross aligned
4189 word boundaries to improve the packing.  A component whose @code{Size} is
4190 greater than the word size may be allocated an integral number of words.
4191 @end cartouche
4192 Followed.  Tight packing of arrays is supported for all component sizes
4193 up to 64-bits.
4194
4195 @sp 1
4196 @cartouche
4197 An implementation should support Address clauses for imported
4198 subprograms.
4199 @end cartouche
4200 Followed.
4201 @cindex @code{Address} clauses
4202 @item 13.3(14-19): Address Clauses
4203
4204 @sp 1
4205 @cartouche
4206 For an array @var{X}, @code{@var{X}'Address} should point at the first
4207 component of the array, and not at the array bounds.
4208 @end cartouche
4209 Followed.
4210
4211 @sp 1
4212 @cartouche
4213 The recommended level of support for the @code{Address} attribute is:
4214
4215 @code{@var{X}'Address} should produce a useful result if @var{X} is an
4216 object that is aliased or of a by-reference type, or is an entity whose
4217 @code{Address} has been specified.
4218 @end cartouche
4219 Followed.  A valid address will be produced even if none of those
4220 conditions have been met.  If necessary, the object is forced into
4221 memory to ensure the address is valid.
4222
4223 @sp 1
4224 @cartouche
4225 An implementation should support @code{Address} clauses for imported
4226 subprograms.
4227 @end cartouche
4228 Followed.
4229             
4230 @sp 1
4231 @cartouche
4232 Objects (including subcomponents) that are aliased or of a by-reference
4233 type should be allocated on storage element boundaries.
4234 @end cartouche
4235 Followed.
4236           
4237 @sp 1
4238 @cartouche
4239 If the @code{Address} of an object is specified, or it is imported or exported,
4240 then the implementation should not perform optimizations based on
4241 assumptions of no aliases.
4242 @end cartouche
4243 Followed.
4244
4245 @cindex @code{Alignment} clauses
4246 @item 13.3(29-35): Alignment Clauses
4247 @sp 1
4248 @cartouche
4249 The recommended level of support for the @code{Alignment} attribute for
4250 subtypes is:
4251
4252 An implementation should support specified Alignments that are factors
4253 and multiples of the number of storage elements per word, subject to the
4254 following:
4255 @end cartouche
4256 Followed.
4257           
4258 @sp 1
4259 @cartouche
4260 An implementation need not support specified @code{Alignment}s for
4261 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
4262 loaded and stored by available machine instructions.
4263 @end cartouche
4264 Followed.
4265             
4266 @sp 1
4267 @cartouche
4268 An implementation need not support specified @code{Alignment}s that are
4269 greater than the maximum @code{Alignment} the implementation ever returns by
4270 default.
4271 @end cartouche
4272 Followed.
4273
4274 @sp 1
4275 @cartouche
4276 The recommended level of support for the @code{Alignment} attribute for
4277 objects is:
4278
4279 Same as above, for subtypes, but in addition:
4280 @end cartouche
4281 Followed.
4282            
4283 @sp 1
4284 @cartouche
4285 For stand-alone library-level objects of statically constrained
4286 subtypes, the implementation should support all @code{Alignment}s
4287 supported by the target linker.  For example, page alignment is likely to
4288 be supported for such objects, but not for subtypes.
4289 @end cartouche
4290 Followed.
4291
4292 @cindex @code{Size} clauses
4293 @item 13.3(42-43): Size Clauses
4294 @sp 1
4295 @cartouche
4296 The recommended level of support for the @code{Size} attribute of
4297 objects is:
4298
4299 A @code{Size} clause should be supported for an object if the specified
4300 @code{Size} is at least as large as its subtype's @code{Size}, and
4301 corresponds to a size in storage elements that is a multiple of the
4302 object's @code{Alignment} (if the @code{Alignment} is nonzero).
4303 @end cartouche
4304 Followed.
4305
4306 @item 13.3(50-56): Size Clauses
4307 @sp 1
4308 @cartouche
4309 If the @code{Size} of a subtype is specified, and allows for efficient
4310 independent addressability (see 9.10) on the target architecture, then
4311 the @code{Size} of the following objects of the subtype should equal the
4312 @code{Size} of the subtype:
4313
4314 Aliased objects (including components).
4315 @end cartouche
4316 Followed.
4317
4318 @sp 1
4319 @cartouche
4320 @code{Size} clause on a composite subtype should not affect the
4321 internal layout of components.
4322 @end cartouche
4323 Followed.
4324
4325 @sp 1
4326 @cartouche
4327 The recommended level of support for the @code{Size} attribute of subtypes is:
4328 @end cartouche
4329 @sp 1
4330 @cartouche
4331 The @code{Size} (if not specified) of a static discrete or fixed point
4332 subtype should be the number of bits needed to represent each value
4333 belonging to the subtype using an unbiased representation, leaving space
4334 for a sign bit only if the subtype contains negative values.  If such a
4335 subtype is a first subtype, then an implementation should support a
4336 specified @code{Size} for it that reflects this representation.
4337 @end cartouche
4338 Followed.
4339
4340 @sp 1
4341 @cartouche
4342 For a subtype implemented with levels of indirection, the @code{Size}
4343 should include the size of the pointers, but not the size of what they
4344 point at.
4345 @end cartouche
4346 Followed.
4347
4348 @cindex @code{Component_Size} clauses
4349 @item 13.3(71-73): Component Size Clauses
4350 @sp 1
4351 @cartouche
4352 The recommended level of support for the @code{Component_Size}
4353 attribute is:
4354 @end cartouche
4355 @sp 1
4356 @cartouche
4357 An implementation need not support specified @code{Component_Sizes} that are
4358 less than the @code{Size} of the component subtype.
4359 @end cartouche
4360 Followed.
4361
4362 @sp 1
4363 @cartouche
4364 An implementation should support specified @code{Component_Size}s that
4365 are factors and multiples of the word size.  For such
4366 @code{Component_Size}s, the array should contain no gaps between
4367 components.  For other @code{Component_Size}s (if supported), the array
4368 should contain no gaps between components when packing is also
4369 specified; the implementation should forbid this combination in cases
4370 where it cannot support a no-gaps representation.
4371 @end cartouche
4372 Followed.
4373
4374 @cindex Enumeration representation clauses
4375 @cindex Representation clauses, enumeration
4376 @item 13.4(9-10): Enumeration Representation Clauses
4377 @sp 1
4378 @cartouche
4379 The recommended level of support for enumeration representation clauses
4380 is:
4381
4382 An implementation need not support enumeration representation clauses
4383 for boolean types, but should at minimum support the internal codes in
4384 the range @code{System.Min_Int.System.Max_Int}.
4385 @end cartouche
4386 Followed.
4387
4388 @cindex Record representation clauses
4389 @cindex Representation clauses, records
4390 @item 13.5.1(17-22): Record Representation Clauses
4391 @sp 1
4392 @cartouche
4393 The recommended level of support for
4394 @*@code{record_representation_clauses} is:
4395
4396 An implementation should support storage places that can be extracted
4397 with a load, mask, shift sequence of machine code, and set with a load,
4398 shift, mask, store sequence, given the available machine instructions
4399 and run-time model.
4400 @end cartouche
4401 Followed.
4402
4403 @sp 1
4404 @cartouche
4405 A storage place should be supported if its size is equal to the
4406 @code{Size} of the component subtype, and it starts and ends on a
4407 boundary that obeys the @code{Alignment} of the component subtype.
4408 @end cartouche
4409 Followed.
4410            
4411 @sp 1
4412 @cartouche
4413 If the default bit ordering applies to the declaration of a given type,
4414 then for a component whose subtype's @code{Size} is less than the word
4415 size, any storage place that does not cross an aligned word boundary
4416 should be supported.
4417 @end cartouche
4418 Followed.
4419
4420 @sp 1
4421 @cartouche
4422 An implementation may reserve a storage place for the tag field of a
4423 tagged type, and disallow other components from overlapping that place.
4424 @end cartouche
4425 Followed.  The storage place for the tag field is the beginning of the tagged
4426 record, and its size is Address'Size.  GNAT will reject an explicit component
4427 clause for the tag field.
4428
4429 @sp 1
4430 @cartouche
4431 An implementation need not support a @code{component_clause} for a
4432 component of an extension part if the storage place is not after the
4433 storage places of all components of the parent type, whether or not
4434 those storage places had been specified.
4435 @end cartouche
4436 Followed.  The above advice on record representation clauses is followed,
4437 and all mentioned features are implemented.
4438
4439 @cindex Storage place attributes
4440 @item 13.5.2(5): Storage Place Attributes
4441 @sp 1
4442 @cartouche
4443 If a component is represented using some form of pointer (such as an
4444 offset) to the actual data of the component, and this data is contiguous
4445 with the rest of the object, then the storage place attributes should
4446 reflect the place of the actual data, not the pointer.  If a component is
4447 allocated discontinuously from the rest of the object, then a warning
4448 should be generated upon reference to one of its storage place
4449 attributes.
4450 @end cartouche
4451 Followed.  There are no such components in GNAT@.
4452
4453 @cindex Bit ordering
4454 @item 13.5.3(7-8): Bit Ordering
4455 @sp 1
4456 @cartouche
4457 The recommended level of support for the non-default bit ordering is:
4458 @end cartouche
4459 @sp 1
4460 @cartouche
4461 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
4462 should support the non-default bit ordering in addition to the default
4463 bit ordering.
4464 @end cartouche
4465 Followed.  Word size does not equal storage size in this implementation.
4466 Thus non-default bit ordering is not supported.
4467
4468 @cindex @code{Address}, as private type
4469 @item 13.7(37): Address as Private
4470 @sp 1
4471 @cartouche
4472 @code{Address} should be of a private type.
4473 @end cartouche
4474 Followed.
4475
4476 @cindex Operations, on @code{Address}
4477 @cindex @code{Address}, operations of
4478 @item 13.7.1(16): Address Operations
4479 @sp 1
4480 @cartouche
4481 Operations in @code{System} and its children should reflect the target
4482 environment semantics as closely as is reasonable.  For example, on most
4483 machines, it makes sense for address arithmetic to ``wrap around''.
4484 Operations that do not make sense should raise @code{Program_Error}.
4485 @end cartouche
4486 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
4487 operation raises @code{Program_Error}, since all operations make sense.
4488
4489 @cindex Unchecked conversion
4490 @item 13.9(14-17): Unchecked Conversion
4491 @sp 1
4492 @cartouche
4493 The @code{Size} of an array object should not include its bounds; hence,
4494 the bounds should not be part of the converted data.
4495 @end cartouche
4496 Followed. 
4497
4498 @sp 1
4499 @cartouche
4500 The implementation should not generate unnecessary run-time checks to
4501 ensure that the representation of @var{S} is a representation of the
4502 target type.  It should take advantage of the permission to return by
4503 reference when possible.  Restrictions on unchecked conversions should be
4504 avoided unless required by the target environment.
4505 @end cartouche
4506 Followed.  There are no restrictions on unchecked conversion.  A warning is
4507 generated if the source and target types do not have the same size since
4508 the semantics in this case may be target dependent.
4509
4510 @sp 1
4511 @cartouche
4512 The recommended level of support for unchecked conversions is:
4513 @end cartouche
4514 @sp 1
4515 @cartouche
4516 Unchecked conversions should be supported and should be reversible in
4517 the cases where this clause defines the result.  To enable meaningful use
4518 of unchecked conversion, a contiguous representation should be used for
4519 elementary subtypes, for statically constrained array subtypes whose
4520 component subtype is one of the subtypes described in this paragraph,
4521 and for record subtypes without discriminants whose component subtypes
4522 are described in this paragraph.
4523 @end cartouche
4524 Followed. 
4525
4526 @cindex Heap usage, implicit
4527 @item 13.11(23-25): Implicit Heap Usage
4528 @sp 1
4529 @cartouche
4530 An implementation should document any cases in which it dynamically
4531 allocates heap storage for a purpose other than the evaluation of an
4532 allocator.
4533 @end cartouche
4534 Followed, the only other points at which heap storage is dynamically
4535 allocated are as follows:
4536
4537 @itemize @bullet
4538 @item
4539 At initial elaboration time, to allocate dynamically sized global
4540 objects.
4541
4542 @item
4543 To allocate space for a task when a task is created.
4544
4545 @item
4546 To extend the secondary stack dynamically when needed.  The secondary
4547 stack is used for returning variable length results.
4548 @end itemize
4549
4550 @sp 1
4551 @cartouche
4552 A default (implementation-provided) storage pool for an 
4553 access-to-constant type should not have overhead to support deallocation of
4554 individual objects.
4555 @end cartouche
4556 Followed. 
4557
4558 @sp 1
4559 @cartouche
4560 A storage pool for an anonymous access type should be created at the
4561 point of an allocator for the type, and be reclaimed when the designated
4562 object becomes inaccessible.
4563 @end cartouche
4564 Followed. 
4565
4566 @cindex Unchecked deallocation
4567 @item 13.11.2(17): Unchecked De-allocation
4568 @sp 1
4569 @cartouche
4570 For a standard storage pool, @code{Free} should actually reclaim the
4571 storage.
4572 @end cartouche
4573 Followed. 
4574
4575 @cindex Stream oriented attributes
4576 @item 13.13.2(17): Stream Oriented Attributes
4577 @sp 1
4578 @cartouche
4579 If a stream element is the same size as a storage element, then the
4580 normal in-memory representation should be used by @code{Read} and
4581 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
4582 should use the smallest number of stream elements needed to represent
4583 all values in the base range of the scalar type.
4584 @end cartouche
4585 Followed.  In particular, the interpretation chosen is that of AI-195,
4586 which specifies that the size to be used is that of the first subtype.
4587
4588 @item A.1(52): Implementation Advice
4589 @sp 1
4590 @cartouche
4591 If an implementation provides additional named predefined integer types,
4592 then the names should end with @samp{Integer} as in
4593 @samp{Long_Integer}.  If an implementation provides additional named
4594 predefined floating point types, then the names should end with
4595 @samp{Float} as in @samp{Long_Float}.
4596 @end cartouche
4597 Followed. 
4598
4599 @findex Ada.Characters.Handling
4600 @item A.3.2(49): @code{Ada.Characters.Handling}
4601 @sp 1
4602 @cartouche
4603 If an implementation provides a localized definition of @code{Character}
4604 or @code{Wide_Character}, then the effects of the subprograms in
4605 @code{Characters.Handling} should reflect the localizations.  See also
4606 3.5.2.
4607 @end cartouche
4608 Followed.  GNAT provides no such localized definitions. 
4609
4610 @cindex Bounded-length strings
4611 @item A.4.4(106): Bounded-Length String Handling
4612 @sp 1
4613 @cartouche
4614 Bounded string objects should not be implemented by implicit pointers
4615 and dynamic allocation.
4616 @end cartouche
4617 Followed.  No implicit pointers or dynamic allocation are used. 
4618
4619 @cindex Random number generation
4620 @item A.5.2(46-47): Random Number Generation
4621 @sp 1
4622 @cartouche
4623 Any storage associated with an object of type @code{Generator} should be
4624 reclaimed on exit from the scope of the object.
4625 @end cartouche
4626 Followed. 
4627
4628 @sp 1
4629 @cartouche
4630 If the generator period is sufficiently long in relation to the number
4631 of distinct initiator values, then each possible value of
4632 @code{Initiator} passed to @code{Reset} should initiate a sequence of
4633 random numbers that does not, in a practical sense, overlap the sequence
4634 initiated by any other value.  If this is not possible, then the mapping
4635 between initiator values and generator states should be a rapidly
4636 varying function of the initiator value.
4637 @end cartouche
4638 Followed.  The generator period is sufficiently long for the first
4639 condition here to hold true. 
4640
4641 @findex Get_Immediate
4642 @item A.10.7(23): @code{Get_Immediate}
4643 @sp 1
4644 @cartouche
4645 The @code{Get_Immediate} procedures should be implemented with
4646 unbuffered input.  For a device such as a keyboard, input should be
4647 @dfn{available} if a key has already been typed, whereas for a disk
4648 file, input should always be available except at end of file.  For a file
4649 associated with a keyboard-like device, any line-editing features of the
4650 underlying operating system should be disabled during the execution of
4651 @code{Get_Immediate}.
4652 @end cartouche
4653 Followed.
4654
4655 @findex Export
4656 @item B.1(39-41): Pragma @code{Export}
4657 @sp 1
4658 @cartouche
4659 If an implementation supports pragma @code{Export} to a given language,
4660 then it should also allow the main subprogram to be written in that
4661 language.  It should support some mechanism for invoking the elaboration
4662 of the Ada library units included in the system, and for invoking the
4663 finalization of the environment task.  On typical systems, the
4664 recommended mechanism is to provide two subprograms whose link names are
4665 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
4666 elaboration code for library units.  @code{adafinal} should contain the
4667 finalization code.  These subprograms should have no effect the second
4668 and subsequent time they are called.
4669 @end cartouche
4670 Followed. 
4671
4672 @sp 1
4673 @cartouche
4674 Automatic elaboration of pre-elaborated packages should be
4675 provided when pragma @code{Export} is supported.
4676 @end cartouche
4677 Followed when the main program is in Ada.  If the main program is in a
4678 foreign language, then
4679 @code{adainit} must be called to elaborate pre-elaborated
4680 packages.
4681
4682 @sp 1
4683 @cartouche
4684 For each supported convention @var{L} other than @code{Intrinsic}, an
4685 implementation should support @code{Import} and @code{Export} pragmas
4686 for objects of @var{L}-compatible types and for subprograms, and pragma
4687 @code{Convention} for @var{L}-eligible types and for subprograms,
4688 presuming the other language has corresponding features.  Pragma
4689 @code{Convention} need not be supported for scalar types.
4690 @end cartouche
4691 Followed. 
4692
4693 @cindex Package @code{Interfaces}
4694 @findex Interfaces
4695 @item B.2(12-13): Package @code{Interfaces}
4696 @sp 1
4697 @cartouche
4698 For each implementation-defined convention identifier, there should be a
4699 child package of package Interfaces with the corresponding name.  This
4700 package should contain any declarations that would be useful for
4701 interfacing to the language (implementation) represented by the
4702 convention.  Any declarations useful for interfacing to any language on
4703 the given hardware architecture should be provided directly in
4704 @code{Interfaces}.
4705 @end cartouche
4706 Followed.  An additional package not defined
4707 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
4708 for interfacing to C++.
4709
4710 @sp 1
4711 @cartouche
4712 An implementation supporting an interface to C, COBOL, or Fortran should
4713 provide the corresponding package or packages described in the following
4714 clauses.
4715 @end cartouche
4716 Followed.  GNAT provides all the packages described in this section. 
4717
4718 @cindex C, interfacing with
4719 @item B.3(63-71): Interfacing with C
4720 @sp 1
4721 @cartouche
4722 An implementation should support the following interface correspondences
4723 between Ada and C@.
4724 @end cartouche
4725 Followed.
4726
4727 @sp 1
4728 @cartouche
4729 An Ada procedure corresponds to a void-returning C function.
4730 @end cartouche
4731 Followed. 
4732
4733 @sp 1
4734 @cartouche
4735 An Ada function corresponds to a non-void C function.
4736 @end cartouche
4737 Followed. 
4738
4739 @sp 1
4740 @cartouche
4741 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
4742 function.
4743 @end cartouche
4744 Followed. 
4745
4746 @sp 1
4747 @cartouche
4748 An Ada @code{in} parameter of an access-to-object type with designated
4749 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
4750 where @var{t} is the C type corresponding to the Ada type @var{T}.
4751 @end cartouche
4752 Followed. 
4753
4754 @sp 1
4755 @cartouche
4756 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
4757 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
4758 argument to a C function, where @var{t} is the C type corresponding to
4759 the Ada type @var{T}.  In the case of an elementary @code{out} or
4760 @code{in out} parameter, a pointer to a temporary copy is used to
4761 preserve by-copy semantics.
4762 @end cartouche
4763 Followed. 
4764
4765 @sp 1
4766 @cartouche
4767 An Ada parameter of a record type @var{T}, of any mode, is passed as a
4768 @code{@var{t}*} argument to a C function, where @var{t} is the C
4769 structure corresponding to the Ada type @var{T}.
4770 @end cartouche
4771 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
4772 pragma, or Convention, or by explicitly specifying the mechanism for a given
4773 call using an extended import or export pragma.
4774
4775 @sp 1
4776 @cartouche
4777 An Ada parameter of an array type with component type @var{T}, of any
4778 mode, is passed as a @code{@var{t}*} argument to a C function, where
4779 @var{t} is the C type corresponding to the Ada type @var{T}.
4780 @end cartouche
4781 Followed. 
4782
4783 @sp 1
4784 @cartouche
4785 An Ada parameter of an access-to-subprogram type is passed as a pointer
4786 to a C function whose prototype corresponds to the designated
4787 subprogram's specification.
4788 @end cartouche
4789 Followed. 
4790
4791 @cindex COBOL, interfacing with
4792 @item B.4(95-98): Interfacing with COBOL
4793 @sp 1
4794 @cartouche
4795 An Ada implementation should support the following interface
4796 correspondences between Ada and COBOL@.
4797 @end cartouche
4798 Followed.
4799
4800 @sp 1
4801 @cartouche
4802 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
4803 the COBOL type corresponding to @var{T}.
4804 @end cartouche
4805 Followed. 
4806
4807 @sp 1
4808 @cartouche
4809 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
4810 the corresponding COBOL type.
4811 @end cartouche
4812 Followed. 
4813
4814 @sp 1
4815 @cartouche
4816 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
4817 COBOL type corresponding to the Ada parameter type; for scalars, a local
4818 copy is used if necessary to ensure by-copy semantics.
4819 @end cartouche
4820 Followed. 
4821
4822 @cindex Fortran, interfacing with
4823 @item B.5(22-26): Interfacing with Fortran
4824 @sp 1
4825 @cartouche
4826 An Ada implementation should support the following interface
4827 correspondences between Ada and Fortran:
4828 @end cartouche
4829 Followed.
4830
4831 @sp 1
4832 @cartouche
4833 An Ada procedure corresponds to a Fortran subroutine.
4834 @end cartouche
4835 Followed.
4836
4837 @sp 1
4838 @cartouche
4839 An Ada function corresponds to a Fortran function.
4840 @end cartouche
4841 Followed.
4842
4843 @sp 1
4844 @cartouche
4845 An Ada parameter of an elementary, array, or record type @var{T} is
4846 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
4847 the Fortran type corresponding to the Ada type @var{T}, and where the
4848 INTENT attribute of the corresponding dummy argument matches the Ada
4849 formal parameter mode; the Fortran implementation's parameter passing
4850 conventions are used.  For elementary types, a local copy is used if
4851 necessary to ensure by-copy semantics.
4852 @end cartouche
4853 Followed.
4854
4855 @sp 1
4856 @cartouche
4857 An Ada parameter of an access-to-subprogram type is passed as a
4858 reference to a Fortran procedure whose interface corresponds to the
4859 designated subprogram's specification.
4860 @end cartouche
4861 Followed.
4862
4863 @cindex Machine operations
4864 @item C.1(3-5): Access to Machine Operations
4865 @sp 1
4866 @cartouche
4867 The machine code or intrinsic support should allow access to all
4868 operations normally available to assembly language programmers for the
4869 target environment, including privileged instructions, if any.
4870 @end cartouche
4871 Followed.
4872
4873 @sp 1
4874 @cartouche
4875 The interfacing pragmas (see Annex B) should support interface to
4876 assembler; the default assembler should be associated with the
4877 convention identifier @code{Assembler}.
4878 @end cartouche
4879 Followed. 
4880
4881 @sp 1
4882 @cartouche
4883 If an entity is exported to assembly language, then the implementation
4884 should allocate it at an addressable location, and should ensure that it
4885 is retained by the linking process, even if not otherwise referenced
4886 from the Ada code.  The implementation should assume that any call to a
4887 machine code or assembler subprogram is allowed to read or update every
4888 object that is specified as exported.
4889 @end cartouche
4890 Followed. 
4891
4892 @item C.1(10-16): Access to Machine Operations
4893 @sp 1
4894 @cartouche
4895 The implementation should ensure that little or no overhead is
4896 associated with calling intrinsic and machine-code subprograms.
4897 @end cartouche
4898 Followed for both intrinsics and machine-code subprograms.
4899
4900 @sp 1
4901 @cartouche
4902 It is recommended that intrinsic subprograms be provided for convenient
4903 access to any machine operations that provide special capabilities or
4904 efficiency and that are not otherwise available through the language
4905 constructs.
4906 @end cartouche
4907 Followed.  A full set of machine operation intrinsic subprograms is provided.
4908
4909 @sp 1
4910 @cartouche
4911 Atomic read-modify-write operations---e.g.@:, test and set, compare and
4912 swap, decrement and test, enqueue/dequeue.
4913 @end cartouche
4914 Followed on any target supporting such operations.
4915
4916 @sp 1
4917 @cartouche
4918 Standard numeric functions---e.g.@:, sin, log.
4919 @end cartouche
4920 Followed on any target supporting such operations.
4921
4922 @sp 1
4923 @cartouche
4924 String manipulation operations---e.g.@:, translate and test.
4925 @end cartouche
4926 Followed on any target supporting such operations.
4927
4928 @sp 1
4929 @cartouche
4930 Vector operations---e.g.@:, compare vector against thresholds.
4931 @end cartouche
4932 Followed on any target supporting such operations.
4933
4934 @sp 1
4935 @cartouche
4936 Direct operations on I/O ports.
4937 @end cartouche
4938 Followed on any target supporting such operations.
4939
4940 @cindex Interrupt support
4941 @item C.3(28): Interrupt Support
4942 @sp 1
4943 @cartouche
4944 If the @code{Ceiling_Locking} policy is not in effect, the
4945 implementation should provide means for the application to specify which
4946 interrupts are to be blocked during protected actions, if the underlying
4947 system allows for a finer-grain control of interrupt blocking.
4948 @end cartouche
4949 Followed.  The underlying system does not allow for finer-grain control
4950 of interrupt blocking.
4951
4952 @cindex Protected procedure handlers
4953 @item C.3.1(20-21): Protected Procedure Handlers
4954 @sp 1
4955 @cartouche
4956 Whenever possible, the implementation should allow interrupt handlers to
4957 be called directly by the hardware.
4958 @end cartouche
4959 @c SGI info:
4960 @ignore
4961 This is never possible under IRIX, so this is followed by default. 
4962 @end ignore
4963 Followed on any target where the underlying operating system permits
4964 such direct calls.
4965
4966 @sp 1
4967 @cartouche
4968 Whenever practical, violations of any
4969 implementation-defined restrictions should be detected before run time.
4970 @end cartouche
4971 Followed.  Compile time warnings are given when possible. 
4972
4973 @cindex Package @code{Interrupts}
4974 @findex Interrupts
4975 @item C.3.2(25): Package @code{Interrupts}
4976
4977 @sp 1
4978 @cartouche
4979 If implementation-defined forms of interrupt handler procedures are
4980 supported, such as protected procedures with parameters, then for each
4981 such form of a handler, a type analogous to @code{Parameterless_Handler}
4982 should be specified in a child package of @code{Interrupts}, with the
4983 same operations as in the predefined package Interrupts.
4984 @end cartouche
4985 Followed. 
4986
4987 @cindex Pre-elaboration requirements
4988 @item C.4(14): Pre-elaboration Requirements
4989 @sp 1
4990 @cartouche
4991 It is recommended that pre-elaborated packages be implemented in such a
4992 way that there should be little or no code executed at run time for the
4993 elaboration of entities not already covered by the Implementation
4994 Requirements.
4995 @end cartouche
4996 Followed.  Executable code is generated in some cases, e.g.@: loops
4997 to initialize large arrays.
4998
4999 @item C.5(8): Pragma @code{Discard_Names}
5000
5001 @sp 1
5002 @cartouche
5003 If the pragma applies to an entity, then the implementation should
5004 reduce the amount of storage used for storing names associated with that
5005 entity.
5006 @end cartouche
5007 Followed.
5008
5009 @cindex Package @code{Task_Attributes}
5010 @findex Task_Attributes
5011 @item C.7.2(30): The Package Task_Attributes
5012 @sp 1
5013 @cartouche
5014 Some implementations are targeted to domains in which memory use at run
5015 time must be completely deterministic.  For such implementations, it is
5016 recommended that the storage for task attributes will be pre-allocated
5017 statically and not from the heap.  This can be accomplished by either
5018 placing restrictions on the number and the size of the task's
5019 attributes, or by using the pre-allocated storage for the first @var{N}
5020 attribute objects, and the heap for the others.  In the latter case,
5021 @var{N} should be documented.
5022 @end cartouche
5023 Not followed.  This implementation is not targeted to such a domain. 
5024
5025 @cindex Locking Policies
5026 @item D.3(17): Locking Policies
5027
5028 @sp 1
5029 @cartouche
5030 The implementation should use names that end with @samp{_Locking} for
5031 locking policies defined by the implementation.
5032 @end cartouche
5033 Followed.  A single implementation-defined locking policy is defined,
5034 whose name (@code{Inheritance_Locking}) follows this suggestion.
5035
5036 @cindex Entry queuing policies
5037 @item D.4(16): Entry Queuing Policies
5038 @sp 1
5039 @cartouche
5040 Names that end with @samp{_Queuing} should be used
5041 for all implementation-defined queuing policies.
5042 @end cartouche
5043 Followed.  No such implementation-defined queueing policies exist. 
5044
5045 @cindex Preemptive abort
5046 @item D.6(9-10): Preemptive Abort
5047 @sp 1
5048 @cartouche
5049 Even though the @code{abort_statement} is included in the list of
5050 potentially blocking operations (see 9.5.1), it is recommended that this
5051 statement be implemented in a way that never requires the task executing
5052 the @code{abort_statement} to block.
5053 @end cartouche
5054 Followed. 
5055
5056 @sp 1
5057 @cartouche
5058 On a multi-processor, the delay associated with aborting a task on
5059 another processor should be bounded; the implementation should use
5060 periodic polling, if necessary, to achieve this.
5061 @end cartouche
5062 Followed. 
5063
5064 @cindex Tasking restrictions
5065 @item D.7(21): Tasking Restrictions
5066 @sp 1
5067 @cartouche
5068 When feasible, the implementation should take advantage of the specified
5069 restrictions to produce a more efficient implementation.
5070 @end cartouche
5071 GNAT currently takes advantage of these restrictions by providing an optimized
5072 run time when the Ravenscar profile and the GNAT restricted run time set
5073 of restrictions are specified.  See pragma @code{Ravenscar} and pragma
5074 @code{Restricted_Run_Time} for more details.
5075
5076 @cindex Time, monotonic
5077 @item D.8(47-49): Monotonic Time
5078 @sp 1
5079 @cartouche
5080 When appropriate, implementations should provide configuration
5081 mechanisms to change the value of @code{Tick}.
5082 @end cartouche
5083 Such configuration mechanisms are not appropriate to this implementation
5084 and are thus not supported.
5085
5086 @sp 1
5087 @cartouche
5088 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
5089 be implemented as transformations of the same time base.
5090 @end cartouche
5091 Followed. 
5092
5093 @sp 1
5094 @cartouche
5095 It is recommended that the @dfn{best} time base which exists in
5096 the underlying system be available to the application through
5097 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
5098 @end cartouche
5099 Followed. 
5100
5101 @cindex Partition communication subsystem
5102 @cindex PCS
5103 @item E.5(28-29): Partition Communication Subsystem
5104 @sp 1
5105 @cartouche
5106 Whenever possible, the PCS on the called partition should allow for
5107 multiple tasks to call the RPC-receiver with different messages and
5108 should allow them to block until the corresponding subprogram body
5109 returns.
5110 @end cartouche
5111 Followed by GLADE, a separately supplied PCS that can be used with
5112 GNAT.  
5113
5114 @sp 1
5115 @cartouche
5116 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
5117 should raise @code{Storage_Error} if it runs out of space trying to
5118 write the @code{Item} into the stream.
5119 @end cartouche
5120 Followed by GLADE, a separately supplied PCS that can be used with
5121 GNAT@.  
5122
5123 @cindex COBOL support
5124 @item F(7): COBOL Support
5125 @sp 1
5126 @cartouche
5127 If COBOL (respectively, C) is widely supported in the target
5128 environment, implementations supporting the Information Systems Annex
5129 should provide the child package @code{Interfaces.COBOL} (respectively,
5130 @code{Interfaces.C}) specified in Annex B and should support a
5131 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
5132 pragmas (see Annex B), thus allowing Ada programs to interface with
5133 programs written in that language.
5134 @end cartouche
5135 Followed. 
5136
5137 @cindex Decimal radix support
5138 @item F.1(2): Decimal Radix Support
5139 @sp 1
5140 @cartouche
5141 Packed decimal should be used as the internal representation for objects
5142 of subtype @var{S} when @var{S}'Machine_Radix = 10.
5143 @end cartouche
5144 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
5145 representations.
5146
5147 @cindex Numerics
5148 @item G: Numerics
5149 @sp 2
5150 @cartouche
5151 If Fortran (respectively, C) is widely supported in the target
5152 environment, implementations supporting the Numerics Annex
5153 should provide the child package @code{Interfaces.Fortran} (respectively,
5154 @code{Interfaces.C}) specified in Annex B and should support a
5155 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
5156 pragmas (see Annex B), thus allowing Ada programs to interface with
5157 programs written in that language.
5158 @end cartouche
5159 Followed.
5160
5161 @cindex Complex types
5162 @item G.1.1(56-58): Complex Types
5163 @sp 2
5164 @cartouche
5165 Because the usual mathematical meaning of multiplication of a complex
5166 operand and a real operand is that of the scaling of both components of
5167 the former by the latter, an implementation should not perform this
5168 operation by first promoting the real operand to complex type and then
5169 performing a full complex multiplication.  In systems that, in the
5170 future, support an Ada binding to IEC 559:1989, the latter technique
5171 will not generate the required result when one of the components of the
5172 complex operand is infinite.  (Explicit multiplication of the infinite
5173 component by the zero component obtained during promotion yields a NaN
5174 that propagates into the final result.) Analogous advice applies in the
5175 case of multiplication of a complex operand and a pure-imaginary
5176 operand, and in the case of division of a complex operand by a real or
5177 pure-imaginary operand.
5178 @end cartouche
5179 Not followed. 
5180
5181 @sp 1
5182 @cartouche
5183 Similarly, because the usual mathematical meaning of addition of a
5184 complex operand and a real operand is that the imaginary operand remains
5185 unchanged, an implementation should not perform this operation by first
5186 promoting the real operand to complex type and then performing a full
5187 complex addition.  In implementations in which the @code{Signed_Zeros}
5188 attribute of the component type is @code{True} (and which therefore
5189 conform to IEC 559:1989 in regard to the handling of the sign of zero in
5190 predefined arithmetic operations), the latter technique will not
5191 generate the required result when the imaginary component of the complex
5192 operand is a negatively signed zero.  (Explicit addition of the negative
5193 zero to the zero obtained during promotion yields a positive zero.)
5194 Analogous advice applies in the case of addition of a complex operand
5195 and a pure-imaginary operand, and in the case of subtraction of a
5196 complex operand and a real or pure-imaginary operand.
5197 @end cartouche
5198 Not followed. 
5199
5200 @sp 1
5201 @cartouche
5202 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
5203 attempt to provide a rational treatment of the signs of zero results and
5204 result components.  As one example, the result of the @code{Argument}
5205 function should have the sign of the imaginary component of the
5206 parameter @code{X} when the point represented by that parameter lies on
5207 the positive real axis; as another, the sign of the imaginary component
5208 of the @code{Compose_From_Polar} function should be the same as
5209 (respectively, the opposite of) that of the @code{Argument} parameter when that
5210 parameter has a value of zero and the @code{Modulus} parameter has a
5211 nonnegative (respectively, negative) value.
5212 @end cartouche
5213 Followed. 
5214
5215 @cindex Complex elementary functions
5216 @item G.1.2(49): Complex Elementary Functions
5217 @sp 1
5218 @cartouche
5219 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
5220 @code{True} should attempt to provide a rational treatment of the signs
5221 of zero results and result components.  For example, many of the complex
5222 elementary functions have components that are odd functions of one of
5223 the parameter components; in these cases, the result component should
5224 have the sign of the parameter component at the origin.  Other complex
5225 elementary functions have zero components whose sign is opposite that of
5226 a parameter component at the origin, or is always positive or always
5227 negative.
5228 @end cartouche
5229 Followed. 
5230
5231 @cindex Accuracy requirements
5232 @item G.2.4(19): Accuracy Requirements
5233 @sp 1
5234 @cartouche
5235 The versions of the forward trigonometric functions without a
5236 @code{Cycle} parameter should not be implemented by calling the
5237 corresponding version with a @code{Cycle} parameter of
5238 @code{2.0*Numerics.Pi}, since this will not provide the required
5239 accuracy in some portions of the domain.  For the same reason, the
5240 version of @code{Log} without a @code{Base} parameter should not be
5241 implemented by calling the corresponding version with a @code{Base}
5242 parameter of @code{Numerics.e}.
5243 @end cartouche
5244 Followed. 
5245
5246 @cindex Complex arithmetic accuracy
5247 @cindex Accuracy, complex arithmetic
5248 @item G.2.6(15): Complex Arithmetic Accuracy
5249
5250 @sp 1
5251 @cartouche
5252 The version of the @code{Compose_From_Polar} function without a
5253 @code{Cycle} parameter should not be implemented by calling the
5254 corresponding version with a @code{Cycle} parameter of
5255 @code{2.0*Numerics.Pi}, since this will not provide the required
5256 accuracy in some portions of the domain.
5257 @end cartouche
5258 Followed.
5259
5260 @end table
5261 @node Implementation Defined Characteristics
5262 @chapter Implementation Defined Characteristics
5263 In addition to the implementation dependent pragmas and attributes, and
5264 the implementation advice, there are a number of other features of Ada
5265 95 that are potentially implementation dependent.  These are mentioned
5266 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
5267
5268 A requirement for conforming Ada compilers is that they provide
5269 documentation describing how the implementation deals with each of these
5270 issues.  In this chapter, you will find each point in annex M listed
5271 followed by a description in italic font of how GNAT
5272 @c SGI info:
5273 @ignore
5274 in the ProDev Ada
5275 implementation on IRIX 5.3 operating system or greater 
5276 @end ignore
5277 handles the implementation dependence.
5278
5279 You can use this chapter as a guide to minimizing implementation
5280 dependent features in your programs if portability to other compilers
5281 and other operating systems is an important consideration.  The numbers
5282 in each section below correspond to the paragraph number in the Ada 95
5283 Reference Manual.
5284
5285 @sp 1
5286 @cartouche
5287 @noindent
5288 @strong{2}.  Whether or not each recommendation given in Implementation
5289 Advice is followed.  See 1.1.2(37).
5290 @end cartouche
5291 @noindent
5292 @xref{Implementation Advice}.
5293
5294 @sp 1
5295 @cartouche
5296 @noindent
5297 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
5298 @end cartouche
5299 @noindent
5300 The complexity of programs that can be processed is limited only by the
5301 total amount of available virtual memory, and disk space for the
5302 generated object files.
5303
5304 @sp 1
5305 @cartouche
5306 @noindent
5307 @strong{4}.  Variations from the standard that are impractical to avoid
5308 given the implementation's execution environment.  See 1.1.3(6).
5309 @end cartouche
5310 @noindent
5311 There are no variations from the standard.
5312
5313 @sp 1
5314 @cartouche
5315 @noindent
5316 @strong{5}.  Which @code{code_statement}s cause external
5317 interactions.  See 1.1.3(10).
5318 @end cartouche
5319 @noindent
5320 Any @code{code_statement} can potentially cause external interactions.
5321
5322 @sp 1
5323 @cartouche
5324 @noindent
5325 @strong{6}.  The coded representation for the text of an Ada
5326 program.  See 2.1(4).
5327 @end cartouche
5328 @noindent
5329 See separate section on source representation.
5330
5331 @sp 1
5332 @cartouche
5333 @noindent
5334 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
5335 @end cartouche
5336 @noindent
5337 See separate section on source representation.
5338
5339 @sp 1
5340 @cartouche
5341 @noindent
5342 @strong{8}.  The representation for an end of line.  See 2.2(2).
5343 @end cartouche
5344 @noindent
5345 See separate section on source representation.
5346
5347 @sp 1
5348 @cartouche
5349 @noindent
5350 @strong{9}.  Maximum supported line length and lexical element
5351 length.  See 2.2(15).
5352 @end cartouche
5353 @noindent
5354 The maximum line length is 255 characters an the maximum length of a
5355 lexical element is also 255 characters.
5356
5357 @sp 1
5358 @cartouche
5359 @noindent
5360 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
5361 @end cartouche
5362 @noindent
5363
5364 @xref{Implementation Defined Pragmas}.
5365
5366 @sp 1
5367 @cartouche
5368 @noindent
5369 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
5370 @end cartouche
5371 @noindent
5372 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
5373 parameter, checks that the optimization flag is set, and aborts if it is
5374 not.
5375
5376 @sp 1
5377 @cartouche
5378 @noindent
5379 @strong{12}.  The sequence of characters of the value returned by
5380 @code{@var{S}'Image} when some of the graphic characters of
5381 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
5382 3.5(37).
5383 @end cartouche
5384 @noindent
5385 The sequence of characters is as defined by the wide character encoding
5386 method used for the source.  See section on source representation for
5387 further details.
5388
5389 @sp 1
5390 @cartouche
5391 @noindent
5392 @strong{13}.  The predefined integer types declared in
5393 @code{Standard}.  See 3.5.4(25).
5394 @end cartouche
5395 @noindent
5396 @table @code
5397 @item Short_Short_Integer
5398 8 bit signed
5399 @item Short_Integer
5400 (Short) 16 bit signed
5401 @item Integer
5402 32 bit signed
5403 @item Long_Integer
5404 64 bit signed (Alpha OpenVMS only)
5405 32 bit signed (all other targets)
5406 @item Long_Long_Integer
5407 64 bit signed
5408 @end table
5409
5410 @sp 1
5411 @cartouche
5412 @noindent
5413 @strong{14}.  Any nonstandard integer types and the operators defined
5414 for them.  See 3.5.4(26).
5415 @end cartouche
5416 @noindent
5417 There are no nonstandard integer types. 
5418
5419 @sp 1
5420 @cartouche
5421 @noindent
5422 @strong{15}.  Any nonstandard real types and the operators defined for
5423 them.  See 3.5.6(8).
5424 @end cartouche
5425 @noindent
5426 There are no nonstandard real types. 
5427
5428 @sp 1
5429 @cartouche
5430 @noindent
5431 @strong{16}.  What combinations of requested decimal precision and range
5432 are supported for floating point types.  See 3.5.7(7).
5433 @end cartouche
5434 @noindent
5435 The precision and range is as defined by the IEEE standard. 
5436
5437 @sp 1
5438 @cartouche
5439 @noindent
5440 @strong{17}.  The predefined floating point types declared in
5441 @code{Standard}.  See 3.5.7(16).
5442 @end cartouche
5443 @noindent
5444 @table @code
5445 @item Short_Float 
5446 32 bit IEEE short
5447 @item Float 
5448 (Short) 32 bit IEEE short 
5449 @item Long_Float 
5450 64 bit IEEE long 
5451 @item Long_Long_Float 
5452 64 bit IEEE long (80 bit IEEE long on x86 processors)
5453 @end table
5454
5455 @sp 1
5456 @cartouche
5457 @noindent
5458 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
5459 @end cartouche
5460 @noindent
5461 @code{Fine_Delta} is 2**(@minus{}63) 
5462
5463 @sp 1
5464 @cartouche
5465 @noindent
5466 @strong{19}.  What combinations of small, range, and digits are
5467 supported for fixed point types.  See 3.5.9(10).
5468 @end cartouche
5469 @noindent
5470 Any combinations are permitted that do not result in a small less than
5471 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
5472 If the mantissa is larger than 53 bits on machines where Long_Long_Float
5473 is 64 bits (true of all architectures except ia32), then the output from
5474 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
5475 is because floating-point conversions are used to convert fixed point.
5476
5477 @sp 1
5478 @cartouche
5479 @noindent
5480 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
5481 within an unnamed @code{block_statement}.  See 3.9(10).
5482 @end cartouche
5483 @noindent
5484 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
5485 decimal integer are allocated.
5486
5487 @sp 1
5488 @cartouche
5489 @noindent
5490 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
5491 @end cartouche
5492 @noindent
5493 @xref{Implementation Defined Attributes}.
5494
5495 @sp 1
5496 @cartouche
5497 @noindent
5498 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
5499 @end cartouche
5500 @noindent
5501 There are no implementation-defined time types. 
5502
5503 @sp 1
5504 @cartouche
5505 @noindent
5506 @strong{23}.  The time base associated with relative delays.
5507 @end cartouche
5508 @noindent
5509 See 9.6(20).  The time base used is that provided by the C library
5510 function @code{gettimeofday}.
5511
5512 @sp 1
5513 @cartouche
5514 @noindent
5515 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
5516 9.6(23).
5517 @end cartouche
5518 @noindent
5519 The time base used is that provided by the C library function
5520 @code{gettimeofday}.
5521
5522 @sp 1
5523 @cartouche
5524 @noindent
5525 @strong{25}.  The time zone used for package @code{Calendar}
5526 operations.  See 9.6(24).
5527 @end cartouche
5528 @noindent
5529 The time zone used by package @code{Calendar} is the current system time zone
5530 setting for local time, as accessed by the C library function
5531 @code{localtime}.
5532
5533 @sp 1
5534 @cartouche
5535 @noindent
5536 @strong{26}.  Any limit on @code{delay_until_statements} of
5537 @code{select_statements}.  See 9.6(29).
5538 @end cartouche
5539 @noindent
5540 There are no such limits. 
5541
5542 @sp 1
5543 @cartouche
5544 @noindent
5545 @strong{27}.  Whether or not two non overlapping parts of a composite
5546 object are independently addressable, in the case where packing, record
5547 layout, or @code{Component_Size} is specified for the object.  See
5548 9.10(1).
5549 @end cartouche
5550 @noindent
5551 Separate components are independently addressable if they do not share
5552 overlapping storage units.
5553
5554 @sp 1
5555 @cartouche
5556 @noindent
5557 @strong{28}.  The representation for a compilation.  See 10.1(2).
5558 @end cartouche
5559 @noindent
5560 A compilation is represented by a sequence of files presented to the
5561 compiler in a single invocation of the @code{gcc} command.
5562
5563 @sp 1
5564 @cartouche
5565 @noindent
5566 @strong{29}.  Any restrictions on compilations that contain multiple
5567 compilation_units.  See 10.1(4).
5568 @end cartouche
5569 @noindent
5570 No single file can contain more than one compilation unit, but any
5571 sequence of files can be presented to the compiler as a single
5572 compilation.
5573
5574 @sp 1
5575 @cartouche
5576 @noindent
5577 @strong{30}.  The mechanisms for creating an environment and for adding
5578 and replacing compilation units.  See 10.1.4(3).
5579 @end cartouche
5580 @noindent
5581 See separate section on compilation model. 
5582
5583 @sp 1
5584 @cartouche
5585 @noindent
5586 @strong{31}.  The manner of explicitly assigning library units to a
5587 partition.  See 10.2(2).
5588 @end cartouche
5589 @noindent
5590 If a unit contains an Ada main program, then the Ada units for the partition
5591 are determined by recursive application of the rules in the Ada Reference
5592 Manual section 10.2(2-6).  In other words, the Ada units will be those that
5593 are needed by the main program, and then this definition of need is applied
5594 recursively to those units, and the partition contains the transitive
5595 closure determined by this relationship.  In short, all the necessary units
5596 are included, with no need to explicitly specify the list.  If additional
5597 units are required, e.g.@: by foreign language units, then all units must be
5598 mentioned in the context clause of one of the needed Ada units.
5599
5600 If the partition contains no main program, or if the main program is in
5601 a language other than Ada, then GNAT 
5602 provides the binder options @code{-z} and @code{-n} respectively, and in this case a
5603 list of units can be explicitly supplied to the binder for inclusion in
5604 the partition (all units needed by these units will also be included
5605 automatically).  For full details on the use of these options, refer to
5606 the @cite{GNAT User's Guide} sections on Binding and Linking.
5607
5608 @sp 1
5609 @cartouche
5610 @noindent
5611 @strong{32}.  The implementation-defined means, if any, of specifying
5612 which compilation units are needed by a given compilation unit.  See
5613 10.2(2).
5614 @end cartouche
5615 @noindent
5616 The units needed by a given compilation unit are as defined in
5617 the Ada Reference Manual section 10.2(2-6).  There are no 
5618 implementation-defined pragmas or other implementation-defined
5619 means for specifying needed units.
5620
5621 @sp 1
5622 @cartouche
5623 @noindent
5624 @strong{33}.  The manner of designating the main subprogram of a
5625 partition.  See 10.2(7).
5626 @end cartouche
5627 @noindent
5628 The main program is designated by providing the name of the
5629 corresponding @file{ALI} file as the input parameter to the binder.
5630
5631 @sp 1
5632 @cartouche
5633 @noindent
5634 @strong{34}.  The order of elaboration of @code{library_items}.  See
5635 10.2(18).
5636 @end cartouche
5637 @noindent
5638 The first constraint on ordering is that it meets the requirements of
5639 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
5640 implementation dependent choices, which are resolved by first
5641 elaborating bodies as early as possible (i.e.@: in preference to specs
5642 where there is a choice), and second by evaluating the immediate with
5643 clauses of a unit to determine the probably best choice, and
5644 third by elaborating in alphabetical order of unit names
5645 where a choice still remains.
5646
5647 @sp 1
5648 @cartouche
5649 @noindent
5650 @strong{35}.  Parameter passing and function return for the main
5651 subprogram.  See 10.2(21).
5652 @end cartouche
5653 @noindent
5654 The main program has no parameters.  It may be a procedure, or a function
5655 returning an integer type.  In the latter case, the returned integer
5656 value is the return code of the program.
5657
5658 @sp 1
5659 @cartouche
5660 @noindent
5661 @strong{36}.  The mechanisms for building and running partitions.  See
5662 10.2(24).
5663 @end cartouche
5664 @noindent
5665 GNAT itself supports programs with only a single partition.  The GNATDIST
5666 tool provided with the GLADE package (which also includes an implementation
5667 of the PCS) provides a completely flexible method for building and running
5668 programs consisting of multiple partitions.  See the separate GLADE manual
5669 for details.
5670
5671 @sp 1
5672 @cartouche
5673 @noindent
5674 @strong{37}.  The details of program execution, including program
5675 termination.  See 10.2(25).
5676 @end cartouche
5677 @noindent
5678 See separate section on compilation model.
5679
5680 @sp 1
5681 @cartouche
5682 @noindent
5683 @strong{38}.  The semantics of any non-active partitions supported by the
5684 implementation.  See 10.2(28).
5685 @end cartouche
5686 @noindent
5687 Passive partitions are supported on targets where shared memory is
5688 provided by the operating system.  See the GLADE reference manual for
5689 further details.
5690
5691 @sp 1
5692 @cartouche
5693 @noindent
5694 @strong{39}.  The information returned by @code{Exception_Message}.  See
5695 11.4.1(10).
5696 @end cartouche
5697 @noindent
5698 Exception message returns the null string unless a specific message has
5699 been passed by the program.
5700
5701 @sp 1
5702 @cartouche
5703 @noindent
5704 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
5705 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
5706 @end cartouche
5707 @noindent
5708 Blocks have implementation defined names of the form @code{B@var{nnn}}
5709 where @var{nnn} is an integer.
5710
5711 @sp 1
5712 @cartouche
5713 @noindent
5714 @strong{41}.  The information returned by
5715 @code{Exception_Information}.  See 11.4.1(13).
5716 @end cartouche
5717 @noindent
5718 @code{Exception_Information} returns a string in the following format:
5719
5720 @smallexample
5721 @emph{Exception_Name:} nnnnn
5722 @emph{Message:} mmmmm
5723 @emph{PID:} ppp
5724 @emph{Call stack traceback locations:}
5725 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
5726 @end smallexample
5727
5728 @noindent
5729 where
5730
5731 @itemize @bullet
5732 @item
5733 @code{nnnn} is the fully qualified name of the exception in all upper
5734 case letters. This line is always present.
5735
5736 @item
5737 @code{mmmm} is the message (this line present only if message is non-null)
5738
5739 @item
5740 @code{ppp} is the Process Id value as a decimal integer (this line is
5741 present only if the Process Id is non-zero). Currently we are
5742 not making use of this field.
5743
5744 @item
5745 The Call stack traceback locations line and the following values
5746 are present only if at least one traceback location was recorded.
5747 The values are given in C style format, with lower case letters
5748 for a-f, and only as many digits present as are necessary.
5749 @end itemize
5750
5751 @noindent
5752 The line terminator sequence at the end of each line, including
5753 the last line is a single @code{LF} character (@code{16#0A#}).
5754
5755 @sp 1
5756 @cartouche
5757 @noindent
5758 @strong{42}.  Implementation-defined check names.  See 11.5(27).
5759 @end cartouche
5760 @noindent
5761 No implementation-defined check names are supported. 
5762
5763 @sp 1
5764 @cartouche
5765 @noindent
5766 @strong{43}.  The interpretation of each aspect of representation.  See
5767 13.1(20).
5768 @end cartouche
5769 @noindent
5770 See separate section on data representations.
5771
5772 @sp 1
5773 @cartouche
5774 @noindent
5775 @strong{44}.  Any restrictions placed upon representation items.  See
5776 13.1(20).
5777 @end cartouche
5778 @noindent
5779 See separate section on data representations.
5780
5781 @sp 1
5782 @cartouche
5783 @noindent
5784 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
5785 13.3(48).
5786 @end cartouche
5787 @noindent
5788 Size for an indefinite subtype is the maximum possible size, except that
5789 for the case of a subprogram parameter, the size of the parameter object
5790 is the actual size.
5791
5792 @sp 1
5793 @cartouche
5794 @noindent
5795 @strong{46}.  The default external representation for a type tag.  See
5796 13.3(75).
5797 @end cartouche
5798 @noindent
5799 The default external representation for a type tag is the fully expanded
5800 name of the type in upper case letters.
5801
5802 @sp 1
5803 @cartouche
5804 @noindent
5805 @strong{47}.  What determines whether a compilation unit is the same in
5806 two different partitions.  See 13.3(76).
5807 @end cartouche
5808 @noindent
5809 A compilation unit is the same in two different partitions if and only
5810 if it derives from the same source file.
5811
5812 @sp 1
5813 @cartouche
5814 @noindent
5815 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
5816 @end cartouche
5817 @noindent
5818 The only implementation defined component is the tag for a tagged type,
5819 which contains a pointer to the dispatching table.
5820
5821 @sp 1
5822 @cartouche
5823 @noindent
5824 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
5825 ordering.  See 13.5.3(5).
5826 @end cartouche
5827 @noindent
5828 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
5829 implementation, so no non-default bit ordering is supported.  The default
5830 bit ordering corresponds to the natural endianness of the target architecture.
5831
5832 @sp 1
5833 @cartouche
5834 @noindent
5835 @strong{50}.  The contents of the visible part of package @code{System}
5836 and its language-defined children.  See 13.7(2).
5837 @end cartouche
5838 @noindent
5839 See the definition of these packages in files @file{system.ads} and
5840 @file{s-stoele.ads}.
5841
5842 @sp 1
5843 @cartouche
5844 @noindent
5845 @strong{51}.  The contents of the visible part of package
5846 @code{System.Machine_Code}, and the meaning of
5847 @code{code_statements}.  See 13.8(7).
5848 @end cartouche
5849 @noindent
5850 See the definition and documentation in file @file{s-maccod.ads}.
5851
5852 @sp 1
5853 @cartouche
5854 @noindent
5855 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
5856 @end cartouche
5857 @noindent
5858 Unchecked conversion between types of the same size
5859 and results in an uninterpreted transmission of the bits from one type
5860 to the other.  If the types are of unequal sizes, then in the case of
5861 discrete types, a shorter source is first zero or sign extended as
5862 necessary, and a shorter target is simply truncated on the left.
5863 For all non-discrete types, the source is first copied if necessary
5864 to ensure that the alignment requirements of the target are met, then
5865 a pointer is constructed to the source value, and the result is obtained
5866 by dereferencing this pointer after converting it to be a pointer to the
5867 target type.
5868
5869 @sp 1
5870 @cartouche
5871 @noindent
5872 @strong{53}.  The manner of choosing a storage pool for an access type
5873 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
5874 @end cartouche
5875 @noindent
5876 There are 3 different standard pools used by the compiler when
5877 @code{Storage_Pool} is not specified depending whether the type is local
5878 to a subprogram or defined at the library level and whether
5879 @code{Storage_Size}is specified or not.  See documentation in the runtime
5880 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
5881 @code{System.Pool_Local} in files @file{s-poosiz.ads},
5882 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
5883 default pools used.
5884
5885 @sp 1
5886 @cartouche
5887 @noindent
5888 @strong{54}.  Whether or not the implementation provides user-accessible
5889 names for the standard pool type(s).  See 13.11(17).
5890 @end cartouche
5891 @noindent
5892
5893 See documentation in the sources of the run time mentioned in paragraph
5894 @strong{53} .  All these pools are accessible by means of @code{with}'ing
5895 these units.
5896
5897 @sp 1
5898 @cartouche
5899 @noindent
5900 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
5901 @end cartouche
5902 @noindent
5903 @code{Storage_Size} is measured in storage units, and refers to the
5904 total space available for an access type collection, or to the primary
5905 stack space for a task.
5906
5907 @sp 1
5908 @cartouche
5909 @noindent
5910 @strong{56}.  Implementation-defined aspects of storage pools.  See
5911 13.11(22).
5912 @end cartouche
5913 @noindent
5914 See documentation in the sources of the run time mentioned in paragraph
5915 @strong{53} for details on GNAT-defined aspects of storage pools.
5916
5917 @sp 1
5918 @cartouche
5919 @noindent
5920 @strong{57}.  The set of restrictions allowed in a pragma
5921 @code{Restrictions}.  See 13.12(7).
5922 @end cartouche
5923 @noindent
5924 All RM defined Restriction identifiers are implemented.  The following
5925 additional restriction identifiers are provided.  There are two separate
5926 lists of implementation dependent restriction identifiers.  The first
5927 set requires consistency throughout a partition (in other words, if the
5928 restriction identifier is used for any compilation unit in the partition,
5929 then all compilation units in the partition must obey the restriction.
5930
5931 @table @code
5932
5933 @item Boolean_Entry_Barriers
5934 @findex Boolean_Entry_Barriers
5935 This restriction ensures at compile time that barriers in entry declarations
5936 for protected types are restricted to references to simple boolean variables
5937 defined in the private part of the protected type.  No other form of entry
5938 barriers is permitted.  This is one of the restrictions of the Ravenscar
5939 profile for limited tasking (see also pragma @code{Ravenscar}).
5940
5941 @item Max_Entry_Queue_Depth => Expr
5942 @findex Max_Entry_Queue_Depth
5943 This restriction is a declaration that any protected entry compiled in
5944 the scope of the restriction has at most the specified number of
5945 tasks waiting on the entry
5946 at any one time, and so no queue is required.  This restriction is not
5947 checked at compile time.  A program execution is erroneous if an attempt
5948 is made to queue more than the specified number of tasks on such an entry.
5949
5950 @item No_Calendar
5951 @findex No_Calendar
5952 This restriction ensures at compile time that there is no implicit or
5953 explicit dependence on the package @code{Ada.Calendar}.
5954
5955 @item No_Dynamic_Interrupts
5956 @findex No_Dynamic_Interrupts
5957 This restriction ensures at compile time that there is no attempt to
5958 dynamically associate interrupts.  Only static association is allowed.
5959
5960 @item No_Enumeration_Maps
5961 @findex No_Enumeration_Maps
5962 This restriction ensures at compile time that no operations requiring
5963 enumeration maps are used (that is Image and Value attributes applied
5964 to enumeration types).
5965
5966 @item No_Entry_Calls_In_Elaboration_Code
5967 @findex No_Entry_Calls_In_Elaboration_Code
5968 This restriction ensures at compile time that no task or protected entry
5969 calls are made during elaboration code.  As a result of the use of this
5970 restriction, the compiler can assume that no code past an accept statement
5971 in a task can be executed at elaboration time.
5972
5973 @item No_Exception_Handlers
5974 @findex No_Exception_Handlers
5975 This restriction ensures at compile time that there are no explicit
5976 exception handlers.
5977
5978 @item No_Implicit_Conditionals
5979 @findex No_Implicit_Conditionals
5980 This restriction ensures that the generated code does not contain any
5981 implicit conditionals, either by modifying the generated code where possible,
5982 or by rejecting any construct that would otherwise generate an implicit
5983 conditional.  The details and use of this restriction are described in
5984 more detail in the High Integrity product documentation.
5985
5986 @item No_Implicit_Loops
5987 @findex No_Implicit_Loops
5988 This restriction ensures that the generated code does not contain any
5989 implicit @code{for} loops, either by modifying
5990 the generated code where possible,
5991 or by rejecting any construct that would otherwise generate an implicit
5992 @code{for} loop.  The details and use of this restriction are described in
5993 more detail in the High Integrity product documentation.
5994
5995 @item No_Local_Protected_Objects
5996 @findex No_Local_Protected_Objects
5997 This restriction ensures at compile time that protected objects are
5998 only declared at the library level.
5999
6000 @item No_Protected_Type_Allocators
6001 @findex No_Protected_Type_Allocators
6002 This restriction ensures at compile time that there are no allocator
6003 expressions that attempt to allocate protected objects.
6004
6005 @item No_Secondary_Stack
6006 @findex No_Secondary_Stack
6007 This restriction ensures at compile time that the generated code does not
6008 contain any reference to the secondary stack.  The secondary stack is used
6009 to implement functions returning unconstrained objects (arrays or records)
6010 on some targets.
6011 The details and use of this restriction are described in
6012 more detail in the High Integrity product documentation.
6013
6014 @item No_Select_Statements
6015 @findex No_Select_Statements
6016 This restriction ensures at compile time no select statements of any kind
6017 are permitted, that is the keyword @code{select} may not appear. 
6018 This is one of the restrictions of the Ravenscar
6019 profile for limited tasking (see also pragma @code{Ravenscar}).
6020
6021 @item No_Standard_Storage_Pools
6022 @findex No_Standard_Storage_Pools
6023 This restriction ensures at compile time that no access types
6024 use the standard default storage pool.  Any access type declared must
6025 have an explicit Storage_Pool attribute defined specifying a
6026 user-defined storage pool.
6027
6028 @item No_Streams
6029 @findex No_Streams
6030 This restriction ensures at compile time that there are no implicit or
6031 explicit dependencies on the package @code{Ada.Streams}.
6032
6033 @item No_Task_Attributes
6034 @findex No_Task_Attributes
6035 This restriction ensures at compile time that there are no implicit or
6036 explicit dependencies on the package @code{Ada.Task_Attributes}.
6037
6038 @item No_Task_Termination
6039 @findex No_Task_Termination
6040 This restriction ensures at compile time that no terminate alternatives
6041 appear in any task body.
6042
6043 @item No_Tasking
6044 @findex No_Tasking
6045 This restriction prevents the declaration of tasks or task types throughout
6046 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
6047 except that violations are caught at compile time and cause an error message
6048 to be output either by the compiler or binder.
6049
6050 @item No_Wide_Characters
6051 @findex No_Wide_Characters
6052 This restriction ensures at compile time that no uses of the types
6053 @code{Wide_Character} or @code{Wide_String}
6054 appear, and that no wide character literals
6055 appear in the program (that is literals representing characters not in
6056 type @code{Character}.
6057
6058 @item Static_Priorities
6059 @findex Static_Priorities
6060 This restriction ensures at compile time that all priority expressions
6061 are static, and that there are no dependencies on the package
6062 @code{Ada.Dynamic_Priorities}.
6063
6064 @item Static_Storage_Size
6065 @findex Static_Storage_Size
6066 This restriction ensures at compile time that any expression appearing
6067 in a Storage_Size pragma or attribute definition clause is static.
6068
6069 @end table
6070
6071 @noindent
6072 The second set of implementation dependent restriction identifiers
6073 does not require partition-wide consistency.
6074 The restriction may be enforced for a single
6075 compilation unit without any effect on any of the
6076 other compilation units in the partition.
6077
6078 @table @code
6079
6080 @item No_Elaboration_Code
6081 @findex No_Elaboration_Code
6082 This restriction ensures at compile time that no elaboration code is
6083 generated.  Note that this is not the same condition as is enforced
6084 by pragma @code{Preelaborate}.  There are cases in which pragma @code{Preelaborate}
6085 still permits code to be generated (e.g.@: code to initialize a large
6086 array to all zeroes), and there are cases of units which do not meet
6087 the requirements for pragma @code{Preelaborate}, but for which no elaboration
6088 code is generated.  Generally, it is the case that preelaborable units
6089 will meet the restrictions, with the exception of large aggregates
6090 initialized with an others_clause, and exception declarations (which
6091 generate calls to a run-time registry procedure).  Note that this restriction
6092 is enforced on a unit by unit basis, it need not be obeyed consistently
6093 throughout a partition.
6094
6095 @item No_Entry_Queue
6096 @findex No_Entry_Queue
6097 This restriction is a declaration that any protected entry compiled in
6098 the scope of the restriction has at most one task waiting on the entry
6099 at any one time, and so no queue is required.  This restriction is not
6100 checked at compile time.  A program execution is erroneous if an attempt
6101 is made to queue a second task on such an entry.
6102
6103 @item No_Implementation_Attributes
6104 @findex No_Implementation_Attributes
6105 This restriction checks at compile time that no GNAT-defined attributes
6106 are present.  With this restriction, the only attributes that can be used
6107 are those defined in the Ada 95 Reference Manual.
6108
6109 @item No_Implementation_Pragmas
6110 @findex No_Implementation_Pragmas
6111 This restriction checks at compile time that no GNAT-defined pragmas
6112 are present.  With this restriction, the only pragmas that can be used
6113 are those defined in the Ada 95 Reference Manual.
6114
6115 @item No_Implementation_Restrictions
6116 @findex No_Implementation_Restrictions
6117 This restriction checks at compile time that no GNAT-defined restriction
6118 identifiers (other than @code{No_Implementation_Restrictions} itself)
6119 are present.  With this restriction, the only other restriction identifiers
6120 that can be used are those defined in the Ada 95 Reference Manual.
6121
6122 @end table
6123
6124 @sp 1
6125 @cartouche
6126 @noindent
6127 @strong{58}.  The consequences of violating limitations on
6128 @code{Restrictions} pragmas.  See 13.12(9).
6129 @end cartouche
6130 @noindent
6131 Restrictions that can be checked at compile time result in illegalities
6132 if violated.  Currently there are no other consequences of violating
6133 restrictions.
6134
6135 @sp 1
6136 @cartouche
6137 @noindent
6138 @strong{59}.  The representation used by the @code{Read} and
6139 @code{Write} attributes of elementary types in terms of stream
6140 elements.  See 13.13.2(9).
6141 @end cartouche
6142 @noindent
6143 The representation is the in-memory representation of the base type of
6144 the type, using the number of bits corresponding to the
6145 @code{@var{type}'Size} value, and the natural ordering of the machine.
6146
6147 @sp 1
6148 @cartouche
6149 @noindent
6150 @strong{60}.  The names and characteristics of the numeric subtypes
6151 declared in the visible part of package @code{Standard}.  See A.1(3).
6152 @end cartouche
6153 @noindent
6154 See items describing the integer and floating-point types supported.
6155
6156 @sp 1
6157 @cartouche
6158 @noindent
6159 @strong{61}.  The accuracy actually achieved by the elementary
6160 functions.  See A.5.1(1).
6161 @end cartouche
6162 @noindent
6163 The elementary functions correspond to the functions available in the C
6164 library.  Only fast math mode is implemented.
6165
6166 @sp 1
6167 @cartouche
6168 @noindent
6169 @strong{62}.  The sign of a zero result from some of the operators or
6170 functions in @code{Numerics.Generic_Elementary_Functions}, when
6171 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
6172 @end cartouche
6173 @noindent
6174 The sign of zeroes follows the requirements of the IEEE 754 standard on
6175 floating-point.
6176
6177 @sp 1
6178 @cartouche
6179 @noindent
6180 @strong{63}.  The value of
6181 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
6182 @end cartouche
6183 @noindent
6184 Maximum image width is 649, see library file @file{a-numran.ads}.
6185
6186 @sp 1
6187 @cartouche
6188 @noindent
6189 @strong{64}.  The value of
6190 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
6191 @end cartouche
6192 @noindent
6193 Maximum image width is 80, see library file @file{a-nudira.ads}.
6194
6195 @sp 1
6196 @cartouche
6197 @noindent
6198 @strong{65}.  The algorithms for random number generation.  See
6199 A.5.2(32).
6200 @end cartouche
6201 @noindent
6202 The algorithm is documented in the source files @file{a-numran.ads} and
6203 @file{a-numran.adb}.
6204
6205 @sp 1
6206 @cartouche
6207 @noindent
6208 @strong{66}.  The string representation of a random number generator's
6209 state.  See A.5.2(38).
6210 @end cartouche
6211 @noindent
6212 See the documentation contained in the file @file{a-numran.adb}. 
6213
6214 @sp 1
6215 @cartouche
6216 @noindent
6217 @strong{67}.  The minimum time interval between calls to the
6218 time-dependent Reset procedure that are guaranteed to initiate different
6219 random number sequences.  See A.5.2(45).
6220 @end cartouche
6221 @noindent
6222 The minimum period between reset calls to guarantee distinct series of
6223 random numbers is one microsecond.
6224
6225 @sp 1
6226 @cartouche
6227 @noindent
6228 @strong{68}.  The values of the @code{Model_Mantissa},
6229 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
6230 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
6231 Annex is not supported.  See A.5.3(72).
6232 @end cartouche
6233 @noindent
6234 See the source file @file{ttypef.ads} for the values of all numeric
6235 attributes.
6236
6237 @sp 1
6238 @cartouche
6239 @noindent
6240 @strong{69}.  Any implementation-defined characteristics of the
6241 input-output packages.  See A.7(14).
6242 @end cartouche
6243 @noindent
6244 There are no special implementation defined characteristics for these
6245 packages.
6246
6247 @sp 1
6248 @cartouche
6249 @noindent
6250 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
6251 A.9(10).
6252 @end cartouche
6253 @noindent
6254 All type representations are contiguous, and the @code{Buffer_Size} is
6255 the value of @code{@var{type}'Size} rounded up to the next storage unit
6256 boundary.
6257
6258 @sp 1
6259 @cartouche
6260 @noindent
6261 @strong{71}.  External files for standard input, standard output, and
6262 standard error See A.10(5).
6263 @end cartouche
6264 @noindent
6265 These files are mapped onto the files provided by the C streams
6266 libraries.  See source file @file{i-cstrea.ads} for further details.
6267
6268 @sp 1
6269 @cartouche
6270 @noindent
6271 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
6272 A.10.9(36).
6273 @end cartouche
6274 @noindent
6275 If more digits are requested in the output than are represented by the
6276 precision of the value, zeroes are output in the corresponding least
6277 significant digit positions.
6278
6279 @sp 1
6280 @cartouche
6281 @noindent
6282 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
6283 @code{Command_Name}.  See A.15(1).
6284 @end cartouche
6285 @noindent
6286 These are mapped onto the @code{argv} and @code{argc} parameters of the
6287 main program in the natural manner.
6288
6289 @sp 1
6290 @cartouche
6291 @noindent
6292 @strong{74}.  Implementation-defined convention names.  See B.1(11).
6293 @end cartouche
6294 @noindent
6295 The following convention names are supported
6296
6297 @table @code
6298 @item  Ada
6299 Ada
6300 @item Assembler 
6301 Assembly language 
6302 @item Asm 
6303 Synonym for Assembler
6304 @item Assembly 
6305 Synonym for Assembler
6306 @item C
6307 C
6308 @item C_Pass_By_Copy
6309 Allowed only for record types, like C, but also notes that record
6310 is to be passed by copy rather than reference.
6311 @item COBOL 
6312 COBOL 
6313 @item CPP 
6314 C++ 
6315 @item Default
6316 Treated the same as C
6317 @item External
6318 Treated the same as C
6319 @item Fortran 
6320 Fortran 
6321 @item Intrinsic 
6322 For support of pragma @code{Import} with convention Intrinsic, see
6323 separate section on Intrinsic Subprograms.
6324 @item Stdcall 
6325 Stdcall (used for Windows implementations only).  This convention correspond
6326 to the WINAPI (previously called Pascal convention) C/C++ convention under
6327 Windows.  A function with this convention cleans the stack before exit.
6328 @item DLL
6329 Synonym for Stdcall
6330 @item Win32
6331 Synonym for Stdcall
6332 @item Stubbed
6333 Stubbed is a special convention used to indicate that the body of the
6334 subprogram will be entirely ignored.  Any call to the subprogram
6335 is converted into a raise of the @code{Program_Error} exception.  If a
6336 pragma @code{Import} specifies convention @code{stubbed} then no body need
6337 be present at all.  This convention is useful during development for the
6338 inclusion of subprograms whose body has not yet been written.
6339
6340 @end table
6341 @noindent
6342 In addition, all otherwise unrecognized convention names are also
6343 treated as being synonymous with convention C@.  In all implementations
6344 except for VMS, use of such other names results in a warning.  In VMS
6345 implementations, these names are accepted silently.
6346
6347 @sp 1
6348 @cartouche
6349 @noindent
6350 @strong{75}.  The meaning of link names.  See B.1(36).
6351 @end cartouche
6352 @noindent
6353 Link names are the actual names used by the linker.
6354
6355 @sp 1
6356 @cartouche
6357 @noindent
6358 @strong{76}.  The manner of choosing link names when neither the link
6359 name nor the address of an imported or exported entity is specified.  See
6360 B.1(36).
6361 @end cartouche
6362 @noindent
6363 The default linker name is that which would be assigned by the relevant
6364 external language, interpreting the Ada name as being in all lower case
6365 letters.
6366
6367 @sp 1
6368 @cartouche
6369 @noindent
6370 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
6371 @end cartouche
6372 @noindent
6373 The string passed to @code{Linker_Options} is presented uninterpreted as
6374 an argument to the link command, unless it contains Ascii.NUL characters.
6375 NUL characters if they appear act as argument separators, so for example
6376
6377 @smallexample
6378 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
6379 @end smallexample
6380
6381 @noindent
6382 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
6383 linker. The order of linker options is preserved for a given unit. The final
6384 list of options passed to the linker is in reverse order of the elaboration
6385 order. For example, linker options fo a body always appear before the options
6386 from the corresponding package spec.
6387
6388 @sp 1
6389 @cartouche
6390 @noindent
6391 @strong{78}.  The contents of the visible part of package
6392 @code{Interfaces} and its language-defined descendants.  See B.2(1).
6393 @end cartouche
6394 @noindent
6395 See files with prefix @file{i-} in the distributed library.
6396
6397 @sp 1
6398 @cartouche
6399 @noindent
6400 @strong{79}.  Implementation-defined children of package
6401 @code{Interfaces}.  The contents of the visible part of package
6402 @code{Interfaces}.  See B.2(11).
6403 @end cartouche
6404 @noindent
6405 See files with prefix @file{i-} in the distributed library.
6406
6407 @sp 1
6408 @cartouche
6409 @noindent
6410 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
6411 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
6412 @code{COBOL_Character}; and the initialization of the variables
6413 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
6414 @code{Interfaces.COBOL}.  See B.4(50).
6415 @end cartouche
6416 @noindent
6417 @table @code
6418 @item Floating
6419 Float
6420 @item Long_Floating 
6421 (Floating) Long_Float 
6422 @item Binary 
6423 Integer 
6424 @item Long_Binary 
6425 Long_Long_Integer 
6426 @item Decimal_Element 
6427 Character 
6428 @item COBOL_Character 
6429 Character 
6430 @end table
6431
6432 For initialization, see the file @file{i-cobol.ads} in the distributed library.
6433
6434 @sp 1
6435 @cartouche
6436 @noindent
6437 @strong{81}.  Support for access to machine instructions.  See C.1(1).
6438 @end cartouche
6439 @noindent
6440 See documentation in file @file{s-maccod.ads} in the distributed library.
6441
6442 @sp 1
6443 @cartouche
6444 @noindent
6445 @strong{82}.  Implementation-defined aspects of access to machine
6446 operations.  See C.1(9).
6447 @end cartouche
6448 @noindent
6449 See documentation in file @file{s-maccod.ads} in the distributed library.
6450
6451 @sp 1
6452 @cartouche
6453 @noindent
6454 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
6455 @end cartouche
6456 @noindent
6457 Interrupts are mapped to signals or conditions as appropriate.  See
6458 definition of unit
6459 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
6460 on the interrupts supported on a particular target.
6461
6462 @sp 1
6463 @cartouche
6464 @noindent
6465 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
6466 C.4(13).
6467 @end cartouche
6468 @noindent
6469 GNAT does not permit a partition to be restarted without reloading,
6470 except under control of the debugger.
6471
6472 @sp 1
6473 @cartouche
6474 @noindent
6475 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
6476 @end cartouche
6477 @noindent
6478 Pragma @code{Discard_Names} causes names of enumeration literals to
6479 be suppressed.  In the presence of this pragma, the Image attribute 
6480 provides the image of the Pos of the literal, and Value accepts
6481 Pos values.
6482
6483 @sp 1
6484 @cartouche
6485 @noindent
6486 @strong{86}.  The result of the @code{Task_Identification.Image}
6487 attribute.  See C.7.1(7).
6488 @end cartouche
6489 @noindent
6490 The result of this attribute is an 8-digit hexadecimal string
6491 representing the virtual address of the task control block.
6492
6493 @sp 1
6494 @cartouche
6495 @noindent
6496 @strong{87}.  The value of @code{Current_Task} when in a protected entry
6497 or interrupt handler.  See C.7.1(17).
6498 @end cartouche
6499 @noindent
6500 Protected entries or interrupt handlers can be executed by any
6501 convenient thread, so the value of @code{Current_Task} is undefined.
6502
6503 @sp 1
6504 @cartouche
6505 @noindent
6506 @strong{88}.  The effect of calling @code{Current_Task} from an entry
6507 body or interrupt handler.  See C.7.1(19).
6508 @end cartouche
6509 @noindent
6510 The effect of calling @code{Current_Task} from an entry body or
6511 interrupt handler is to return the identification of the task currently
6512 executing the code.
6513
6514 @sp 1
6515 @cartouche
6516 @noindent
6517 @strong{89}.  Implementation-defined aspects of
6518 @code{Task_Attributes}.  See C.7.2(19).
6519 @end cartouche
6520 @noindent
6521 There are no implementation-defined aspects of @code{Task_Attributes}.
6522
6523 @sp 1
6524 @cartouche
6525 @noindent
6526 @strong{90}.  Values of all @code{Metrics}.  See D(2).
6527 @end cartouche
6528 @noindent
6529 The metrics information for GNAT depends on the performance of the
6530 underlying operating system.  The sources of the run-time for tasking
6531 implementation, together with the output from @code{-gnatG} can be
6532 used to determine the exact sequence of operating systems calls made
6533 to implement various tasking constructs.  Together with appropriate
6534 information on the performance of the underlying operating system,
6535 on the exact target in use, this information can be used to determine
6536 the required metrics.
6537
6538 @sp 1
6539 @cartouche
6540 @noindent
6541 @strong{91}.  The declarations of @code{Any_Priority} and
6542 @code{Priority}.  See D.1(11).
6543 @end cartouche
6544 @noindent
6545 See declarations in file @file{system.ads}.
6546
6547 @sp 1
6548 @cartouche
6549 @noindent
6550 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
6551 @end cartouche
6552 @noindent
6553 There are no implementation-defined execution resources.
6554
6555 @sp 1
6556 @cartouche
6557 @noindent
6558 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
6559 access to a protected object keeps its processor busy.  See D.2.1(3).
6560 @end cartouche
6561 @noindent
6562 On a multi-processor, a task that is waiting for access to a protected
6563 object does not keep its processor busy.
6564
6565 @sp 1
6566 @cartouche
6567 @noindent
6568 @strong{94}.  The affect of implementation defined execution resources
6569 on task dispatching.  See D.2.1(9).
6570 @end cartouche
6571 @noindent
6572 @c SGI info
6573 @ignore
6574 Tasks map to IRIX threads, and the dispatching policy is as defined by
6575 the IRIX implementation of threads.
6576 @end ignore
6577 Tasks map to threads in the threads package used by GNAT@.  Where possible
6578 and appropriate, these threads correspond to native threads of the
6579 underlying operating system.
6580
6581 @sp 1
6582 @cartouche
6583 @noindent
6584 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
6585 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
6586 @end cartouche
6587 @noindent
6588 There are no implementation-defined policy-identifiers allowed in this
6589 pragma.
6590
6591 @sp 1
6592 @cartouche
6593 @noindent
6594 @strong{96}.  Implementation-defined aspects of priority inversion.  See
6595 D.2.2(16).
6596 @end cartouche
6597 @noindent
6598 Execution of a task cannot be preempted by the implementation processing
6599 of delay expirations for lower priority tasks.
6600
6601 @sp 1
6602 @cartouche
6603 @noindent
6604 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
6605 @end cartouche
6606 @noindent
6607 @c SGI info:
6608 @ignore
6609 Tasks map to IRIX threads, and the dispatching policy is as defied by
6610 the IRIX implementation of threads.
6611 @end ignore
6612 The policy is the same as that of the underlying threads implementation.
6613
6614 @sp 1
6615 @cartouche
6616 @noindent
6617 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
6618 in a pragma @code{Locking_Policy}.  See D.3(4).
6619 @end cartouche
6620 @noindent
6621 The only implementation defined policy permitted in GNAT is
6622 @code{Inheritance_Locking}.  On targets that support this policy, locking
6623 is implemented by inheritance, i.e.@: the task owning the lock operates
6624 at a priority equal to the highest priority of any task currently
6625 requesting the lock.
6626
6627 @sp 1
6628 @cartouche
6629 @noindent
6630 @strong{99}.  Default ceiling priorities.  See D.3(10).
6631 @end cartouche
6632 @noindent
6633 The ceiling priority of protected objects of the type
6634 @code{System.Interrupt_Priority'Last} as described in the Ada 95
6635 Reference Manual D.3(10),
6636
6637 @sp 1
6638 @cartouche
6639 @noindent
6640 @strong{100}.  The ceiling of any protected object used internally by
6641 the implementation.  See D.3(16).
6642 @end cartouche
6643 @noindent
6644 The ceiling priority of internal protected objects is
6645 @code{System.Priority'Last}.
6646
6647 @sp 1
6648 @cartouche
6649 @noindent
6650 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
6651 @end cartouche
6652 @noindent
6653 There are no implementation-defined queueing policies. 
6654
6655 @sp 1
6656 @cartouche
6657 @noindent
6658 @strong{102}.  On a multiprocessor, any conditions that cause the
6659 completion of an aborted construct to be delayed later than what is
6660 specified for a single processor.  See D.6(3).
6661 @end cartouche
6662 @noindent
6663 The semantics for abort on a multi-processor is the same as on a single
6664 processor, there are no further delays.
6665
6666 @sp 1
6667 @cartouche
6668 @noindent
6669 @strong{103}.  Any operations that implicitly require heap storage
6670 allocation.  See D.7(8).
6671 @end cartouche
6672 @noindent
6673 The only operation that implicitly requires heap storage allocation is
6674 task creation.
6675
6676 @sp 1
6677 @cartouche
6678 @noindent
6679 @strong{104}.  Implementation-defined aspects of pragma
6680 @code{Restrictions}.  See D.7(20).
6681 @end cartouche
6682 @noindent
6683 There are no such implementation-defined aspects. 
6684
6685 @sp 1
6686 @cartouche
6687 @noindent
6688 @strong{105}.  Implementation-defined aspects of package
6689 @code{Real_Time}.  See D.8(17).
6690 @end cartouche
6691 @noindent
6692 There are no implementation defined aspects of package @code{Real_Time}.
6693
6694 @sp 1
6695 @cartouche
6696 @noindent
6697 @strong{106}.  Implementation-defined aspects of
6698 @code{delay_statements}.  See D.9(8).
6699 @end cartouche
6700 @noindent
6701 Any difference greater than one microsecond will cause the task to be
6702 delayed (see D.9(7)).
6703
6704 @sp 1
6705 @cartouche
6706 @noindent
6707 @strong{107}.  The upper bound on the duration of interrupt blocking
6708 caused by the implementation.  See D.12(5).
6709 @end cartouche
6710 @noindent
6711 The upper bound is determined by the underlying operating system.  In
6712 no cases is it more than 10 milliseconds.
6713
6714 @sp 1
6715 @cartouche
6716 @noindent
6717 @strong{108}.  The means for creating and executing distributed
6718 programs.  See E(5).
6719 @end cartouche
6720 @noindent
6721 The GLADE package provides a utility GNATDIST for creating and executing
6722 distributed programs.  See the GLADE reference manual for further details.
6723
6724 @sp 1
6725 @cartouche
6726 @noindent
6727 @strong{109}.  Any events that can result in a partition becoming
6728 inaccessible.  See E.1(7).
6729 @end cartouche
6730 @noindent
6731 See the GLADE reference manual for full details on such events.
6732
6733 @sp 1
6734 @cartouche
6735 @noindent
6736 @strong{110}.  The scheduling policies, treatment of priorities, and
6737 management of shared resources between partitions in certain cases.  See
6738 E.1(11).
6739 @end cartouche
6740 @noindent
6741 See the GLADE reference manual for full details on these aspects of
6742 multi-partition execution.
6743
6744 @sp 1
6745 @cartouche
6746 @noindent
6747 @strong{111}.  Events that cause the version of a compilation unit to
6748 change.  See E.3(5).
6749 @end cartouche
6750 @noindent
6751 Editing the source file of a compilation unit, or the source files of
6752 any units on which it is dependent in a significant way cause the version
6753 to change.  No other actions cause the version number to change.  All changes
6754 are significant except those which affect only layout, capitalization or
6755 comments.
6756
6757 @sp 1
6758 @cartouche
6759 @noindent
6760 @strong{112}.  Whether the execution of the remote subprogram is
6761 immediately aborted as a result of cancellation.  See E.4(13).
6762 @end cartouche
6763 @noindent
6764 See the GLADE reference manual for details on the effect of abort in
6765 a distributed application.
6766
6767 @sp 1
6768 @cartouche
6769 @noindent
6770 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
6771 @end cartouche
6772 @noindent
6773 See the GLADE reference manual for a full description of all implementation
6774 defined aspects of the PCS@.
6775
6776 @sp 1
6777 @cartouche
6778 @noindent
6779 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
6780 E.5(26).
6781 @end cartouche
6782 @noindent
6783 See the GLADE reference manual for a full description of all
6784 implementation defined interfaces.
6785
6786 @sp 1
6787 @cartouche
6788 @noindent
6789 @strong{115}.  The values of named numbers in the package
6790 @code{Decimal}.  See F.2(7).
6791 @end cartouche
6792 @noindent
6793 @table @code
6794 @item Max_Scale
6795 +18
6796 @item Min_Scale
6797 -18
6798 @item Min_Delta
6799 1.0E-18
6800 @item Max_Delta
6801 1.0E+18
6802 @item Max_Decimal_Digits
6803 18
6804 @end table
6805
6806 @sp 1
6807 @cartouche
6808 @noindent
6809 @strong{116}.  The value of @code{Max_Picture_Length} in the package
6810 @code{Text_IO.Editing}.  See F.3.3(16).
6811 @end cartouche
6812 @noindent
6813 64
6814
6815 @sp 1
6816 @cartouche
6817 @noindent
6818 @strong{117}.  The value of @code{Max_Picture_Length} in the package
6819 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
6820 @end cartouche
6821 @noindent
6822 64
6823
6824 @sp 1
6825 @cartouche
6826 @noindent
6827 @strong{118}.  The accuracy actually achieved by the complex elementary
6828 functions and by other complex arithmetic operations.  See G.1(1).
6829 @end cartouche
6830 @noindent
6831 Standard library functions are used for the complex arithmetic
6832 operations.  Only fast math mode is currently supported.
6833
6834 @sp 1
6835 @cartouche
6836 @noindent
6837 @strong{119}.  The sign of a zero result (or a component thereof) from
6838 any operator or function in @code{Numerics.Generic_Complex_Types}, when
6839 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
6840 @end cartouche
6841 @noindent
6842 The signs of zero values are as recommended by the relevant
6843 implementation advice.
6844
6845 @sp 1
6846 @cartouche
6847 @noindent
6848 @strong{120}.  The sign of a zero result (or a component thereof) from
6849 any operator or function in
6850 @code{Numerics.Generic_Complex_Elementary_Functions}, when
6851 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
6852 @end cartouche
6853 @noindent
6854 The signs of zero values are as recommended by the relevant
6855 implementation advice.
6856
6857 @sp 1
6858 @cartouche
6859 @noindent
6860 @strong{121}.  Whether the strict mode or the relaxed mode is the
6861 default.  See G.2(2).
6862 @end cartouche
6863 @noindent
6864 The strict mode is the default.  There is no separate relaxed mode.  GNAT
6865 provides a highly efficient implementation of strict mode.
6866
6867 @sp 1
6868 @cartouche
6869 @noindent
6870 @strong{122}.  The result interval in certain cases of fixed-to-float
6871 conversion.  See G.2.1(10).
6872 @end cartouche
6873 @noindent
6874 For cases where the result interval is implementation dependent, the
6875 accuracy is that provided by performing all operations in 64-bit IEEE
6876 floating-point format.
6877
6878 @sp 1
6879 @cartouche
6880 @noindent
6881 @strong{123}.  The result of a floating point arithmetic operation in
6882 overflow situations, when the @code{Machine_Overflows} attribute of the
6883 result type is @code{False}.  See G.2.1(13).
6884 @end cartouche
6885 @noindent
6886 Infinite and Nan values are produced as dictated by the IEEE
6887 floating-point standard.
6888
6889 @sp 1
6890 @cartouche
6891 @noindent
6892 @strong{124}.  The result interval for division (or exponentiation by a
6893 negative exponent), when the floating point hardware implements division
6894 as multiplication by a reciprocal.  See G.2.1(16).
6895 @end cartouche
6896 @noindent
6897 Not relevant, division is IEEE exact. 
6898
6899 @sp 1
6900 @cartouche
6901 @noindent
6902 @strong{125}.  The definition of close result set, which determines the
6903 accuracy of certain fixed point multiplications and divisions.  See
6904 G.2.3(5).
6905 @end cartouche
6906 @noindent
6907 Operations in the close result set are performed using IEEE long format
6908 floating-point arithmetic.  The input operands are converted to
6909 floating-point, the operation is done in floating-point, and the result
6910 is converted to the target type.
6911
6912 @sp 1
6913 @cartouche
6914 @noindent
6915 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
6916 point multiplication or division for which the result shall be in the
6917 perfect result set.  See G.2.3(22).
6918 @end cartouche
6919 @noindent
6920 The result is only defined to be in the perfect result set if the result
6921 can be computed by a single scaling operation involving a scale factor
6922 representable in 64-bits.
6923
6924 @sp 1
6925 @cartouche
6926 @noindent
6927 @strong{127}.  The result of a fixed point arithmetic operation in
6928 overflow situations, when the @code{Machine_Overflows} attribute of the
6929 result type is @code{False}.  See G.2.3(27).
6930 @end cartouche
6931 @noindent
6932 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
6933 types.
6934
6935 @sp 1
6936 @cartouche
6937 @noindent
6938 @strong{128}.  The result of an elementary function reference in
6939 overflow situations, when the @code{Machine_Overflows} attribute of the
6940 result type is @code{False}.  See G.2.4(4).
6941 @end cartouche
6942 @noindent
6943 IEEE infinite and Nan values are produced as appropriate.
6944
6945 @sp 1
6946 @cartouche
6947 @noindent
6948 @strong{129}.  The value of the angle threshold, within which certain
6949 elementary functions, complex arithmetic operations, and complex
6950 elementary functions yield results conforming to a maximum relative
6951 error bound.  See G.2.4(10).
6952 @end cartouche
6953 @noindent
6954 Information on this subject is not yet available.
6955
6956 @sp 1
6957 @cartouche
6958 @noindent
6959 @strong{130}.  The accuracy of certain elementary functions for
6960 parameters beyond the angle threshold.  See G.2.4(10).
6961 @end cartouche
6962 @noindent
6963 Information on this subject is not yet available.
6964
6965 @sp 1
6966 @cartouche
6967 @noindent
6968 @strong{131}.  The result of a complex arithmetic operation or complex
6969 elementary function reference in overflow situations, when the
6970 @code{Machine_Overflows} attribute of the corresponding real type is
6971 @code{False}.  See G.2.6(5).
6972 @end cartouche
6973 @noindent
6974 IEEE infinite and Nan values are produced as appropriate. 
6975
6976 @sp 1
6977 @cartouche
6978 @noindent
6979 @strong{132}.  The accuracy of certain complex arithmetic operations and
6980 certain complex elementary functions for parameters (or components
6981 thereof) beyond the angle threshold.  See G.2.6(8).
6982 @end cartouche
6983 @noindent
6984 Information on those subjects is not yet available.
6985
6986 @sp 1
6987 @cartouche
6988 @noindent
6989 @strong{133}.  Information regarding bounded errors and erroneous
6990 execution.  See H.2(1).
6991 @end cartouche
6992 @noindent
6993 Information on this subject is not yet available.
6994
6995 @sp 1
6996 @cartouche
6997 @noindent
6998 @strong{134}.  Implementation-defined aspects of pragma
6999 @code{Inspection_Point}.  See H.3.2(8).
7000 @end cartouche
7001 @noindent
7002 Pragma @code{Inspection_Point} ensures that the variable is live and can
7003 be examined by the debugger at the inspection point.
7004
7005 @sp 1
7006 @cartouche
7007 @noindent
7008 @strong{135}.  Implementation-defined aspects of pragma
7009 @code{Restrictions}.  See H.4(25).
7010 @end cartouche
7011 @noindent
7012 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
7013 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
7014 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
7015
7016 @sp 1
7017 @cartouche
7018 @noindent
7019 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
7020 H.4(27).
7021 @end cartouche
7022 @noindent
7023 There are no restrictions on pragma @code{Restrictions}.
7024
7025 @node Intrinsic Subprograms
7026 @chapter Intrinsic Subprograms
7027 @cindex Intrinsic Subprograms
7028
7029 @menu
7030 * Intrinsic Operators::
7031 * Enclosing_Entity::
7032 * Exception_Information::
7033 * Exception_Message::
7034 * Exception_Name::
7035 * File::
7036 * Line::
7037 * Rotate_Left::
7038 * Rotate_Right::
7039 * Shift_Left::
7040 * Shift_Right::
7041 * Shift_Right_Arithmetic::
7042 * Source_Location::
7043 @end menu
7044
7045 GNAT allows a user application program to write the declaration:
7046
7047 @smallexample
7048    pragma Import (Intrinsic, name);
7049 @end smallexample
7050
7051 @noindent
7052 providing that the name corresponds to one of the implemented intrinsic
7053 subprograms in GNAT, and that the parameter profile of the referenced
7054 subprogram meets the requirements.  This chapter describes the set of
7055 implemented intrinsic subprograms, and the requirements on parameter profiles.
7056 Note that no body is supplied; as with other uses of pragma Import, the
7057 body is supplied elsewhere (in this case by the compiler itself).  Note
7058 that any use of this feature is potentially non-portable, since the
7059 Ada standard does not require Ada compilers to implement this feature.
7060
7061 @node Intrinsic Operators
7062 @section Intrinsic Operators
7063 @cindex Intrinsic operator
7064
7065 @noindent
7066 All the predefined numeric operators in package Standard
7067 in @code{pragma Import (Intrinsic,..)}
7068 declarations.  In the binary operator case, the operands must have the same
7069 size.  The operand or operands must also be appropriate for
7070 the operator.  For example, for addition, the operands must 
7071 both be floating-point or both be fixed-point, and the
7072 right operand for @code{"**"} must have a root type of
7073 @code{Standard.Integer'Base}.
7074 You can use an intrinsic operator declaration as in the following example:
7075
7076 @smallexample
7077    type Int1 is new Integer;
7078    type Int2 is new Integer;
7079
7080    function "+" (X1 : Int1; X2 : Int2) return Int1;
7081    function "+" (X1 : Int1; X2 : Int2) return Int2;
7082    pragma Import (Intrinsic, "+");
7083 @end smallexample
7084
7085 @noindent
7086 This declaration would permit ``mixed mode'' arithmetic on items
7087 of the differing types @code{Int1} and @code{Int2}.
7088 It is also possible to specify such operators for private types, if the
7089 full views are appropriate arithmetic types.
7090
7091 @node Enclosing_Entity
7092 @section Enclosing_Entity
7093 @cindex Enclosing_Entity
7094 @noindent
7095 This intrinsic subprogram is used in the implementation of the
7096 library routine @code{GNAT.Source_Info}.  The only useful use of the
7097 intrinsic import in this case is the one in this unit, so an
7098 application program should simply call the function
7099 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
7100 the current subprogram, package, task, entry, or protected subprogram.
7101
7102 @node Exception_Information
7103 @section Exception_Information
7104 @cindex Exception_Information'
7105 @noindent
7106 This intrinsic subprogram is used in the implementation of the
7107 library routine @code{GNAT.Current_Exception}.  The only useful
7108 use of the intrinsic import in this case is the one in this unit,
7109 so an application program should simply call the function
7110 @code{GNAT.Current_Exception.Exception_Information} to obtain
7111 the exception information associated with the current exception.
7112
7113 @node Exception_Message
7114 @section Exception_Message
7115 @cindex Exception_Message
7116 @noindent
7117 This intrinsic subprogram is used in the implementation of the
7118 library routine @code{GNAT.Current_Exception}.  The only useful
7119 use of the intrinsic import in this case is the one in this unit,
7120 so an application program should simply call the function
7121 @code{GNAT.Current_Exception.Exception_Message} to obtain
7122 the message associated with the current exception.
7123
7124 @node Exception_Name
7125 @section Exception_Name
7126 @cindex Exception_Name
7127 @noindent
7128 This intrinsic subprogram is used in the implementation of the
7129 library routine @code{GNAT.Current_Exception}.  The only useful
7130 use of the intrinsic import in this case is the one in this unit,
7131 so an application program should simply call the function
7132 @code{GNAT.Current_Exception.Exception_Name} to obtain
7133 the name of the current exception.
7134
7135 @node File
7136 @section File
7137 @cindex File
7138 @noindent
7139 This intrinsic subprogram is used in the implementation of the
7140 library routine @code{GNAT.Source_Info}.  The only useful use of the
7141 intrinsic import in this case is the one in this unit, so an
7142 application program should simply call the function
7143 @code{GNAT.Source_Info.File} to obtain the name of the current
7144 file.
7145
7146 @node Line
7147 @section Line
7148 @cindex Line
7149 @noindent
7150 This intrinsic subprogram is used in the implementation of the
7151 library routine @code{GNAT.Source_Info}.  The only useful use of the
7152 intrinsic import in this case is the one in this unit, so an
7153 application program should simply call the function
7154 @code{GNAT.Source_Info.Line} to obtain the number of the current
7155 source line.
7156
7157 @node Rotate_Left
7158 @section Rotate_Left
7159 @cindex Rotate_Left
7160 @noindent
7161 In standard Ada 95, the @code{Rotate_Left} function is available only
7162 for the predefined modular types in package @code{Interfaces}.  However, in
7163 GNAT it is possible to define a Rotate_Left function for a user
7164 defined modular type or any signed integer type as in this example:
7165
7166 @smallexample
7167    function Shift_Left
7168      (Value  : My_Modular_Type;
7169       Amount : Natural)
7170       return   My_Modular_Type;
7171 @end smallexample
7172
7173 @noindent
7174 The requirements are that the profile be exactly as in the example
7175 above.  The only modifications allowed are in the formal parameter
7176 names, and in the type of @code{Value} and the return type, which
7177 must be the same, and must be either a signed integer type, or
7178 a modular integer type with a binary modulus, and the size must
7179 be 8.  16, 32 or 64 bits.
7180
7181 @node Rotate_Right
7182 @section Rotate_Right
7183 @cindex Rotate_Right
7184 @noindent
7185 A @code{Rotate_Right} function can be defined for any user defined
7186 binary modular integer type, or signed integer type, as described
7187 above for @code{Rotate_Left}.
7188
7189 @node Shift_Left
7190 @section Shift_Left
7191 @cindex Shift_Left
7192 @noindent
7193 A @code{Shift_Left} function can be defined for any user defined
7194 binary modular integer type, or signed integer type, as described
7195 above for @code{Rotate_Left}.
7196
7197 @node Shift_Right
7198 @section Shift_Right
7199 @cindex Shift_Right
7200 @noindent
7201 A @code{Shift_Right} function can be defined for any user defined
7202 binary modular integer type, or signed integer type, as described
7203 above for @code{Rotate_Left}.
7204
7205 @node Shift_Right_Arithmetic
7206 @section Shift_Right_Arithmetic
7207 @cindex Shift_Right_Arithmetic
7208 @noindent
7209 A @code{Shift_Right_Arithmetic} function can be defined for any user
7210 defined binary modular integer type, or signed integer type, as described
7211 above for @code{Rotate_Left}.
7212
7213 @node Source_Location
7214 @section Source_Location
7215 @cindex Source_Location
7216 @noindent
7217 This intrinsic subprogram is used in the implementation of the
7218 library routine @code{GNAT.Source_Info}.  The only useful use of the
7219 intrinsic import in this case is the one in this unit, so an
7220 application program should simply call the function
7221 @code{GNAT.Source_Info.Source_Location} to obtain the current
7222 source file location.
7223
7224 @node Representation Clauses and Pragmas
7225 @chapter Representation Clauses and Pragmas
7226 @cindex Representation Clauses
7227
7228 @menu
7229 * Alignment Clauses::
7230 * Size Clauses::
7231 * Storage_Size Clauses::
7232 * Size of Variant Record Objects::
7233 * Biased Representation ::
7234 * Value_Size and Object_Size Clauses::
7235 * Component_Size Clauses::
7236 * Bit_Order Clauses::
7237 * Effect of Bit_Order on Byte Ordering::
7238 * Pragma Pack for Arrays::
7239 * Pragma Pack for Records::
7240 * Record Representation Clauses::
7241 * Enumeration Clauses::
7242 * Address Clauses::
7243 * Effect of Convention on Representation::
7244 * Determining the Representations chosen by GNAT::
7245 @end menu
7246
7247 @noindent
7248 @cindex Representation Clause
7249 @cindex Representation Pragma
7250 @cindex Pragma, representation
7251 This section describes the representation clauses accepted by GNAT, and
7252 their effect on the representation of corresponding data objects.
7253
7254 GNAT fully implements Annex C (Systems Programming).  This means that all
7255 the implementation advice sections in chapter 13 are fully implemented.
7256 However, these sections only require a minimal level of support for
7257 representation clauses.  GNAT provides much more extensive capabilities,
7258 and this section describes the additional capabilities provided.
7259
7260 @node Alignment Clauses
7261 @section Alignment Clauses
7262 @cindex Alignment Clause
7263
7264 @noindent
7265 GNAT requires that all alignment clauses specify a power of 2, and all
7266 default alignments are always a power of 2.  The default alignment
7267 values are as follows:
7268
7269 @itemize @bullet
7270 @item Primitive Types
7271 For primitive types, the alignment is the maximum of the actual size of
7272 objects of the type, and the maximum alignment supported by the target.
7273 For example, for type Long_Float, the object size is 8 bytes, and the
7274 default alignment will be 8 on any target that supports alignments
7275 this large, but on some targets, the maximum alignment may be smaller
7276 than 8, in which case objects of type Long_Float will be maximally
7277 aligned.
7278
7279 @item Arrays
7280 For arrays, the alignment is equal to the alignment of the component type
7281 for the normal case where no packing or component size is given.  If the
7282 array is packed, and the packing is effective (see separate section on
7283 packed arrays), then the alignment will be one for long packed arrays,
7284 or arrays whose length is not known at compile time.  For short packed
7285 arrays, which are handled internally as modular types, the alignment
7286 will be as described for primitive types, e.g.@: a packed array of length
7287 31 bits will have an object size of four bytes, and an alignment of 4.
7288
7289 @item Records
7290 For the normal non-packed case, the alignment of a record is equal to
7291 the maximum alignment of any of its components.  For tagged records, this
7292 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
7293 used and all fields are packable (see separate section on pragma @code{Pack}),
7294 then the resulting alignment is 1.
7295
7296 A special case is when the size of the record is given explicitly, or a
7297 full record representation clause is given, and the size of the record
7298 is 2, 4, or 8 bytes. In this case, an alignment is chosen to match the
7299 size of the record. For example, if we have:
7300
7301 @smallexample
7302    type Small is record
7303       A, B : Character;
7304    end record;
7305 @end smallexample
7306
7307 @noindent
7308 then the default alignment of the record type @code{Small} is 2, not 1. This
7309 leads to more efficient code when the record is treated as a unit, and also
7310 allows the type to specified as @code{Atomic} on architectures requiring
7311 strict alignment.
7312
7313 @end itemize
7314
7315 @noindent
7316 An alignment clause may
7317 always specify a larger alignment than the default value, up to some
7318 maximum value dependent on the target (obtainable by using the
7319 attribute reference System'Maximum_Alignment).  The only case in which
7320 it is permissible to specify a smaller alignment than the default value
7321 is in the case of a record for which a record representation clause is
7322 given.  In this case, packable fields for which a component clause is
7323 given still result in a default alignment corresponding to the original
7324 type, but this may be overridden, since these components in fact only
7325 require an alignment of one byte.  For example, given
7326
7327 @smallexample
7328   type v is record
7329      a : integer;
7330   end record;
7331
7332   for v use record
7333      a at 0  range 0 .. 31;
7334   end record;
7335
7336   for v'alignment use 1;
7337 @end smallexample
7338
7339 @noindent
7340 @cindex Alignment, default
7341 The default alignment for the type @code{v} is 4, as a result of the
7342 integer field in the record, but since this field is placed with a
7343 component clause, it is permissible, as shown, to override the default
7344 alignment of the record to a smaller value.
7345
7346 @node Size Clauses
7347 @section Size Clauses
7348 @cindex Size Clause
7349
7350 @noindent
7351 The default size of types is as specified in the reference manual.  For
7352 objects, GNAT will generally increase the type size so that the object
7353 size is a multiple of storage units, and also a multiple of the
7354 alignment.  For example
7355
7356 @smallexample
7357    type Smallint is range 1 .. 6;
7358
7359    type Rec is record
7360       y1 : integer;
7361       y2 : boolean;
7362    end record;
7363 @end smallexample
7364
7365 @noindent
7366 In this example, @code{Smallint}
7367 has a size of 3, as specified by the RM rules,
7368 but objects of this type will have a size of 8, 
7369 since objects by default occupy an integral number
7370 of storage units.  On some targets, notably older
7371 versions of the Digital Alpha, the size of stand
7372 alone objects of this type may be 32, reflecting
7373 the inability of the hardware to do byte load/stores.
7374
7375 Similarly, the size of type @code{Rec} is 40 bits, but
7376 the alignment is 4, so objects of this type will have
7377 their size increased to 64 bits so that it is a multiple
7378 of the alignment.  The reason for this decision, which is
7379 in accordance with the specific note in RM 13.3(43):
7380
7381 @smallexample
7382 A Size clause should be supported for an object if the specified
7383 Size is at least as large as its subtype's Size, and corresponds
7384 to a size in storage elements that is a multiple of the object's
7385 Alignment (if the Alignment is nonzero).
7386 @end smallexample
7387
7388 @noindent
7389 An explicit size clause may be used to override the default size by
7390 increasing it.  For example, if we have:
7391
7392 @smallexample
7393    type My_Boolean is new Boolean;
7394    for My_Boolean'Size use 32;
7395 @end smallexample
7396
7397 @noindent
7398 then objects of this type will always be 32 bits long.  In the case of
7399 discrete types, the size can be increased up to 64 bits, with the effect
7400 that the entire specified field is used to hold the value, sign- or
7401 zero-extended as appropriate.  If more than 64 bits is specified, then
7402 padding space is allocated after the value, and a warning is issued that
7403 there are unused bits.
7404
7405 Similarly the size of records and arrays may be increased, and the effect
7406 is to add padding bits after the value.  This also causes a warning message
7407 to be generated.
7408
7409 The largest Size value permitted in GNAT is 2**32@minus{}1.  Since this is a
7410 Size in bits, this corresponds to an object of size 256 megabytes (minus
7411 one).  This limitation is true on all targets.  The reason for this
7412 limitation is that it improves the quality of the code in many cases
7413 if it is known that a Size value can be accommodated in an object of
7414 type Integer.
7415
7416 @node Storage_Size Clauses
7417 @section Storage_Size Clauses
7418 @cindex Storage_Size Clause
7419
7420 @noindent
7421 For tasks, the @code{Storage_Size} clause specifies the amount of space
7422 to be allocated for the task stack.  This cannot be extended, and if the
7423 stack is exhausted, then @code{Storage_Error} will be raised if stack
7424 checking is enabled.  If the default size of 20K bytes is insufficient,  
7425 then you need to use a @code{Storage_Size} attribute definition clause,
7426 or a @code{Storage_Size} pragma in the task definition to set the
7427 appropriate required size.  A useful technique is to include in every
7428 task definition a pragma of the form:
7429
7430 @smallexample
7431    pragma Storage_Size (Default_Stack_Size);
7432 @end smallexample
7433
7434 @noindent
7435 Then Default_Stack_Size can be defined in a global package, and modified
7436 as required.  Any tasks requiring different task stack sizes from the
7437 default can have an appropriate alternative reference in the pragma.
7438
7439 For access types, the @code{Storage_Size} clause specifies the maximum
7440 space available for allocation of objects of the type.  If this space is
7441 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
7442 In the case where the access type is declared local to a subprogram, the
7443 use of a @code{Storage_Size} clause triggers automatic use of a special
7444 predefined storage pool (@code{System.Pool_Size}) that ensures that all
7445 space for the pool is automatically reclaimed on exit from the scope in
7446 which the type is declared.
7447
7448 A special case recognized by the compiler is the specification of a
7449 @code{Storage_Size} of zero for an access type.  This means that no
7450 items can be allocated from the pool, and this is recognized at compile
7451 time, and all the overhead normally associated with maintaining a fixed
7452 size storage pool is eliminated.  Consider the following example:
7453
7454 @smallexample
7455    procedure p is
7456       type R is array (Natural) of Character;
7457       type P is access all R;
7458       for P'Storage_Size use 0;
7459       --  Above access type intended only for interfacing purposes
7460    
7461       y : P;
7462    
7463       procedure g (m : P);
7464       pragma Import (C, g);
7465    
7466       --  @dots{}
7467    
7468    begin
7469       --  @dots{}
7470       y := new R;
7471    end;
7472 @end smallexample
7473
7474 @noindent
7475 As indicated in this example, these dummy storage pools are often useful in
7476 connection with interfacing where no object will ever be allocated.  If you
7477 compile the above example, you get the warning:
7478
7479 @smallexample
7480    p.adb:16:09: warning: allocation from empty storage pool
7481    p.adb:16:09: warning: Storage_Error will be raised at run time
7482 @end smallexample
7483
7484 @noindent
7485 Of course in practice, there will not be any explicit allocators in the
7486 case of such an access declaration.
7487
7488 @node Size of Variant Record Objects
7489 @section Size of Variant Record Objects
7490 @cindex Size, variant record objects
7491 @cindex Variant record objects, size
7492
7493 @noindent
7494 An issue arises in the case of variant record objects of whether Size gives
7495 information about a particular variant, or the maximum size required
7496 for any variant.  Consider the following program
7497
7498 @smallexample
7499 with Text_IO; use Text_IO;
7500 procedure q is
7501    type R1 (A : Boolean := False) is record
7502      case A is
7503        when True  => X : Character;
7504        when False => null;
7505      end case;
7506    end record;
7507    
7508    V1 : R1 (False);
7509    V2 : R1;
7510
7511 begin
7512    Put_Line (Integer'Image (V1'Size));
7513    Put_Line (Integer'Image (V2'Size));
7514 end q;
7515 @end smallexample
7516
7517 @noindent
7518 Here we are dealing with a variant record, where the True variant
7519 requires 16 bits, and the False variant requires 8 bits.
7520 In the above example, both V1 and V2 contain the False variant,
7521 which is only 8 bits long.  However, the result of running the
7522 program is:
7523
7524 @smallexample
7525 8
7526 16
7527 @end smallexample
7528
7529 @noindent
7530 The reason for the difference here is that the discriminant value of
7531 V1 is fixed, and will always be False.  It is not possible to assign
7532 a True variant value to V1, therefore 8 bits is sufficient.  On the
7533 other hand, in the case of V2, the initial discriminant value is
7534 False (from the default), but it is possible to assign a True
7535 variant value to V2, therefore 16 bits must be allocated for V2
7536 in the general case, even fewer bits may be needed at any particular
7537 point during the program execution.
7538
7539 As can be seen from the output of this program, the @code{'Size}
7540 attribute applied to such an object in GNAT gives the actual allocated
7541 size of the variable, which is the largest size of any of the variants.
7542 The Ada Reference Manual is not completely clear on what choice should
7543 be made here, but the GNAT behavior seems most consistent with the
7544 language in the RM@.
7545
7546 In some cases, it may be desirable to obtain the size of the current
7547 variant, rather than the size of the largest variant.  This can be
7548 achieved in GNAT by making use of the fact that in the case of a
7549 subprogram parameter, GNAT does indeed return the size of the current
7550 variant (because a subprogram has no way of knowing how much space
7551 is actually allocated for the actual).
7552
7553 Consider the following modified version of the above program:
7554
7555 @smallexample
7556 with Text_IO; use Text_IO;
7557 procedure q is
7558    type R1 (A : Boolean := False) is record
7559      case A is
7560        when True  => X : Character;
7561        when False => null;
7562      end case;
7563    end record;
7564    
7565    V2 : R1;
7566
7567    function Size (V : R1) return Integer is
7568    begin
7569       return V'Size;
7570    end Size;
7571
7572 begin
7573    Put_Line (Integer'Image (V2'Size));
7574    Put_Line (Integer'IMage (Size (V2)));
7575    V2 := (True, 'x');
7576    Put_Line (Integer'Image (V2'Size));
7577    Put_Line (Integer'IMage (Size (V2)));
7578 end q;
7579 @end smallexample
7580
7581 @noindent
7582 The output from this program is
7583
7584 @smallexample
7585 16
7586 8
7587 16
7588 16
7589 @end smallexample
7590
7591 @noindent
7592 Here we see that while the @code{'Size} attribute always returns
7593 the maximum size, regardless of the current variant value, the
7594 @code{Size} function does indeed return the size of the current
7595 variant value.
7596
7597 @node Biased Representation
7598 @section Biased Representation
7599 @cindex Size for biased representation
7600 @cindex Biased representation
7601
7602 @noindent
7603 In the case of scalars with a range starting at other than zero, it is
7604 possible in some cases to specify a size smaller than the default minimum
7605 value, and in such cases, GNAT uses an unsigned biased representation,
7606 in which zero is used to represent the lower bound, and successive values
7607 represent successive values of the type.
7608
7609 For example, suppose we have the declaration:
7610
7611 @smallexample
7612    type Small is range -7 .. -4;
7613    for Small'Size use 2;
7614 @end smallexample
7615
7616 @noindent
7617 Although the default size of type @code{Small} is 4, the @code{Size}
7618 clause is accepted by GNAT and results in the following representation
7619 scheme:
7620
7621 @smallexample
7622   -7 is represented as 2#00#
7623   -6 is represented as 2#01#
7624   -5 is represented as 2#10#
7625   -4 is represented as 2#11#
7626 @end smallexample
7627
7628 @noindent
7629 Biased representation is only used if the specified @code{Size} clause
7630 cannot be accepted in any other manner.  These reduced sizes that force
7631 biased representation can be used for all discrete types except for 
7632 enumeration types for which a representation clause is given.
7633
7634 @node Value_Size and Object_Size Clauses
7635 @section Value_Size and Object_Size Clauses
7636 @findex Value_Size
7637 @findex Object_Size
7638 @cindex Size, of objects
7639
7640 @noindent
7641 In Ada 95, the @code{Size} of a discrete type is the minimum number of bits
7642 required to hold values of the type.  Although this interpretation was
7643 allowed in Ada 83, it was not required, and this requirement in practice
7644 can cause some significant difficulties.  For example, in most Ada 83
7645 compilers, @code{Natural'Size} was 32.  However, in Ada-95,
7646 @code{Natural'Size} is
7647 typically 31.  This means that code may change in behavior when moving
7648 from Ada 83 to Ada 95.  For example, consider:
7649
7650 @smallexample
7651    type Rec is record;
7652       A : Natural;
7653       B : Natural;
7654    end record;
7655
7656    for Rec use record
7657       for A use at 0  range 0 .. Natural'Size - 1;
7658       for B use at 0  range Natural'Size .. 2 * Natural'Size - 1;
7659    end record;
7660 @end smallexample
7661
7662 @noindent
7663 In the above code, since the typical size of @code{Natural} objects
7664 is 32 bits and @code{Natural'Size} is 31, the above code can cause
7665 unexpected inefficient packing in Ada 95, and in general there are
7666 surprising cases where the fact that the object size can exceed the
7667 size of the type causes surprises.
7668
7669 To help get around this problem GNAT provides two implementation
7670 dependent attributes @code{Value_Size} and @code{Object_Size}.  When 
7671 applied to a type, these attributes yield the size of the type
7672 (corresponding to the RM defined size attribute), and the size of
7673 objects of the type respectively.
7674
7675 The @code{Object_Size} is used for determining the default size of
7676 objects and components.  This size value can be referred to using the
7677 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
7678 the basis of the determination of the size.  The backend is free to
7679 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
7680 character might be stored in 32 bits on a machine with no efficient
7681 byte access instructions such as the Alpha.
7682
7683 The default rules for the value of @code{Object_Size} for fixed-point and
7684 discrete types are as follows:
7685
7686 @itemize @bullet
7687 @item
7688 The @code{Object_Size} for base subtypes reflect the natural hardware
7689 size in bits (run the utility @code{gnatpsta} to find those values for numeric types). 
7690 Enumeration types and fixed-point base subtypes have 8, 16, 32 or 64
7691 bits for this size, depending on the range of values to be stored.
7692
7693 @item
7694 The @code{Object_Size} of a subtype is the same as the
7695 @code{Object_Size} of
7696 the type from which it is obtained.
7697
7698 @item
7699 The @code{Object_Size} of a derived base type is copied from the parent
7700 base type, and the @code{Object_Size} of a derived first subtype is copied
7701 from the parent first subtype.
7702 @end itemize
7703
7704 @noindent
7705 The @code{Value_Size} attribute
7706 is the number of bits required to store a value
7707 of the type.  This size can be referred to using the @code{Value_Size}
7708 attribute.  This value is used to determine how tightly to pack
7709 records or arrays with components of this type, and also affects
7710 the semantics of unchecked conversion (unchecked conversions where
7711 the @code{Value_Size} values differ generate a warning, and are potentially
7712 target dependent).
7713
7714 The default rules for the value of @code{Value_Size} are as follows:
7715
7716 @itemize @bullet
7717 @item
7718 The @code{Value_Size} for a base subtype is the minimum number of bits
7719 required to store all values of the type (including the sign bit
7720 only if negative values are possible).
7721
7722 @item
7723 If a subtype statically matches the first subtype of a given type, then it has
7724 by default the same @code{Value_Size} as the first subtype.  This is a
7725 consequence of RM 13.1(14) (``if two subtypes statically match,
7726 then their subtype-specific aspects are the same''.)
7727
7728 @item
7729 All other subtypes have a @code{Value_Size} corresponding to the minimum
7730 number of bits required to store all values of the subtype.  For
7731 dynamic bounds, it is assumed that the value can range down or up
7732 to the corresponding bound of the ancestor
7733 @end itemize
7734
7735 @noindent
7736 The RM defined attribute @code{Size} corresponds to the
7737 @code{Value_Size} attribute.
7738
7739 The @code{Size} attribute may be defined for a first-named subtype.  This sets
7740 the @code{Value_Size} of
7741 the first-named subtype to the given value, and the
7742 @code{Object_Size} of this first-named subtype to the given value padded up
7743 to an appropriate boundary.  It is a consequence of the default rules
7744 above that this @code{Object_Size} will apply to all further subtypes.  On the
7745 other hand, @code{Value_Size} is affected only for the first subtype, any
7746 dynamic subtypes obtained from it directly, and any statically matching
7747 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
7748
7749 @code{Value_Size} and
7750 @code{Object_Size} may be explicitly set for any subtype using
7751 an attribute definition clause.  Note that the use of these attributes
7752 can cause the RM 13.1(14) rule to be violated.  If two access types
7753 reference aliased objects whose subtypes have differing @code{Object_Size}
7754 values as a result of explicit attribute definition clauses, then it
7755 is erroneous to convert from one access subtype to the other.
7756
7757 At the implementation level, Esize stores the Object_SIze and the
7758 RM_Size field stores the @code{Value_Size} (and hence the value of the
7759 @code{Size} attribute,
7760 which, as noted above, is equivalent to @code{Value_Size}).
7761
7762 To get a feel for the difference, consider the following examples (note
7763 that in each case the base is short_short_integer with a size of 8):
7764
7765 @smallexample
7766                                        Object_Size     Value_Size
7767
7768 type x1 is range 0 .. 5;                    8               3
7769
7770 type x2 is range 0 .. 5;
7771 for x2'size use 12;                        12              12
7772
7773 subtype x3 is x2 range 0 .. 3;             12               2
7774
7775 subtype x4 is x2'base range 0 .. 10;        8               4
7776
7777 subtype x5 is x2 range 0 .. dynamic;       12              (7)
7778
7779 subtype x6 is x2'base range 0 .. dynamic;   8              (7)
7780
7781 @end smallexample
7782
7783 @noindent
7784 Note: the entries marked (7) are not actually specified by the Ada 95 RM,
7785 but it seems in the spirit of the RM rules to allocate the minimum number
7786 of bits known to be large enough to hold the given range of values.
7787
7788 So far, so good, but GNAT has to obey the RM rules, so the question is
7789 under what conditions must the RM @code{Size} be used.
7790 The following is a list
7791 of the occasions on which the RM @code{Size} must be used:
7792
7793 @itemize @bullet
7794 @item
7795 Component size for packed arrays or records
7796
7797 @item
7798 Value of the attribute @code{Size} for a type
7799
7800 @item
7801 Warning about sizes not matching for unchecked conversion
7802 @end itemize
7803
7804 @noindent
7805 For types other than discrete and fixed-point types, the @code{Object_Size}
7806 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
7807 Only @code{Size} may be specified for such types.
7808
7809 @node Component_Size Clauses
7810 @section Component_Size Clauses
7811 @cindex Component_Size Clause
7812
7813 @noindent
7814 Normally, the value specified in a component clause must be consistent
7815 with the subtype of the array component with regard to size and alignment.
7816 In other words, the value specified must be at least equal to the size
7817 of this subtype, and must be a multiple of the alignment value.
7818
7819 In addition, component size clauses are allowed which cause the array
7820 to be packed, by specifying a smaller value.  The cases in which this
7821 is allowed are for component size values in the range 1 through 63.  The value
7822 specified must not be smaller than the Size of the subtype.  GNAT will
7823 accurately honor all packing requests in this range.  For example, if
7824 we have:
7825
7826 @smallexample
7827 type r is array (1 .. 8) of Natural;
7828 for r'Size use 31;
7829 @end smallexample
7830
7831 @noindent
7832 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
7833 Of course access to the components of such an array is considerably
7834 less efficient than if the natural component size of 32 is used.
7835
7836 @node Bit_Order Clauses
7837 @section Bit_Order Clauses
7838 @cindex Bit_Order Clause
7839 @cindex bit ordering
7840 @cindex ordering, of bits
7841
7842 @noindent
7843 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
7844 attribute.  The specification may either correspond to the default bit
7845 order for the target, in which case the specification has no effect and
7846 places no additional restrictions, or it may be for the non-standard
7847 setting (that is the opposite of the default).
7848
7849 In the case where the non-standard value is specified, the effect is
7850 to renumber bits within each byte, but the ordering of bytes is not
7851 affected.  There are certain
7852 restrictions placed on component clauses as follows:
7853
7854 @itemize @bullet
7855
7856 @item Components fitting within a single storage unit.
7857 @noindent
7858 These are unrestricted, and the effect is merely to renumber bits.  For
7859 example if we are on a little-endian machine with @code{Low_Order_First}
7860 being the default, then the following two declarations have exactly
7861 the same effect:
7862
7863 @smallexample
7864    type R1 is record
7865       A : Boolean;
7866       B : Integer range 1 .. 120;
7867    end record;
7868
7869    for R1 use record
7870       A at 0 range 0 .. 0;
7871       B at 0 range 1 .. 7;
7872    end record;
7873
7874    type R2 is record
7875       A : Boolean;
7876       B : Integer range 1 .. 120;
7877    end record;
7878
7879    for R2'Bit_Order use High_Order_First;
7880
7881    for R2 use record
7882       A at 0 range 7 .. 7;
7883       B at 0 range 0 .. 6;
7884    end record;
7885 @end smallexample
7886
7887 @noindent
7888 The useful application here is to write the second declaration with the
7889 @code{Bit_Order} attribute definition clause, and know that it will be treated
7890 the same, regardless of whether the target is little-endian or big-endian.
7891
7892 @item Components occupying an integral number of bytes.
7893 @noindent
7894 These are components that exactly fit in two or more bytes.  Such component
7895 declarations are allowed, but have no effect, since it is important to realize
7896 that the @code{Bit_Order} specification does not affect the ordering of bytes.
7897 In particular, the following attempt at getting an endian-independent integer
7898 does not work:
7899
7900 @smallexample
7901    type R2 is record
7902       A : Integer;
7903    end record;
7904
7905    for R2'Bit_Order use High_Order_First;
7906
7907    for R2 use record
7908       A at 0 range 0 .. 31;
7909    end record;
7910 @end smallexample
7911
7912 @noindent
7913 This declaration will result in a little-endian integer on a
7914 little-endian machine, and a big-endian integer on a big-endian machine.
7915 If byte flipping is required for interoperability between big- and
7916 little-endian machines, this must be explicitly programmed.  This capability
7917 is not provided by @code{Bit_Order}.
7918
7919 @item Components that are positioned across byte boundaries
7920 @noindent
7921 but do not occupy an integral number of bytes.  Given that bytes are not
7922 reordered, such fields would occupy a non-contiguous sequence of bits
7923 in memory, requiring non-trivial code to reassemble.  They are for this
7924 reason not permitted, and any component clause specifying such a layout
7925 will be flagged as illegal by GNAT@.
7926
7927 @end itemize
7928
7929 @noindent
7930 Since the misconception that Bit_Order automatically deals with all
7931 endian-related incompatibilities is a common one, the specification of
7932 a component field that is an integral number of bytes will always
7933 generate a warning.  This warning may be suppressed using
7934 @code{pragma Suppress} if desired.  The following section contains additional
7935 details regarding the issue of byte ordering.
7936
7937 @node Effect of Bit_Order on Byte Ordering
7938 @section Effect of Bit_Order on Byte Ordering
7939 @cindex byte ordering
7940 @cindex ordering, of bytes
7941
7942 @noindent
7943 In this section we will review the effect of the @code{Bit_Order} attribute
7944 definition clause on byte ordering.  Briefly, it has no effect at all, but
7945 a detailed example will be helpful.  Before giving this
7946 example, let us review the precise
7947 definition of the effect of defining @code{Bit_Order}.  The effect of a
7948 non-standard bit order is described in section 15.5.3 of the Ada
7949 Reference Manual:
7950
7951 @smallexample
7952 2   A bit ordering is a method of interpreting the meaning of
7953 the storage place attributes.
7954 @end smallexample
7955
7956 @noindent
7957 To understand the precise definition of storage place attributes in
7958 this context, we visit section 13.5.1 of the manual:
7959
7960 @smallexample
7961 13   A record_representation_clause (without the mod_clause)
7962 specifies the layout.  The storage place attributes (see 13.5.2)
7963 are taken from the values of the position, first_bit, and last_bit
7964 expressions after normalizing those values so that first_bit is
7965 less than Storage_Unit.
7966 @end smallexample
7967
7968 @noindent
7969 The critical point here is that storage places are taken from
7970 the values after normalization, not before.  So the @code{Bit_Order}
7971 interpretation applies to normalized values.  The interpretation
7972 is described in the later part of the 15.5.3 paragraph:
7973
7974 @smallexample
7975 2   A bit ordering is a method of interpreting the meaning of
7976 the storage place attributes.  High_Order_First (known in the
7977 vernacular as ``big endian'') means that the first bit of a
7978 storage element (bit 0) is the most significant bit (interpreting
7979 the sequence of bits that represent a component as an unsigned
7980 integer value).  Low_Order_First (known in the vernacular as
7981 ``little endian'') means the opposite: the first bit is the
7982 least significant.
7983 @end smallexample
7984
7985 @noindent
7986 Note that the numbering is with respect to the bits of a storage
7987 unit.  In other words, the specification affects only the numbering
7988 of bits within a single storage unit.
7989
7990 We can make the effect clearer by giving an example.
7991
7992 Suppose that we have an external device which presents two bytes, the first
7993 byte presented, which is the first (low addressed byte) of the two byte
7994 record is called Master, and the second byte is called Slave.
7995
7996 The left most (most significant bit is called Control for each byte, and
7997 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
7998 (least significant) bit.
7999
8000 On a big-endian machine, we can write the following representation clause
8001
8002 @smallexample
8003    type Data is record
8004       Master_Control : Bit;
8005       Master_V1      : Bit;
8006       Master_V2      : Bit;
8007       Master_V3      : Bit;
8008       Master_V4      : Bit;
8009       Master_V5      : Bit;
8010       Master_V6      : Bit;
8011       Master_V7      : Bit;
8012       Slave_Control  : Bit;
8013       Slave_V1       : Bit;
8014       Slave_V2       : Bit;
8015       Slave_V3       : Bit;
8016       Slave_V4       : Bit;
8017       Slave_V5       : Bit;
8018       Slave_V6       : Bit;
8019       Slave_V7       : Bit;
8020    end record;
8021
8022    for Data use record
8023       Master_Control at 0 range 0 .. 0;
8024       Master_V1      at 0 range 1 .. 1;
8025       Master_V2      at 0 range 2 .. 2;
8026       Master_V3      at 0 range 3 .. 3;
8027       Master_V4      at 0 range 4 .. 4;
8028       Master_V5      at 0 range 5 .. 5;
8029       Master_V6      at 0 range 6 .. 6;
8030       Master_V7      at 0 range 7 .. 7;
8031       Slave_Control  at 1 range 0 .. 0;
8032       Slave_V1       at 1 range 1 .. 1;
8033       Slave_V2       at 1 range 2 .. 2;
8034       Slave_V3       at 1 range 3 .. 3;
8035       Slave_V4       at 1 range 4 .. 4;
8036       Slave_V5       at 1 range 5 .. 5;
8037       Slave_V6       at 1 range 6 .. 6;
8038       Slave_V7       at 1 range 7 .. 7;
8039    end record;
8040 @end smallexample
8041
8042 @noindent
8043 Now if we move this to a little endian machine, then the bit ordering within
8044 the byte is backwards, so we have to rewrite the record rep clause as:
8045
8046 @smallexample
8047    for Data use record
8048       Master_Control at 0 range 7 .. 7;
8049       Master_V1      at 0 range 6 .. 6;
8050       Master_V2      at 0 range 5 .. 5;
8051       Master_V3      at 0 range 4 .. 4;
8052       Master_V4      at 0 range 3 .. 3;
8053       Master_V5      at 0 range 2 .. 2;
8054       Master_V6      at 0 range 1 .. 1;
8055       Master_V7      at 0 range 0 .. 0;
8056       Slave_Control  at 1 range 7 .. 7;
8057       Slave_V1       at 1 range 6 .. 6;
8058       Slave_V2       at 1 range 5 .. 5;
8059       Slave_V3       at 1 range 4 .. 4;
8060       Slave_V4       at 1 range 3 .. 3;
8061       Slave_V5       at 1 range 2 .. 2;
8062       Slave_V6       at 1 range 1 .. 1;
8063       Slave_V7       at 1 range 0 .. 0;
8064    end record;
8065 @end smallexample
8066
8067 It is a nuisance to have to rewrite the clause, especially if
8068 the code has to be maintained on both machines.  However,
8069 this is a case that we can handle with the
8070 @code{Bit_Order} attribute if it is implemented.
8071 Note that the implementation is not required on byte addressed
8072 machines, but it is indeed implemented in GNAT.
8073 This means that we can simply use the
8074 first record clause, together with the declaration
8075
8076 @smallexample
8077    for Data'Bit_Order use High_Order_First;
8078 @end smallexample
8079
8080 @noindent
8081 and the effect is what is desired, namely the layout is exactly the same,
8082 independent of whether the code is compiled on a big-endian or little-endian
8083 machine.
8084
8085 The important point to understand is that byte ordering is not affected.
8086 A @code{Bit_Order} attribute definition never affects which byte a field
8087 ends up in, only where it ends up in that byte.
8088 To make this clear, let us rewrite the record rep clause of the previous
8089 example as:
8090
8091 @smallexample
8092    for Data'Bit_Order use High_Order_First;
8093    for Data use record
8094       Master_Control at 0 range  0 .. 0;
8095       Master_V1      at 0 range  1 .. 1;
8096       Master_V2      at 0 range  2 .. 2;
8097       Master_V3      at 0 range  3 .. 3;
8098       Master_V4      at 0 range  4 .. 4;
8099       Master_V5      at 0 range  5 .. 5;
8100       Master_V6      at 0 range  6 .. 6;
8101       Master_V7      at 0 range  7 .. 7;
8102       Slave_Control  at 0 range  8 .. 8;
8103       Slave_V1       at 0 range  9 .. 9;
8104       Slave_V2       at 0 range 10 .. 10;
8105       Slave_V3       at 0 range 11 .. 11;
8106       Slave_V4       at 0 range 12 .. 12;
8107       Slave_V5       at 0 range 13 .. 13;
8108       Slave_V6       at 0 range 14 .. 14;
8109       Slave_V7       at 0 range 15 .. 15;
8110    end record;
8111 @end smallexample
8112
8113 @noindent
8114 This is exactly equivalent to saying (a repeat of the first example):
8115
8116 @smallexample
8117    for Data'Bit_Order use High_Order_First;
8118    for Data use record
8119       Master_Control at 0 range 0 .. 0;
8120       Master_V1      at 0 range 1 .. 1;
8121       Master_V2      at 0 range 2 .. 2;
8122       Master_V3      at 0 range 3 .. 3;
8123       Master_V4      at 0 range 4 .. 4;
8124       Master_V5      at 0 range 5 .. 5;
8125       Master_V6      at 0 range 6 .. 6;
8126       Master_V7      at 0 range 7 .. 7;
8127       Slave_Control  at 1 range 0 .. 0;
8128       Slave_V1       at 1 range 1 .. 1;
8129       Slave_V2       at 1 range 2 .. 2;
8130       Slave_V3       at 1 range 3 .. 3;
8131       Slave_V4       at 1 range 4 .. 4;
8132       Slave_V5       at 1 range 5 .. 5;
8133       Slave_V6       at 1 range 6 .. 6;
8134       Slave_V7       at 1 range 7 .. 7;
8135    end record;
8136 @end smallexample
8137
8138 @noindent
8139 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
8140 field.  The storage place attributes are obtained by normalizing the
8141 values given so that the @code{First_Bit} value is less than 8.  After
8142 nromalizing the values (0,10,10) we get (1,2,2) which is exactly what
8143 we specified in the other case.
8144
8145 Now one might expect that the @code{Bit_Order} attribute might affect
8146 bit numbering within the entire record component (two bytes in this
8147 case, thus affecting which byte fields end up in), but that is not
8148 the way this feature is defined, it only affects numbering of bits,
8149 not which byte they end up in.
8150
8151 Consequently it never makes sense to specify a starting bit number
8152 greater than 7 (for a byte addressable field) if an attribute
8153 definition for @code{Bit_Order} has been given, and indeed it
8154 may be actively confusing to specify such a value, so the compiler
8155 generates a warning for such usage.
8156
8157 If you do need to control byte ordering then appropriate conditional
8158 values must be used.  If in our example, the slave byte came first on
8159 some machines we might write:
8160
8161 @smallexample
8162    Master_Byte_First constant Boolean := @dots{};
8163
8164    Master_Byte : constant Natural :=
8165                    1 - Boolean'Pos (Master_Byte_First);
8166    Slave_Byte  : constant Natural :=
8167                    Boolean'Pos (Master_Byte_First);
8168
8169    for Data'Bit_Order use High_Order_First;
8170    for Data use record
8171       Master_Control at Master_Byte range 0 .. 0;
8172       Master_V1      at Master_Byte range 1 .. 1;
8173       Master_V2      at Master_Byte range 2 .. 2;
8174       Master_V3      at Master_Byte range 3 .. 3;
8175       Master_V4      at Master_Byte range 4 .. 4;
8176       Master_V5      at Master_Byte range 5 .. 5;
8177       Master_V6      at Master_Byte range 6 .. 6;
8178       Master_V7      at Master_Byte range 7 .. 7;
8179       Slave_Control  at Slave_Byte  range 0 .. 0;
8180       Slave_V1       at Slave_Byte  range 1 .. 1;
8181       Slave_V2       at Slave_Byte  range 2 .. 2;
8182       Slave_V3       at Slave_Byte  range 3 .. 3;
8183       Slave_V4       at Slave_Byte  range 4 .. 4;
8184       Slave_V5       at Slave_Byte  range 5 .. 5;
8185       Slave_V6       at Slave_Byte  range 6 .. 6;
8186       Slave_V7       at Slave_Byte  range 7 .. 7;
8187    end record;
8188 @end smallexample
8189
8190 @noindent
8191 Now to switch between machines, all that is necessary is
8192 to set the boolean constant @code{Master_Byte_First} in
8193 an appropriate manner.
8194
8195 @node Pragma Pack for Arrays
8196 @section Pragma Pack for Arrays
8197 @cindex Pragma Pack (for arrays)
8198
8199 @noindent
8200 Pragma @code{Pack} applied to an array has no effect unless the component type
8201 is packable.  For a component type to be packable, it must be one of the
8202 following cases:
8203
8204 @itemize @bullet
8205 @item
8206 Any scalar type
8207 @item
8208 Any fixed-point type
8209 @item
8210 Any type whose size is specified with a size clause
8211 @item
8212 Any packed array type with a static size
8213 @end itemize
8214
8215 @noindent
8216 For all these cases, if the component subtype size is in the range
8217 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
8218 component size were specified giving the component subtype size.
8219 For example if we have:
8220
8221 @smallexample
8222    type r is range 0 .. 17;
8223  
8224    type ar is array (1 .. 8) of r;
8225    pragma Pack (ar);
8226 @end smallexample
8227
8228 @noindent
8229 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
8230 and the size of the array @code{ar} will be exactly 40 bits.
8231
8232 Note that in some cases this rather fierce approach to packing can produce
8233 unexpected effects.  For example, in Ada 95, type Natural typically has a
8234 size of 31, meaning that if you pack an array of Natural, you get 31-bit
8235 close packing, which saves a few bits, but results in far less efficient
8236 access.  Since many other Ada compilers will ignore such a packing request,
8237 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
8238 might not be what is intended.  You can easily remove this warning by
8239 using an explicit @code{Component_Size} setting instead, which never generates
8240 a warning, since the intention of the programmer is clear in this case.
8241
8242 GNAT treats packed arrays in one of two ways.  If the size of the array is
8243 known at compile time and is less than 64 bits, then internally the array
8244 is represented as a single modular type, of exactly the appropriate number
8245 of bits.  If the length is greater than 63 bits, or is not known at compile
8246 time, then the packed array is represented as an array of bytes, and the
8247 length is always a multiple of 8 bits.
8248
8249 @node Pragma Pack for Records
8250 @section Pragma Pack for Records
8251 @cindex Pragma Pack (for records)
8252
8253 @noindent
8254 Pragma @code{Pack} applied to a record will pack the components to reduce wasted
8255 space from alignment gaps and by reducing the amount of space taken by
8256 components.  We distinguish between package components and non-packable
8257 components.  Components of the following types are considered packable:
8258
8259 @itemize @bullet
8260 @item
8261 All scalar types are packable.
8262
8263 @item
8264 All fixed-point types are represented internally as integers, and
8265 are packable.
8266
8267 @item
8268 Small packed arrays, whose size does not exceed 64 bits, and where the
8269 size is statically known at compile time, are represented internally
8270 as modular integers, and so they are also packable.
8271
8272 @end itemize
8273
8274 @noindent
8275 All packable components occupy the exact number of bits corresponding to
8276 their @code{Size} value, and are packed with no padding bits, i.e.@: they
8277 can start on an arbitrary bit boundary.
8278
8279 All other types are non-packable, they occupy an integral number of
8280 storage units, and 
8281 are placed at a boundary corresponding to their alignment requirements.
8282
8283 For example, consider the record
8284
8285 @smallexample
8286    type Rb1 is array (1 .. 13) of Boolean;
8287    pragma Pack (rb1);
8288
8289    type Rb2 is array (1 .. 65) of Boolean;
8290    pragma Pack (rb2);
8291
8292    type x2 is record
8293       l1 : Boolean;
8294       l2 : Duration;
8295       l3 : Float;
8296       l4 : Boolean;
8297       l5 : Rb1;
8298       l6 : Rb2;
8299    end record;
8300    pragma Pack (x2);
8301 @end smallexample
8302
8303 @noindent
8304 The representation for the record x2 is as follows:
8305
8306 @smallexample
8307 for x2'Size use 224;
8308 for x2 use record
8309    l1 at  0 range  0 .. 0;
8310    l2 at  0 range  1 .. 64;
8311    l3 at 12 range  0 .. 31;
8312    l4 at 16 range  0 .. 0;
8313    l5 at 16 range  1 .. 13;
8314    l6 at 18 range  0 .. 71;
8315 end record;
8316 @end smallexample
8317
8318 @noindent
8319 Studying this example, we see that the packable fields @code{l1}
8320 and @code{l2} are
8321 of length equal to their sizes, and placed at specific bit boundaries (and
8322 not byte boundaries) to
8323 eliminate padding.  But @code{l3} is of a non-packable float type, so
8324 it is on the next appropriate alignment boundary. 
8325
8326 The next two fields are fully packable, so @code{l4} and @code{l5} are
8327 minimally packed with no gaps.  However, type @code{Rb2} is a packed
8328 array that is longer than 64 bits, so it is itself non-packable.  Thus
8329 the @code{l6} field is aligned to the next byte boundary, and takes an
8330 integral number of bytes, i.e.@: 72 bits.
8331
8332 @node Record Representation Clauses
8333 @section Record Representation Clauses
8334 @cindex Record Representation Clause
8335
8336 @noindent
8337 Record representation clauses may be given for all record types, including
8338 types obtained by record extension.  Component clauses are allowed for any
8339 static component.  The restrictions on component clauses depend on the type
8340 of the component.
8341
8342 @cindex Component Clause
8343 For all components of an elementary type, the only restriction on component
8344 clauses is that the size must be at least the 'Size value of the type
8345 (actually the Value_Size).  There are no restrictions due to alignment,
8346 and such components may freely cross storage boundaries.
8347
8348 Packed arrays with a size up to and including 64 bits are represented
8349 internally using a modular type with the appropriate number of bits, and
8350 thus the same lack of restriction applies.  For example, if you declare:
8351
8352 @smallexample
8353    type R is array (1 .. 49) of Boolean;
8354    pragma Pack (R);
8355    for R'Size use 49;
8356 @end smallexample
8357
8358 @noindent
8359 then a component clause for a component of type R may start on any
8360 specified bit boundary, and may specify a value of 49 bits or greater.
8361
8362 For non-primitive types, including packed arrays with a size greater than
8363 64 bits, component clauses must respect the alignment requirement of the
8364 type, in particular, always starting on a byte boundary, and the length
8365 must be a multiple of the storage unit.
8366
8367 The tag field of a tagged type always occupies an address sized field at
8368 the start of the record.  No component clause may attempt to overlay this
8369 tag.
8370
8371 In the case of a record extension T1, of a type T, no component clause applied
8372 to the type T1 can specify a storage location that would overlap the first
8373 T'Size bytes of the record.
8374
8375 @node Enumeration Clauses
8376 @section Enumeration Clauses
8377
8378 The only restriction on enumeration clauses is that the range of values
8379 must be representable.  For the signed case, if one or more of the
8380 representation values are negative, all values must be in the range:
8381
8382 @smallexample
8383    System.Min_Int .. System.Max_Int
8384 @end smallexample
8385
8386 @noindent
8387 For the unsigned case, where all values are non negative, the values must
8388 be in the range:
8389
8390 @smallexample
8391    0 .. System.Max_Binary_Modulus;
8392 @end smallexample
8393
8394 @noindent
8395 A @emph{confirming} representation clause is one in which the values range
8396 from 0 in sequence, i.e.@: a clause that confirms the default representation
8397 for an enumeration type.
8398 Such a confirming representation
8399 is permitted by these rules, and is specially recognized by the compiler so
8400 that no extra overhead results from the use of such a clause.
8401
8402 If an array has an index type which is an enumeration type to which an
8403 enumeration clause has been applied, then the array is stored in a compact
8404 manner.  Consider the declarations:
8405
8406 @smallexample
8407    type r is (A, B, C);
8408    for r use (A => 1, B => 5, C => 10);
8409    type t is array (r) of Character;
8410 @end smallexample
8411
8412 @noindent
8413 The array type t corresponds to a vector with exactly three elements and
8414 has a default size equal to @code{3*Character'Size}.  This ensures efficient
8415 use of space, but means that accesses to elements of the array will incur
8416 the overhead of converting representation values to the corresponding
8417 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
8418
8419 @node Address Clauses
8420 @section Address Clauses
8421 @cindex Address Clause
8422
8423 The reference manual allows a general restriction on representation clauses,
8424 as found in RM 13.1(22):
8425
8426 @smallexample
8427    An implementation need not support representation
8428    items containing nonstatic expressions, except that
8429    an implementation should support a representation item
8430    for a given entity if each nonstatic expression in the
8431    representation item is a name that statically denotes
8432    a constant declared before the entity.
8433 @end smallexample
8434
8435 @noindent
8436 In practice this is applicable only to address clauses, since this is the
8437 only case in which a non-static expression is permitted by the syntax.  As
8438 the AARM notes in sections 13.1 (22.a-22.h):
8439
8440 @smallexample
8441   22.a   Reason: This is to avoid the following sort
8442          of thing:
8443
8444   22.b        X : Integer := F(@dots{});
8445               Y : Address := G(@dots{});
8446               for X'Address use Y;
8447
8448   22.c   In the above, we have to evaluate the
8449          initialization expression for X before we
8450          know where to put the result.  This seems
8451          like an unreasonable implementation burden.
8452
8453   22.d   The above code should instead be written
8454          like this:
8455
8456   22.e        Y : constant Address := G(@dots{});
8457               X : Integer := F(@dots{});
8458               for X'Address use Y;
8459
8460   22.f   This allows the expression ``Y'' to be safely
8461          evaluated before X is created.
8462
8463   22.g   The constant could be a formal parameter of mode in.
8464
8465   22.h   An implementation can support other nonstatic
8466          expressions if it wants to.  Expressions of type
8467          Address are hardly ever static, but their value
8468          might be known at compile time anyway in many
8469          cases.
8470 @end smallexample
8471
8472 @noindent
8473 GNAT does indeed permit many additional cases of non-static expressions.  In
8474 particular, if the type involved is elementary there are no restrictions
8475 (since in this case, holding a temporary copy of the initialization value,
8476 if one is present, is inexpensive).  In addition, if there is no implicit or
8477 explicit initialization, then there are no restrictions.  GNAT will reject
8478 only the case where all three of these conditions hold:
8479
8480 @itemize @bullet
8481
8482 @item
8483 The type of the item is non-elementary (e.g.@: a record or array).
8484
8485 @item
8486 There is explicit or implicit initialization required for the object.
8487
8488 @item
8489 The address value is non-static.  Here GNAT is more permissive than the
8490 RM, and allows the address value to be the address of a previously declared
8491 stand-alone variable, as long as it does not itself have an address clause.
8492
8493 @smallexample
8494            Anchor : Some_Initialized_Type;
8495            Overlay : Some_Initialized_Type;
8496            for Overlay'Address use Anchor'Address;
8497 @end smallexample
8498
8499 However, the prefix of the address clause cannot be an array component, or
8500 a component of a discriminated record.
8501
8502 @end itemize
8503
8504 @noindent
8505 As noted above in section 22.h, address values are typically non-static.  In
8506 particular the To_Address function, even if applied to a literal value, is
8507 a non-static function call.  To avoid this minor annoyance, GNAT provides
8508 the implementation defined attribute 'To_Address.  The following two 
8509 expressions have identical values:
8510
8511 Another issue with address clauses is the interaction with alignment
8512 requirements.  When an address clause is given for an object, the address
8513 value must be consistent with the alignment of the object (which is usually
8514 the same as the alignment of the type of the object).  If an address clause
8515 is given that specifies an inappropriately aligned address value, then the
8516 program execution is erroneous.
8517
8518 Since this source of erroneous behavior can have unfortunate effects, GNAT
8519 checks (at compile time if possible, generating a warning, or at execution
8520 time with a run-time check) that the alignment is appropriate.  If the
8521 run-time check fails, then @code{Program_Error} is raised.  This run-time
8522 check is suppressed if range checks are suppressed, or if
8523 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
8524
8525 @findex Attribute
8526 @findex To_Address
8527 @smallexample
8528    To_Address (16#1234_0000#)
8529    System'To_Address (16#1234_0000#);
8530 @end smallexample
8531
8532 @noindent
8533 except that the second form is considered to be a static expression, and
8534 thus when used as an address clause value is always permitted.
8535
8536 @noindent
8537 Additionally, GNAT treats as static an address clause that is an
8538 unchecked_conversion of a static integer value.  This simplifies the porting
8539 of legacy code, and provides a portable equivalent to the GNAT attribute
8540 To_Address.
8541
8542 @findex Export
8543 An address clause cannot be given for an exported object.  More
8544 understandably the real restriction is that objects with an address
8545 clause cannot be exported.  This is because such variables are not
8546 defined by the Ada program, so there is no external object so export.
8547
8548 @findex Import
8549 It is permissible to give an address clause and a pragma Import for the
8550 same object.  In this case, the variable is not really defined by the
8551 Ada program, so there is no external symbol to be linked.  The link name
8552 and the external name are ignored in this case.  The reason that we allow this
8553 combination is that it provides a useful idiom to avoid unwanted
8554 initializations on objects with address clauses.
8555
8556 When an address clause is given for an object that has implicit or
8557 explicit initialization, then by default initialization takes place.  This
8558 means that the effect of the object declaration is to overwrite the
8559 memory at the specified address.  This is almost always not what the
8560 programmer wants, so GNAT will output a warning:
8561
8562 @smallexample
8563   with System;
8564   package G is
8565      type R is record
8566         M : Integer := 0;
8567      end record;
8568   
8569      Ext : R;
8570      for Ext'Address use System'To_Address (16#1234_1234#);
8571          |
8572   >>> warning: implicit initialization of "Ext" may
8573       modify overlaid storage
8574   >>> warning: use pragma Import for "Ext" to suppress
8575       initialization (RM B(24))
8576   
8577   end G;
8578 @end smallexample
8579
8580 @noindent
8581 As indicated by the warning message, the solution is to use a (dummy) pragma
8582 Import to suppress this initialization.  The pragma tell the compiler that the
8583 object is declared and initialized elsewhere.  The following package compiles
8584 without warnings (and the initialization is suppressed):
8585
8586 @smallexample
8587    with System;
8588    package G is
8589       type R is record
8590          M : Integer := 0;
8591       end record;
8592    
8593       Ext : R;
8594       for Ext'Address use System'To_Address (16#1234_1234#);
8595       pragma Import (Ada, Ext);
8596    end G;
8597 @end smallexample
8598
8599 @node Effect of Convention on Representation
8600 @section Effect of Convention on Representation
8601 @cindex Convention, effect on representation
8602
8603 @noindent
8604 Normally the specification of a foreign language convention for a type or
8605 an object has no effect on the chosen representation.  In particular, the
8606 representation chosen for data in GNAT generally meets the standard system
8607 conventions, and for example records are laid out in a manner that is
8608 consistent with C@.  This means that specifying convention C (for example)
8609 has no effect.
8610
8611 There are three exceptions to this general rule:
8612
8613 @itemize @bullet
8614
8615 @item Convention Fortran and array subtypes
8616 If pragma Convention Fortran is specified for an array subtype, then in
8617 accordance with the implementation advice in section 3.6.2(11) of the
8618 Ada Reference Manual, the array will be stored in a Fortran-compatible
8619 column-major manner, instead of the normal default row-major order.
8620
8621 @item Convention C and enumeration types
8622 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
8623 to accommodate all values of the type.  For example, for the enumeration
8624 type declared by:
8625
8626 @smallexample
8627    type Color is (Red, Green, Blue);
8628 @end smallexample
8629
8630 @noindent
8631 8 bits is sufficient to store all values of the type, so by default, objects
8632 of type @code{Color} will be represented using 8 bits.  However, normal C
8633 convention is to use 32 bits for all enum values in C, since enum values
8634 are essentially of type int.  If pragma @code{Convention C} is specified for an
8635 Ada enumeration type, then the size is modified as necessary (usually to
8636 32 bits) to be consistent with the C convention for enum values.
8637
8638 @item Convention C/Fortran and Boolean types
8639 In C, the usual convention for boolean values, that is values used for
8640 conditions, is that zero represents false, and nonzero values represent
8641 true.  In Ada, the normal convention is that two specific values, typically
8642 0/1, are used to represent false/true respectively.
8643
8644 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
8645 value represents true).
8646
8647 To accommodate the Fortran and C conventions, if a pragma Convention specifies
8648 C or Fortran convention for a derived Boolean, as in the following example:
8649
8650 @smallexample
8651    type C_Switch is new Boolean;
8652    pragma Convention (C, C_Switch);
8653 @end smallexample
8654
8655 @noindent
8656 then the GNAT generated code will treat any nonzero value as true.  For truth
8657 values generated by GNAT, the conventional value 1 will be used for True, but
8658 when one of these values is read, any nonzero value is treated as True.
8659
8660 @end itemize
8661
8662 @node Determining the Representations chosen by GNAT
8663 @section Determining the Representations chosen by GNAT
8664 @cindex Representation, determination of
8665 @cindex @code{-gnatR} switch
8666
8667 @noindent
8668 Although the descriptions in this section are intended to be complete, it is
8669 often easier to simply experiment to see what GNAT accepts and what the
8670 effect is on the layout of types and objects.
8671
8672 As required by the Ada RM, if a representation clause is not accepted, then
8673 it must be rejected as illegal by the compiler.  However, when a representation
8674 clause or pragma is accepted, there can still be questions of what the
8675 compiler actually does.  For example, if a partial record representation
8676 clause specifies the location of some components and not others, then where
8677 are the non-specified components placed? Or if pragma @code{Pack} is used on a
8678 record, then exactly where are the resulting fields placed? The section
8679 on pragma @code{Pack} in this chapter can be used to answer the second question,
8680 but it is often easier to just see what the compiler does.
8681
8682 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
8683 with this option, then the compiler will output information on the actual
8684 representations chosen, in a format similar to source representation
8685 clauses.  For example, if we compile the package:
8686
8687 @smallexample
8688 package q is
8689    type r (x : boolean) is tagged record
8690       case x is
8691          when True => S : String (1 .. 100);
8692          when False => null;
8693       end case;
8694    end record;
8695
8696    type r2 is new r (false) with record
8697       y2 : integer;
8698    end record;
8699
8700    for r2 use record
8701       y2 at 16 range 0 .. 31;
8702    end record;
8703
8704    type x is record
8705       y : character;
8706    end record;
8707
8708    type x1 is array (1 .. 10) of x;
8709    for x1'component_size use 11;
8710
8711    type ia is access integer;
8712
8713    type Rb1 is array (1 .. 13) of Boolean;
8714    pragma Pack (rb1);
8715
8716    type Rb2 is array (1 .. 65) of Boolean;
8717    pragma Pack (rb2);
8718
8719    type x2 is record
8720       l1 : Boolean;
8721       l2 : Duration;
8722       l3 : Float;
8723       l4 : Boolean;
8724       l5 : Rb1;
8725       l6 : Rb2;
8726    end record;
8727    pragma Pack (x2);
8728 end q;
8729 @end smallexample
8730
8731 @noindent
8732 using the switch @code{-gnatR} we obtain the following output:
8733
8734 @smallexample
8735 Representation information for unit q
8736 -------------------------------------
8737
8738 for r'Size use ??;
8739 for r'Alignment use 4;
8740 for r use record
8741    x    at 4 range  0 .. 7;
8742    _tag at 0 range  0 .. 31;
8743    s    at 5 range  0 .. 799;
8744 end record;
8745
8746 for r2'Size use 160;
8747 for r2'Alignment use 4;
8748 for r2 use record
8749    x       at  4 range  0 .. 7;
8750    _tag    at  0 range  0 .. 31;
8751    _parent at  0 range  0 .. 63;
8752    y2      at 16 range  0 .. 31;
8753 end record;
8754
8755 for x'Size use 8;
8756 for x'Alignment use 1;
8757 for x use record
8758    y at 0 range  0 .. 7;
8759 end record;
8760
8761 for x1'Size use 112;
8762 for x1'Alignment use 1;
8763 for x1'Component_Size use 11;
8764
8765 for rb1'Size use 13;
8766 for rb1'Alignment use 2;
8767 for rb1'Component_Size use 1;
8768
8769 for rb2'Size use 72;
8770 for rb2'Alignment use 1;
8771 for rb2'Component_Size use 1;
8772
8773 for x2'Size use 224;
8774 for x2'Alignment use 4;
8775 for x2 use record
8776    l1 at  0 range  0 .. 0;
8777    l2 at  0 range  1 .. 64;
8778    l3 at 12 range  0 .. 31;
8779    l4 at 16 range  0 .. 0;
8780    l5 at 16 range  1 .. 13;
8781    l6 at 18 range  0 .. 71;
8782 end record;
8783 @end smallexample
8784
8785 @noindent
8786 The Size values are actually the Object_Size, i.e.@: the default size that
8787 will be allocated for objects of the type.
8788 The ?? size for type r indicates that we have a variant record, and the
8789 actual size of objects will depend on the discriminant value.
8790
8791 The Alignment values show the actual alignment chosen by the compiler
8792 for each record or array type.
8793
8794 The record representation clause for type r shows where all fields
8795 are placed, including the compiler generated tag field (whose location
8796 cannot be controlled by the programmer).
8797
8798 The record representation clause for the type extension r2 shows all the
8799 fields present, including the parent field, which is a copy of the fields
8800 of the parent type of r2, i.e.@: r1.
8801
8802 The component size and size clauses for types rb1 and rb2 show
8803 the exact effect of pragma @code{Pack} on these arrays, and the record
8804 representation clause for type x2 shows how pragma @code{Pack} affects
8805 this record type.
8806
8807 In some cases, it may be useful to cut and paste the representation clauses
8808 generated by the compiler into the original source to fix and guarantee
8809 the actual representation to be used.
8810
8811 @node Standard Library Routines
8812 @chapter Standard Library Routines
8813
8814 @noindent
8815 The Ada 95 Reference Manual contains in Annex A a full description of an
8816 extensive set of standard library routines that can be used in any Ada
8817 program, and which must be provided by all Ada compilers.  They are
8818 analogous to the standard C library used by C programs.
8819
8820 GNAT implements all of the facilities described in annex A, and for most
8821 purposes the description in the Ada 95
8822 reference manual, or appropriate Ada
8823 text book, will be sufficient for making use of these facilities.
8824
8825 In the case of the input-output facilities, @xref{The Implementation of
8826 Standard I/O}, gives details on exactly how GNAT interfaces to the
8827 file system.  For the remaining packages, the Ada 95 reference manual
8828 should be sufficient.  The following is a list of the packages included,
8829 together with a brief description of the functionality that is provided.
8830
8831 For completeness, references are included to other predefined library
8832 routines defined in other sections of the Ada 95 reference manual (these are
8833 cross-indexed from annex A).
8834
8835 @table @code
8836 @item Ada (A.2)
8837 This is a parent package for all the standard library packages.  It is
8838 usually included implicitly in your program, and itself contains no
8839 useful data or routines.
8840
8841 @item Ada.Calendar (9.6)
8842 @code{Calendar} provides time of day access, and routines for
8843 manipulating times and durations.
8844
8845 @item Ada.Characters (A.3.1)
8846 This is a dummy parent package that contains no useful entities
8847
8848 @item Ada.Characters.Handling (A.3.2)
8849 This package provides some basic character handling capabilities,
8850 including classification functions for classes of characters (e.g.@: test
8851 for letters, or digits).
8852
8853 @item Ada.Characters.Latin_1 (A.3.3)
8854 This package includes a complete set of definitions of the characters
8855 that appear in type CHARACTER@.  It is useful for writing programs that
8856 will run in international environments.  For example, if you want an
8857 upper case E with an acute accent in a string, it is often better to use
8858 the definition of @code{UC_E_Acute} in this package.  Then your program
8859 will print in an understandable manner even if your environment does not
8860 support these extended characters.
8861
8862 @item Ada.Command_Line (A.15)
8863 This package provides access to the command line parameters and the name
8864 of the current program (analogous to the use of @code{argc} and @code{argv} in C), and
8865 also allows the exit status for the program to be set in a
8866 system-independent manner.
8867
8868 @item Ada.Decimal (F.2)
8869 This package provides constants describing the range of decimal numbers
8870 implemented, and also a decimal divide routine (analogous to the COBOL
8871 verb DIVIDE .. GIVING .. REMAINDER ..)
8872
8873 @item Ada.Direct_IO (A.8.4)
8874 This package provides input-output using a model of a set of records of
8875 fixed-length, containing an arbitrary definite Ada type, indexed by an
8876 integer record number.
8877
8878 @item Ada.Dynamic_Priorities (D.5)
8879 This package allows the priorities of a task to be adjusted dynamically
8880 as the task is running.
8881
8882 @item Ada.Exceptions (11.4.1)
8883 This package provides additional information on exceptions, and also
8884 contains facilities for treating exceptions as data objects, and raising
8885 exceptions with associated messages.
8886
8887 @item Ada.Finalization (7.6)
8888 This package contains the declarations and subprograms to support the
8889 use of controlled types, providing for automatic initialization and
8890 finalization (analogous to the constructors and destructors of C++)
8891
8892 @item Ada.Interrupts (C.3.2)
8893 This package provides facilities for interfacing to interrupts, which
8894 includes the set of signals or conditions that can be raised and
8895 recognized as interrupts.
8896
8897 @item Ada.Interrupts.Names (C.3.2)
8898 This package provides the set of interrupt names (actually signal
8899 or condition names) that can be handled by GNAT@.
8900
8901 @item Ada.IO_Exceptions (A.13)
8902 This package defines the set of exceptions that can be raised by use of
8903 the standard IO packages.
8904
8905 @item Ada.Numerics
8906 This package contains some standard constants and exceptions used
8907 throughout the numerics packages.  Note that the constants pi and e are
8908 defined here, and it is better to use these definitions than rolling
8909 your own.
8910
8911 @item Ada.Numerics.Complex_Elementary_Functions
8912 Provides the implementation of standard elementary functions (such as
8913 log and trigonometric functions) operating on complex numbers using the
8914 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
8915 created by the package @code{Numerics.Complex_Types}.
8916
8917 @item Ada.Numerics.Complex_Types
8918 This is a predefined instantiation of
8919 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
8920 build the type @code{Complex} and @code{Imaginary}.
8921
8922 @item Ada.Numerics.Discrete_Random
8923 This package provides a random number generator suitable for generating
8924 random integer values from a specified range.
8925
8926 @item Ada.Numerics.Float_Random
8927 This package provides a random number generator suitable for generating
8928 uniformly distributed floating point values.
8929
8930 @item Ada.Numerics.Generic_Complex_Elementary_Functions
8931 This is a generic version of the package that provides the
8932 implementation of standard elementary functions (such as log and
8933 trigonometric functions) for an arbitrary complex type.
8934
8935 The following predefined instantiations of this package are provided:
8936
8937 @table @code
8938 @item Short_Float
8939 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
8940 @item Float
8941 @code{Ada.Numerics.Complex_Elementary_Functions}
8942 @item Long_Float
8943 @code{Ada.Numerics.
8944  Long_Complex_Elementary_Functions}
8945 @end table
8946
8947 @item Ada.Numerics.Generic_Complex_Types
8948 This is a generic package that allows the creation of complex types,
8949 with associated complex arithmetic operations.
8950
8951 The following predefined instantiations of this package exist
8952 @table @code
8953 @item Short_Float
8954 @code{Ada.Numerics.Short_Complex_Complex_Types}
8955 @item Float
8956 @code{Ada.Numerics.Complex_Complex_Types}
8957 @item Long_Float
8958 @code{Ada.Numerics.Long_Complex_Complex_Types}
8959 @end table
8960
8961 @item Ada.Numerics.Generic_Elementary_Functions
8962 This is a generic package that provides the implementation of standard
8963 elementary functions (such as log an trigonometric functions) for an
8964 arbitrary float type.
8965
8966 The following predefined instantiations of this package exist
8967
8968 @table @code
8969 @item Short_Float
8970 @code{Ada.Numerics.Short_Elementary_Functions}
8971 @item Float
8972 @code{Ada.Numerics.Elementary_Functions}
8973 @item Long_Float
8974 @code{Ada.Numerics.Long_Elementary_Functions}
8975 @end table
8976
8977 @item Ada.Real_Time (D.8)
8978 This package provides facilities similar to those of @code{Calendar}, but
8979 operating with a finer clock suitable for real time control. Note that
8980 annex D requires that there be no backward clock jumps, and GNAT generally
8981 guarantees this behavior, but of course if the external clock on which
8982 the GNAT runtime depends is deliberately reset by some external event,
8983 then such a backward jump may occur.
8984
8985 @item Ada.Sequential_IO (A.8.1)
8986 This package provides input-output facilities for sequential files,
8987 which can contain a sequence of values of a single type, which can be
8988 any Ada type, including indefinite (unconstrained) types.
8989
8990 @item Ada.Storage_IO (A.9)
8991 This package provides a facility for mapping arbitrary Ada types to and
8992 from a storage buffer.  It is primarily intended for the creation of new
8993 IO packages.
8994
8995 @item Ada.Streams (13.13.1)
8996 This is a generic package that provides the basic support for the
8997 concept of streams as used by the stream attributes (@code{Input},
8998 @code{Output}, @code{Read} and @code{Write}).
8999
9000 @item Ada.Streams.Stream_IO (A.12.1)
9001 This package is a specialization of the type @code{Streams} defined in
9002 package @code{Streams} together with a set of operations providing
9003 Stream_IO capability.  The Stream_IO model permits both random and
9004 sequential access to a file which can contain an arbitrary set of values
9005 of one or more Ada types.
9006
9007 @item Ada.Strings (A.4.1)
9008 This package provides some basic constants used by the string handling
9009 packages.
9010
9011 @item Ada.Strings.Bounded (A.4.4)
9012 This package provides facilities for handling variable length
9013 strings.  The bounded model requires a maximum length.  It is thus
9014 somewhat more limited than the unbounded model, but avoids the use of
9015 dynamic allocation or finalization.
9016
9017 @item Ada.Strings.Fixed (A.4.3)
9018 This package provides facilities for handling fixed length strings.
9019
9020 @item Ada.Strings.Maps (A.4.2)
9021 This package provides facilities for handling character mappings and
9022 arbitrarily defined subsets of characters.  For instance it is useful in
9023 defining specialized translation tables.
9024
9025 @item Ada.Strings.Maps.Constants (A.4.6)
9026 This package provides a standard set of predefined mappings and
9027 predefined character sets.  For example, the standard upper to lower case
9028 conversion table is found in this package.  Note that upper to lower case
9029 conversion is non-trivial if you want to take the entire set of
9030 characters, including extended characters like E with an acute accent,
9031 into account.  You should use the mappings in this package (rather than
9032 adding 32 yourself) to do case mappings.
9033
9034 @item Ada.Strings.Unbounded (A.4.5)
9035 This package provides facilities for handling variable length
9036 strings.  The unbounded model allows arbitrary length strings, but
9037 requires the use of dynamic allocation and finalization.
9038
9039 @item Ada.Strings.Wide_Bounded (A.4.7)
9040 @itemx Ada.Strings.Wide_Fixed (A.4.7)
9041 @itemx Ada.Strings.Wide_Maps (A.4.7)
9042 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
9043 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
9044 These package provide analogous capabilities to the corresponding
9045 packages without @samp{Wide_} in the name, but operate with the types
9046 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
9047 and @code{Character}.
9048
9049 @item Ada.Synchronous_Task_Control (D.10)
9050 This package provides some standard facilities for controlling task
9051 communication in a synchronous manner.
9052
9053 @item Ada.Tags
9054 This package contains definitions for manipulation of the tags of tagged
9055 values.
9056
9057 @item Ada.Task_Attributes
9058 This package provides the capability of associating arbitrary
9059 task-specific data with separate tasks.
9060
9061 @item Ada.Text_IO
9062 This package provides basic text input-output capabilities for
9063 character, string and numeric data.  The subpackages of this
9064 package are listed next.
9065
9066 @item Ada.Text_IO.Decimal_IO
9067 Provides input-output facilities for decimal fixed-point types
9068
9069 @item Ada.Text_IO.Enumeration_IO 
9070 Provides input-output facilities for enumeration types.
9071
9072 @item Ada.Text_IO.Fixed_IO
9073 Provides input-output facilities for ordinary fixed-point types.
9074
9075 @item Ada.Text_IO.Float_IO
9076 Provides input-output facilities for float types.  The following
9077 predefined instantiations of this generic package are available:
9078
9079 @table @code
9080 @item Short_Float
9081 @code{Short_Float_Text_IO}
9082 @item Float
9083 @code{Float_Text_IO}
9084 @item Long_Float
9085 @code{Long_Float_Text_IO}
9086 @end table
9087
9088 @item Ada.Text_IO.Integer_IO
9089 Provides input-output facilities for integer types.  The following
9090 predefined instantiations of this generic package are available:
9091
9092 @table @code
9093 @item Short_Short_Integer
9094 @code{Ada.Short_Short_Integer_Text_IO}
9095 @item Short_Integer
9096 @code{Ada.Short_Integer_Text_IO}
9097 @item Integer
9098 @code{Ada.Integer_Text_IO}
9099 @item Long_Integer
9100 @code{Ada.Long_Integer_Text_IO}
9101 @item Long_Long_Integer
9102 @code{Ada.Long_Long_Integer_Text_IO}
9103 @end table
9104
9105 @item Ada.Text_IO.Modular_IO
9106 Provides input-output facilities for modular (unsigned) types
9107
9108 @item Ada.Text_IO.Complex_IO (G.1.3)
9109 This package provides basic text input-output capabilities for complex
9110 data.
9111
9112 @item Ada.Text_IO.Editing (F.3.3)
9113 This package contains routines for edited output, analogous to the use
9114 of pictures in COBOL@.  The picture formats used by this package are a
9115 close copy of the facility in COBOL@.
9116
9117 @item Ada.Text_IO.Text_Streams (A.12.2)
9118 This package provides a facility that allows Text_IO files to be treated
9119 as streams, so that the stream attributes can be used for writing
9120 arbitrary data, including binary data, to Text_IO files.
9121
9122 @item Ada.Unchecked_Conversion (13.9)
9123 This generic package allows arbitrary conversion from one type to
9124 another of the same size, providing for breaking the type safety in
9125 special circumstances.
9126
9127 If the types have the same Size (more accurately the same Value_Size),
9128 then the effect is simply to transfer the bits from the source to the
9129 target type without any modification.  This usage is well defined, and
9130 for simple types whose representation is typically the same across
9131 all implementations, gives a portable method of performing such
9132 conversions.
9133
9134 If the types do not have the same size, then the result is implementation
9135 defined, and thus may be non-portable.  The following describes how GNAT
9136 handles such unchecked conversion cases.
9137
9138 If the types are of different sizes, and are both discrete types, then
9139 the effect is of a normal type conversion without any constraint checking.
9140 In particular if the result type has a larger size, the result will be
9141 zero or sign extended.  If the result type has a smaller size, the result
9142 will be truncated by ignoring high order bits.
9143
9144 If the types are of different sizes, and are not both discrete types,
9145 then the conversion works as though pointers were created to the source
9146 and target, and the pointer value is converted.  The effect is that bits
9147 are copied from successive low order storage units and bits of the source
9148 up to the length of the target type.
9149
9150 A warning is issued if the lengths differ, since the effect in this
9151 case is implementation dependent, and the above behavior may not match
9152 that of some other compiler.
9153
9154 A pointer to one type may be converted to a pointer to another type using
9155 unchecked conversion.  The only case in which the effect is undefined is
9156 when one or both pointers are pointers to unconstrained array types.  In
9157 this case, the bounds information may get incorrectly transferred, and in
9158 particular, GNAT uses double size pointers for such types, and it is
9159 meaningless to convert between such pointer types.  GNAT will issue a
9160 warning if the alignment of the target designated type is more strict
9161 than the alignment of the source designated type (since the result may
9162 be unaligned in this case).
9163
9164 A pointer other than a pointer to an unconstrained array type may be
9165 converted to and from System.Address.  Such usage is common in Ada 83
9166 programs, but note that Ada.Address_To_Access_Conversions is the
9167 preferred method of performing such conversions in Ada 95.  Neither
9168 unchecked conversion nor Ada.Address_To_Access_Conversions should be
9169 used in conjunction with pointers to unconstrained objects, since
9170 the bounds information cannot be handled correctly in this case.
9171
9172 @item Ada.Unchecked_Deallocation (13.11.2)
9173 This generic package allows explicit freeing of storage previously
9174 allocated by use of an allocator.
9175
9176 @item Ada.Wide_Text_IO (A.11)
9177 This package is similar to @code{Ada.Text_IO}, except that the external
9178 file supports wide character representations, and the internal types are
9179 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
9180 and @code{String}.  It contains generic subpackages listed next.
9181
9182 @item Ada.Wide_Text_IO.Decimal_IO
9183 Provides input-output facilities for decimal fixed-point types
9184
9185 @item Ada.Wide_Text_IO.Enumeration_IO
9186 Provides input-output facilities for enumeration types.
9187
9188 @item Ada.Wide_Text_IO.Fixed_IO
9189 Provides input-output facilities for ordinary fixed-point types.
9190
9191 @item Ada.Wide_Text_IO.Float_IO
9192 Provides input-output facilities for float types.  The following
9193 predefined instantiations of this generic package are available:
9194
9195 @table @code
9196 @item Short_Float
9197 @code{Short_Float_Wide_Text_IO}
9198 @item Float
9199 @code{Float_Wide_Text_IO}
9200 @item Long_Float
9201 @code{Long_Float_Wide_Text_IO}
9202 @end table
9203
9204 @item Ada.Wide_Text_IO.Integer_IO
9205 Provides input-output facilities for integer types.  The following
9206 predefined instantiations of this generic package are available:
9207
9208 @table @code
9209 @item Short_Short_Integer
9210 @code{Ada.Short_Short_Integer_Wide_Text_IO}
9211 @item Short_Integer
9212 @code{Ada.Short_Integer_Wide_Text_IO}
9213 @item Integer
9214 @code{Ada.Integer_Wide_Text_IO}
9215 @item Long_Integer
9216 @code{Ada.Long_Integer_Wide_Text_IO}
9217 @item Long_Long_Integer
9218 @code{Ada.Long_Long_Integer_Wide_Text_IO}
9219 @end table
9220
9221 @item Ada.Wide_Text_IO.Modular_IO
9222 Provides input-output facilities for modular (unsigned) types
9223
9224 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
9225 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
9226 external file supports wide character representations.
9227
9228 @item Ada.Wide_Text_IO.Editing (F.3.4)
9229 This package is similar to @code{Ada.Text_IO.Editing}, except that the
9230 types are @code{Wide_Character} and @code{Wide_String} instead of
9231 @code{Character} and @code{String}.
9232
9233 @item Ada.Wide_Text_IO.Streams (A.12.3)
9234 This package is similar to @code{Ada.Text_IO.Streams}, except that the
9235 types are @code{Wide_Character} and @code{Wide_String} instead of
9236 @code{Character} and @code{String}.
9237 @end table
9238 @node The Implementation of Standard I/O
9239 @chapter The Implementation of Standard I/O
9240
9241 @noindent
9242 GNAT implements all the required input-output facilities described in
9243 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
9244 required behavior of these packages from the Ada point of view, and if
9245 you are writing a portable Ada program that does not need to know the
9246 exact manner in which Ada maps to the outside world when it comes to
9247 reading or writing external files, then you do not need to read this
9248 chapter.  As long as your files are all regular files (not pipes or
9249 devices), and as long as you write and read the files only from Ada, the
9250 description in the Ada 95 reference manual is sufficient.
9251
9252 However, if you want to do input-output to pipes or other devices, such
9253 as the keyboard or screen, or if the files you are dealing with are
9254 either generated by some other language, or to be read by some other
9255 language, then you need to know more about the details of how the GNAT
9256 implementation of these input-output facilities behaves.
9257
9258 In this chapter we give a detailed description of exactly how GNAT
9259 interfaces to the file system.  As always, the sources of the system are
9260 available to you for answering questions at an even more detailed level,
9261 but for most purposes the information in this chapter will suffice.
9262
9263 Another reason that you may need to know more about how input-output is
9264 implemented arises when you have a program written in mixed languages
9265 where, for example, files are shared between the C and Ada sections of
9266 the same program.  GNAT provides some additional facilities, in the form
9267 of additional child library packages, that facilitate this sharing, and
9268 these additional facilities are also described in this chapter.
9269
9270 @menu
9271 * Standard I/O Packages::       
9272 * FORM Strings::                
9273 * Direct_IO::                   
9274 * Sequential_IO::               
9275 * Text_IO::                     
9276 * Wide_Text_IO::                
9277 * Stream_IO::                   
9278 * Shared Files::                
9279 * Open Modes::                  
9280 * Operations on C Streams::     
9281 * Interfacing to C Streams::    
9282 @end menu
9283
9284 @node Standard I/O Packages
9285 @section Standard I/O Packages
9286
9287 @noindent
9288 The Standard I/O packages described in Annex A for
9289
9290 @itemize @bullet
9291 @item
9292 Ada.Text_IO
9293 @item
9294 Ada.Text_IO.Complex_IO
9295 @item
9296 Ada.Text_IO.Text_Streams,
9297 @item
9298 Ada.Wide_Text_IO
9299 @item
9300 Ada.Wide_Text_IO.Complex_IO,
9301 @item
9302 Ada.Wide_Text_IO.Text_Streams
9303 @item
9304 Ada.Stream_IO
9305 @item
9306 Ada.Sequential_IO
9307 @item
9308 Ada.Direct_IO
9309 @end itemize
9310
9311 @noindent
9312 are implemented using the C
9313 library streams facility; where
9314
9315 @itemize @bullet
9316 @item
9317 All files are opened using @code{fopen}.
9318 @item
9319 All input/output operations use @code{fread}/@code{fwrite}.
9320 @end itemize
9321
9322 There is no internal buffering of any kind at the Ada library level.  The
9323 only buffering is that provided at the system level in the
9324 implementation of the C library routines that support streams.  This
9325 facilitates shared use of these streams by mixed language programs.
9326
9327 @node FORM Strings
9328 @section FORM Strings
9329
9330 @noindent
9331 The format of a FORM string in GNAT is:
9332
9333 @smallexample
9334 "keyword=value,keyword=value,@dots{},keyword=value"
9335 @end smallexample
9336
9337 @noindent
9338 where letters may be in upper or lower case, and there are no spaces
9339 between values.  The order of the entries is not important.  Currently
9340 there are two keywords defined.
9341
9342 @smallexample
9343 SHARED=[YES|NO]
9344 WCEM=[n|h|u|s\e]
9345 @end smallexample
9346
9347 The use of these parameters is described later in this section.
9348
9349 @node Direct_IO
9350 @section Direct_IO
9351
9352 @noindent
9353 Direct_IO can only be instantiated for definite types.  This is a
9354 restriction of the Ada language, which means that the records are fixed
9355 length (the length being determined by @code{@var{type}'Size}, rounded
9356 up to the next storage unit boundary if necessary).
9357
9358 The records of a Direct_IO file are simply written to the file in index
9359 sequence, with the first record starting at offset zero, and subsequent
9360 records following.  There is no control information of any kind.  For
9361 example, if 32-bit integers are being written, each record takes
9362 4-bytes, so the record at index @var{K} starts at offset 
9363 (@var{K}@minus{}1)*4.
9364
9365 There is no limit on the size of Direct_IO files, they are expanded as
9366 necessary to accommodate whatever records are written to the file.
9367
9368 @node Sequential_IO
9369 @section Sequential_IO
9370
9371 @noindent
9372 Sequential_IO may be instantiated with either a definite (constrained)
9373 or indefinite (unconstrained) type.
9374
9375 For the definite type case, the elements written to the file are simply
9376 the memory images of the data values with no control information of any
9377 kind.  The resulting file should be read using the same type, no validity
9378 checking is performed on input.
9379
9380 For the indefinite type case, the elements written consist of two
9381 parts.  First is the size of the data item, written as the memory image
9382 of a @code{Interfaces.C.size_t} value, followed by the memory image of
9383 the data value.  The resulting file can only be read using the same
9384 (unconstrained) type.  Normal assignment checks are performed on these
9385 read operations, and if these checks fail, @code{Data_Error} is
9386 raised.  In particular, in the array case, the lengths must match, and in
9387 the variant record case, if the variable for a particular read operation
9388 is constrained, the discriminants must match.
9389
9390 Note that it is not possible to use Sequential_IO to write variable
9391 length array items, and then read the data back into different length
9392 arrays.  For example, the following will raise @code{Data_Error}:
9393
9394 @smallexample
9395  package IO is new Sequential_IO (String);
9396  F : IO.File_Type;
9397  S : String (1..4);
9398  @dots{}
9399  IO.Create (F)
9400  IO.Write (F, "hello!")
9401  IO.Reset (F, Mode=>In_File);
9402  IO.Read (F, S);
9403  Put_Line (S);
9404
9405 @end smallexample
9406
9407 On some Ada implementations, this will print @samp{hell}, but the program is
9408 clearly incorrect, since there is only one element in the file, and that
9409 element is the string @samp{hello!}.
9410
9411 In Ada 95, this kind of behavior can be legitimately achieved using
9412 Stream_IO, and this is the preferred mechanism.  In particular, the above
9413 program fragment rewritten to use Stream_IO will work correctly.
9414
9415 @node Text_IO
9416 @section Text_IO
9417
9418 @noindent
9419 Text_IO files consist of a stream of characters containing the following
9420 special control characters:
9421
9422 @smallexample
9423 LF (line feed, 16#0A#) Line Mark
9424 FF (form feed, 16#0C#) Page Mark
9425 @end smallexample
9426
9427 A canonical Text_IO file is defined as one in which the following
9428 conditions are met:
9429
9430 @itemize @bullet
9431 @item
9432 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
9433 of the line.
9434
9435 @item
9436 The character @code{FF} is used only as a page mark, i.e.@: to mark the
9437 end of a page and consequently can appear only immediately following a
9438 @code{LF} (line mark) character.
9439
9440 @item
9441 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
9442 (line mark, page mark).  In the former case, the page mark is implicitly
9443 assumed to be present.
9444 @end itemize
9445
9446 A file written using Text_IO will be in canonical form provided that no
9447 explicit @code{LF} or @code{FF} characters are written using @code{Put}
9448 or @code{Put_Line}.  There will be no @code{FF} character at the end of
9449 the file unless an explicit @code{New_Page} operation was performed
9450 before closing the file.
9451
9452 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
9453 pipe, can be read using any of the routines in Text_IO@.  The
9454 semantics in this case will be exactly as defined in the Ada 95 reference
9455 manual and all the routines in Text_IO are fully implemented.
9456
9457 A text file that does not meet the requirements for a canonical Text_IO
9458 file has one of the following:
9459
9460 @itemize @bullet
9461 @item
9462 The file contains @code{FF} characters not immediately following a
9463 @code{LF} character.
9464
9465 @item
9466 The file contains @code{LF} or @code{FF} characters written by
9467 @code{Put} or @code{Put_Line}, which are not logically considered to be
9468 line marks or page marks.
9469
9470 @item
9471 The file ends in a character other than @code{LF} or @code{FF},
9472 i.e.@: there is no explicit line mark or page mark at the end of the file.
9473 @end itemize
9474
9475 Text_IO can be used to read such non-standard text files but subprograms
9476 to do with line or page numbers do not have defined meanings.  In
9477 particular, a @code{FF} character that does not follow a @code{LF}
9478 character may or may not be treated as a page mark from the point of
9479 view of page and line numbering.  Every @code{LF} character is considered
9480 to end a line, and there is an implied @code{LF} character at the end of
9481 the file.
9482
9483 @menu
9484 * Text_IO Stream Pointer Positioning::  
9485 * Text_IO Reading and Writing Non-Regular Files::  
9486 * Get_Immediate::               
9487 * Treating Text_IO Files as Streams::
9488 * Text_IO Extensions::
9489 * Text_IO Facilities for Unbounded Strings::
9490 @end menu
9491 @node Text_IO Stream Pointer Positioning
9492
9493 @subsection Stream Pointer Positioning
9494
9495 @noindent
9496 @code{Ada.Text_IO} has a definition of current position for a file that
9497 is being read.  No internal buffering occurs in Text_IO, and usually the
9498 physical position in the stream used to implement the file corresponds
9499 to this logical position defined by Text_IO@.  There are two exceptions:
9500
9501 @itemize @bullet
9502 @item
9503 After a call to @code{End_Of_Page} that returns @code{True}, the stream
9504 is positioned past the @code{LF} (line mark) that precedes the page
9505 mark.  Text_IO maintains an internal flag so that subsequent read
9506 operations properly handle the logical position which is unchanged by
9507 the @code{End_Of_Page} call.
9508
9509 @item
9510 After a call to @code{End_Of_File} that returns @code{True}, if the
9511 Text_IO file was positioned before the line mark at the end of file
9512 before the call, then the logical position is unchanged, but the stream
9513 is physically positioned right at the end of file (past the line mark,
9514 and past a possible page mark following the line mark.  Again Text_IO
9515 maintains internal flags so that subsequent read operations properly
9516 handle the logical position.
9517 @end itemize
9518
9519 These discrepancies have no effect on the observable behavior of
9520 Text_IO, but if a single Ada stream is shared between a C program and
9521 Ada program, or shared (using @samp{shared=yes} in the form string)
9522 between two Ada files, then the difference may be observable in some
9523 situations.
9524
9525 @node Text_IO Reading and Writing Non-Regular Files
9526 @subsection Reading and Writing Non-Regular Files
9527
9528 @noindent
9529 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
9530 can be used for reading and writing.  Writing is not affected and the
9531 sequence of characters output is identical to the normal file case, but
9532 for reading, the behavior of Text_IO is modified to avoid undesirable
9533 look-ahead as follows:
9534
9535 An input file that is not a regular file is considered to have no page
9536 marks.  Any @code{Ascii.FF} characters (the character normally used for a
9537 page mark) appearing in the file are considered to be data
9538 characters.  In particular:
9539
9540 @itemize @bullet
9541 @item
9542 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
9543 following a line mark.  If a page mark appears, it will be treated as a
9544 data character.
9545
9546 @item
9547 This avoids the need to wait for an extra character to be typed or
9548 entered from the pipe to complete one of these operations.
9549
9550 @item
9551 @code{End_Of_Page} always returns @code{False}
9552
9553 @item
9554 @code{End_Of_File} will return @code{False} if there is a page mark at
9555 the end of the file.
9556 @end itemize
9557
9558 Output to non-regular files is the same as for regular files.  Page marks
9559 may be written to non-regular files using @code{New_Page}, but as noted
9560 above they will not be treated as page marks on input if the output is
9561 piped to another Ada program.
9562
9563 Another important discrepancy when reading non-regular files is that the end
9564 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
9565 pressing the @key{EOT} key,
9566 then end of file
9567 is signalled once (i.e.@: the test @code{End_Of_File}
9568 will yield @code{True}, or a read will
9569 raise @code{End_Error}), but then reading can resume
9570 to read data past that end of
9571 file indication, until another end of file indication is entered.
9572
9573 @node Get_Immediate
9574 @subsection Get_Immediate
9575 @cindex Get_Immediate
9576
9577 @noindent
9578 Get_Immediate returns the next character (including control characters)
9579 from the input file.  In particular, Get_Immediate will return LF or FF
9580 characters used as line marks or page marks.  Such operations leave the
9581 file positioned past the control character, and it is thus not treated
9582 as having its normal function.  This means that page, line and column
9583 counts after this kind of Get_Immediate call are set as though the mark
9584 did not occur.  In the case where a Get_Immediate leaves the file
9585 positioned between the line mark and page mark (which is not normally
9586 possible), it is undefined whether the FF character will be treated as a
9587 page mark.
9588
9589 @node Treating Text_IO Files as Streams
9590 @subsection Treating Text_IO Files as Streams
9591 @cindex Stream files
9592
9593 @noindent
9594 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
9595 as a stream.  Data written to a Text_IO file in this stream mode is
9596 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
9597 16#0C# (@code{FF}), the resulting file may have non-standard
9598 format.  Similarly if read operations are used to read from a Text_IO
9599 file treated as a stream, then @code{LF} and @code{FF} characters may be
9600 skipped and the effect is similar to that described above for
9601 @code{Get_Immediate}.
9602
9603 @node Text_IO Extensions
9604 @subsection Text_IO Extensions
9605 @cindex Text_IO extensions
9606
9607 @noindent
9608 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
9609 to the standard @code{Text_IO} package:
9610
9611 @itemize @bullet
9612 @item function File_Exists (Name : String) return Boolean;
9613 Determines if a file of the given name exists and can be successfully
9614 opened (without actually performing the open operation).
9615
9616 @item function Get_Line return String;
9617 Reads a string from the standard input file.  The value returned is exactly
9618 the length of the line that was read.
9619
9620 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
9621 Similar, except that the parameter File specifies the file from which
9622 the string is to be read.
9623
9624 @end itemize
9625
9626 @node Text_IO Facilities for Unbounded Strings
9627 @subsection Text_IO Facilities for Unbounded Strings
9628 @cindex Text_IO for unbounded strings
9629 @cindex Unbounded_String, Text_IO operations
9630
9631 @noindent
9632 The package @code{Ada.Strings.Unbounded.Text_IO}
9633 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
9634 subprograms useful for Text_IO operations on unbounded strings:
9635
9636 @itemize @bullet
9637
9638 @item function Get_Line (File : File_Type) return Unbounded_String;
9639 Reads a line from the specified file
9640 and returns the result as an unbounded string.
9641
9642 @item procedure Put (File : File_Type; U : Unbounded_String);
9643 Writes the value of the given unbounded string to the specified file
9644 Similar to the effect of
9645 @code{Put (To_String (U))} except that an extra copy is avoided.
9646
9647 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
9648 Writes the value of the given unbounded string to the specified file,
9649 followed by a @code{New_Line}.
9650 Similar to the effect of @code{Put_Line (To_String (U))} except
9651 that an extra copy is avoided.
9652 @end itemize
9653
9654 @noindent
9655 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
9656 and is optional.  If the parameter is omitted, then the standard input or
9657 output file is referenced as appropriate.
9658
9659 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
9660 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended @code{Wide_Text_IO}
9661 functionality for unbounded wide strings.
9662
9663 @node Wide_Text_IO
9664 @section Wide_Text_IO
9665
9666 @noindent
9667 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
9668 both input and output files may contain special sequences that represent
9669 wide character values.  The encoding scheme for a given file may be
9670 specified using a FORM parameter:
9671
9672 @smallexample
9673 WCEM=@var{x}
9674 @end smallexample
9675
9676 @noindent
9677 as part of the FORM string (WCEM = wide character encoding method),
9678 where @var{x} is one of the following characters
9679
9680 @table @samp
9681 @item h
9682 Hex ESC encoding
9683 @item u
9684 Upper half encoding
9685 @item s
9686 Shift-JIS encoding
9687 @item e
9688 EUC Encoding
9689 @item 8
9690 UTF-8 encoding
9691 @item b
9692 Brackets encoding
9693 @end table
9694
9695 The encoding methods match those that
9696 can be used in a source
9697 program, but there is no requirement that the encoding method used for
9698 the source program be the same as the encoding method used for files,
9699 and different files may use different encoding methods.
9700
9701 The default encoding method for the standard files, and for opened files
9702 for which no WCEM parameter is given in the FORM string matches the
9703 wide character encoding specified for the main program (the default
9704 being brackets encoding if no coding method was specified with -gnatW).
9705
9706 @table @asis
9707 @item Hex Coding
9708 In this encoding, a wide character is represented by a five character
9709 sequence:
9710
9711 @smallexample
9712 ESC a b c d
9713 @end smallexample
9714
9715 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
9716 characters (using upper case letters) of the wide character code.  For
9717 example, ESC A345 is used to represent the wide character with code
9718 16#A345#.  This scheme is compatible with use of the full
9719 @code{Wide_Character} set.
9720
9721 @item Upper Half Coding
9722 The wide character with encoding 16#abcd#, where the upper bit is on
9723 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
9724 16#cd#.  The second byte may never be a format control character, but is
9725 not required to be in the upper half.  This method can be also used for
9726 shift-JIS or EUC where the internal coding matches the external coding. 
9727
9728 @item Shift JIS Coding
9729 A wide character is represented by a two character sequence 16#ab# and
9730 16#cd#, with the restrictions described for upper half encoding as
9731 described above.  The internal character code is the corresponding JIS
9732 character according to the standard algorithm for Shift-JIS
9733 conversion.  Only characters defined in the JIS code set table can be
9734 used with this encoding method.
9735
9736 @item EUC Coding
9737 A wide character is represented by a two character sequence 16#ab# and
9738 16#cd#, with both characters being in the upper half.  The internal
9739 character code is the corresponding JIS character according to the EUC
9740 encoding algorithm.  Only characters defined in the JIS code set table
9741 can be used with this encoding method.
9742
9743 @item UTF-8 Coding
9744 A wide character is represented using
9745 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
9746 10646-1/Am.2.  Depending on the character value, the representation
9747 is a one, two, or three byte sequence:
9748
9749 @smallexample
9750 16#0000#-16#007f#: 2#0xxxxxxx#
9751 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
9752 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
9753 @end smallexample
9754
9755 where the xxx bits correspond to the left-padded bits of the
9756 16-bit character value.  Note that all lower half ASCII characters
9757 are represented as ASCII bytes and all upper half characters and
9758 other wide characters are represented as sequences of upper-half
9759 (The full UTF-8 scheme allows for encoding 31-bit characters as
9760 6-byte sequences, but in this implementation, all UTF-8 sequences
9761 of four or more bytes length will raise a Constraint_Error, as
9762 will all invalid UTF-8 sequences.)
9763
9764 @item Brackets Coding
9765 In this encoding, a wide character is represented by the following eight
9766 character sequence:
9767
9768 @smallexample
9769 [ " a b c d " ]
9770 @end smallexample
9771
9772 Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
9773 characters (using uppercase letters) of the wide character code.  For
9774 example, @code{["A345"]} is used to represent the wide character with code
9775 @code{16#A345#}.
9776 This scheme is compatible with use of the full Wide_Character set.
9777 On input, brackets coding can also be used for upper half characters,
9778 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
9779 is only used for wide characters with a code greater than @code{16#FF#}.
9780
9781 @end table
9782
9783 For the coding schemes other than Hex and Brackets encoding,
9784 not all wide character
9785 values can be represented.  An attempt to output a character that cannot
9786 be represented using the encoding scheme for the file causes
9787 Constraint_Error to be raised.  An invalid wide character sequence on
9788 input also causes Constraint_Error to be raised.
9789
9790 @menu
9791 * Wide_Text_IO Stream Pointer Positioning::  
9792 * Wide_Text_IO Reading and Writing Non-Regular Files::  
9793 @end menu
9794
9795 @node Wide_Text_IO Stream Pointer Positioning
9796 @subsection Stream Pointer Positioning
9797
9798 @noindent
9799 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
9800 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
9801 case:
9802
9803 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
9804 normal lower ASCII set (i.e.@: a character in the range:
9805
9806 @smallexample
9807 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
9808 @end smallexample
9809
9810 @noindent
9811 then although the logical position of the file pointer is unchanged by
9812 the @code{Look_Ahead} call, the stream is physically positioned past the
9813 wide character sequence.  Again this is to avoid the need for buffering
9814 or backup, and all @code{Wide_Text_IO} routines check the internal
9815 indication that this situation has occurred so that this is not visible
9816 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
9817 can be observed if the wide text file shares a stream with another file.
9818
9819 @node Wide_Text_IO Reading and Writing Non-Regular Files
9820 @subsection Reading and Writing Non-Regular Files
9821
9822 @noindent
9823 As in the case of Text_IO, when a non-regular file is read, it is
9824 assumed that the file contains no page marks (any form characters are
9825 treated as data characters), and @code{End_Of_Page} always returns
9826 @code{False}.  Similarly, the end of file indication is not sticky, so
9827 it is possible to read beyond an end of file.
9828
9829 @node Stream_IO
9830 @section Stream_IO
9831
9832 @noindent
9833 A stream file is a sequence of bytes, where individual elements are
9834 written to the file as described in the Ada 95 reference manual.  The type
9835 @code{Stream_Element} is simply a byte.  There are two ways to read or
9836 write a stream file.
9837
9838 @itemize @bullet
9839 @item
9840 The operations @code{Read} and @code{Write} directly read or write a
9841 sequence of stream elements with no control information.
9842
9843 @item
9844 The stream attributes applied to a stream file transfer data in the
9845 manner described for stream attributes.
9846 @end itemize
9847
9848 @node Shared Files
9849 @section Shared Files
9850
9851 @noindent
9852 Section A.14 of the Ada 95 Reference Manual allows implementations to
9853 provide a wide variety of behavior if an attempt is made to access the
9854 same external file with two or more internal files.
9855
9856 To provide a full range of functionality, while at the same time
9857 minimizing the problems of portability caused by this implementation
9858 dependence, GNAT handles file sharing as follows:
9859
9860 @itemize @bullet
9861 @item
9862 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
9863 to open two or more files with the same full name is considered an error
9864 and is not supported.  The exception @code{Use_Error} will be
9865 raised.  Note that a file that is not explicitly closed by the program
9866 remains open until the program terminates.
9867
9868 @item
9869 If the form parameter @samp{shared=no} appears in the form string, the
9870 file can be opened or created with its own separate stream identifier,
9871 regardless of whether other files sharing the same external file are
9872 opened.  The exact effect depends on how the C stream routines handle
9873 multiple accesses to the same external files using separate streams.
9874
9875 @item
9876 If the form parameter @samp{shared=yes} appears in the form string for
9877 each of two or more files opened using the same full name, the same
9878 stream is shared between these files, and the semantics are as described
9879 in Ada 95 Reference Manual, Section A.14.
9880 @end itemize
9881
9882 When a program that opens multiple files with the same name is ported
9883 from another Ada compiler to GNAT, the effect will be that
9884 @code{Use_Error} is raised.
9885
9886 The documentation of the original compiler and the documentation of the
9887 program should then be examined to determine if file sharing was
9888 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
9889 and @code{Create} calls as required.
9890
9891 When a program is ported from GNAT to some other Ada compiler, no
9892 special attention is required unless the @samp{shared=@var{xxx}} form
9893 parameter is used in the program.  In this case, you must examine the
9894 documentation of the new compiler to see if it supports the required
9895 file sharing semantics, and form strings modified appropriately.  Of
9896 course it may be the case that the program cannot be ported if the
9897 target compiler does not support the required functionality.  The best
9898 approach in writing portable code is to avoid file sharing (and hence
9899 the use of the @samp{shared=@var{xxx}} parameter in the form string)
9900 completely.
9901
9902 One common use of file sharing in Ada 83 is the use of instantiations of
9903 Sequential_IO on the same file with different types, to achieve
9904 heterogeneous input-output.  Although this approach will work in GNAT if
9905 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
9906 for this purpose (using the stream attributes)
9907
9908 @node Open Modes
9909 @section Open Modes
9910
9911 @noindent
9912 @code{Open} and @code{Create} calls result in a call to @code{fopen}
9913 using the mode shown in Table 6.1
9914
9915 @sp 2
9916 @center Table 6-1 @code{Open} and @code{Create} Call Modes
9917 @smallexample
9918                                @b{OPEN }           @b{CREATE}
9919 Append_File                    "r+"             "w+"
9920 In_File                        "r"              "w+"
9921 Out_File (Direct_IO)           "r+"             "w"
9922 Out_File (all other cases)     "w"              "w"
9923 Inout_File                     "r+"             "w+"
9924 @end smallexample
9925
9926 If text file translation is required, then either @samp{b} or @samp{t}
9927 is added to the mode, depending on the setting of Text.  Text file
9928 translation refers to the mapping of CR/LF sequences in an external file
9929 to LF characters internally.  This mapping only occurs in DOS and
9930 DOS-like systems, and is not relevant to other systems.
9931
9932 A special case occurs with Stream_IO@.  As shown in the above table, the
9933 file is initially opened in @samp{r} or @samp{w} mode for the
9934 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
9935 subsequently requires switching from reading to writing or vice-versa,
9936 then the file is reopened in @samp{r+} mode to permit the required operation.
9937
9938 @node Operations on C Streams
9939 @section Operations on C Streams
9940 The package @code{Interfaces.C_Streams} provides an Ada program with direct
9941 access to the C library functions for operations on C streams:
9942
9943 @smallexample
9944 package Interfaces.C_Streams is
9945   -- Note: the reason we do not use the types that are in
9946   -- Interfaces.C is that we want to avoid dragging in the
9947   -- code in this unit if possible.
9948   subtype chars is System.Address;
9949   -- Pointer to null-terminated array of characters
9950   subtype FILEs is System.Address;
9951   -- Corresponds to the C type FILE*
9952   subtype voids is System.Address;
9953   -- Corresponds to the C type void*
9954   subtype int is Integer;
9955   subtype long is Long_Integer;
9956   -- Note: the above types are subtypes deliberately, and it
9957   -- is part of this spec that the above correspondences are
9958   -- guaranteed.  This means that it is legitimate to, for
9959   -- example, use Integer instead of int.  We provide these
9960   -- synonyms for clarity, but in some cases it may be
9961   -- convenient to use the underlying types (for example to
9962   -- avoid an unnecessary dependency of a spec on the spec
9963   -- of this unit).
9964   type size_t is mod 2 ** Standard'Address_Size;
9965   NULL_Stream : constant FILEs;
9966   -- Value returned (NULL in C) to indicate an
9967   -- fdopen/fopen/tmpfile error
9968   ----------------------------------
9969   -- Constants Defined in stdio.h --
9970   ----------------------------------
9971   EOF : constant int;
9972   -- Used by a number of routines to indicate error or 
9973   -- end of file
9974   IOFBF : constant int;
9975   IOLBF : constant int;
9976   IONBF : constant int;
9977   -- Used to indicate buffering mode for setvbuf call
9978   SEEK_CUR : constant int;
9979   SEEK_END : constant int;
9980   SEEK_SET : constant int;
9981   -- Used to indicate origin for fseek call
9982   function stdin return FILEs;
9983   function stdout return FILEs;
9984   function stderr return FILEs;
9985   -- Streams associated with standard files
9986   --------------------------
9987   -- Standard C functions --
9988   --------------------------
9989   -- The functions selected below are ones that are
9990   -- available in DOS, OS/2, UNIX and Xenix (but not
9991   -- necessarily in ANSI C).  These are very thin interfaces
9992   -- which copy exactly the C headers.  For more
9993   -- documentation on these functions, see the Microsoft C 
9994   -- "Run-Time Library Reference" (Microsoft Press, 1990,
9995   -- ISBN 1-55615-225-6), which includes useful information
9996   -- on system compatibility.
9997   procedure clearerr (stream : FILEs);
9998   function fclose (stream : FILEs) return int;
9999   function fdopen (handle : int; mode : chars) return FILEs; 
10000   function feof (stream : FILEs) return int; 
10001   function ferror (stream : FILEs) return int; 
10002   function fflush (stream : FILEs) return int; 
10003   function fgetc (stream : FILEs) return int; 
10004   function fgets (strng : chars; n : int; stream : FILEs) 
10005       return chars; 
10006   function fileno (stream : FILEs) return int; 
10007   function fopen (filename : chars; Mode : chars) 
10008       return FILEs;
10009   -- Note: to maintain target independence, use
10010   -- text_translation_required, a boolean variable defined in
10011   -- a-sysdep.c to deal with the target dependent text
10012   -- translation requirement.  If this variable is set, 
10013   -- then  b/t should be appended to the standard mode
10014   -- argument to set the text translation mode off or on 
10015   -- as required.
10016   function fputc (C : int; stream : FILEs) return int;
10017   function fputs (Strng : chars; Stream : FILEs) return int;
10018   function fread
10019      (buffer : voids;
10020       size : size_t;
10021       count : size_t;
10022       stream : FILEs)
10023       return size_t;
10024   function freopen
10025      (filename : chars;
10026       mode : chars;
10027       stream : FILEs)
10028       return FILEs;
10029   function fseek
10030      (stream : FILEs;
10031       offset : long;
10032       origin : int)
10033       return int;
10034   function ftell (stream : FILEs) return long;
10035   function fwrite
10036      (buffer : voids;
10037       size : size_t;
10038       count : size_t;
10039       stream : FILEs)
10040       return size_t; 
10041   function isatty (handle : int) return int;
10042   procedure mktemp (template : chars);
10043   -- The return value (which is just a pointer to template)
10044   -- is discarded
10045   procedure rewind (stream : FILEs);
10046   function rmtmp return int;
10047   function setvbuf
10048      (stream : FILEs;
10049       buffer : chars;
10050       mode : int;
10051       size : size_t)
10052       return int;
10053
10054   function tmpfile return FILEs;
10055   function ungetc (c : int; stream : FILEs) return int;
10056   function unlink (filename : chars) return int;
10057   ---------------------
10058   -- Extra functions --
10059   ---------------------
10060   -- These functions supply slightly thicker bindings than
10061   -- those above.  They are derived from functions in the 
10062   -- C Run-Time Library, but may do a bit more work than
10063   -- just directly calling one of the Library functions.
10064   function is_regular_file (handle : int) return int;
10065   -- Tests if given handle is for a regular file (result 1)
10066   -- or for a non-regular file (pipe or device, result 0).
10067   ---------------------------------
10068   -- Control of Text/Binary Mode --
10069   ---------------------------------
10070   -- If text_translation_required is true, then the following
10071   -- functions may be used to dynamically switch a file from
10072   -- binary to text mode or vice versa.  These functions have
10073   -- no effect if text_translation_required is false (i.e.  in
10074   -- normal UNIX mode).  Use fileno to get a stream handle.
10075   procedure set_binary_mode (handle : int);
10076   procedure set_text_mode (handle : int);
10077   ----------------------------
10078   -- Full Path Name support --
10079   ----------------------------
10080   procedure full_name (nam : chars; buffer : chars);
10081   -- Given a NUL terminated string representing a file
10082   -- name, returns in buffer a NUL terminated string
10083   -- representing the full path name for the file name. 
10084   -- On systems where it is relevant the   drive is also
10085   -- part of the full path name.  It is the responsibility 
10086   -- of the caller to pass an actual parameter for buffer
10087   -- that is big enough for any full path name.  Use
10088   -- max_path_len given below as the size of buffer.
10089   max_path_len : integer;
10090   -- Maximum length of an allowable full path name on the
10091   -- system, including a terminating NUL character.
10092 end Interfaces.C_Streams;
10093 @end smallexample
10094
10095 @node Interfacing to C Streams
10096 @section Interfacing to C Streams
10097
10098 @noindent
10099 The packages in this section permit interfacing Ada files to C Stream
10100 operations.
10101
10102 @smallexample
10103  with Interfaces.C_Streams;
10104  package Ada.Sequential_IO.C_Streams is
10105     function C_Stream (F : File_Type)  
10106        return Interfaces.C_Streams.FILEs;
10107     procedure Open
10108       (File : in out File_Type;
10109        Mode : in File_Mode;
10110        C_Stream : in Interfaces.C_Streams.FILEs;
10111        Form : in String := "");
10112  end Ada.Sequential_IO.C_Streams;
10113
10114   with Interfaces.C_Streams;
10115   package Ada.Direct_IO.C_Streams is
10116      function C_Stream (F : File_Type) 
10117         return Interfaces.C_Streams.FILEs;
10118      procedure Open
10119        (File : in out File_Type;
10120         Mode : in File_Mode;
10121         C_Stream : in Interfaces.C_Streams.FILEs;
10122         Form : in String := "");
10123   end Ada.Direct_IO.C_Streams;
10124
10125   with Interfaces.C_Streams;
10126   package Ada.Text_IO.C_Streams is
10127      function C_Stream (F : File_Type)
10128         return Interfaces.C_Streams.FILEs;
10129      procedure Open
10130        (File : in out File_Type;
10131         Mode : in File_Mode;
10132         C_Stream : in Interfaces.C_Streams.FILEs;
10133         Form : in String := "");
10134   end Ada.Text_IO.C_Streams;
10135
10136   with Interfaces.C_Streams;
10137   package Ada.Wide_Text_IO.C_Streams is
10138      function C_Stream (F : File_Type)  
10139         return Interfaces.C_Streams.FILEs;
10140      procedure Open
10141        (File : in out File_Type;
10142         Mode : in File_Mode;
10143         C_Stream : in Interfaces.C_Streams.FILEs;
10144         Form : in String := "");
10145  end Ada.Wide_Text_IO.C_Streams;
10146
10147  with Interfaces.C_Streams;
10148  package Ada.Stream_IO.C_Streams is
10149     function C_Stream (F : File_Type)
10150        return Interfaces.C_Streams.FILEs;
10151     procedure Open
10152       (File : in out File_Type;
10153        Mode : in File_Mode;
10154        C_Stream : in Interfaces.C_Streams.FILEs;
10155        Form : in String := "");
10156  end Ada.Stream_IO.C_Streams;
10157 @end smallexample
10158
10159 In each of these five packages, the @code{C_Stream} function obtains the
10160 @code{FILE} pointer from a currently opened Ada file.  It is then
10161 possible to use the @code{Interfaces.C_Streams} package to operate on
10162 this stream, or the stream can be passed to a C program which can
10163 operate on it directly.  Of course the program is responsible for
10164 ensuring that only appropriate sequences of operations are executed.
10165
10166 One particular use of relevance to an Ada program is that the
10167 @code{setvbuf} function can be used to control the buffering of the
10168 stream used by an Ada file.  In the absence of such a call the standard
10169 default buffering is used.
10170
10171 The @code{Open} procedures in these packages open a file giving an
10172 existing C Stream instead of a file name.  Typically this stream is
10173 imported from a C program, allowing an Ada file to operate on an
10174 existing C file.
10175
10176 @node The GNAT Library
10177 @chapter The GNAT Library
10178
10179 @noindent
10180 The GNAT library contains a number of general and special purpose packages.
10181 It represents functionality that the GNAT developers have found useful, and
10182 which is made available to GNAT users.  The packages described here are fully
10183 supported, and upwards compatibility will be maintained in future releases,
10184 so you can use these facilities with the confidence that the same functionality
10185 will be available in future releases.
10186
10187 The chapter here simply gives a brief summary of the facilities available.
10188 The full documentation is found in the spec file for the package.  The full
10189 sources of these library packages, including both spec and body, are provided
10190 with all GNAT releases.  For example, to find out the full specifications of
10191 the SPITBOL pattern matching capability, including a full tutorial and 
10192 extensive examples, look in the @file{g-spipat.ads} file in the library.
10193
10194 For each entry here, the package name (as it would appear in a @code{with}
10195 clause) is given, followed by the name of the corresponding spec file in
10196 parentheses.  The packages are children in four hierarchies, @code{Ada},
10197 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
10198 GNAT-specific hierarchy.
10199
10200 Note that an application program should only use packages in one of these
10201 four hierarchies if the package is defined in the Ada Reference Manual,
10202 or is listed in this section of the GNAT Programmers Reference Manual.
10203 All other units should be considered internal implementation units and
10204 should not be directly @code{with}'ed by application code.  The use of
10205 a @code{with} statement that references one of these internal implementation
10206 units makes an application potentially dependent on changes in versions
10207 of GNAT, and will generate a warning message.
10208
10209 @menu
10210 * Ada.Characters.Latin_9 (a-chlat9.ads)::
10211 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
10212 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
10213 * Ada.Command_Line.Remove (a-colire.ads)::
10214 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
10215 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
10216 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
10217 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
10218 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
10219 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
10220 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
10221 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
10222 * GNAT.AWK (g-awk.ads)::
10223 * GNAT.Bubble_Sort_A (g-busora.ads)::
10224 * GNAT.Bubble_Sort_G (g-busorg.ads)::
10225 * GNAT.Calendar (g-calend.ads)::
10226 * GNAT.Calendar.Time_IO (g-catiio.ads)::
10227 * GNAT.CRC32 (g-crc32.ads)::
10228 * GNAT.Case_Util (g-casuti.ads)::
10229 * GNAT.CGI (g-cgi.ads)::
10230 * GNAT.CGI.Cookie (g-cgicoo.ads)::
10231 * GNAT.CGI.Debug (g-cgideb.ads)::
10232 * GNAT.Command_Line (g-comlin.ads)::
10233 * GNAT.Current_Exception (g-curexc.ads)::
10234 * GNAT.Debug_Pools (g-debpoo.ads)::
10235 * GNAT.Debug_Utilities (g-debuti.ads)::
10236 * GNAT.Directory_Operations (g-dirope.ads)::
10237 * GNAT.Dynamic_Tables (g-dyntab.ads)::
10238 * GNAT.Exception_Traces (g-exctra.ads)::
10239 * GNAT.Expect (g-expect.ads)::
10240 * GNAT.Float_Control (g-flocon.ads)::
10241 * GNAT.Heap_Sort_A (g-hesora.ads)::
10242 * GNAT.Heap_Sort_G (g-hesorg.ads)::
10243 * GNAT.HTable (g-htable.ads)::
10244 * GNAT.IO (g-io.ads)::
10245 * GNAT.IO_Aux (g-io_aux.ads)::
10246 * GNAT.Lock_Files (g-locfil.ads)::
10247 * GNAT.MD5 (g-md5.ads)::
10248 * GNAT.Most_Recent_Exception (g-moreex.ads)::
10249 * GNAT.OS_Lib (g-os_lib.ads)::
10250 * GNAT.Regexp (g-regexp.ads)::
10251 * GNAT.Registry (g-regist.ads)::
10252 * GNAT.Regpat (g-regpat.ads)::
10253 * GNAT.Sockets (g-socket.ads)::
10254 * GNAT.Source_Info (g-souinf.ads)::
10255 * GNAT.Spell_Checker (g-speche.ads)::
10256 * GNAT.Spitbol.Patterns (g-spipat.ads)::
10257 * GNAT.Spitbol (g-spitbo.ads)::
10258 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
10259 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
10260 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
10261 * GNAT.Table (g-table.ads)::
10262 * GNAT.Task_Lock (g-tasloc.ads)::
10263 * GNAT.Threads (g-thread.ads)::
10264 * GNAT.Traceback (g-traceb.ads)::
10265 * GNAT.Traceback.Symbolic (g-trasym.ads)::
10266 * Interfaces.C.Extensions (i-cexten.ads)::
10267 * Interfaces.C.Streams (i-cstrea.ads)::
10268 * Interfaces.CPP (i-cpp.ads)::
10269 * Interfaces.Os2lib (i-os2lib.ads)::
10270 * Interfaces.Os2lib.Errors (i-os2err.ads)::
10271 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
10272 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
10273 * Interfaces.Packed_Decimal (i-pacdec.ads)::
10274 * Interfaces.VxWorks (i-vxwork.ads)::
10275 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
10276 * System.Address_Image (s-addima.ads)::
10277 * System.Assertions (s-assert.ads)::
10278 * System.Partition_Interface (s-parint.ads)::
10279 * System.Task_Info (s-tasinf.ads)::
10280 * System.Wch_Cnv (s-wchcnv.ads)::
10281 * System.Wch_Con (s-wchcon.ads)::
10282 @end menu
10283
10284 @node Ada.Characters.Latin_9 (a-chlat9.ads)
10285 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
10286 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
10287 @cindex Latin_9 constants for Character
10288
10289 @noindent
10290 This child of @code{Ada.Characters}
10291 provides a set of definitions corresponding to those in the
10292 RM-defined package @code{Ada.Characters.Latin_1} but with the
10293 few modifications required for @code{Latin-9}
10294 The provision of such a package
10295 is specifically authorized by the Ada Reference Manual
10296 (RM A.3(27)).
10297
10298 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
10299 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
10300 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
10301 @cindex Latin_1 constants for Wide_Character
10302
10303 @noindent
10304 This child of @code{Ada.Characters}
10305 provides a set of definitions corresponding to those in the
10306 RM-defined package @code{Ada.Characters.Latin_1} but with the
10307 types of the constants being @code{Wide_Character}
10308 instead of @code{Character}.  The provision of such a package
10309 is specifically authorized by the Ada Reference Manual
10310 (RM A.3(27)).
10311
10312 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
10313 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
10314 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
10315 @cindex Latin_9 constants for Wide_Character
10316
10317 @noindent
10318 This child of @code{Ada.Characters}
10319 provides a set of definitions corresponding to those in the
10320 GNAT defined package @code{Ada.Characters.Latin_9} but with the
10321 types of the constants being @code{Wide_Character}
10322 instead of @code{Character}.  The provision of such a package
10323 is specifically authorized by the Ada Reference Manual
10324 (RM A.3(27)).
10325
10326 @node Ada.Command_Line.Remove (a-colire.ads)
10327 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
10328 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
10329 @cindex Removing command line arguments
10330 @cindex Command line, argument removal
10331
10332 @noindent
10333 This child of @code{Ada.Command_Line}
10334 provides a mechanism for logically removing
10335 arguments from the argument list.  Once removed, an argument is not visible
10336 to further calls on the subprograms in @code{Ada.Command_Line} will not
10337 see the removed argument.
10338
10339 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
10340 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
10341 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
10342 @cindex C Streams, Interfacing with Direct_IO
10343
10344 @noindent
10345 This package provides subprograms that allow interfacing between 
10346 C streams and @code{Direct_IO}.  The stream identifier can be
10347 extracted from a file opened on the Ada side, and an Ada file
10348 can be constructed from a stream opened on the C side.
10349
10350 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
10351 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
10352 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
10353 @cindex Null_Occurrence, testing for
10354
10355 @noindent
10356 This child subprogram provides a way of testing for the null 
10357 exception occurrence (@code{Null_Occurrence}) without raising
10358 an exception.
10359
10360 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
10361 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
10362 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
10363 @cindex C Streams, Interfacing with Sequential_IO
10364
10365 @noindent
10366 This package provides subprograms that allow interfacing between 
10367 C streams and @code{Sequential_IO}.  The stream identifier can be
10368 extracted from a file opened on the Ada side, and an Ada file
10369 can be constructed from a stream opened on the C side.
10370
10371 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
10372 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
10373 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
10374 @cindex C Streams, Interfacing with Stream_IO
10375
10376 @noindent
10377 This package provides subprograms that allow interfacing between 
10378 C streams and @code{Stream_IO}.  The stream identifier can be
10379 extracted from a file opened on the Ada side, and an Ada file
10380 can be constructed from a stream opened on the C side.
10381
10382 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
10383 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
10384 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
10385 @cindex @code{Unbounded_String}, IO support
10386 @cindex @code{Text_IO}, extensions for unbounded strings
10387
10388 @noindent
10389 This package provides subprograms for Text_IO for unbounded
10390 strings, avoiding the necessity for an intermediate operation
10391 with ordinary strings.
10392
10393 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
10394 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
10395 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
10396 @cindex @code{Unbounded_Wide_String}, IO support
10397 @cindex @code{Text_IO}, extensions for unbounded wide strings
10398
10399 @noindent
10400 This package provides subprograms for Text_IO for unbounded
10401 wide strings, avoiding the necessity for an intermediate operation
10402 with ordinary wide strings.
10403
10404 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
10405 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
10406 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
10407 @cindex C Streams, Interfacing with @code{Text_IO}
10408
10409 @noindent
10410 This package provides subprograms that allow interfacing between 
10411 C streams and @code{Text_IO}.  The stream identifier can be
10412 extracted from a file opened on the Ada side, and an Ada file
10413 can be constructed from a stream opened on the C side.
10414
10415 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
10416 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
10417 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
10418 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
10419
10420 @noindent
10421 This package provides subprograms that allow interfacing between 
10422 C streams and @code{Wide_Text_IO}.  The stream identifier can be
10423 extracted from a file opened on the Ada side, and an Ada file
10424 can be constructed from a stream opened on the C side.
10425
10426 @node GNAT.AWK (g-awk.ads)
10427 @section @code{GNAT.AWK} (@file{g-awk.ads})
10428 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
10429 @cindex Parsing
10430 @cindex AWK
10431
10432 @noindent
10433 Provides AWK-like parsing functions, with an easy interface for parsing one
10434 or more files containing formatted data.  The file is viewed as a database
10435 where each record is a line and a field is a data element in this line.
10436
10437 @node GNAT.Bubble_Sort_A (g-busora.ads)
10438 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
10439 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
10440 @cindex Sorting
10441 @cindex Bubble sort
10442
10443 @noindent
10444 Provides a general implementation of bubble sort usable for sorting arbitrary
10445 data items.  Move and comparison procedures are provided by passing
10446 access-to-procedure values.
10447
10448 @node GNAT.Bubble_Sort_G (g-busorg.ads)
10449 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
10450 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
10451 @cindex Sorting
10452 @cindex Bubble sort
10453
10454 @noindent
10455 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
10456 are provided as generic parameters, this improves efficiency, especially
10457 if the procedures can be inlined, at the expense of duplicating code for
10458 multiple instantiations.
10459
10460 @node GNAT.Calendar (g-calend.ads)
10461 @section @code{GNAT.Calendar} (@file{g-calend.ads})
10462 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
10463 @cindex @code{Calendar}
10464
10465 @noindent
10466 Extends the facilities provided by @code{Ada.Calendar} to include handling
10467 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
10468 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
10469 C @code{timeval} format.
10470
10471 @node GNAT.Calendar.Time_IO (g-catiio.ads)
10472 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
10473 @cindex @code{Calendar}
10474 @cindex Time
10475 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
10476
10477 @node GNAT.CRC32 (g-crc32.ads)
10478 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
10479 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
10480 @cindex CRC32
10481 @cindex Cyclic Redundancy Check
10482
10483 @noindent
10484 This package implements the CRC-32 algorithm.  For a full description
10485 of this algorithm you should have a look at:
10486 ``Computation of Cyclic Redundancy Checks via Table Look-Up'', @cite{Communications
10487 of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013, Aug.@: 1988.  Sarwate, D.V@.
10488
10489 @noindent
10490 Provides an extended capability for formatted output of time values with
10491 full user control over the format.  Modeled on the GNU Date specification.
10492
10493 @node GNAT.Case_Util (g-casuti.ads)
10494 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
10495 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
10496 @cindex Casing utilities
10497 @cindex Character handling (@code{GNAT.Case_Util})
10498
10499 @noindent
10500 A set of simple routines for handling upper and lower casing of strings
10501 without the overhead of the full casing tables
10502 in @code{Ada.Characters.Handling}.
10503
10504 @node GNAT.CGI (g-cgi.ads)
10505 @section @code{GNAT.CGI} (@file{g-cgi.ads})
10506 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
10507 @cindex CGI (Common Gateway Interface)
10508
10509 @noindent
10510 This is a package for interfacing a GNAT program with a Web server via the
10511 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
10512 parameters, which are a set of key/value pairs sent by the Web server.  It
10513 builds a table whose index is the key and provides some services to deal
10514 with this table.
10515
10516 @node GNAT.CGI.Cookie (g-cgicoo.ads)
10517 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
10518 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
10519 @cindex CGI (Common Gateway Interface) cookie support
10520 @cindex Cookie support in CGI
10521
10522 @noindent
10523 This is a package to interface a GNAT program with a Web server via the
10524 Common Gateway Interface (CGI).  It exports services to deal with Web
10525 cookies (piece of information kept in the Web client software).
10526
10527 @node GNAT.CGI.Debug (g-cgideb.ads)
10528 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
10529 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
10530 @cindex CGI (Common Gateway Interface) debugging
10531
10532 @noindent
10533 This is a package to help debugging CGI (Common Gateway Interface)
10534 programs written in Ada.
10535
10536 @node GNAT.Command_Line (g-comlin.ads)
10537 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
10538 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
10539 @cindex Command line
10540
10541 @noindent
10542 Provides a high level interface to @code{Ada.Command_Line} facilities,
10543 including the ability to scan for named switches with optional parameters
10544 and expand file names using wild card notations.
10545
10546 @node GNAT.Current_Exception (g-curexc.ads)
10547 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
10548 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
10549 @cindex Current exception
10550 @cindex Exception retrieval
10551
10552 @noindent
10553 Provides access to information on the current exception that has been raised
10554 without the need for using the Ada-95 exception choice parameter specification
10555 syntax.  This is particularly useful in simulating typical facilities for
10556 obtaining information about exceptions provided by Ada 83 compilers.
10557
10558 @node GNAT.Debug_Pools (g-debpoo.ads)
10559 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
10560 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
10561 @cindex Debugging
10562 @cindex Debug pools
10563 @cindex Memory corruption debugging
10564
10565 @noindent
10566 Provide a debugging storage pools that helps tracking memory corruption
10567 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
10568 the @cite{GNAT User's Guide}.
10569
10570 @node GNAT.Debug_Utilities (g-debuti.ads)
10571 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
10572 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
10573 @cindex Debugging
10574
10575 @noindent
10576 Provides a few useful utilities for debugging purposes, including conversion
10577 to and from string images of address values.
10578
10579 @node GNAT.Directory_Operations (g-dirope.ads)
10580 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
10581 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
10582 @cindex Directory operations
10583
10584 @noindent
10585 Provides a set of routines for manipulating directories, including changing
10586 the current directory, making new directories, and scanning the files in a
10587 directory.
10588
10589 @node GNAT.Dynamic_Tables (g-dyntab.ads)
10590 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
10591 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
10592 @cindex Table implementation
10593 @cindex Arrays, extendable
10594
10595 @noindent
10596 A generic package providing a single dimension array abstraction where the
10597 length of the array can be dynamically modified.
10598
10599 @noindent
10600 This package provides a facility similar to that of GNAT.Table, except 
10601 that this package declares a type that can be used to define dynamic
10602 instances of the table, while an instantiation of GNAT.Table creates a
10603 single instance of the table type.
10604
10605 @node GNAT.Exception_Traces (g-exctra.ads)
10606 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
10607 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
10608 @cindex Exception traces
10609 @cindex Debugging
10610
10611 @noindent
10612 Provides an interface allowing to control automatic output upon exception
10613 occurrences.
10614
10615 @node GNAT.Expect (g-expect.ads)
10616 @section @code{GNAT.Expect} (@file{g-expect.ads})
10617 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
10618
10619 @noindent
10620 Provides a set of subprograms similar to what is available
10621 with the standard Tcl Expect tool.
10622 It allows you to easily spawn and communicate with an external process.
10623 You can send commands or inputs to the process, and compare the output
10624 with some expected regular expression.
10625 Currently GNAT.Expect is implemented on all native GNAT ports except for
10626 OpenVMS@.  It is not implemented for cross ports, and in particular is not
10627 implemented for VxWorks or LynxOS@.
10628
10629 @node GNAT.Float_Control (g-flocon.ads)
10630 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
10631 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
10632 @cindex Floating-Point Processor
10633
10634 @noindent
10635 Provides an interface for resetting the floating-point processor into the
10636 mode required for correct semantic operation in Ada.  Some third party
10637 library calls may cause this mode to be modified, and the Reset procedure
10638 in this package can be used to reestablish the required mode.
10639
10640 @node GNAT.Heap_Sort_A (g-hesora.ads)
10641 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
10642 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
10643 @cindex Sorting
10644
10645 @noindent
10646 Provides a general implementation of heap sort usable for sorting arbitrary
10647 data items.  Move and comparison procedures are provided by passing
10648 access-to-procedure values.  The algorithm used is a modified heap sort
10649 that performs approximately N*log(N) comparisons in the worst case.
10650
10651 @node GNAT.Heap_Sort_G (g-hesorg.ads)
10652 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
10653 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
10654 @cindex Sorting
10655
10656 @noindent
10657 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
10658 are provided as generic parameters, this improves efficiency, especially
10659 if the procedures can be inlined, at the expense of duplicating code for
10660 multiple instantiations.
10661
10662 @node GNAT.HTable (g-htable.ads)
10663 @section @code{GNAT.HTable} (@file{g-htable.ads})
10664 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
10665 @cindex Hash tables
10666
10667 @noindent
10668 A generic implementation of hash tables that can be used to hash arbitrary
10669 data.  Provides two approaches, one a simple static approach, and the other
10670 allowing arbitrary dynamic hash tables.
10671
10672 @node GNAT.IO (g-io.ads)
10673 @section @code{GNAT.IO} (@file{g-io.ads})
10674 @cindex @code{GNAT.IO} (@file{g-io.ads})
10675 @cindex Simple I/O
10676 @cindex Input/Output facilities
10677
10678 @noindent
10679 A simple preealborable input-output package that provides a subset of
10680 simple Text_IO functions for reading characters and strings from
10681 Standard_Input, and writing characters, strings and integers to either
10682 Standard_Output or Standard_Error.
10683
10684 @node GNAT.IO_Aux (g-io_aux.ads)
10685 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
10686 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
10687 @cindex Text_IO
10688 @cindex Input/Output facilities
10689
10690 Provides some auxiliary functions for use with Text_IO, including a test
10691 for whether a file exists, and functions for reading a line of text.
10692
10693 @node GNAT.Lock_Files (g-locfil.ads)
10694 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
10695 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
10696 @cindex File locking
10697 @cindex Locking using files
10698
10699 @noindent
10700 Provides a general interface for using files as locks.  Can be used for
10701 providing program level synchronization. 
10702
10703 @node GNAT.MD5 (g-md5.ads)
10704 @section @code{GNAT.MD5} (@file{g-md5.ads})
10705 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
10706 @cindex Message Digest MD5
10707
10708 @noindent
10709 Implements the  MD5 Message-Digest Algorithm as described in RFC 1321.
10710
10711 @node GNAT.Most_Recent_Exception (g-moreex.ads)
10712 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
10713 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
10714 @cindex Exception, obtaining most recent
10715
10716 @noindent
10717 Provides access to the most recently raised exception.  Can be used for
10718 various logging purposes, including duplicating functionality of some
10719 Ada 83 implementation dependent extensions.
10720
10721 @node GNAT.OS_Lib (g-os_lib.ads)
10722 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
10723 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
10724 @cindex Operating System interface
10725 @cindex Spawn capability
10726
10727 @noindent
10728 Provides a range of target independent operating system interface functions,
10729 including time/date management, file operations, subprocess management,
10730 including a portable spawn procedure, and access to environment variables
10731 and error return codes.
10732
10733 @node GNAT.Regexp (g-regexp.ads)
10734 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
10735 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
10736 @cindex Regular expressions
10737 @cindex Pattern matching
10738
10739 @noindent
10740 A simple implementation of regular expressions, using a subset of regular
10741 expression syntax copied from familiar Unix style utilities.  This is the
10742 simples of the three pattern matching packages provided, and is particularly
10743 suitable for ``file globbing'' applications.
10744
10745 @node GNAT.Registry (g-regist.ads)
10746 @section @code{GNAT.Registry} (@file{g-regist.ads})
10747 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
10748 @cindex Windows Registry
10749
10750 @noindent
10751 This is a high level binding to the Windows registry.  It is possible to
10752 do simple things like reading a key value, creating a new key.  For full
10753 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
10754 package provided with the Win32Ada binding
10755
10756 @node GNAT.Regpat (g-regpat.ads)
10757 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
10758 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
10759 @cindex Regular expressions
10760 @cindex Pattern matching
10761
10762 @noindent
10763 A complete implementation of Unix-style regular expression matching, copied
10764 from the original V7 style regular expression library written in C by
10765 Henry Spencer (and binary compatible with this C library).
10766
10767 @node GNAT.Sockets (g-socket.ads)
10768 @section @code{GNAT.Sockets} (@file{g-socket.ads})
10769 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
10770 @cindex Sockets
10771
10772 @noindent
10773 A high level and portable interface to develop sockets based applications.
10774 This package is based on the sockets thin binding found in GNAT.Sockets.Thin.
10775 Currently GNAT.Sockets is implemented on all native GNAT ports except for
10776 OpenVMS@.  It is not implemented for the LynxOS@ cross port.
10777
10778 @node GNAT.Source_Info (g-souinf.ads)
10779 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
10780 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
10781 @cindex Source Information
10782
10783 @noindent
10784 Provides subprograms that give access to source code information known at
10785 compile time, such as the current file name and line number.
10786
10787 @node GNAT.Spell_Checker (g-speche.ads)
10788 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
10789 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
10790 @cindex Spell checking
10791
10792 @noindent
10793 Provides a function for determining whether one string is a plausible
10794 near misspelling of another string.
10795
10796 @node GNAT.Spitbol.Patterns (g-spipat.ads)
10797 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
10798 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
10799 @cindex SPITBOL pattern matching
10800 @cindex Pattern matching
10801
10802 @noindent
10803 A complete implementation of SNOBOL4 style pattern matching.  This is the
10804 most elaborate of the pattern matching packages provided.  It fully duplicates
10805 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
10806 efficient algorithm developed by Robert Dewar for the SPITBOL system.
10807
10808 @node GNAT.Spitbol (g-spitbo.ads)
10809 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
10810 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
10811 @cindex SPITBOL interface
10812
10813 @noindent
10814 The top level package of the collection of SPITBOL-style functionality, this
10815 package provides basic SNOBOL4 string manipulation functions, such as
10816 Pad, Reverse, Trim, Substr capability, as well as a generic table function
10817 useful for constructing arbitrary mappings from strings in the style of
10818 the SNOBOL4 TABLE function.
10819
10820 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
10821 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
10822 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
10823 @cindex Sets of strings
10824 @cindex SPITBOL Tables
10825
10826 @noindent
10827 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10828 for type @code{Standard.Boolean}, giving an implementation of sets of
10829 string values.
10830
10831 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
10832 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
10833 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
10834 @cindex Integer maps
10835 @cindex Maps
10836 @cindex SPITBOL Tables
10837
10838 @noindent
10839 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10840 for type @code{Standard.Integer}, giving an implementation of maps
10841 from string to integer values.
10842
10843 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
10844 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
10845 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
10846 @cindex String maps
10847 @cindex Maps
10848 @cindex SPITBOL Tables
10849
10850 @noindent
10851 A library level of instantiation of GNAT.Spitbol.Patterns.Table for 
10852 a variable length string type, giving an implementation of general
10853 maps from strings to strings.
10854
10855 @node GNAT.Table (g-table.ads)
10856 @section @code{GNAT.Table} (@file{g-table.ads})
10857 @cindex @code{GNAT.Table} (@file{g-table.ads})
10858 @cindex Table implementation
10859 @cindex Arrays, extendable
10860
10861 @noindent
10862 A generic package providing a single dimension array abstraction where the
10863 length of the array can be dynamically modified.
10864
10865 @noindent
10866 This package provides a facility similar to that of GNAT.Dynamic_Tables,
10867 except that this package declares a single instance of the table type,
10868 while an instantiation of GNAT.Dynamic_Tables creates a type that can be
10869 used to define dynamic instances of the table.
10870
10871 @node GNAT.Task_Lock (g-tasloc.ads)
10872 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
10873 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
10874 @cindex Task synchronization
10875 @cindex Task locking
10876 @cindex Locking
10877
10878 @noindent
10879 A very simple facility for locking and unlocking sections of code using a
10880 single global task lock.  Appropriate for use in situations where contention
10881 between tasks is very rarely expected.
10882
10883 @node GNAT.Threads (g-thread.ads)
10884 @section @code{GNAT.Threads} (@file{g-thread.ads})
10885 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
10886 @cindex Foreign threads
10887 @cindex Threads, foreign
10888
10889 @noindent
10890 Provides facilities for creating and destroying threads with explicit calls.
10891 These threads are known to the GNAT run-time system.  These subprograms are
10892 exported C-convention procedures intended to be called from foreign code.
10893 By using these primitives rather than directly calling operating systems
10894 routines, compatibility with the Ada tasking runt-time is provided.
10895
10896 @node GNAT.Traceback (g-traceb.ads)
10897 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
10898 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
10899 @cindex Trace back facilities
10900
10901 @noindent
10902 Provides a facility for obtaining non-symbolic traceback information, useful
10903 in various debugging situations.
10904
10905 @node GNAT.Traceback.Symbolic (g-trasym.ads)
10906 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
10907 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
10908 @cindex Trace back facilities
10909
10910 @noindent
10911 Provides symbolic traceback information that includes the subprogram
10912 name and line number information.
10913
10914 @node Interfaces.C.Extensions (i-cexten.ads)
10915 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
10916 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
10917
10918 @noindent
10919 This package contains additional C-related definitions, intended
10920 for use with either manually or automatically generated bindings
10921 to C libraries.
10922
10923 @node Interfaces.C.Streams (i-cstrea.ads)
10924 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
10925 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
10926 @cindex  C streams, interfacing
10927
10928 @noindent
10929 This package is a binding for the most commonly used operations
10930 on C streams.
10931
10932 @node Interfaces.CPP (i-cpp.ads)
10933 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
10934 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
10935 @cindex  C++ interfacing
10936 @cindex  Interfacing, to C++
10937
10938 @noindent
10939 This package provides facilities for use in interfacing to C++.  It
10940 is primarily intended to be used in connection with automated tools
10941 for the generation of C++ interfaces.
10942
10943 @node Interfaces.Os2lib (i-os2lib.ads)
10944 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
10945 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
10946 @cindex Interfacing, to OS/2
10947 @cindex OS/2 interfacing
10948
10949 @noindent
10950 This package provides interface definitions to the OS/2 library.
10951 It is a thin binding which is a direct translation of the
10952 various @file{<bse@.h>} files.
10953
10954 @node Interfaces.Os2lib.Errors (i-os2err.ads)
10955 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
10956 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
10957 @cindex OS/2 Error codes
10958 @cindex Interfacing, to OS/2
10959 @cindex OS/2 interfacing
10960
10961 @noindent
10962 This package provides definitions of the OS/2 error codes.
10963
10964 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
10965 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
10966 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
10967 @cindex Interfacing, to OS/2
10968 @cindex Synchronization, OS/2
10969 @cindex OS/2 synchronization primitives
10970
10971 @noindent
10972 This is a child package that provides definitions for interfacing
10973 to the @code{OS/2} synchronization primitives.
10974
10975 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
10976 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
10977 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
10978 @cindex Interfacing, to OS/2
10979 @cindex Thread control, OS/2
10980 @cindex OS/2 thread interfacing
10981
10982 @noindent
10983 This is a child package that provides definitions for interfacing
10984 to the @code{OS/2} thread primitives.
10985
10986 @node Interfaces.Packed_Decimal (i-pacdec.ads)
10987 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
10988 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
10989 @cindex  IBM Packed Format
10990 @cindex  Packed Decimal
10991
10992 @noindent
10993 This package provides a set of routines for conversions to and
10994 from a packed decimal format compatible with that used on IBM
10995 mainframes.
10996
10997 @node Interfaces.VxWorks (i-vxwork.ads)
10998 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
10999 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
11000 @cindex Interfacing to VxWorks
11001 @cindex VxWorks, interfacing
11002
11003 @noindent
11004 This package provides a limited binding to the VxWorks API.
11005 In particular, it interfaces with the
11006 VxWorks hardware interrupt facilities.
11007
11008 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
11009 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
11010 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
11011 @cindex Interfacing to VxWorks' I/O
11012 @cindex VxWorks, I/O interfacing
11013 @cindex VxWorks, Get_Immediate
11014
11015 @noindent
11016 This package provides a limited binding to the VxWorks' I/O API.
11017 In particular, it provides procedures that enable the use of
11018 Get_Immediate under VxWorks.
11019
11020 @node System.Address_Image (s-addima.ads)
11021 @section @code{System.Address_Image} (@file{s-addima.ads})
11022 @cindex @code{System.Address_Image} (@file{s-addima.ads})
11023 @cindex Address image
11024 @cindex Image, of an address
11025
11026 @noindent
11027 This function provides a useful debugging
11028 function that gives an (implementation dependent)
11029 string which identifies an address.
11030
11031 @node System.Assertions (s-assert.ads)
11032 @section @code{System.Assertions} (@file{s-assert.ads})
11033 @cindex @code{System.Assertions} (@file{s-assert.ads})
11034 @cindex Assertions
11035 @cindex Assert_Failure, exception
11036
11037 @noindent
11038 This package provides the declaration of the exception raised
11039 by an run-time assertion failure, as well as the routine that
11040 is used internally to raise this assertion.
11041
11042 @node System.Partition_Interface (s-parint.ads)
11043 @section @code{System.Partition_Interface} (@file{s-parint.ads})
11044 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
11045 @cindex Partition intefacing functions
11046
11047 @noindent
11048 This package provides facilities for partition interfacing.  It
11049 is used primarily in a distribution context when using Annex E
11050 with @code{GLADE}.
11051
11052 @node System.Task_Info (s-tasinf.ads)
11053 @section @code{System.Task_Info} (@file{s-tasinf.ads})
11054 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
11055 @cindex Task_Info pragma
11056
11057 @noindent
11058 This package provides target dependent functionality that is used
11059 to support the @code{Task_Info} pragma
11060
11061 @node System.Wch_Cnv (s-wchcnv.ads)
11062 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
11063 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
11064 @cindex Wide Character, Representation
11065 @cindex Wide String, Conversion
11066 @cindex Representation of wide characters
11067
11068 @noindent
11069 This package provides routines for converting between
11070 wide characters and a representation as a value of type
11071 @code{Standard.String}, using a specified wide character
11072 encoding method.  It uses definitions in
11073 package @code{System.Wch_Con}.
11074
11075 @node System.Wch_Con (s-wchcon.ads)
11076 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
11077 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
11078
11079 @noindent
11080 This package provides definitions and descriptions of
11081 the various methods used for encoding wide characters
11082 in ordinary strings.  These definitions are used by
11083 the package @code{System.Wch_Cnv}.
11084
11085 @node Interfacing to Other Languages
11086 @chapter Interfacing to Other Languages
11087 @noindent
11088 The facilities in annex B of the Ada 95 Reference Manual are fully
11089 implemented in GNAT, and in addition, a full interface to C++ is
11090 provided.
11091
11092 @menu
11093 * Interfacing to C::          
11094 * Interfacing to C++::          
11095 * Interfacing to COBOL::        
11096 * Interfacing to Fortran::      
11097 * Interfacing to non-GNAT Ada code::
11098 @end menu
11099
11100 @node Interfacing to C
11101 @section Interfacing to C
11102
11103 @noindent
11104 Interfacing to C with GNAT can use one of two approaches:
11105
11106 @enumerate
11107 @item
11108 The types in the package @code{Interfaces.C} may be used.
11109 @item
11110 Standard Ada types may be used directly.  This may be less portable to
11111 other compilers, but will work on all GNAT compilers, which guarantee
11112 correspondence between the C and Ada types.
11113 @end enumerate
11114
11115 @noindent
11116 Pragma @code{Convention C} maybe applied to Ada types, but mostly has no
11117 effect, since this is the default.  The following table shows the
11118 correspondence between Ada scalar types and the corresponding C types.
11119
11120 @table @code
11121 @item Integer
11122 @code{int}
11123 @item Short_Integer
11124 @code{short}
11125 @item Short_Short_Integer
11126 @code{signed char}
11127 @item Long_Integer
11128 @code{long}
11129 @item Long_Long_Integer
11130 @code{long long}
11131 @item Short_Float
11132 @code{float}
11133 @item Float
11134 @code{float}
11135 @item Long_Float
11136 @code{double}
11137 @item Long_Long_Float
11138 This is the longest floating-point type supported by the hardware.
11139 @end table
11140
11141 @itemize @bullet
11142 @item
11143 Ada enumeration types map to C enumeration types directly if pragma
11144 @code{Convention C} is specified, which causes them to have int
11145 length.  Without pragma @code{Convention C}, Ada enumeration types map to
11146 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short}, @code{int}, respectively)
11147 depending on the number of values passed.  This is the only case in which
11148 pragma @code{Convention C} affects the representation of an Ada type.
11149
11150 @item
11151 Ada access types map to C pointers, except for the case of pointers to
11152 unconstrained types in Ada, which have no direct C equivalent.
11153
11154 @item
11155 Ada arrays map directly to C arrays.
11156
11157 @item
11158 Ada records map directly to C structures.
11159
11160 @item
11161 Packed Ada records map to C structures where all members are bit fields
11162 of the length corresponding to the @code{@var{type}'Size} value in Ada.
11163 @end itemize
11164
11165 @node Interfacing to C++
11166 @section Interfacing to C++
11167
11168 @noindent
11169 The interface to C++ makes use of the following pragmas, which are
11170 primarily intended to be constructed automatically using a binding generator
11171 tool, although it is possible to construct them by hand.  Ada Core 
11172 Technologies does not currently supply a suitable binding generator tool.
11173
11174 Using these pragmas it is possible to achieve complete
11175 inter-operability between Ada tagged types and C class definitions.
11176 See @ref{Implementation Defined Pragmas} for more details.
11177
11178 @table @code
11179 @item pragma CPP_Class ([Entity =>] @var{local_name})
11180 The argument denotes an entity in the current declarative region that is
11181 declared as a tagged or untagged record type.  It indicates that the type
11182 corresponds to an externally declared C++ class type, and is to be laid
11183 out the same way that C++ would lay out the type.
11184
11185 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
11186 This pragma identifies an imported function (imported in the usual way
11187 with pragma @code{Import}) as corresponding to a C++ constructor.
11188
11189 @item pragma CPP_Vtable @dots{}
11190 One @code{CPP_Vtable} pragma can be present for each component of type
11191 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
11192 applies.
11193 @end table
11194
11195 @node Interfacing to COBOL
11196 @section Interfacing to COBOL
11197
11198 @noindent
11199 Interfacing to COBOL is achieved as described in section B.4 of
11200 the Ada 95 reference manual.
11201
11202 @node Interfacing to Fortran
11203 @section Interfacing to Fortran
11204
11205 @noindent
11206 Interfacing to Fortran is achieved as described in section B.5 of the
11207 reference manual.  The pragma @code{Convention Fortran}, applied to a
11208 multi-dimensional array causes the array to be stored in column-major
11209 order as required for convenient interface to Fortran.
11210
11211 @node Interfacing to non-GNAT Ada code
11212 @section Interfacing to non-GNAT Ada code
11213
11214 It is possible to specify the convention @code{Ada} in a pragma @code{Import} or
11215 pragma @code{Export}.  However this refers to the calling conventions used
11216 by GNAT, which may or may not be similar enough to those used by
11217 some other Ada 83 or Ada 95 compiler to allow interoperation.
11218
11219 If arguments types are kept simple, and if the foreign compiler generally
11220 follows system calling conventions, then it may be possible to integrate
11221 files compiled by other Ada compilers, provided that the elaboration
11222 issues are adequately addressed (for example by eliminating the 
11223 need for any load time elaboration).
11224
11225 In particular, GNAT running on VMS is designed to
11226 be highly compatible with the DEC Ada 83 compiler, so this is one
11227 case in which it is possible to import foreign units of this type,
11228 provided that the data items passed are restricted to simple scalar
11229 values or simple record types without variants, or simple array
11230 types with fixed bounds.
11231
11232 @node Machine Code Insertions
11233 @chapter Machine Code Insertions
11234
11235 @noindent
11236 Package @code{Machine_Code} provides machine code support as described
11237 in the Ada 95 Reference Manual in two separate forms:
11238 @itemize @bullet
11239 @item
11240 Machine code statements, consisting of qualified expressions that
11241 fit the requirements of RM section 13.8.
11242 @item
11243 An intrinsic callable procedure, providing an alternative mechanism of
11244 including machine instructions in a subprogram.
11245 @end itemize
11246
11247 The two features are similar, and both closely related to the mechanism
11248 provided by the asm instruction in the GNU C compiler.  Full understanding
11249 and use of the facilities in this package requires understanding the asm
11250 instruction as described in 
11251 @cite{Using and Porting the GNU Compiler Collection (GCC)} by Richard
11252 Stallman.  Calls to the function @code{Asm} and the procedure @code{Asm}
11253 have identical semantic restrictions and effects as described below.
11254 Both are provided so that the procedure call can be used as a statement,
11255 and the function call can be used to form a code_statement.
11256
11257 The first example given in the GCC documentation is the C @code{asm}
11258 instruction:
11259 @smallexample
11260    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
11261 @end smallexample
11262
11263 @noindent
11264 The equivalent can be written for GNAT as:
11265
11266 @smallexample
11267 Asm ("fsinx %1 %0",
11268      My_Float'Asm_Output ("=f", result),
11269      My_Float'Asm_Input  ("f",  angle));
11270 @end smallexample
11271
11272 The first argument to @code{Asm} is the assembler template, and is
11273 identical to what is used in GNU C@.  This string must be a static
11274 expression.  The second argument is the output operand list.  It is
11275 either a single @code{Asm_Output} attribute reference, or a list of such
11276 references enclosed in parentheses (technically an array aggregate of
11277 such references).
11278
11279 The @code{Asm_Output} attribute denotes a function that takes two
11280 parameters.  The first is a string, the second is the name of a variable
11281 of the type designated by the attribute prefix.  The first (string)
11282 argument is required to be a static expression and designates the
11283 constraint for the parameter (e.g.@: what kind of register is
11284 required).  The second argument is the variable to be updated with the
11285 result.  The possible values for constraint are the same as those used in
11286 the RTL, and are dependent on the configuration file used to build the
11287 GCC back end.  If there are no output operands, then this argument may
11288 either be omitted, or explicitly given as @code{No_Output_Operands}.
11289
11290 The second argument of @code{@var{my_float}'Asm_Output} functions as
11291 though it were an @code{out} parameter, which is a little curious, but
11292 all names have the form of expressions, so there is no syntactic
11293 irregularity, even though normally functions would not be permitted
11294 @code{out} parameters.  The third argument is the list of input
11295 operands.  It is either a single @code{Asm_Input} attribute reference, or
11296 a list of such references enclosed in parentheses (technically an array
11297 aggregate of such references).
11298
11299 The @code{Asm_Input} attribute denotes a function that takes two
11300 parameters.  The first is a string, the second is an expression of the
11301 type designated by the prefix.  The first (string) argument is required
11302 to be a static expression, and is the constraint for the parameter,
11303 (e.g.@: what kind of register is required).  The second argument is the
11304 value to be used as the input argument.  The possible values for the
11305 constant are the same as those used in the RTL, and are dependent on
11306 the configuration file used to built the GCC back end.
11307
11308 If there are no input operands, this argument may either be omitted, or
11309 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
11310 present in the above example, is a list of register names, called the
11311 @dfn{clobber} argument.  This argument, if given, must be a static string
11312 expression, and is a space or comma separated list of names of registers
11313 that must be considered destroyed as a result of the @code{Asm} call.  If
11314 this argument is the null string (the default value), then the code
11315 generator assumes that no additional registers are destroyed.
11316
11317 The fifth argument, not present in the above example, called the
11318 @dfn{volatile} argument, is by default @code{False}.  It can be set to
11319 the literal value @code{True} to indicate to the code generator that all
11320 optimizations with respect to the instruction specified should be
11321 suppressed, and that in particular, for an instruction that has outputs,
11322 the instruction will still be generated, even if none of the outputs are
11323 used.  See the full description in the GCC manual for further details.
11324
11325 The @code{Asm} subprograms may be used in two ways.  First the procedure
11326 forms can be used anywhere a procedure call would be valid, and
11327 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
11328 be used to intersperse machine instructions with other Ada statements.
11329 Second, the function forms, which return a dummy value of the limited
11330 private type @code{Asm_Insn}, can be used in code statements, and indeed
11331 this is the only context where such calls are allowed.  Code statements
11332 appear as aggregates of the form:
11333
11334 @smallexample
11335 Asm_Insn'(Asm (@dots{}));
11336 Asm_Insn'(Asm_Volatile (@dots{}));
11337 @end smallexample
11338
11339 In accordance with RM rules, such code statements are allowed only
11340 within subprograms whose entire body consists of such statements.  It is
11341 not permissible to intermix such statements with other Ada statements.
11342
11343 Typically the form using intrinsic procedure calls is more convenient
11344 and more flexible.  The code statement form is provided to meet the RM
11345 suggestion that such a facility should be made available.  The following
11346 is the exact syntax of the call to @code{Asm} (of course if named notation is
11347 used, the arguments may be given in arbitrary order, following the
11348 normal rules for use of positional and named arguments)
11349
11350 @smallexample
11351 ASM_CALL ::= Asm (
11352                  [Template =>] static_string_EXPRESSION
11353                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
11354                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
11355                [,[Clobber  =>] static_string_EXPRESSION ]
11356                [,[Volatile =>] static_boolean_EXPRESSION] )
11357 OUTPUT_OPERAND_LIST ::=
11358   No_Output_Operands
11359 | OUTPUT_OPERAND_ATTRIBUTE
11360 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
11361 OUTPUT_OPERAND_ATTRIBUTE ::=
11362   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
11363 INPUT_OPERAND_LIST ::=
11364   No_Input_Operands
11365 | INPUT_OPERAND_ATTRIBUTE
11366 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
11367 INPUT_OPERAND_ATTRIBUTE ::=
11368   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
11369 @end smallexample
11370
11371 @node GNAT Implementation of Tasking
11372 @chapter GNAT Implementation of Tasking
11373 @menu
11374 * Mapping Ada Tasks onto the Underlying Kernel Threads::
11375 * Ensuring Compliance with the Real-Time Annex::
11376 @end menu
11377
11378 @node Mapping Ada Tasks onto the Underlying Kernel Threads
11379 @section Mapping Ada Tasks onto the Underlying Kernel Threads
11380
11381 GNAT run-time system comprises two layers:
11382
11383 @itemize @bullet
11384 @item GNARL (GNAT Run-time  Layer)
11385 @item GNULL (GNAT Low-level Library)
11386 @end itemize
11387
11388 In GNAT, Ada's tasking services rely on a platform and OS independent
11389 layer known as GNARL@.  This code is responsible for implementing the
11390 correct semantics of Ada's task creation, rendezvous, protected
11391 operations etc.
11392
11393 GNARL decomposes Ada's tasking semantics into simpler lower level
11394 operations such as create a thread, set the priority of a thread,
11395 yield, create a lock, lock/unlock, etc.  The spec for these low-level
11396 operations constitutes GNULLI, the GNULL Interface.  This interface is
11397 directly inspired from the POSIX real-time API@.
11398
11399 If the underlying executive or OS implements the POSIX standard
11400 faithfully, the GNULL Interface maps as is to the services offered by
11401 the underlying kernel.  Otherwise, some target dependent glue code maps
11402 the services offered by the underlying kernel to the semantics expected
11403 by GNARL@.
11404
11405 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
11406 key point is that each Ada task is mapped on a thread in the underlying 
11407 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
11408
11409 In addition Ada task priorities map onto the underlying thread priorities.
11410 Mapping Ada tasks onto the underlying kernel threads has several advantages:
11411
11412 @enumerate
11413
11414 @item
11415 The underlying scheduler is used to schedule the Ada tasks.  This
11416 makes Ada tasks as efficient as kernel threads from a scheduling
11417 standpoint.  
11418
11419 @item
11420 Interaction with code written in C containing threads is eased
11421 since at the lowest level Ada tasks and C threads map onto the same
11422 underlying kernel concept.
11423
11424 @item
11425 When an Ada task is blocked during I/O the remaining Ada tasks are
11426 able to proceed.
11427
11428 @item
11429 On multi-processor systems Ada Tasks can execute in parallel.
11430 @end enumerate
11431
11432 @node Ensuring Compliance with the Real-Time Annex
11433 @section Ensuring Compliance with the Real-Time Annex
11434
11435 The reader will be quick to notice that while mapping Ada tasks onto
11436 the underlying threads has significant advantages, it does create some
11437 complications when it comes to respecting the scheduling semantics
11438 specified in the real-time annex (Annex D).
11439
11440 For instance Annex D requires that for the FIFO_Within_Priorities
11441 scheduling policy we have:
11442
11443 @smallexample
11444 When the active priority of a ready task that is not running
11445 changes, or the setting of its base priority takes effect, the
11446 task is removed from the ready queue for its old active priority
11447 and is added at the tail of the ready queue for its new active
11448 priority, except in the case where the active priority is lowered
11449 due to the loss of inherited priority, in which case the task is
11450 added at the head of the ready queue for its new active priority.
11451 @end smallexample
11452
11453 While most kernels do put tasks at the end of the priority queue when
11454 a task changes its priority, (which respects the main
11455 FIFO_Within_Priorities requirement), almost none keep a thread at the
11456 beginning of its priority queue when its priority drops from the loss
11457 of inherited priority.
11458
11459 As a result most vendors have provided incomplete Annex D implementations.
11460
11461 The GNAT run-time, has a nice cooperative solution to this problem
11462 which ensures that accurate FIFO_Within_Priorities semantics are
11463 respected.
11464
11465 The principle is as follows.  When an Ada task T is about to start
11466 running, it checks whether some other Ada task R with the same
11467 priority as T has been suspended due to the loss of priority
11468 inheritance.  If this is the case, T yields and is placed at the end of
11469 its priority queue.  When R arrives at the front of the queue it
11470 executes. 
11471
11472 Note that this simple scheme preserves the relative order of the tasks
11473 that were ready to execute in the priority queue where R has been
11474 placed at the end.
11475
11476 @node    Code generation for array aggregates
11477 @chapter  Code generation for array aggregates
11478
11479 @menu
11480 * Static constant aggregates with static bounds::
11481 * Constant aggregates with an unconstrained nominal types::
11482 * Aggregates with static bounds::
11483 * Aggregates with non-static bounds::
11484 * Aggregates in assignments statements::
11485 @end menu
11486  
11487 Aggregate have a rich syntax and allow the user to specify the values of
11488 complex data structures by means of a single construct.  As a result, the
11489 code generated for aggregates can be quite complex and involve loops, case
11490 statements and multiple assignments.  In the simplest cases, however, the
11491 compiler will recognize aggregates whose components and constraints are
11492 fully static, and in those cases the compiler will generate little or no
11493 executable code.  The following is an outline of the code that GNAT generates
11494 for various aggregate constructs.  For further details, the user will find it
11495 useful to examine the output produced by the -gnatG flag to see the expanded
11496 source that is input to the code generator.  The user will also want to examine
11497 the assembly code generated at various levels of optimization.
11498
11499 The code generated for aggregates depends on the context, the component values,
11500 and the type.  In the context of an object declaration the code generated is
11501 generally simpler than in the case of an assignment.  As a general rule, static
11502 component values and static subtypes also lead to simpler code.
11503  
11504 @node Static constant aggregates with static bounds
11505 @section Static constant aggregates with static bounds
11506  
11507  For the declarations:
11508 @smallexample 
11509     type One_Dim is array (1..10) of integer;
11510     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
11511 @end smallexample 
11512
11513 GNAT generates no executable code: the constant ar0 is placed in static memory.
11514 The same is true for constant aggregates with named associations:
11515  
11516 @smallexample 
11517     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
11518     Cr3 : constant One_Dim := (others => 7777);
11519 @end smallexample 
11520  
11521  The same is true for multidimensional constant arrays such as:
11522  
11523 @smallexample 
11524     type two_dim is array (1..3, 1..3) of integer;
11525     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
11526 @end smallexample 
11527  
11528 The same is true for arrays of one-dimensional arrays: the following are
11529 static:
11530  
11531 @smallexample 
11532 type ar1b is array (1..3) of boolean;
11533 type ar_ar is array (1..3) of ar1b;
11534 None : constant ar1b := (others => false);      --  fully static
11535 None2 : constant ar_ar := (1..3 => None);       --  fully static
11536 @end smallexample 
11537  
11538 However, for multidimensional aggregates with named associations, GNAT will
11539 generate assignments and loops, even if all associations are static.  The
11540 following two declarations generate a loop for the first dimension, and
11541 individual component assignments for the second dimension:
11542  
11543 @smallexample 
11544 Zero1: constant two_dim := (1..3 => (1..3 => 0));
11545 Zero2: constant two_dim := (others => (others => 0));     
11546 @end smallexample 
11547  
11548 @node Constant aggregates with an unconstrained nominal types
11549 @section Constant aggregates with an unconstrained nominal types
11550  
11551 In such cases the aggregate itself establishes the subtype, so that associations
11552 with @code{others} cannot be used.  GNAT determines the bounds for the actual
11553 subtype of the aggregate, and allocates the aggregate statically as well.  No
11554 code is generated for the following:
11555  
11556 @smallexample 
11557     type One_Unc is array (natural range <>) of integer;
11558     Cr_Unc : constant One_Unc := (12,24,36);
11559 @end smallexample 
11560  
11561 @node Aggregates with static bounds
11562 @section Aggregates with static bounds
11563  
11564 In all previous examples the aggregate was the initial (and immutable) value
11565 of a constant.  If the aggregate initializes a variable, then code is generated
11566 for it as a combination of individual assignments and loops over the target
11567 object.  The declarations
11568  
11569 @smallexample 
11570        Cr_Var1 : One_Dim := (2, 5, 7, 11);
11571        Cr_Var2 : One_Dim := (others > -1);
11572 @end smallexample 
11573  
11574 generate the equivalent of
11575  
11576 @smallexample 
11577        Cr_Var1 (1) := 2;
11578        Cr_Var1 (2) := 3;
11579        Cr_Var1 (3) := 5;
11580        Cr_Var1 (4) := 11;
11581  
11582        for I in Cr_Var2'range loop
11583           Cr_Var2 (I) := =-1;
11584        end loop;
11585 @end smallexample 
11586  
11587 @node Aggregates with non-static bounds
11588 @section Aggregates with non-static bounds
11589  
11590 If the bounds of the aggregate are not statically compatible with the bounds
11591 of the nominal subtype  of the target, then constraint checks have to be
11592 generated on the bounds.  For a multidimensional array, constraint checks may
11593 have to be applied to sub-arrays individually, if they do not have statically
11594 compatible subtypes.
11595  
11596 @node Aggregates in assignments statements
11597 @section Aggregates in assignments statements
11598  
11599 In general, aggregate assignment requires the construction of a temporary,
11600 and a copy from the temporary to the target of the assignment.  This is because
11601 it is not always possible to convert the assignment into a series of individual 
11602 component assignments.  For example, consider the simple case:
11603  
11604 @smallexample 
11605 @end smallexample 
11606         A := (A(2), A(1));
11607  
11608 This cannot be converted into:
11609  
11610 @smallexample 
11611         A(1) := A(2);
11612         A(2) := A(1);
11613 @end smallexample 
11614  
11615 So the aggregate has to be built first in a separate location, and then
11616 copied into the target.  GNAT recognizes simple cases where this intermediate
11617 step is not required, and the assignments can be performed in place, directly
11618 into the target.  The following sufficient criteria are applied:
11619
11620 @enumerate 
11621 @item The bounds of the aggregate are static, and the associations are static.
11622 @item  The components of the aggregate are static constants, names of
11623     simple variables that are not renamings, or expressions not involving
11624     indexed components whose operands obey these rules.
11625 @end enumerate
11626  
11627 If any of these conditions are violated, the aggregate will be built in
11628 a temporary (created either by the front-end or the code generator) and then
11629 that temporary will be copied onto the target.
11630  
11631  
11632 @node Specialized Needs Annexes
11633 @chapter Specialized Needs Annexes
11634
11635 @noindent
11636 Ada 95 defines a number of specialized needs annexes, which are not
11637 required in all implementations.  However, as described in this chapter,
11638 GNAT implements all of these special needs annexes:
11639
11640 @table @asis
11641 @item Systems Programming (Annex C)
11642 The Systems Programming Annex is fully implemented.
11643
11644 @item Real-Time Systems (Annex D)
11645 The Real-Time Systems Annex is fully implemented.
11646
11647 @item Distributed Systems (Annex E)
11648 Stub generation is fully implemented in the GNAT compiler.  In addition,
11649 a complete compatible PCS is available as part of the GLADE system,
11650 a separate product.  When the two
11651 products are used in conjunction, this annex is fully implemented.
11652
11653 @item Information Systems (Annex F)
11654 The Information Systems annex is fully implemented.
11655
11656 @item Numerics (Annex G)
11657 The Numerics Annex is fully implemented.
11658
11659 @item Safety and Security (Annex H)
11660 The Safety and Security annex is fully implemented.
11661
11662 @end table
11663
11664 @node Compatibility Guide
11665 @chapter Compatibility Guide
11666
11667 @noindent
11668 This chapter contains sections that describe compatibility issues between
11669 GNAT and other Ada 83 and Ada 95 compilation systems, to aid in porting
11670 applications developed in other Ada environments.
11671
11672 @menu
11673 * Compatibility with Ada 83::       
11674 * Compatibility with DEC Ada 83::
11675 * Compatibility with Other Ada 95 Systems::
11676 * Representation Clauses::
11677 @end menu
11678
11679 @node Compatibility with Ada 83
11680 @section Compatibility with Ada 83
11681 @cindex Compatibility (between Ada 83 and Ada 95)
11682
11683 @noindent
11684 Ada 95 is designed to be highly upwards compatible with Ada 83.  In
11685 particular, the design intention is that the difficulties associated
11686 with moving from Ada 83 to Ada 95 should be no greater than those
11687 that occur when moving from one Ada 83 system to another.
11688
11689 However, there are a number of points at which there are minor
11690 incompatibilities.  The Ada 95 Annotated Reference Manual contains
11691 full details of these issues,
11692 and should be consulted for a complete treatment.
11693 In practice the
11694 following are the most likely issues to be encountered.
11695
11696 @table @asis
11697 @item Character range
11698 The range of @code{Standard.Character} is now the full 256 characters of Latin-1,
11699 whereas in most Ada 83 implementations it was restricted to 128 characters.
11700 This may show up as compile time or runtime errors.  The desirable fix is to
11701 adapt the program to accommodate the full character set, but in some cases
11702 it may be convenient to define a subtype or derived type of Character that
11703 covers only the restricted range.
11704 @cindex Latin-1
11705
11706 @item New reserved words
11707 The identifiers @code{abstract}, @code{aliased}, @code{protected},
11708 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
11709 Existing Ada 83 code using any of these identifiers must be edited to
11710 use some alternative name.
11711
11712 @item Freezing rules
11713 The rules in Ada 95 are slightly different with regard to the point at
11714 which entities are frozen, and representation pragmas and clauses are
11715 not permitted past the freeze point.  This shows up most typically in
11716 the form of an error message complaining that a representation item
11717 appears too late, and the appropriate corrective action is to move
11718 the item nearer to the declaration of the entity to which it refers.
11719
11720 A particular case is that representation pragmas (including the
11721 extended DEC Ada 83 compatibility pragmas such as @code{Export_Procedure}), cannot
11722 be applied to a subprogram body.  If necessary, a separate subprogram 
11723 declaration must be introduced to which the pragma can be applied.
11724
11725 @item Optional bodies for library packages
11726 In Ada 83, a package that did not require a package body was nevertheless
11727 allowed to have one.  This lead to certain surprises in compiling large
11728 systems (situations in which the body could be unexpectedly ignored).  In
11729 Ada 95, if a package does not require a body then it is not permitted to
11730 have a body.  To fix this problem, simply remove a redundant body if it
11731 is empty, or, if it is non-empty, introduce a dummy declaration into the
11732 spec that makes the body required.  One approach is to add a private part
11733 to the package declaration (if necessary), and define a parameterless
11734 procedure called Requires_Body, which must then be given a dummy
11735 procedure body in the package body, which then becomes required.
11736
11737 @item @code{Numeric_Error} is now the same as @code{Constraint_Error}
11738 In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
11739 This means that it is illegal to have separate exception handlers for
11740 the two exceptions.  The fix is simply to remove the handler for the
11741 @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
11742 @code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
11743
11744 @item Indefinite subtypes in generics
11745 In Ada 83, it was permissible to pass an indefinite type (e.g.@: @code{String}) as
11746 the actual for a generic formal private type, but then the instantiation
11747 would be illegal if there were any instances of declarations of variables
11748 of this type in the generic body.  In Ada 95, to avoid this clear violation
11749 of the contract model, the generic declaration clearly indicates whether
11750 or not such instantiations are permitted.  If a generic formal parameter
11751 has explicit unknown discriminants, indicated by using @code{(<>)} after the
11752 type name, then it can be instantiated with indefinite types, but no
11753 variables can be declared of this type.  Any attempt to declare a variable
11754 will result in an illegality at the time the generic is declared.  If the
11755 @code{(<>)} notation is not used, then it is illegal to instantiate the generic
11756 with an indefinite type.  This will show up as a compile time error, and
11757 the fix is usually simply to add the @code{(<>)} to the generic declaration.
11758 @end table
11759
11760 All implementations of GNAT provide a switch that causes GNAT to operate
11761 in Ada 83 mode.  In this mode, some but not all compatibility problems
11762 of the type described above are handled automatically.  For example, the
11763 new Ada 95 protected keywords are not recognized in this mode.  However,
11764 in practice, it is usually advisable to make the necessary modifications
11765 to the program to remove the need for using this switch.
11766
11767 @node Compatibility with Other Ada 95 Systems
11768 @section Compatibility with Other Ada 95 Systems
11769
11770 @noindent
11771 Providing that programs avoid the use of implementation dependent and
11772 implementation defined features of Ada 95, as documented in the Ada 95
11773 reference manual, there should be a high degree of portability between
11774 GNAT and other Ada 95 systems.  The following are specific items which
11775 have proved troublesome in moving GNAT programs to other Ada 95
11776 compilers, but do not affect porting code to GNAT@.
11777
11778 @table @asis
11779 @item Ada 83 Pragmas and Attributes
11780 Ada 95 compilers are allowed, but not required, to implement the missing
11781 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
11782 GNAT implements all such pragmas and attributes, eliminating this as
11783 a compatibility concern, but some other Ada 95 compilers reject these
11784 pragmas and attributes.
11785
11786 @item Special-needs Annexes
11787 GNAT implements the full set of special needs annexes.  At the
11788 current time, it is the only Ada 95 compiler to do so.  This means that
11789 programs making use of these features may not be portable to other Ada
11790 95 compilation systems.
11791
11792 @item Representation Clauses
11793 Some other Ada 95 compilers implement only the minimal set of
11794 representation clauses required by the Ada 95 reference manual.  GNAT goes
11795 far beyond this minimal set, as described in the next section.
11796 @end table
11797
11798 @node Representation Clauses
11799 @section Representation Clauses
11800
11801 @noindent
11802 The Ada 83 reference manual was quite vague in describing both the minimal
11803 required implementation of representation clauses, and also their precise
11804 effects.  The Ada 95 reference manual is much more explicit, but the minimal
11805 set of capabilities required in Ada 95 is quite limited.
11806
11807 GNAT implements the full required set of capabilities described in the
11808 Ada 95 reference manual, but also goes much beyond this, and in particular
11809 an effort has been made to be compatible with existing Ada 83 usage to the
11810 greatest extent possible.
11811
11812 A few cases exist in which Ada 83 compiler behavior is incompatible with
11813 requirements in the Ada 95 reference manual.  These are instances of
11814 intentional or accidental dependence on specific implementation dependent
11815 characteristics of these Ada 83 compilers.  The following is a list of
11816 the cases most likely to arise in existing legacy Ada 83 code.
11817
11818 @table @asis
11819 @item Implicit Packing
11820 Some Ada 83 compilers allowed a Size specification to cause implicit
11821 packing of an array or record.  This could cause expensive implicit
11822 conversions for change of representation in the presence of derived
11823 types, and the Ada design intends to avoid this possibility.
11824 Subsequent AI's were issued to make it clear that such implicit
11825 change of representation in response to a Size clause is inadvisable,
11826 and this recommendation is represented explicitly in the Ada 95 RM
11827 as implementation advice that is followed by GNAT@.
11828 The problem will show up as an error
11829 message rejecting the size clause.  The fix is simply to provide
11830 the explicit pragma @code{Pack}, or for more fine tuned control, provide
11831 a Component_Size clause.
11832
11833 @item Meaning of Size Attribute
11834 The Size attribute in Ada 95 for discrete types is defined as being the
11835 minimal number of bits required to hold values of the type.  For example,
11836 on a 32-bit machine, the size of Natural will typically be 31 and not
11837 32 (since no sign bit is required).  Some Ada 83 compilers gave 31, and
11838 some 32 in this situation.  This problem will usually show up as a compile
11839 time error, but not always.  It is a good idea to check all uses of the
11840 'Size attribute when porting Ada 83 code.  The GNAT specific attribute
11841 Object_Size can provide a useful way of duplicating the behavior of
11842 some Ada 83 compiler systems.
11843
11844 @item Size of Access Types
11845 A common assumption in Ada 83 code is that an access type is in fact a pointer,
11846 and that therefore it will be the same size as a System.Address value.  This
11847 assumption is true for GNAT in most cases with one exception.  For the case of
11848 a pointer to an unconstrained array type (where the bounds may vary from one
11849 value of the access type to another), the default is to use a ``fat pointer'',
11850 which is represented as two separate pointers, one to the bounds, and one to
11851 the array.  This representation has a number of advantages, including improved
11852 efficiency.  However, it may cause some difficulties in porting existing Ada 83
11853 code which makes the assumption that, for example, pointers fit in 32 bits on
11854 a machine with 32-bit addressing.
11855
11856 To get around this problem, GNAT also permits the use of ``thin pointers'' for
11857 access types in this case (where the designated type is an unconstrained array
11858 type).  These thin pointers are indeed the same size as a System.Address value.
11859 To specify a thin pointer, use a size clause for the type, for example:
11860
11861 @smallexample
11862 type X is access all String;
11863 for X'Size use Standard'Address_Size;
11864 @end smallexample
11865
11866 @noindent
11867 which will cause the type X to be represented using a single pointer.  When using
11868 this representation, the bounds are right behind the array.  This representation
11869 is slightly less efficient, and does not allow quite such flexibility in the
11870 use of foreign pointers or in using the Unrestricted_Access attribute to create
11871 pointers to non-aliased objects.  But for any standard portable use of the access
11872 type it will work in a functionally correct manner and allow porting of existing
11873 code.  Note that another way of forcing a thin pointer representation is to use
11874 a component size clause for the element size in an array, or a record 
11875 representation clause for an access field in a record.
11876 @end table
11877
11878 @node Compatibility with DEC Ada 83
11879 @section Compatibility with DEC Ada 83
11880
11881 @noindent
11882 The VMS version of GNAT fully implements all the pragmas and attributes
11883 provided by DEC Ada 83, as well as providing the standard DEC Ada 83
11884 libraries, including Starlet.  In addition, data layouts and parameter
11885 passing conventions are highly compatible.  This means that porting
11886 existing DEC Ada 83 code to GNAT in VMS systems should be easier than
11887 most other porting efforts.  The following are some of the most
11888 significant differences between GNAT and DEC Ada 83.
11889
11890 @table @asis
11891 @item Default floating-point representation
11892 In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83,
11893 it is VMS format.  GNAT does implement the necessary pragmas
11894 (Long_Float, Float_Representation) for changing this default.
11895
11896 @item System
11897 The package System in GNAT exactly corresponds to the definition in the
11898 Ada 95 reference manual, which means that it excludes many of the 
11899 DEC Ada 83 extensions.  However, a separate package Aux_DEC is provided
11900 that contains the additional definitions, and a special pragma,
11901 Extend_System allows this package to be treated transparently as an
11902 extension of package System.
11903
11904 @item To_Address
11905 The definitions provided by Aux_DEC are exactly compatible with those
11906 in the DEC Ada 83 version of System, with one exception.  DEC Ada provides
11907 the following declarations:
11908
11909 @smallexample
11910 TO_ADDRESS(INTEGER)
11911 TO_ADDRESS(UNSIGNED_LONGWORD)
11912 TO_ADDRESS(universal_integer)
11913 @end smallexample
11914
11915 @noindent
11916 The version of TO_ADDRESS taking a universal integer argument is in fact
11917 an extension to Ada 83 not strictly compatible with the reference manual.
11918 In GNAT, we are constrained to be exactly compatible with the standard,
11919 and this means we cannot provide this capability.  In DEC Ada 83, the
11920 point of this definition is to deal with a call like:
11921
11922 @smallexample
11923    TO_ADDRESS (16#12777#);
11924 @end smallexample
11925
11926 @noindent
11927 Normally, according to the Ada 83 standard, one would expect this to be
11928 ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms
11929 of TO_ADDRESS@.  However, in DEC Ada 83, there is no ambiguity, since the
11930 definition using universal_integer takes precedence.
11931
11932 In GNAT, since the version with universal_integer cannot be supplied, it is
11933 not possible to be 100% compatible.  Since there are many programs using
11934 numeric constants for the argument to TO_ADDRESS, the decision in GNAT was
11935 to change the name of the function in the UNSIGNED_LONGWORD case, so the
11936 declarations provided in the GNAT version of AUX_Dec are:
11937
11938 @smallexample
11939 function To_Address (X : Integer) return Address;
11940 pragma Pure_Function (To_Address);
11941
11942 function To_Address_Long (X : Unsigned_Longword)
11943  return Address;
11944 pragma Pure_Function (To_Address_Long);
11945 @end smallexample
11946
11947 @noindent
11948 This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must
11949 change the name to TO_ADDRESS_LONG@.
11950
11951 @item Task_Id values
11952 The Task_Id values assigned will be different in the two systems, and GNAT
11953 does not provide a specified value for the Task_Id of the environment task,
11954 which in GNAT is treated like any other declared task.
11955 @end table
11956
11957 For full details on these and other less significant compatibility issues,
11958 see appendix E of the Digital publication entitled @cite{DEC Ada, Technical
11959 Overview and Comparison on DIGITAL Platforms}.
11960
11961 For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and
11962 attributes are recognized, although only a subset of them can sensibly
11963 be implemented.  The description of pragmas in this reference manual
11964 indicates whether or not they are applicable to non-VMS systems.
11965
11966 @include fdl.texi
11967 @c GNU Free Documentation License
11968
11969 @node Index,,GNU Free Documentation License, Top
11970 @unnumbered Index
11971
11972 @printindex cp
11973
11974 @contents
11975
11976 @bye