OSDN Git Service

* gnat_rm.texi: Add GNAT Reference Manual.
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2 @input texiplus
3
4 @c %**start of header
5
6 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c                                                                            o
8 @c                           GNAT DOCUMENTATION                               o
9 @c                                                                            o
10 @c                              G N A T _ RM                                  o
11 @c                                                                            o
12 @c                            $Revision$
13 @c                                                                            o
14 @c          Copyright (C) 1992-2001 Ada Core Technologies, Inc.               o
15 @c                                                                            o
16 @c  GNAT is free software;  you can  redistribute it  and/or modify it under  o
17 @c  terms of the  GNU General Public License as published  by the Free Soft-  o
18 @c  ware  Foundation;  either version 2,  or (at your option) any later ver-  o
19 @c  sion.  GNAT is distributed in the hope that it will be useful, but WITH-  o
20 @c  OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY  o
21 @c  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License  o
22 @c  for  more details.  You should have  received  a copy of the GNU General  o
23 @c  Public License  distributed with GNAT;  see file COPYING.  If not, write  o
24 @c  to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston,  o
25 @c  MA 02111-1307, USA.                                                       o
26 @c                                                                            o
27 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
28 @c                                                                            o
29 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
30
31 @setfilename gnat_rm.info
32 @settitle GNAT Reference Manual
33 @setchapternewpage odd
34 @syncodeindex fn cp
35
36 @titlepage
37
38
39 @title GNAT Reference Manual
40 @subtitle GNAT, The GNU Ada 95 Compiler
41 @subtitle Version 3.15w
42 @subtitle Document revision level $Revision$
43 @subtitle Date: $Date$
44 @author Ada Core Technologies, Inc.
45
46 @page
47 @vskip 0pt plus 1filll
48
49
50 Copyright @copyright{} 1995-2001, Ada Core Technologies
51
52 Permission is granted to copy, distribute and/or modify this document
53 under the terms of the GNU Free Documentation License, Version 1.1
54 or any later version published by the Free Software Foundation;
55 with the Invariant Sections being ``GNU Free Documentation License'', with the
56 Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts.
57 A copy of the license is included in the section entitled ``GNU
58 Free Documentation License''.
59
60 Silicon Graphics and IRIS are registered trademarks
61 and IRIX is a trademark of Silicon Graphics, Inc.
62
63 IBM PC is a trademark of International
64 Business Machines Corporation.
65
66 UNIX is a registered trademark of AT&T
67 Bell Laboratories. 
68 DIGITAL 
69
70 VADS is a registered trademark of Rational Software Inc.
71
72 The following are trademarks of Digital Equipment Corporation:
73 DEC, DEC Ada, DECthreads, Digital, OpenVMS, and VAX.
74
75 @end titlepage
76 @ifinfo
77 @node Top, About This Guide, (dir), (dir)
78 @top GNAT Reference Manual
79
80
81 GNAT Reference Manual
82
83 GNAT, The GNU Ada 95 Compiler
84
85 Version 3.14a
86
87 Date: $Date$
88
89 Ada Core Technologies, Inc.
90
91
92 Copyright @copyright{} 1995-2001, Ada Core Technologies
93
94 Permission is granted to copy, distribute and/or modify this document
95 under the terms of the GNU Free Documentation License, Version 1.1
96 or any later version published by the Free Software Foundation;
97 with the Invariant Sections being "GNU Free Documentation License", with the
98 Front-Cover Texts being "GNAT Reference Manual", and with no Back-Cover Texts.
99 A copy of the license is included in the section entitled "GNU
100 Free Documentation License".
101
102
103 Silicon Graphics and IRIS are registered trademarks
104 and IRIX is a trademark of Silicon Graphics, Inc.
105
106 IBM PC is a trademark of International
107 Business Machines Corporation.
108
109 UNIX is a registered trademark of AT&T
110 Bell Laboratories. 
111 DIGITAL 
112
113 VADS is a registered trademark of Rational Software Inc.
114
115 The following are trademarks of Digital Equipment Corporation:
116 DEC, DEC Ada, DECthreads, Digital, OpenVMS, and VAX.
117
118 @menu
119 * About This Guide::            
120 * Implementation Defined Pragmas::  
121 * Implementation Defined Attributes::  
122 * Implementation Advice::       
123 * Implementation Defined Characteristics::  
124 * Intrinsic Subprograms::
125 * Representation Clauses and Pragmas::
126 * Standard Library Routines::   
127 * The Implementation of Standard I/O::  
128 * The GNAT Library::
129 * Interfacing to Other Languages::  
130 * Machine Code Insertions::
131 * GNAT Implementation of Tasking::
132 * Code generation for array aggregates::
133 * Specialized Needs Annexes::   
134 * Compatibility Guide::
135 * GNU Free Documentation License::
136 * Index::                       
137
138  --- The Detailed Node Listing ---
139
140 About This Guide
141
142 * What This Reference Manual Contains::  
143 * Related Information::         
144
145 The Implementation of Standard I/O
146
147 * Standard I/O Packages::       
148 * FORM Strings::                
149 * Direct_IO::                   
150 * Sequential_IO::               
151 * Text_IO::                     
152 * Wide_Text_IO::                
153 * Stream_IO::                   
154 * Shared Files::                
155 * Open Modes::                  
156 * Operations on C Streams::     
157 * Interfacing to C Streams::    
158
159 The GNAT Library
160
161 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
162 * Ada.Command_Line.Remove (a-colire.ads)::
163 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
164 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
165 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
166 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
167 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
168 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
169 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
170 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
171 * GNAT.AWK (g-awk.ads)::
172 * GNAT.Bubble_Sort_A (g-busora.ads)::
173 * GNAT.Bubble_Sort_G (g-busorg.ads)::
174 * GNAT.Calendar (g-calend.ads)::
175 * GNAT.Calendar.Time_IO (g-catiio.ads)::
176 * GNAT.Case_Util (g-casuti.ads)::
177 * GNAT.CGI (g-cgi.ads)::
178 * GNAT.CGI.Cookie (g-cgicoo.ads)::
179 * GNAT.CGI.Debug (g-cgideb.ads)::
180 * GNAT.Command_Line (g-comlin.ads)::
181 * GNAT.CRC32 (g-crc32.ads)::
182 * GNAT.Current_Exception (g-curexc.ads)::
183 * GNAT.Debug_Pools (g-debpoo.ads)::
184 * GNAT.Debug_Utilities (g-debuti.ads)::
185 * GNAT.Directory_Operations (g-dirope.ads)::
186 * GNAT.Dynamic_Tables (g-dyntab.ads)::
187 * GNAT.Exception_Traces (g-exctra.ads)::
188 * GNAT.Expect (g-expect.ads)::
189 * GNAT.Float_Control (g-flocon.ads)::
190 * GNAT.Heap_Sort_A (g-hesora.ads)::
191 * GNAT.Heap_Sort_G (g-hesorg.ads)::
192 * GNAT.HTable (g-htable.ads)::
193 * GNAT.IO (g-io.ads)::
194 * GNAT.IO_Aux (g-io_aux.ads)::
195 * GNAT.Lock_Files (g-locfil.ads)::
196 * GNAT.Most_Recent_Exception (g-moreex.ads)::
197 * GNAT.OS_Lib (g-os_lib.ads)::
198 * GNAT.Regexp (g-regexp.ads)::
199 * GNAT.Registry (g-regist.ads)::
200 * GNAT.Regpat (g-regpat.ads)::
201 * GNAT.Sockets (g-socket.ads)::
202 * GNAT.Source_Info (g-souinf.ads)::
203 * GNAT.Spell_Checker (g-speche.ads)::
204 * GNAT.Spitbol.Patterns (g-spipat.ads)::
205 * GNAT.Spitbol (g-spitbo.ads)::
206 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
207 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
208 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
209 * GNAT.Table (g-table.ads)::
210 * GNAT.Task_Lock (g-tasloc.ads)::
211 * GNAT.Threads (g-thread.ads)::
212 * GNAT.Traceback (g-traceb.ads)::
213 * GNAT.Traceback.Symbolic (g-trasym.ads)::
214 * Interfaces.C.Extensions (i-cexten.ads)::
215 * Interfaces.C.Streams (i-cstrea.ads)::
216 * Interfaces.CPP (i-cpp.ads)::
217 * Interfaces.Os2lib (i-os2lib.ads)::
218 * Interfaces.Os2lib.Errors (i-os2err.ads)::
219 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
220 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
221 * Interfaces.Packed_Decimal (i-pacdec.ads)::
222 * Interfaces.VxWorks (i-vxwork.ads)::
223 * System.Address_Image (s-addima.ads)::
224 * System.Assertions (s-assert.ads)::
225 * System.Partition_Interface (s-parint.ads)::
226 * System.Task_Info (s-tasinf.ads)::
227 * System.Wch_Cnv (s-wchcnv.ads)::
228 * System.Wch_Con (s-wchcon.ads)::
229
230 Text_IO
231
232 * Text_IO Stream Pointer Positioning::  
233 * Text_IO Reading and Writing Non-Regular Files::  
234 * Get_Immediate::               
235 * Treating Text_IO Files as Streams::
236 * Text_IO Extensions::
237 * Text_IO Facilities for Unbounded Strings::
238
239 Wide_Text_IO
240
241 * Wide_Text_IO Stream Pointer Positioning::  
242 * Wide_Text_IO Reading and Writing Non-Regular Files::  
243
244 Interfacing to Other Languages
245
246 * Interfacing to C::
247 * Interfacing to C++::          
248 * Interfacing to COBOL::        
249 * Interfacing to Fortran::      
250 * Interfacing to non-GNAT Ada code::
251
252 GNAT Implementation of Tasking
253
254 * Mapping Ada Tasks onto the Underlying Kernel Threads::
255 * Ensuring Compliance with the Real-Time Annex::
256 @end menu
257
258 @end ifinfo
259
260 @node About This Guide
261 @unnumbered About This Guide
262
263 @noindent
264 This manual contains useful information in writing programs using the
265 GNAT compiler. It includes information on implementation dependent
266 characteristics of GNAT, including all the information required by Annex
267 M of the standard.
268
269 Ada 95 is designed to be highly portable,and guarantees that, for most
270 programs, Ada 95 compilers behave in exactly the same manner on
271 different machines. However, since Ada 95 is designed to be used in a
272 wide variety of applications, it also contains a number of system
273 dependent features to be used in interfacing to the external world. 
274
275 @c Maybe put the following in platform-specific section
276 @ignore
277 @cindex ProDev Ada
278 This reference manual discusses how these features are implemented for
279 use in ProDev Ada running on the IRIX 5.3 or greater operating systems.
280 @end ignore
281
282 @cindex Implementation-dependent features
283 @cindex Portability
284 Note: Any program that makes use of implementation-dependent features
285 may be non-portable.  You should follow good programming practice and
286 isolate and clearly document any sections of your program that make use
287 of these features in a non-portable manner.
288
289 @menu
290 * What This Reference Manual Contains::  
291 * Conventions::
292 * Related Information::         
293 @end menu
294
295 @node What This Reference Manual Contains
296 @unnumberedsec What This Reference Manual Contains
297
298 This reference manual contains the following chapters:
299
300 @itemize @bullet
301 @item
302 @ref{Implementation Defined Pragmas} lists GNAT implementation-dependent
303 pragmas, which can be used to extend and enhance the functionality of the
304 compiler.
305
306 @item
307 @ref{Implementation Defined Attributes} lists GNAT
308 implementation-dependent attributes which can be used to extend and
309 enhance the functionality of the compiler.
310
311 @item
312 @ref{Implementation Advice} provides information on generally
313 desirable behavior which are not requirements that all compilers must
314 follow since it cannot be provided on all systems, or which may be
315 undesirable on some systems.
316
317 @item
318 @ref{Implementation Defined Characteristics} provides a guide to
319 minimizing implementation dependent features.
320
321 @item
322 @ref{Intrinsic Subprograms} describes the intrinsic subprograms
323 implemented by GNAT, and how they can be imported into user
324 application programs.
325
326 @item
327 @ref{Representation Clauses and Pragmas} describes in detail the
328 way that GNAT represents data, and in particular the exact set
329 of representation clauses and pragmas that is accepted.
330
331 @item
332 @ref{Standard Library Routines} provides a listing of packages and a
333 brief description of the functionality that is provided by Ada's
334 extensive set of standard library routines as implemented by GNAT.
335
336 @item
337 @ref{The Implementation of Standard I/O} details how the GNAT
338 implementation of the input-output facilities.
339
340 @item
341 @ref{Interfacing to Other Languages} describes how programs
342 written in Ada using GNAT can be interfaced to other programming
343 languages.
344
345 @item
346 @ref{Specialized Needs Annexes} describes the GNAT implementation of all
347 of the special needs annexes.
348
349 @item
350 @ref{Compatibility Guide} includes sections on compatibility of GNAT with
351 other Ada 83 and Ada 95 compilation systems, to assist in porting code
352 from other environments.
353 @end itemize
354
355 @cindex Ada 95 ISO/ANSI Standard
356 This reference manual assumes that you are familiar with Ada 95
357 language, as described in the International Standard
358 ANSI/ISO/IEC-8652:1995, Jan 1995.
359
360 @node Conventions
361 @unnumberedsec Conventions
362 @cindex Conventions, typographical
363 @cindex Typographical conventions
364
365 @noindent
366 Following are examples of the typographical and graphic conventions used
367 in this guide:
368
369 @itemize @bullet
370 @item
371 @code{Functions}, @code{utility program names}, @code{standard names},
372 and @code{classes}.
373
374 @item
375 @samp{Option flags}
376
377 @item
378 @file{File Names}, @file{button names}, and @file{field names}.
379
380 @item
381 @var{Variables}.
382
383 @item
384 @emph{Emphasis}.
385
386 @item
387 [optional information or parameters]
388
389 @item
390 Examples are described by text
391 @smallexample
392 and then shown this way.
393 @end smallexample
394 @end itemize
395
396 @noindent
397 Commands that are entered by the user are preceded in this manual by the
398 characters "$ " (dollar sign followed by space). If your system uses this
399 sequence as a prompt, then the commands will appear exactly as you see them
400 in the manual. If your system uses some other prompt, then the command will
401 appear with the $ replaced by whatever prompt character you are using.
402
403 @node Related Information
404 @unnumberedsec Related Information
405 See the following documents for further information on GNAT
406
407 @itemize @bullet
408 @item
409 @cite{GNAT User's Guide}, which provides information on how to use
410 the GNAT compiler system.
411
412 @item
413 @cite{Ada 95 Reference Manual}, which contains all reference
414 material for the Ada 95 programming language.
415
416 @item
417 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
418 of the standard reference manual cited above. The annotations describe
419 detailed aspects of the design decision, and in particular contain useful
420 sections on Ada 83 compatibility.
421
422 @item
423 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
424 which contains specific information on compatibility between GNAT and
425 DEC Ada 83 systems.
426
427 @item
428 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
429 describes in detail the pragmas and attributes provided by the DEC Ada 83
430 compiler system.
431
432 @end itemize
433
434 @node Implementation Defined Pragmas
435 @chapter Implementation Defined Pragmas
436
437 @noindent
438 Ada 95 defines a set of pragmas that can be used to supply additional
439 information to the compiler. These language defined pragmas are
440 implemented in GNAT and work as described in the Ada 95 Reference
441 Manual.
442
443 In addition, Ada 95 allows implementations to define additional pragmas
444 whose meaning is defined by the implementation. GNAT provides a number
445 of these implementation-dependent pragmas which can be used to extend
446 and enhance the functionality of the compiler. This section of the GNAT
447 Reference Manual describes these additional pragmas.
448
449 Note that any program using these pragmas may not be portable to other
450 compilers (although GNAT implements this set of pragmas on all
451 platforms). Therefore if portability to other compilers is an important
452 consideration, the use of these pragmas should be minimized.
453
454 @table @code
455
456 @findex Abort_Defer
457 @cindex Deferring aborts
458 @item pragma Abort_Defer
459 @noindent
460 Syntax:
461
462 @smallexample
463 pragma Abort_Defer;
464 @end smallexample
465
466 @noindent
467 This pragma must appear at the start of the statement sequence of a
468 handled sequence of statements (right after the @code{begin}). It has
469 the effect of deferring aborts for the sequence of statements (but not
470 for the declarations or handlers, if any, associated with this statement
471 sequence).
472
473 @item pragma Ada_83
474 @findex Ada_83
475 @noindent
476 Syntax:
477
478 @smallexample
479 pragma Ada_83;
480 @end smallexample
481
482 @noindent
483 A configuration pragma that establishes Ada 83 mode for the unit to
484 which it applies, regardless of the mode set by the command line
485 switches. In Ada 83 mode, GNAT attempts to be as compatible with
486 the syntax and semantics of Ada 83, as defined in the original Ada
487 83 Reference Manual as possible. In particular, the new Ada 95
488 keywords are not recognized, optional package bodies are allowed,
489 and generics may name types with unknown discriminants without using
490 the (<>) notation. In addition, some but not all of the additional
491 restrictions of Ada 83 are enforced.
492
493 Ada 83 mode is intended for two purposes. Firstly, it allows existing
494 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
495 Secondly, it aids in keeping code backwards compatible with Ada 83. 
496 However, there is no guarantee that code that is processed correctly
497 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
498 83 compiler, since GNAT does not enforce all the additional checks
499 required by Ada 83.
500
501 @findex Ada_95
502 @item pragma Ada_95
503 @noindent
504 Syntax:
505
506 @smallexample
507 pragma Ada_95;
508 @end smallexample
509
510 @noindent
511 A configuration pragma that establishes Ada 95 mode for the unit to which
512 it applies, regardless of the mode set by the command line switches.
513 This mode is set automatically for the @code{Ada} and @code{System}
514 packages and their children, so you need not specify it in these
515 contexts. This pragma is useful when writing a reusable component that
516 itself uses Ada 95 features, but which is intended to be usable from
517 either Ada 83 or Ada 95 programs.
518
519 @findex Annotate
520 @item pragma Annotate
521 @noindent
522 Syntax:
523
524 @smallexample
525 pragma Annotate (IDENTIFIER @{, ARG@});
526
527 ARG ::= NAME | EXPRESSION
528 @end smallexample
529
530 @noindent
531 This pragma is used to annotate programs. @var{identifier} identifies
532 the type of annotation. GNAT verifies this is an identifier, but does
533 not otherwise analyze it. The @var{arg} argument
534 can be either a string literal or an
535 expression. String literals are assumed to be of type
536 @code{Standard.String}. Names of entities are simply analyzed as entity
537 names. All other expressions are analyzed as expressions, and must be
538 unambiguous.
539
540 The analyzed pragma is retained in the tree, but not otherwise processed
541 by any part of the GNAT compiler. This pragma is intended for use by
542 external tools, including ASIS.
543
544 @findex Assert
545 @item pragma Assert
546 @noindent
547 Syntax:
548
549 @smallexample
550 pragma Assert (
551   boolean_EXPRESSION
552   [, static_string_EXPRESSION])
553 @end smallexample
554
555 @noindent
556 The effect of this pragma depends on whether the corresponding command
557 line switch is set to activate assertions. The pragma expands into code
558 equivalent to the following:
559
560 @smallexample
561 if assertions-enabled then
562    if not boolean_EXPRESSION then
563       System.Assertions.Raise_Assert_Failure
564         (string_EXPRESSION); 
565    end if;
566 end if;
567 @end smallexample
568
569 @noindent
570 The string argument, if given, is the message that will be associated
571 with the exception occurrence if the exception is raised. If no second
572 argument is given, the default message is @samp{@var{file}:@var{nnn}},
573 where @var{file} is the name of the source file containing the assert,
574 and @var{nnn} is the line number of the assert. A pragma is not a
575 statement, so if a statement sequence contains nothing but a pragma
576 assert, then a null statement is required in addition, as in:
577
578 @smallexample
579 ...
580 if J > 3 then
581    pragma Assert (K > 3, "Bad value for K");
582    null;
583 end if;
584 @end smallexample
585
586 @noindent
587 Note that, as with the if statement to which it is equivalent, the
588 type of the expression is either Standard.Boolean, or any type derived
589 from this standard type.
590
591 If assertions are disabled (switch @code{-gnata} not used), then there
592 is no effect (and in particular, any side effects from the expression
593 are suppressed). More precisely it is not quite true that the pragma
594 has no effect, since the expression is analyzed, and may cause types
595 to be frozen if they are mentioned here for the first time.
596
597 If assertions are enabled, then the given expression is tested, and if
598 it is @code{False} then System.Assertions.Raise_Assert_Failure is called
599 which results in the raising of Assert_Failure with the given message.
600
601 If the boolean expression has side effects, these side effects will turn
602 on and off with the setting of the assertions mode, resulting in
603 assertions that have an effect on the program. You should generally 
604 avoid side effects in the expression arguments of this pragma. However,
605 the expressions are analyzed for semantic correctness whether or not
606 assertions are enabled, so turning assertions on and off cannot affect
607 the legality of a program.
608
609 @cindex OpenVMS
610 @findex Ast_Entry
611 @item pragma Ast_Entry
612 @noindent
613 Syntax:
614
615 @smallexample
616 pragma AST_Entry (entry_IDENTIFIER);
617 @end smallexample
618
619 @noindent
620 This pragma is implemented only in the OpenVMS implementation of GNAT. The
621 argument is the simple name of a single entry; at most one @code{AST_Entry}
622 pragma is allowed for any given entry. This pragma must be used in 
623 conjunction with the @code{AST_Entry} attribute, and is only allowed after
624 the entry declaration and in the same task type specification or single task
625 as the entry to which it applies. This pragma specifies that the given entry
626 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
627 resulting from an OpenVMS system service call. The pragma does not affect
628 normal use of the entry. For further details on this pragma, see the 
629 DEC Ada Language Reference Manual, section 9.12a.
630
631 @cindex Passing by copy
632 @findex C_Pass_By_Copy
633 @item pragma C_Pass_By_Copy
634 @noindent
635 Syntax:
636
637 @smallexample
638 pragma C_Pass_By_Copy
639   ([Max_Size =>] static_integer_EXPRESSION);
640 @end smallexample
641
642 @noindent
643 Normally the default mechanism for passing C convention records to C
644 convention subprograms is to pass them by reference, as suggested by RM
645 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
646 this default, by requiring that record formal parameters be passed by
647 copy if all of the following conditions are met:
648
649 @itemize @bullet
650 @item
651 The size of the record type does not exceed@*@var{static_integer_expression}.
652 @item
653 The record type has @code{Convention C}.
654 @item
655 The formal parameter has this record type, and the subprogram has a
656 foreign (non-Ada) convention.
657 @end itemize
658
659 @noindent
660 If these conditions are met the argument is passed by copy, i.e. in a
661 manner consistent with what C expects if the corresponding formal in the
662 C prototype is a struct (rather than a pointer to a struct).
663
664 You can also pass records by copy by specifying the convention
665 @code{C_Pass_By_Copy} for the record type, or by using the extended
666 @code{Import} and @code{Export} pragmas, which allow specification of
667 passing mechanisms on a parameter by parameter basis.
668
669 @findex Comment
670 @item pragma Comment
671 @noindent
672 Syntax:
673
674 @smallexample
675 pragma Comment (static_string_EXPRESSION);
676 @end smallexample
677
678 @noindent
679 This is almost identical in effect to pragma Ident. It allows the
680 placement of a comment into the object file and hence into the
681 executable file if the operating system permits such usage. The
682 difference is that Comment, unlike Ident, has no limit on the
683 length of the string argument, and no limitations on placement
684 of the pragma (it can be placed anywhere in the main source unit).
685
686 @findex Common_Object
687 @item pragma Common_Object
688 @noindent
689 Syntax:
690
691 @smallexample
692 pragma Common_Object (
693      [Internal =>] LOCAL_NAME,
694   [, [External =>] EXTERNAL_SYMBOL]
695   [, [Size     =>] EXTERNAL_SYMBOL] )
696
697 EXTERNAL_SYMBOL ::=
698   IDENTIFIER
699 | static_string_EXPRESSION
700 @end smallexample
701
702 @noindent
703 This pragma enables the shared use of variables stored in overlaid
704 linker areas corresponding to the use of @code{COMMON}
705 in Fortran.  The single
706 object @var{local_name} is assigned to the area designated by
707 the @var{External} argument.
708 You may define a record to correspond to a series
709 of fields. The @var{size} argument
710 is syntax checked in GNAT, but otherwise ignored.
711
712 @code{Common_Object} is not supported on all platforms. If no
713 support is available, then the code generator will issue a message
714 indicating that the necessary attribute for implementation of this
715 pragma is not available.
716
717 @findex Complex_Representation
718 @item pragma Complex_Representation
719 @noindent
720 Syntax:
721
722 @smallexample
723 pragma Complex_Representation
724         ([Entity =>] LOCAL_NAME);
725 @end smallexample
726
727 @noindent
728 The @var{Entity} argument must be the name of a record type which has
729 two fields of the same floating-point type. The effect of this pragma is
730 to force gcc to use the special internal complex representation form for
731 this record, which may be more efficient. Note that this may result in
732 the code for this type not conforming to standard ABI (application
733 binary interface) requirements for the handling of record types. For
734 example, in some environments, there is a requirement for passing
735 records by pointer, and the use of this pragma may result in passing
736 this type in floating-point registers.
737
738 @cindex Alignments of components
739 @findex Component_Alignment
740 @item pragma Component_Alignment
741 @noindent
742 Syntax:
743
744 @smallexample
745 pragma Component_Alignment (
746      [Form =>] ALIGNMENT_CHOICE
747   [, [Name =>] type_LOCAL_NAME]);
748
749 ALIGNMENT_CHOICE ::=
750   Component_Size
751 | Component_Size_4
752 | Storage_Unit
753 | Default
754 @end smallexample
755
756 @noindent
757 Specifies the alignment of components in array or record types.
758 The meaning of the @var{Form} argument is as follows:
759
760 @table @code
761 @findex Component_Size
762 @item Component_Size
763 Aligns scalar components and subcomponents of the array or record type
764 on boundaries appropriate to their inherent size (naturally
765 aligned). For example, 1-byte components are aligned on byte boundaries,
766 2-byte integer components are aligned on 2-byte boundaries, 4-byte
767 integer components are aligned on 4-byte boundaries and so on. These
768 alignment rules correspond to the normal rules for C compilers on all
769 machines except the VAX.
770
771 @findex Component_Size_4
772 @item Component_Size_4
773 Naturally aligns components with a size of four or fewer
774 bytes. Components that are larger than 4 bytes are placed on the next
775 4-byte boundary.
776
777 @findex Storage_Unit
778 @item Storage_Unit
779 Specifies that array or record components are byte aligned, i.e.
780 aligned on boundaries determined by the value of the constant
781 @code{System.Storage_Unit}.
782
783 @cindex OpenVMS
784 @item Default
785 Specifies that array or record components are aligned on default
786 boundaries, appropriate to the underlying hardware or operating system or
787 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
788 the @code{Storage_Unit} choice (byte alignment). For all other systems,
789 the @code{Default} choice is the same as @code{Component_Size} (natural
790 alignment).
791 @end table
792
793 If the @code{Name} parameter is present, @var{type_local_name} must
794 refer to a local record or array type, and the specified alignment
795 choice applies to the specified type. The use of
796 @code{Component_Alignment} together with a pragma @code{Pack} causes the
797 @code{Component_Alignment} pragma to be ignored. The use of
798 @code{Component_Alignment} together with a record representation clause
799 is only effective for fields not specified by the representation clause.
800
801 If the @code{Name} parameter is absent, the pragma can be used as either
802 a configuration pragma, in which case it applies to one or more units in
803 accordance with the normal rules for configuration pragmas, or it can be
804 used within a declarative part, in which case it applies to types that
805 are declared within this declarative part, or within any nested scope
806 within this declarative part. In either case it specifies the alignment
807 to be applied to any record or array type which has otherwise standard
808 representation.
809
810 If the alignment for a record or array type is not specified (using
811 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
812 clause), the GNAT uses the default alignment as described previously.
813   
814 @findex CPP_Class
815 @cindex Interfacing with C++
816 @item pragma CPP_Class
817 @noindent
818 Syntax:
819
820 @smallexample
821 pragma CPP_Class ([Entity =>] LOCAL_NAME);
822 @end smallexample
823
824 @noindent
825 The argument denotes an entity in the current declarative region
826 that is declared as a tagged or untagged record type. It indicates that
827 the type corresponds to an externally declared C++ class type, and is to
828 be laid out the same way that C++ would lay out the type.
829
830 If (and only if) the type is tagged, at least one component in the
831 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
832 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
833 for dispatching.
834
835 Types for which @code{CPP_Class} is specified do not have assignment or
836 equality operators defined (such operations can be imported or declared
837 as subprograms as required). Initialization is allowed only by
838 constructor functions (see pragma @code{CPP_Constructor}).
839
840 Pragma @code{CPP_Class} is intended primarily for automatic generation
841 using an automatic binding generator tool. Ada Core Technologies does
842 not currently supply such a
843 tool; See @ref{Interfacing to C++} for more details.
844
845 @cindex Interfacing with C++
846 @findex CPP_Constructor
847 @item pragma CPP_Constructor
848 @noindent
849 Syntax:
850
851 @smallexample
852 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
853 @end smallexample
854
855 @noindent
856 This pragma identifies an imported function (imported in the usual way
857 with pragma Import) as corresponding to a C++
858 constructor. The argument is a name that must have been
859 previously mentioned in a pragma
860 Import with @var{Convention CPP}, and must be of one of the following
861 forms:
862
863 @itemize @bullet
864 @item
865 @code{function @var{Fname} return @var{T}'Class}
866
867 @item
868 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
869 @end itemize
870
871 @noindent
872 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
873
874 The first form is the default constructor, used when an object of type
875 @var{T} is created on the Ada side with no explicit constructor. Other
876 constructors (including the copy constructor, which is simply a special
877 case of the second form in which the one and only argument is of type
878 @var{T}), can only appear in two contexts:
879
880 @itemize @bullet
881 @item
882 On the right side of an initialization of an object of type @var{T}.
883 @item
884 In an extension aggregate for an object of a type derived from @var{T}.
885 @end itemize
886
887 Although the constructor is described as a function that returns a value
888 on the Ada side, it is typically a procedure with an extra implicit
889 argument (the object being initialized) at the implementation
890 level. GNAT issues the appropriate call, whatever it is, to get the
891 object properly initialized.
892
893 In the case of derived objects, you may use one of two possible forms
894 for declaring and creating an object:
895
896 @itemize @bullet
897 @item @code{New_Object : Derived_T}
898 @item @code{New_Object : Derived_T := (@var{constructor-function-call with} @dots{})}
899 @end itemize
900
901 In the first case the default constructor is called and extension fields
902 if any are initialized according to the default initialization
903 expressions in the Ada declaration. In the second case, the given
904 constructor is called and the extension aggregate indicates the explicit
905 values of the extension fields.
906
907 If no constructors are imported, it is impossible to create any objects
908 on the Ada side. If no default constructor is imported, only the
909 initialization forms using an explicit call to a constructor are
910 permitted.
911
912 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
913 using an automatic binding generator tool. Ada Core Technologies does
914 not currently supply such a
915 tool; See @ref{Interfacing to C++} for more details.
916
917 @cindex Interfacing to C++
918 @findex CPP_Virtual
919 @item pragma CPP_Virtual
920 @noindent
921 Syntax:
922
923 @smallexample
924 pragma CPP_Virtual
925      [Entity     =>] ENTITY,
926   [, [Vtable_Ptr =>] vtable_ENTITY,]
927   [, [Position   =>] static_integer_EXPRESSION])
928 @end smallexample
929
930 This pragma serves the same function as pragma @code{Import} in that
931 case of a virtual function imported from C++. The @var{Entity} argument
932 must be a
933 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
934 applies. The @var{Vtable_Ptr} argument specifies
935 the Vtable_Ptr component which contains the
936 entry for this virtual function. The @var{Position} argument
937 is the sequential number
938 counting virtual functions for this Vtable starting at 1.
939
940 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
941 there is one Vtable_Ptr present (single inheritance case) and all
942 virtual functions are imported.  In that case the compiler can deduce both
943 these values.
944
945 No @code{External_Name} or @code{Link_Name} arguments are required for a
946 virtual function, since it is always accessed indirectly via the
947 appropriate Vtable entry.
948
949 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
950 using an automatic binding generator tool. Ada Core Technologies does
951 not currently supply such a
952 tool; See @ref{Interfacing to C++} for more details.
953
954 @cindex Interfacing with C++
955 @findex CPP_Vtable
956 @item pragma CPP_Vtable
957 @noindent
958 Syntax:
959
960 @smallexample
961 pragma CPP_Vtable (
962   [Entity      =>] ENTITY,
963   [Vtable_Ptr  =>] vtable_ENTITY,
964   [Entry_Count =>] static_integer_EXPRESSION);
965 @end smallexample
966
967 @noindent
968 Given a record to which the pragma @code{CPP_Class} applies,
969 this pragma can be specified for each component of type
970 @code{CPP.Interfaces.Vtable_Ptr}.
971 @var{Entity} is the tagged type, @var{Vtable_Ptr}
972 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
973 the number of virtual functions on the C++ side. Not all of these
974 functions need to be imported on the Ada side.
975
976 You may omit the @code{CPP_Vtable} pragma if there is only one
977 @code{Vtable_Ptr} component in the record and all virtual functions are
978 imported on the Ada side (the default value for the entry count in this
979 case is simply the total number of virtual functions).
980
981 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
982 using an automatic binding generator tool. Ada Core Technologies does
983 not currently supply such a
984 tool; See @ref{Interfacing to C++} for more details.
985
986 @findex Debug
987 @item pragma Debug
988 @noindent
989 Syntax:
990
991 @smallexample
992 pragma Debug (PROCEDURE_CALL_STATEMENT);
993 @end smallexample
994
995 @noindent
996 If assertions are not enabled on the command line, this pragma has no
997 effect. If asserts are enabled, the semantics of the pragma is exactly
998 equivalent to the procedure call. Pragmas are permitted in sequences of
999 declarations, so you can use pragma @code{Debug} to intersperse calls to
1000 debug procedures in the middle of declarations.
1001
1002 @cindex Elaboration control
1003 @findex Elaboration_Checks
1004 @item pragma Elaboration_Checks
1005 @noindent
1006 Syntax:
1007
1008 @smallexample
1009 pragma Elaboration_Checks (RM | Static);
1010 @end smallexample
1011
1012 @noindent
1013 This is a configuration pragma that provides control over the
1014 elaboration model used by the compilation affected by the
1015 pragma. If the parameter is RM, then the dynamic elaboration
1016 model described in the Ada Reference Manual is used, as though
1017 the @code{-gnatE} switch had been specified on the command
1018 line. If the parameter is Static, then the default GNAT static
1019 model is used. This configuration pragma overrides the setting
1020 of the command line. For full details on the elaboration models
1021 used by the GNAT compiler, see section "Elaboration Order
1022 Handling in GNAT" in the GNAT Users Guide.
1023
1024 @cindex Elimination of unused subprograms
1025 @findex Eliminate
1026 @item pragma Eliminate
1027 @noindent
1028 Syntax:
1029
1030 @smallexample
1031 pragma Eliminate (
1032     [Unit_Name =>] IDENTIFIER |
1033                    SELECTED_COMPONENT);
1034
1035 pragma Eliminate (
1036     [Unit_Name       =>]  IDENTIFIER |
1037                           SELECTED_COMPONENT
1038     [Entity          =>]  IDENTIFIER |
1039                           SELECTED_COMPONENT |
1040                           STRING_LITERAL]
1041    [,[Parameter_Types =>] PARAMETER_TYPES]
1042    [,[Result_Type     =>] result_SUBTYPE_NAME]]);
1043
1044 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1045 SUBTYPE_NAME    ::= STRING_LITERAL
1046 @end smallexample
1047
1048 @noindent
1049 This pragma indicates that the given entity is not used outside the
1050 compilation unit it is defined in. The entity may be either a subprogram 
1051 or a variable.
1052
1053 If the entity to be eliminated is a library level subprogram, then
1054 the first form of pragma @code{Eliminate} is used with only a single argument.
1055 In this form, the @code{Unit_Name} argument specifies the name of the
1056 library  level unit to be eliminated.
1057
1058 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1059 are required. item is an entity of a library package, then the first
1060 argument specifies the unit name, and the second argument specifies
1061 the particular entity. If the second argument is in string form, it must
1062 correspond to the internal manner in which GNAT stores entity names (see
1063 compilation unit Namet in the compiler sources for details).
1064 The third and fourth parameters are optionally used to distinguish
1065 between overloaded subprograms, in a manner similar to that used for 
1066 the extended @code{Import} and @code{Export} pragmas, except that the
1067 subtype names are always given as string literals, again corresponding
1068 to the internal manner in which GNAT stores entity names.
1069
1070 The effect of the pragma is to allow the compiler to eliminate
1071 the code or data associated with the named entity.  Any reference to 
1072 an eliminated entity outside the compilation unit it is defined in,
1073 causes a compile time or link time error.
1074
1075 The intention of pragma Eliminate is to allow a program to be compiled
1076 in a system independent manner, with unused entities eliminated, without
1077 the requirement of modifying the source text. Normally the required set
1078 of Eliminate pragmas is constructed automatically using the gnatelim tool.
1079 Elimination of unused entities local to a compilation unit is automatic,
1080 without requiring the use of pragma Eliminate.
1081
1082 Note that the reason this pragma takes string literals where names might
1083 be expected is that a pragma Eliminate can appear in a context where the
1084 relevant names are not visible.
1085
1086 @cindex OpenVMS
1087 @findex Export_Exception
1088 @item pragma Export_Exception
1089 @noindent
1090 Syntax:
1091
1092 @smallexample
1093 pragma Export_Exception (
1094      [Internal =>] LOCAL_NAME,
1095   [, [External =>] EXTERNAL_SYMBOL,]
1096   [, [Form     =>] Ada | VMS]
1097   [, [Code     =>] static_integer_EXPRESSION]);
1098
1099 EXTERNAL_SYMBOL ::=
1100   IDENTIFIER
1101 | static_string_EXPRESSION
1102 @end smallexample
1103
1104 @noindent
1105 This pragma is implemented only in the OpenVMS implementation of GNAT. It
1106 causes the specified exception to be propagated outside of the Ada program,
1107 so that it can be handled by programs written in other OpenVMS languages.
1108 This pragma establishes an external name for an Ada exception and makes the
1109 name available to the OpenVMS Linker as a global symbol. For further details
1110 on this pragma, see the
1111 DEC Ada Language Reference Manual, section 13.9a3.2.
1112
1113 @cindex Argument passing mechanisms
1114 @findex Export_Function
1115 @item pragma Export_Function @dots{}
1116
1117 @noindent
1118 Syntax:
1119
1120 @smallexample
1121 pragma Export_Function (
1122      [Internal         =>] LOCAL_NAME,      
1123   [, [External         =>] EXTERNAL_SYMBOL]
1124   [, [Parameter_Types  =>] PARAMETER_TYPES]
1125   [, [Result_Type      =>] result_SUBTYPE_MARK]
1126   [, [Mechanism        =>] MECHANISM]
1127   [, [Result_Mechanism =>] MECHANISM_NAME]);
1128
1129 EXTERNAL_SYMBOL ::=
1130   IDENTIFIER
1131 | static_string_EXPRESSION
1132
1133 PARAMETER_TYPES ::=
1134   null
1135 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1136
1137 MECHANISM ::=
1138   MECHANISM_NAME
1139 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1140
1141 MECHANISM_ASSOCIATION ::=
1142   [formal_parameter_NAME =>] MECHANISM_NAME
1143
1144 MECHANISM_NAME ::=
1145   Value
1146 | Reference
1147 | Descriptor [([Class =>] CLASS_NAME)]
1148
1149 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1150 @end smallexample
1151
1152 Use this pragma to make a function externally callable and optionally
1153 provide information on mechanisms to be used for passing parameter and
1154 result values. We recommend, for the purposes of improving portability,
1155 this pragma always be used in conjunction with a separate pragma
1156 @code{Export}, which must precede the pragma @code{Export_Function}.
1157 GNAT does not require a separate pragma @code{Export}, but if none is
1158 present, @code{Convention Ada} is assumed, which is usually
1159 not what is wanted, so it is usually appropriate to use this
1160 pragma in conjunction with a @code{Export} or @code{Convention}
1161 pragma that specifies the desired foreign convention.
1162 Pragma @code{Export_Function}
1163 (and @code{Export}, if present) must appear in the same declarative
1164 region as the function to which they apply.
1165
1166 @var{internal_name} must uniquely designate the function to which the
1167 pragma applies. If more than one function name exists of this name in
1168 the declarative part you must use the @code{Parameter_Types} and
1169 @code{Result_Type} parameters is mandatory to achieve the required
1170 unique designation. @var{subtype_ mark}s in these parameters must
1171 exactly match the subtypes in the corresponding function specification,
1172 using positional notation to match parameters with subtype marks.
1173 @cindex OpenVMS
1174 @cindex Passing by descriptor
1175 Passing by descriptor is supported only on the OpenVMS ports of GNAT.
1176
1177 @findex Export_Object
1178 @item pragma Export_Object @dots{}
1179 @noindent
1180 Syntax:
1181
1182 @smallexample
1183 pragma Export_Object
1184       [Internal =>] LOCAL_NAME,
1185    [, [External =>] EXTERNAL_SYMBOL]
1186    [, [Size     =>] EXTERNAL_SYMBOL]
1187
1188 EXTERNAL_SYMBOL ::=
1189   IDENTIFIER
1190 | static_string_EXPRESSION
1191 @end smallexample
1192
1193 This pragma designates an object as exported, and apart from the
1194 extended rules for external symbols, is identical in effect to the use of
1195 the normal @code{Export} pragma applied to an object. You may use a
1196 separate Export pragma (and you probably should from the point of view
1197 of portability), but it is not required.  @var{Size} is syntax checked,
1198 but otherwise ignored by GNAT.
1199
1200 @findex Export_Procedure
1201 @item pragma Export_Procedure @dots{}
1202 @noindent
1203 Syntax:
1204
1205 @smallexample
1206 pragma Export_Procedure (
1207      [Internal        =>] LOCAL_NAME
1208   [, [External        =>] EXTERNAL_SYMBOL]
1209   [, [Parameter_Types =>] PARAMETER_TYPES]
1210   [, [Mechanism       =>] MECHANISM]);
1211
1212 EXTERNAL_SYMBOL ::=
1213   IDENTIFIER
1214 | static_string_EXPRESSION
1215
1216 PARAMETER_TYPES ::=
1217   null
1218 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1219
1220 MECHANISM ::=
1221   MECHANISM_NAME
1222 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1223
1224 MECHANISM_ASSOCIATION ::=
1225   [formal_parameter_NAME =>] MECHANISM_NAME
1226
1227 MECHANISM_NAME ::=
1228   Value
1229 | Reference
1230 | Descriptor [([Class =>] CLASS_NAME)]
1231
1232 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1233 @end smallexample
1234
1235 @noindent
1236 This pragma is identical to @code{Export_Function} except that it
1237 applies to a procedure rather than a function and the parameters
1238 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1239 GNAT does not require a separate pragma @code{Export}, but if none is
1240 present, @code{Convention Ada} is assumed, which is usually
1241 not what is wanted, so it is usually appropriate to use this
1242 pragma in conjunction with a @code{Export} or @code{Convention}
1243 pragma that specifies the desired foreign convention.
1244
1245 @findex Export_Valued_Procedure
1246 @item pragma Export_Valued_Procedure
1247 @noindent
1248 Syntax:
1249
1250 @smallexample
1251 pragma Export_Valued_Procedure (
1252      [Internal        =>] LOCAL_NAME
1253   [, [External        =>] EXTERNAL_SYMBOL]
1254   [, [Parameter_Types =>] PARAMETER_TYPES]
1255   [, [Mechanism       =>] MECHANISM]);
1256
1257 EXTERNAL_SYMBOL ::=
1258   IDENTIFIER
1259 | static_string_EXPRESSION
1260
1261 PARAMETER_TYPES ::=
1262   null
1263 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1264
1265 MECHANISM ::=
1266   MECHANISM_NAME
1267 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1268
1269 MECHANISM_ASSOCIATION ::=
1270   [formal_parameter_NAME =>] MECHANISM_NAME
1271
1272 MECHANISM_NAME ::=
1273   Value
1274 | Reference
1275 | Descriptor [([Class =>] CLASS_NAME)]
1276
1277 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1278 @end smallexample
1279
1280 This pragma is identical to @code{Export_Procedure} except that the
1281 first parameter of @var{local_name}, which must be present, must be of
1282 mode @code{OUT}, and externally the subprogram is treated as a function
1283 with this parameter as the result of the function. GNAT provides for
1284 this capability to allow the use of @code{OUT} and @code{IN OUT}
1285 parameters in interfacing to external functions (which are not permitted
1286 in Ada functions).
1287 GNAT does not require a separate pragma @code{Export}, but if none is
1288 present, @code{Convention Ada} is assumed, which is almost certainly
1289 not what is wanted since the whole point of this pragma is to interface
1290 with foreign language functions, so it is usually appropriate to use this
1291 pragma in conjunction with a @code{Export} or @code{Convention}
1292 pragma that specifies the desired foreign convention.
1293
1294 @cindex @code{system}, extending
1295 @cindex Dec Ada 83
1296 @findex Extend_System
1297 @item pragma Extend_System
1298 @noindent
1299 Syntax:
1300
1301 @smallexample
1302 pragma Extend_System ([Name =>] IDENTIFIER);
1303 @end smallexample
1304
1305 @noindent
1306 This pragma is used to provide backwards compatibility with other
1307 implementations that extend the facilities of package @code{System}. In
1308 GNAT, @code{System} contains only the definitions that are present in
1309 the Ada 95 RM. However, other implementations, notably the DEC Ada 83
1310 implementation, provide many extensions to package @code{System}.
1311
1312 For each such implementation accommodated by this pragma, GNAT provides a
1313 package @code{Aux_@var{xxx}}, e.g. @code{Aux_DEC} for the DEC Ada 83
1314 implementation, which provides the required additional definitions. You
1315 can use this package in two ways.  You can @code{with} it in the normal
1316 way and access entities either by selection or using a @code{use}
1317 clause. In this case no special processing is required.
1318
1319 However, if existing code contains references such as
1320 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1321 definitions provided in package @code{System}, you may use this pragma
1322 to extend visibility in @code{System} in a non-standard way that
1323 provides greater compatibility with the existing code. Pragma
1324 @code{Extend_System} is a configuration pragma whose single argument is
1325 the name of the package containing the extended definition
1326 (e.g. @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1327 control of this pragma will be processed using special visibility
1328 processing that looks in package @code{System.Aux_@var{xxx}} where
1329 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1330 package @code{System}, but not found in package @code{System}.
1331
1332 You can use this pragma either to access a predefined @code{System}
1333 extension supplied with the compiler, for example @code{Aux_DEC} or
1334 you can construct your own extension unit following the above
1335 definition. Note that such a package is a child of @code{System}
1336 and thus is considered part of the implementation. To compile
1337 it you will have to use the appropriate switch for compiling
1338 system units. See the GNAT User's Guide for details.
1339
1340 @findex External
1341 @item pragma External
1342 @noindent
1343 Syntax:
1344
1345 @smallexample
1346 pragma External (
1347   [   Convention    =>] convention_IDENTIFIER,
1348   [   Entity        =>] local_NAME
1349   [, [External_Name =>] static_string_EXPRESSION ]
1350   [, [Link_Name     =>] static_string_EXPRESSION ]);
1351 @end smallexample
1352
1353 @noindent
1354 This pragma is identical in syntax and semantics to pragma
1355 @code{Export} as defined in the Ada Reference Manual. It is
1356 provided for compatibility with some Ada 83 compilers that
1357 used this pragma for exactly the same purposes as pragma
1358 @code{Export} before the latter was standardized.
1359
1360 @cindex Dec Ada 83 casing compatibility
1361 @cindex External Names, casing
1362 @cindex Casing of External names
1363 @findex External_Name_Casing
1364 @item pragma External_Name_Casing
1365 @noindent
1366 Syntax:
1367
1368 @smallexample
1369 pragma External_Name_Casing (
1370   Uppercase | Lowercase
1371   [, Uppercase | Lowercase | As_Is]);
1372 @end smallexample
1373
1374 @noindent
1375 This pragma provides control over the casing of external names associated
1376 with Import and Export pragmas. There are two cases to consider:
1377
1378 @table @asis
1379 @item Implicit external names
1380 Implicit external names are derived from identifiers. The most common case
1381 arises when a standard Ada 95 Import or Export pragma is used with only two
1382 arguments, as in:
1383
1384 @smallexample
1385    pragma Import (C, C_Routine);
1386 @end smallexample
1387
1388 @noindent
1389 Since Ada is a case insensitive language, the spelling of the identifier in
1390 the Ada source program does not provide any information on the desired
1391 casing of the external name, and so a convention is needed. In GNAT the
1392 default treatment is that such names are converted to all lower case
1393 letters. This corresponds to the normal C style in many environments.
1394 The first argument of pragma @code{External_Name_Casing} can be used to
1395 control this treatment. If @code{Uppercase} is specified, then the name
1396 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1397 then the normal default of all lower case letters will be used.
1398
1399 This same implicit treatment is also used in the case of extended DEC Ada 83
1400 compatible Import and Export pragmas where an external name is explicitly
1401 specified using an identifier rather than a string.
1402
1403 @item Explicit external names
1404 Explicit external names are given as string literals. The most common case
1405 arises when a standard Ada 95 Import or Export pragma is used with three
1406 arguments, as in:
1407
1408 @smallexample
1409 pragma Import (C, C_Routine, "C_routine");
1410 @end smallexample
1411
1412 @noindent
1413 In this case, the string literal normally provides the exact casing required
1414 for the external name. The second argument of pragma 
1415 @code{External_Name_Casing} may be used to modify this behavior. 
1416 If @code{Uppercase} is specified, then the name
1417 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1418 then the name will be forced to all lowercase letters. A specification of
1419 @code{As_Is} provides the normal default behavior in which the casing is
1420 taken from the string provided.
1421 @end table
1422
1423 @noindent
1424 This pragma may appear anywhere that a pragma is valid. in particular, it
1425 can be used as a configuration pragma in the @code{gnat.adc} file, in which
1426 case it applies to all subsequent compilations, or it can be used as a program
1427 unit pragma, in which case it only applies to the current unit, or it can
1428 be used more locally to control individual Import/Export pragmas.
1429
1430 It is primarily intended for use with @code{OpenVMS} systems, where many
1431 compilers convert all symbols to upper case by default. For interfacing to
1432 such compilers (e.g. the DEC C compiler), it may be convenient to use
1433 the pragma:
1434
1435 @smallexample
1436 pragma External_Name_Casing (Uppercase, Uppercase);
1437 @end smallexample
1438
1439 @noindent
1440 to enforce the upper casing of all external symbols. 
1441
1442 @findex Finalize_Storage_Only
1443 @item pragma Finalize_Storage_Only
1444 @noindent
1445 Syntax:
1446
1447 @smallexample
1448 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1449 @end smallexample
1450
1451 @noindent
1452 This pragma allows the compiler not to emit a Finalize call for objects
1453 defined at the library level. This is mostly useful for types where
1454 finalization is only used to deal with storage reclamation since in most
1455 environments it is not necessary to reclaim memory just before terminating
1456 execution, hence the name.
1457
1458 @cindex OpenVMS
1459 @findex Float_Representation
1460 @item pragma Float_Representation
1461 @noindent
1462 Syntax:
1463
1464 @smallexample
1465 pragma Float_Representation (FLOAT_REP);
1466
1467 FLOAT_REP ::= VAX_Float | IEEE_Float
1468 @end smallexample
1469
1470 @noindent
1471 This pragma is implemented only in the OpenVMS implementation of GNAT.
1472 It allows control over the internal representation chosen for the predefined
1473 floating point types declared in the packages @code{Standard} and
1474 @code{System}. For further details on this pragma, see the
1475 DEC Ada Language Reference Manual, section 3.5.7a. Note that to use this
1476 pragma, the standard runtime libraries must be recompiled. See the
1477 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1478 of the GNAT Users Guide for details on the use of this command.
1479
1480 @findex Ident
1481 @item pragma Ident
1482 @noindent
1483 Syntax:
1484
1485 @smallexample
1486 pragma Ident (static_string_EXPRESSION);
1487 @end smallexample
1488
1489 @noindent
1490 This pragma provides a string identification in the generated object file,
1491 if the system supports the concept of this kind of identification string.
1492 The maximum permitted length of the string literal is 31 characters.
1493 This pragma is allowed only in the outermost declarative part or
1494 declarative items of a compilation unit.
1495 @cindex OpenVMS
1496 On OpenVMS systems, the effect of the pragma is identical to the effect of
1497 the DEC Ada 83 pragma of the same name. 
1498
1499 @cindex OpenVMS
1500 @findex Import_Exception
1501 @item pragma Import_Exception
1502 @noindent
1503 Syntax:
1504
1505 @smallexample
1506 pragma Import_Exception (
1507      [Internal =>] LOCAL_NAME,
1508   [, [External =>] EXTERNAL_SYMBOL,]
1509   [, [Form     =>] Ada | VMS]
1510   [, [Code     =>] static_integer_EXPRESSION]);
1511
1512 EXTERNAL_SYMBOL ::=
1513   IDENTIFIER
1514 | static_string_EXPRESSION
1515 @end smallexample
1516
1517 @noindent
1518 This pragma is implemented only in the OpenVMS implementation of GNAT.
1519 It allows OpenVMS conditions (for example, from OpenVMS system services or
1520 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1521 The pragma specifies that the exception associated with an exception
1522 declaration in an Ada program be defined externally (in non-Ada code).
1523 For further details on this pragma, see the
1524 DEC Ada Language Reference Manual, section 13.9a.3.1.
1525
1526 @findex Import_Function
1527 @item pragma Import_Function @dots{}
1528 @noindent
1529 Syntax:
1530
1531 @smallexample
1532 pragma Import_Function (
1533      [Internal                 =>] LOCAL_NAME,
1534   [, [External                 =>] EXTERNAL_SYMBOL]
1535   [, [Parameter_Types          =>] PARAMETER_TYPES]
1536   [, [Result_Type              =>] SUBTYPE_MARK]
1537   [, [Mechanism                =>] MECHANISM]
1538   [, [Result_Mechanism         =>] MECHANISM_NAME]
1539   [, [First_Optional_Parameter =>] IDENTIFIER]);
1540
1541 EXTERNAL_SYMBOL ::=
1542   IDENTIFIER
1543 | static_string_EXPRESSION
1544
1545 PARAMETER_TYPES ::=
1546   null
1547 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1548
1549 MECHANISM ::=
1550   MECHANISM_NAME
1551 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1552
1553 MECHANISM_ASSOCIATION ::=
1554   [formal_parameter_NAME =>] MECHANISM_NAME
1555
1556 MECHANISM_NAME ::=
1557   Value
1558 | Reference
1559 | Descriptor [([Class =>] CLASS_NAME)]
1560
1561 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1562 @end smallexample
1563
1564 This pragma is used in conjunction with a pragma @code{Import} to
1565 specify additional information for an imported function. The pragma
1566 @code{Import} (or equivalent pragma @code{Interface}) must precede the
1567 @code{Import_Function} pragma and both must appear in the same
1568 declarative part as the function specification.
1569
1570 The @var{Internal_Name} argument must uniquely designate
1571 the function to which the
1572 pragma applies. If more than one function name exists of this name in
1573 the declarative part you must use the @code{Parameter_Types} and
1574 @var{Result_Type} parameters to achieve the required unique
1575 designation. Subtype marks in these parameters must exactly match the
1576 subtypes in the corresponding function specification, using positional
1577 notation to match parameters with subtype marks.
1578
1579 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
1580 parameters to specify passing mechanisms for the
1581 parameters and result. If you specify a single mechanism name, it
1582 applies to all parameters.  Otherwise you may specify a mechanism on a
1583 parameter by parameter basis using either positional or named
1584 notation. If the mechanism is not specified, the default mechanism
1585 is used.
1586
1587 @cindex OpenVMS
1588 @cindex Passing by descriptor
1589 Passing by descriptor is supported only on the to OpenVMS ports of GNAT.
1590
1591 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT.
1592 It specifies that the designated parameter and all following parameters
1593 are optional, meaning that they are not passed at the generated code
1594 level (this is distinct from the notion of optional parameters in Ada
1595 where the parameters are passed anyway with the designated optional
1596 parameters). All optional parameters must be of mode @code{IN} and have
1597 default parameter values that are either known at compile time
1598 expressions, or uses of the @code{'Null_Parameter} attribute.
1599
1600 @findex Import_Object
1601 @item pragma Import_Object
1602 @noindent
1603 Syntax:
1604
1605 @smallexample
1606 pragma Import_Object
1607      [Internal =>] LOCAL_NAME,
1608   [, [External =>] EXTERNAL_SYMBOL],
1609   [, [Size     =>] EXTERNAL_SYMBOL])
1610
1611 EXTERNAL_SYMBOL ::=
1612   IDENTIFIER
1613 | static_string_EXPRESSION
1614 @end smallexample
1615
1616 @noindent
1617 This pragma designates an object as imported, and apart from the
1618 extended rules for external symbols, is identical in effect to the use of
1619 the normal @code{Import} pragma applied to an object.  Unlike the
1620 subprogram case, you need not use a separate @code{Import} pragma,
1621 although you may do so (and probably should do so from a portability
1622 point of view). @var{size} is syntax checked, but otherwise ignored by
1623 GNAT.
1624
1625 @findex Import_Procedure
1626 @item pragma Import_Procedure
1627 @noindent
1628 Syntax:
1629
1630 @smallexample
1631 pragma Import_Procedure (
1632      [Internal                 =>] LOCAL_NAME,
1633   [, [External                 =>] EXTERNAL_SYMBOL]
1634   [, [Parameter_Types          =>] PARAMETER_TYPES]
1635   [, [Mechanism                =>] MECHANISM]
1636   [, [First_Optional_Parameter =>] IDENTIFIER]);
1637
1638 EXTERNAL_SYMBOL ::=
1639   IDENTIFIER
1640 | static_string_EXPRESSION
1641
1642 PARAMETER_TYPES ::=
1643   null
1644 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1645
1646 MECHANISM ::=
1647   MECHANISM_NAME
1648 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1649
1650 MECHANISM_ASSOCIATION ::=
1651   [formal_parameter_NAME =>] MECHANISM_NAME
1652
1653 MECHANISM_NAME ::=
1654   Value
1655 | Reference
1656 | Descriptor [([Class =>] CLASS_NAME)]
1657
1658 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1659 @end smallexample
1660
1661 @noindent
1662 This pragma is identical to @code{Import_Function} except that it
1663 applies to a procedure rather than a function and the parameters
1664 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1665
1666 @findex Import_Valued_Procedure
1667 @item pragma Import_Valued_Procedure @dots{}
1668 @noindent
1669 Syntax:
1670
1671 @smallexample
1672 pragma Import_Valued_Procedure (
1673      [Internal                 =>] LOCAL_NAME,
1674   [, [External                 =>] EXTERNAL_SYMBOL]
1675   [, [Parameter_Types          =>] PARAMETER_TYPES]
1676   [, [Mechanism                =>] MECHANISM]
1677   [, [First_Optional_Parameter =>] IDENTIFIER]);
1678
1679 EXTERNAL_SYMBOL ::=
1680   IDENTIFIER
1681 | static_string_EXPRESSION
1682
1683 PARAMETER_TYPES ::=
1684   null
1685 | SUBTYPE_MARK @{, SUBTYPE_MARK@}
1686
1687 MECHANISM ::=
1688   MECHANISM_NAME
1689 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1690
1691 MECHANISM_ASSOCIATION ::=
1692   [formal_parameter_NAME =>] MECHANISM_NAME
1693
1694 MECHANISM_NAME ::=
1695   Value
1696 | Reference
1697 | Descriptor [([Class =>] CLASS_NAME)]
1698
1699 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1700 @end smallexample
1701
1702 @noindent
1703 This pragma is identical to @code{Import_Procedure} except that the
1704 first parameter of @var{local_name}, which must be present, must be of
1705 mode @code{OUT}, and externally the subprogram is treated as a function
1706 with this parameter as the result of the function. The purpose of this
1707 capability is to allow the use of @code{OUT} and @code{IN OUT}
1708 parameters in interfacing to external functions (which are not permitted
1709 in Ada functions).  You may optionally use the @code{Mechanism}
1710 parameters to specify passing mechanisms for the parameters.
1711 If you specify a single mechanism name, it applies to all parameters.
1712 Otherwise you may specify a mechanism on a parameter by parameter
1713 basis using either positional or named notation. If the mechanism is not
1714 specified, the default mechanism is used.
1715
1716 Note that it is important to use this pragma in conjunction with a separate
1717 pragma Import that specifies the desired convention, since otherwise the
1718 default convention is Ada, which is almost certainly not what is required.
1719
1720 @findex Initialize_Scalars
1721 @cindex debugging with Initialize_Scalars
1722 @item pragma Initialize_Scalars
1723 @noindent
1724 Syntax:
1725
1726 @smallexample
1727 pragma Initialize_Scalars;
1728 @end smallexample
1729
1730 @noindent
1731 This pragma is similar to @code{Normalize_Scalars} conceptually but has 
1732 two important differences. First, there is no requirement for the pragma
1733 to be used uniformly in all units of a partition, in particular, it is fine
1734 to use this just for some or all of the application units of a partition,
1735 without needing to recompile the run-time library.
1736
1737 In the case where some units are compiled with the pragma, and some without,
1738 then a declaration of a variable where the type is defined in package
1739 Standard or is locally declared will always be subject to initialization,
1740 as will any declaration of a scalar variable. For composite variables,
1741 whether the variable is initialized may also depend on whether the package
1742 in which the type of the variable is declared is compiled with the pragma.
1743
1744 The other important difference is that there is control over the value used
1745 for initializing scalar objects. At bind time, you can select whether to
1746 initialize with invalid values (like Normalize_Scalars), or with high or
1747 low values, or with a specified bit pattern. See the users guide for binder
1748 options for specifying these cases.
1749
1750 This means that you can compile a program, and then without having to
1751 recompile the program, you can run it with different values being used
1752 for initializing otherwise uninitialized values, to test if your program
1753 behavior depends on the choice. Of course the behavior should not change,
1754 and if it does, then most likely you have an erroneous reference to an
1755 uninitialized value.
1756
1757 Note that pragma @code{Initialize_Scalars} is particularly useful in
1758 conjunction with the enhanced validity checking that is now provided
1759 in @code{GNAT}, which checks for invalid values under more conditions.
1760 Using this feature (see description of the @code{-gnatv} flag in the
1761 users guide) in conjunction with pragma @code{Initialize_Scalars}
1762 provides a powerful new tool to assist in the detection of problems
1763 caused by uninitialized variables.
1764
1765 @findex Inline_Always
1766 @item pragma Inline_Always
1767 @noindent
1768 Syntax:
1769
1770 @smallexample
1771 pragma Inline_Always (NAME [, NAME]);
1772 @end smallexample
1773
1774 @noindent
1775 Similar to pragma  @code{Inline} except that inlining is not subject to
1776 the use of option @code{-gnatn} for inter-unit inlining.
1777
1778 @findex Inline_Generic
1779 @item pragma Inline_Generic
1780 @noindent
1781 Syntax:
1782
1783 @smallexample
1784 pragma Inline_Generic (generic_package_NAME)
1785 @end smallexample
1786
1787 @noindent
1788 This is implemented for compatibility with DEC Ada 83 and is recognized,
1789 but otherwise ignored, by GNAT. All generic instantiations are inlined
1790 by default when using GNAT.
1791
1792 @findex Interface
1793 @item pragma Interface
1794 @noindent
1795 Syntax:
1796
1797 @smallexample
1798 pragma Interface (
1799      [Convention    =>] convention_identifier,
1800      [Entity =>] local_name
1801   [, [External_Name =>] static_string_expression],
1802   [, [Link_Name     =>] static_string_expression]);
1803 @end smallexample
1804
1805 @noindent
1806 This pragma is identical in syntax and semantics to
1807 the standard Ada 95 pragma @code{Import}. It is provided for compatibility
1808 with Ada 83. The definition is upwards compatible both with pragma
1809 @code{Interface} as defined in the Ada 83 Reference Manual, and also
1810 with some extended implementations of this pragma in certain Ada 83
1811 implementations.
1812
1813 @findex Interface_Name
1814 @item pragma Interface_Name
1815 @noindent
1816 Syntax:
1817
1818 @smallexample
1819 pragma Interface_Name ( 
1820      [Entity        =>] LOCAL_NAME
1821   [, [External_Name =>] static_string_EXPRESSION]
1822   [, [Link_Name     =>] static_string_EXPRESSION]);
1823 @end smallexample
1824
1825 @noindent
1826 This pragma provides an alternative way of specifying the interface name
1827 for an interfaced subprogram, and is provided for compatibility with Ada
1828 83 compilers that use the pragma for this purpose. You must provide at
1829 least one of @var{External_Name} or @var{Link_Name}.
1830
1831 @findex License
1832 @item pragma License
1833 @cindex License checking
1834 @noindent
1835 Syntax:
1836
1837 @smallexample
1838 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
1839 @end smallexample
1840
1841 @noindent
1842 This pragma is provided to allow automated checking for appropriate license
1843 conditions with respect to the standard and modified GPL. A pragma License,
1844 which is a configuration pragma that typically appears at the start of a
1845 source file or in a separate @file{gnat.adc} file, specifies the licensing
1846 conditions of a unit as follows:
1847
1848 @itemize @bullet
1849 @item Unrestricted
1850 This is used for a unit that can be freely used with no license restrictions.
1851 Examples of such units are public domain units, and units from the Ada
1852 Reference Manual.
1853
1854 @item GPL
1855 This is used for a unit that is licensed under the unmodified GPL, and which
1856 therefore cannot be @code{with}'ed by a restricted unit.
1857
1858 @item Modified_GPL
1859 This is used for a unit licensed under the GNAT modified GPL that includes
1860 a special exception paragraph that specifically permits the inclusion of
1861 the unit in programs without requiring the entire program to be released
1862 under the GPL. This is the license used for the GNAT run-time which ensures
1863 that the run-time can be used freely in any program without GPL concerns.
1864
1865 @item Restricted
1866 This is used for a unit that is restricted in that it is not permitted to
1867 depend on units that are licensed under the GPL. Typical examples are
1868 proprietary code that is to be released under more restrictive license
1869 conditions. Note that restricted units are permitted to @code{with} units
1870 which are licensed under the modified GPL (this is the whole point of the
1871 modified GPL).
1872
1873 @end itemize
1874
1875 @noindent
1876 Normally a unit with no @code{License} pragma is considered to have an
1877 unknown license, and no checking is done. However, standard GNAT headers
1878 are recognized, and license information is derived from them as follows.
1879
1880 @itemize @bullet
1881
1882 A GNAT license header starts with a line containing 78 hyphens. The following
1883 comment text is searched for the appearence of any of the following strings.
1884
1885 If the string "GNU General Public License" is found, then the unit is assumed
1886 to have GPL license, unless the string "As a special exception" follows, in
1887 which case the license is assumed to be modified GPL.
1888
1889 If one of the strings
1890 "This specification is adapated from the Ada Semantic Interface" or
1891 "This specification is derived from the Ada Reference Manual" is found
1892 then the unit is assumed to be unrestricted.
1893 @end itemize
1894
1895 @noindent
1896 These default actions means that a program with a restricted license pragma
1897 will automatically get warnings if a GPL unit is inappropriately
1898 @code{with}'ed. For example, the program:
1899
1900 @smallexample
1901 with Sem_Ch3;
1902 with GNAT.Sockets;
1903 procedure Secret_Stuff is
1904 ...
1905 end Secret_Stuff
1906 @end smallexample
1907
1908 @noindent
1909 if compiled with pragma @code{License} (@code{Restricted}) in a
1910 @file{gnat.adc} file will generate the warning:
1911
1912 @smallexample
1913 1. with Sem_Ch3;
1914         |
1915    >>> license of withed unit "Sem_Ch3" is incompatible
1916
1917 2. with GNAT.Sockets;
1918 3. procedure Secret_Stuff is
1919 @end smallexample
1920 @noindent
1921 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
1922 compiler and is licensed under the
1923 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT 
1924 run time, and is therefore licensed under the modified GPL.
1925
1926 @findex Link_With
1927 @item pragma Link_With
1928 @noindent
1929 Syntax:
1930
1931 @smallexample
1932 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
1933 @end smallexample
1934
1935 @noindent
1936 This pragma is provided for compatibility with certain Ada 83 compilers.
1937 It has exactly the same effect as pragma @code{Linker_Options} except
1938 that spaces occurring within one of the string expressions are treated
1939 as separators. For example, in the following case:
1940
1941 @smallexample
1942 pragma Link_With ("-labc -ldef");
1943 @end smallexample
1944
1945 @noindent
1946 results in passing the strings @code{-labc} and @code{-ldef} as two
1947 separate arguments to the linker.
1948
1949 @findex Linker_Alias
1950 @item pragma Linker_Alias
1951 @noindent
1952 Syntax:
1953
1954 @smallexample
1955 pragma Linker_Alias (
1956   [Entity =>] LOCAL_NAME
1957   [Alias  =>] static_string_EXPRESSION);
1958 @end smallexample
1959
1960 @noindent
1961 This pragma establishes a linker alias for the given named entity. For
1962 further details on the exact effect, consult the GCC manual.
1963
1964 @findex Linker_Section
1965 @item pragma Linker_Section
1966 @noindent
1967 Syntax:
1968
1969 @smallexample
1970 pragma Linker_Section (
1971   [Entity  =>] LOCAL_NAME
1972   [Section =>] static_string_EXPRESSION);
1973 @end smallexample
1974
1975 @noindent
1976 This pragma specifies the name of the linker section for the given entity.
1977 For further details on the exact effect, consult the GCC manual.
1978
1979 @findex No_Run_Time
1980 @item pragma No_Run_Time
1981 @noindent
1982 Syntax:
1983
1984 @smallexample
1985 pragma No_Run_Time;
1986 @end smallexample
1987
1988 @noindent
1989 This is a configuration pragma that makes sure the user code does not
1990 use nor need anything from the GNAT run time. This is mostly useful in
1991 context where code certification is required. Please consult the High
1992 Integrity product documentation for additional information.
1993
1994 @findex Normalize_Scalars
1995 @item pragma Normalize_Scalars
1996 @noindent
1997 Syntax:
1998
1999 @smallexample
2000 pragma Normalize_Scalars;
2001 @end smallexample
2002
2003 @noindent
2004 This is a language defined pragma which is fully implemented in GNAT. The
2005 effect is to cause all scalar objects that are not otherwise initialized
2006 to be initialized. The initial values are implementation dependent and
2007 are as follows:
2008
2009 @table @code
2010 @item Standard.Character
2011 @noindent
2012 Objects whose root type is Standard.Character are initialized to
2013 Character'Last. This will be out of range of the subtype only if
2014 the subtype range excludes this value.
2015
2016 @item Standard.Wide_Character
2017 @noindent
2018 Objects whose root type is Standard.Wide_Character are initialized to
2019 Wide_Character'Last. This will be out of range of the subtype only if
2020 the subtype range excludes this value.
2021
2022 @item Integer types
2023 @noindent
2024 Objects of an integer type are initialized to base_type'First, where
2025 base_type is the base type of the object type. This will be out of range
2026 of the subtype only if the subtype range excludes this value. For example,
2027 if you declare the subtype:
2028
2029 @smallexample
2030 subtype Ityp is integer range 1 .. 10;
2031 @end smallexample
2032
2033 @noindent
2034 then objects of type x will be initialized to Integer'First, a negative
2035 number that is certainly outside the range of subtype @code{Ityp}.
2036
2037 @item Real types
2038 Objects of all real types (fixed and floating) are initialized to
2039 base_type'First, where base_Type is the base type of the object type.
2040 This will be out of range of the subtype only if the subtype range
2041 excludes this value.
2042
2043 @item Modular types
2044 Objects of a modular type are initialized to typ'Last. This will be out
2045 of range of the subtype only if the subtype excludes this value.
2046
2047 @item Enumeration types
2048 Objects of an enumeration type are initialized to all one-bits, i.e. to
2049 the value 2 ** typ'Size - 1. This will be out of range of the enumeration
2050 subtype in all cases except where the subtype contains exactly
2051 2**8, 2**16, or 2**32.
2052
2053 @end table
2054
2055 @cindex OpenVMS
2056 @findex Long_Float
2057 @item pragma Long_Float
2058 @noindent
2059 Syntax:
2060
2061 @smallexample
2062 pragma Long_Float (FLOAT_FORMAT);
2063
2064 FLOAT_FORMAT ::= D_Float | G_Float
2065 @end smallexample
2066
2067 @noindent
2068 This pragma is implemented only in the OpenVMS implementation of GNAT.
2069 It allows control over the internal representation chosen for the predefined
2070 type @code{Long_Float} and for floating point type representations with
2071 @code{digits} specified in the range 7 .. 15.
2072 For further details on this pragma, see the
2073 DEC Ada Language Reference Manual, section 3.5.7b. Note that to use this
2074 pragma, the standard runtime libraries must be recompiled. See the
2075 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2076 of the GNAT Users Guide for details on the use of this command.
2077
2078 @findex Machine_Attribute
2079 @item pragma Machine_Attribute @dots{}
2080 @noindent
2081 Syntax:
2082
2083 @smallexample
2084 pragma Machine_Attribute (
2085   [Attribute_Name =>] string_EXPRESSION,
2086   [Entity         =>] LOCAL_NAME);
2087 @end smallexample
2088
2089 Machine dependent attributes can be specified for types and/or
2090 declarations. Currently only subprogram entities are supported.  This
2091 pragma is semantically equivalent to @code{__attribute__((
2092 @var{string_expression}))} in GNU C, where @code{string_expression}> is
2093 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2094 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2095 configuration header file @file{tm.h} for each machine.  See the GCC
2096 manual for further information.
2097
2098 @cindex OpenVMS
2099 @findex Main_Storage
2100 @item pragma Main_Storage
2101 @noindent
2102 Syntax:
2103
2104 @smallexample
2105 pragma Main_Storage
2106   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2107
2108 MAIN_STORAGE_OPTION ::=
2109   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2110 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2111
2112 @end smallexample
2113
2114 @noindent
2115 This pragma is provided for compatibility with OpenVMS Vax Systems. It has
2116 no effect in GNAT, other than being syntax checked. Note that the pragma
2117 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2118
2119 @findex No_Return
2120 @item pragma No_Return
2121 @noindent
2122 Syntax:
2123
2124 @smallexample
2125 pragma No_Return (procedure_LOCAL_NAME);
2126 @end smallexample
2127
2128 @noindent
2129 @var{procedure_local_NAME} must refer to one or more procedure
2130 declarations in the current declarative part. A procedure to which this
2131 pragma is applied may not contain any explicit @code{return} statements,
2132 and also may not contain any implicit return statements from falling off
2133 the end of a statement sequence. One use of this pragma is to identify
2134 procedures whose only purpose is to raise an exception.
2135
2136 Another use of this pragma is to suppress incorrect warnings about
2137 missing returns in functions, where the last statement of a function
2138 statement sequence is a call to such a procedure.
2139
2140 @findex Passive
2141 @item pragma Passive
2142 @noindent
2143 Syntax:
2144
2145 @smallexample
2146 pragma Passive ([Semaphore | No]);
2147 @end smallexample
2148
2149 @noindent
2150 Syntax checked, but otherwise ignored by GNAT. This is recognized for
2151 compatibility with DEC Ada 83 implementations, where it is used within a
2152 task definition to request that a task be made passive.  If the argument
2153 @code{Semaphore} is present, or no argument is omitted, then DEC Ada 83
2154 treats the pragma as an assertion that the containing task is passive
2155 and that optimization of context switch with this task is permitted and
2156 desired.  If the argument @code{No} is present, the task must not be
2157 optimized. GNAT does not attempt to optimize any tasks in this manner
2158 (since protected objects are available in place of passive tasks).
2159
2160 @findex Polling 
2161 @item pragma Polling
2162 @noindent
2163 Syntax:
2164
2165 @smallexample
2166 pragma Polling (ON | OFF);
2167 @end smallexample
2168
2169 @noindent
2170 This pragma controls the generation of polling code. This is normally off.
2171 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2172 the routine Ada.Exceptions.Poll. This routine is a separate unit in the
2173 runtime library, and can be found in file a-excpol.adb.
2174
2175 Pragma polling can appear as a configuration pragma (for example it can be
2176 placed in the gnat.adc file) to enable polling globally, or it can be used
2177 in the statement or declaration sequence to control polling more locally.
2178
2179 A call to the polling routine is generated at the start of every loop and
2180 at the start of every subprogram call. This guarantees that the Poll
2181 routine is called frequently, and places an upper bound (determined by
2182 the complexity of the code) on the period between two Poll calls.
2183
2184 The primary purpose of the polling interface is to enable asynchronous 
2185 aborts on targets that cannot otherwise support it (for example Windows
2186 NT), but it may be used for any other purpose requiring periodic polling.
2187 The standard version is null, and can be replaced by a user program. This
2188 will require re-compilation of the Ada.Exceptions package that can be found
2189 in files a-except.ads/adb.
2190
2191 A standard alternative unit (called 4wexcpol.adb in the standard GNAT
2192 distribution) is used to enable the asynchronous abort capability on
2193 targets that do not normally support the capability. The version of Poll
2194 in this file makes a call to the appropriate runtime routine to test for
2195 an abort condition.
2196
2197 Note that polling can also be enabled by use of the -gnatP switch. See
2198 the GNAT User's Guide for details.
2199
2200 @findex Propagate_Exceptions
2201 @cindex Zero Cost Exceptions
2202 @item pragma Propagate_Exceptions
2203 @noindent
2204 Syntax:
2205
2206 @smallexample
2207 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2208 @end smallexample
2209
2210 @noindent
2211 This pragma indicates that the given entity, which is the name of an
2212 imported foreign-language subprogram may receive an Ada exception, 
2213 and that the exception should be propagated. It is relevant only if
2214 zero cost exception handling is in use, and is thus never needed if
2215 the alternative longjmp/setjmp implementation of exceptions is used
2216 (although it is harmless to use it in such cases).
2217
2218 The implementation of fast exceptions always properly propagates
2219 exceptions through Ada code, as described in the Ada Reference Manual.
2220 However, this manual is silent about the propagation of exceptions
2221 through foreign code. For example, consider the
2222 situation where @code{P1} calls
2223 @code{P2}, and @code{P2} calls @code{P3}, where
2224 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C.
2225 @code{P3} raises an Ada exception. The question is whether or not
2226 it will be propagated through @code{P2} and can be handled in 
2227 @code{P1}.
2228
2229 For the longjmp/setjmp implementation of exceptions, the answer is
2230 always yes. For some targets on which zero cost exception handling
2231 is implemented, the answer is also always yes. However, there are
2232 some targets, notably in the current version all x86 architecture
2233 targets, in which the answer is that such propagation does not
2234 happen automatically. If such propagation is required on these
2235 targets, it is mandatory to use @code{Propagate_Exceptions} to 
2236 name all foreign language routines through which Ada exceptions
2237 may be propagated.
2238
2239 @findex Psect_Object
2240 @item pragma Psect_Object
2241 @noindent
2242 Syntax:
2243
2244 @smallexample
2245 pragma Psect_Object
2246      [Internal =>] LOCAL_NAME,
2247   [, [External =>] EXTERNAL_SYMBOL]
2248   [, [Size     =>] EXTERNAL_SYMBOL]
2249
2250 EXTERNAL_SYMBOL ::=
2251   IDENTIFIER
2252 | static_string_EXPRESSION
2253 @end smallexample
2254
2255 @noindent
2256 This pragma is identical in effect to pragma @code{Common_Object}.
2257
2258 @findex Pure_Function
2259 @item pragma Pure_Function
2260 @noindent
2261 Syntax:
2262
2263 @smallexample
2264 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2265 @end smallexample
2266
2267 This pragma appears in the same declarative part as a function
2268 declaration (or a set of function declarations if more than one
2269 overloaded declaration exists, in which case the pragma applies
2270 to all entities). If specifies that the function @code{Entity} is
2271 to be considered pure for the purposes of code generation. This means
2272 that the compiler can assume that there are no side effects, and
2273 in particular that two calls with identical arguments produce the
2274 same result. It also means that the function can be used in an
2275 address clause.
2276
2277 Note that, quite deliberately, there are no static checks to try
2278 to ensure that this promise is met, so @var{Pure_Function} can be used
2279 with functions that are conceptually pure, even if they do modify
2280 global variables. For example, a square root function that is
2281 instrumented to count the number of times it is called is still
2282 conceptually pure, and can still be optimized, even though it
2283 modifies a global variable (the count). Memo functions are another
2284 example (where a table of previous calls is kept and consulted to
2285 avoid re-computation).
2286
2287 @findex Pure
2288 Note: Most functions in a @code{Pure} package are automatically pure, and
2289 there is no need to use pragma @code{Pure_Function} for such functions. An
2290 exception is any function that has at least one formal of type
2291 @code{System.Address} or a type derived from it. Such functions are not
2292 considered pure by default, since the compiler assumes that the
2293 @code{Address} parameter may be functioning as a pointer and that the
2294 referenced data may change even if the address value does not. The use
2295 of pragma Pure_Function for such a function will override this default
2296 assumption, and cause the compiler to treat such a function as pure.
2297
2298 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2299 applies to the underlying renamed function. This can be used to
2300 disambiguate cases of overloading where some but not all functions
2301 in a set of overloaded functions are to be designated as pure.
2302
2303 @findex Ravenscar
2304 @item pragma Ravenscar
2305 @noindent
2306 Syntax:
2307
2308 @smallexample
2309 pragma Ravenscar
2310 @end smallexample
2311
2312 @noindent
2313 A configuration pragma that establishes the following set of restrictions:
2314
2315 @table @code
2316 @item No_Abort_Statements
2317 [RM D.7] There are no abort_statements, and there are 
2318 no calls to Task_Identification.Abort_Task.
2319
2320 @item No_Select_Statements
2321 There are no select_statements.
2322
2323 @item No_Task_Hierarchy
2324 [RM D.7] All (non-environment) tasks depend 
2325 directly on the environment task of the partition.  
2326
2327 @item No_Task_Allocators
2328 [RM D.7] There are no allocators for task types
2329 or types containing task subcomponents.
2330
2331 @item No_Dynamic_Priorities
2332 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2333
2334 @item No_Terminate_Alternatives
2335 [RM D.7] There are no selective_accepts with terminate_alternatives
2336
2337 @item No_Dynamic_Interrupts
2338 There are no semantic dependencies on Ada.Interrupts.
2339
2340 @item No_Protected_Type_Allocators
2341 There are no allocators for protected types or
2342 types containing protected subcomponents.
2343
2344 @item No_Local_Protected_Objects
2345 Protected objects and access types that designate 
2346 such objects shall be declared only at library level.
2347
2348 @item No_Requeue
2349 Requeue statements are not allowed.
2350
2351 @item No_Calendar
2352 There are no semantic dependencies on the package Ada.Calendar.
2353
2354 @item No_Relative_Delay
2355 There are no delay_relative_statements.
2356
2357 @item No_Task_Attributes
2358 There are no semantic dependencies on the Ada.Task_Attributes package and
2359 there are no references to the attributes Callable and Terminated [RM 9.9].
2360
2361 @item Static_Storage_Size
2362 The expression for pragma Storage_Size is static.
2363
2364 @item Boolean_Entry_Barriers
2365 Entry barrier condition expressions shall be boolean 
2366 objects which are declared in the protected type 
2367 which contains the entry.
2368
2369 @item Max_Asynchronous_Select_Nesting = 0
2370 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2371 A value of zero prevents the use of any asynchronous_select.
2372
2373 @item Max_Task_Entries = 0
2374 [RM D.7] Specifies the maximum number of entries
2375 per task.  The bounds of every entry family
2376 of a task unit shall be static, or shall be
2377 defined by a discriminant of a subtype whose
2378 corresponding bound is static.  A value of zero
2379 indicates that no rendezvous are possible.  For
2380 the Ravenscar pragma, the value of Max_Task_Entries is always
2381 0 (zero).
2382
2383 @item Max_Protected_Entries = 1
2384 [RM D.7] Specifies the maximum number of entries per 
2385 protected type.  The bounds of every entry family of 
2386 a protected unit shall be static, or shall be defined 
2387 by a discriminant of a subtype whose corresponding 
2388 bound is static.  For the Ravenscar pragma the value of 
2389 Max_Protected_Entries is always 1.
2390
2391 @item Max_Select_Alternatives = 0
2392 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
2393 For the Ravenscar pragma the value if always 0.
2394
2395 @item No_Task_Termination
2396 Tasks which terminate are erroneous.
2397
2398 @item No_Entry_Queue
2399 No task can be queued on a protected entry. Note that this restrictions is
2400 checked at run time. The violation of this restriction generates a
2401 Program_Error exception.
2402 @end table
2403
2404 @noindent
2405 This set of restrictions corresponds to the definition of the "Ravenscar
2406 Profile" for limited tasking, devised and published by the International
2407 Workshop On Real Time Ada", 1997. 
2408
2409 The above set is a superset of the restrictions provided by pragma
2410 @code{Restricted_Run_Time}, it includes six additional restrictions
2411 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
2412 @code{No_Calendar}, @code{Static_Storage_Size},
2413 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
2414 that pragma Ravenscar, like the pragma Restricted_Run_Time, automatically
2415 causes the use of a simplified, more efficient version of the tasking
2416 run-time system.
2417
2418 @findex Restricted_Run_Time
2419 @item pragma Restricted_Run_Time
2420 @noindent
2421 Syntax:
2422
2423 @smallexample
2424 pragma Restricted_Run_Time
2425 @end smallexample
2426
2427 @noindent
2428 A configuration pragma that establishes the following set of restrictions:
2429
2430 @itemize @bullet
2431 @item No_Abort_Statements
2432 @item No_Asynchronous_Control
2433 @item No_Entry_Queue
2434 @item No_Task_Hierarchy
2435 @item No_Task_Allocators
2436 @item No_Dynamic_Priorities
2437 @item No_Terminate_Alternatives
2438 @item No_Dynamic_Interrupts
2439 @item No_Protected_Type_Allocators
2440 @item No_Local_Protected_Objects
2441 @item No_Requeue
2442 @item No_Task_Attributes
2443 @item Max_Asynchronous_Select_Nesting =  0
2444 @item Max_Task_Entries =  0
2445 @item Max_Protected_Entries = 1
2446 @item Max_Select_Alternatives = 0
2447 @end itemize
2448
2449 @noindent
2450 This set of restrictions causes the automatic selection of a simplified
2451 version of the run time that provides improved performance for the
2452 limited set of tasking functionality permitted by this set of restrictions.
2453
2454 @findex Share_Generic
2455 @item pragma Share_Generic
2456 @noindent
2457 Syntax:
2458
2459 @smallexample
2460 pragma Share_Generic (NAME @{, NAME@});
2461 @end smallexample
2462
2463 @noindent
2464 This pragma is recognized for compatibility with other Ada compilers
2465 but is ignored by GNAT. GNAT does not provide the capability for
2466 sharing of generic code. All generic instantiations result in making
2467 an inlined copy of the template with appropriate substitutions.
2468
2469 @findex Source_File_Name
2470 @item pragma Source_File_Name
2471 @noindent
2472 Syntax:
2473
2474 @smallexample
2475 pragma Source_File_Name (
2476   [Unit_Name   =>] unit_NAME,
2477   Spec_File_Name =>  STRING_LITERAL);
2478
2479 pragma Source_File_Name (
2480   [Unit_Name   =>] unit_NAME,
2481   Body_File_Name =>  STRING_LITERAL);
2482 @end smallexample
2483
2484 @noindent
2485 Use this to override the normal naming convention. It is a configuration
2486 pragma, and so has the usual applicability of configuration pragmas
2487 (i.e. it applies to either an entire partition, or to all units in a
2488 compilation, or to a single unit, depending on how it is used.
2489 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
2490 the second argument is required, and indicates whether this is the file
2491 name for the spec or for the body.
2492
2493 Another form of the @code{Source_File_Name} pragma allows
2494 the specification of patterns defining alternative file naming schemes
2495 to apply to all files. 
2496
2497 @smallexample
2498 pragma Source_File_Name
2499   (Spec_File_Name => STRING_LITERAL
2500    [,Casing => CASING_SPEC]
2501    [,Dot_Replacement => STRING_LITERAL]);
2502
2503 pragma Source_File_Name
2504   (Body_File_Name => STRING_LITERAL
2505    [,Casing => CASING_SPEC]
2506    [,Dot_Replacement => STRING_LITERAL]);
2507
2508 pragma Source_File_Name
2509   (Subunit_File_Name => STRING_LITERAL
2510    [,Casing => CASING_SPEC]
2511    [,Dot_Replacement => STRING_LITERAL]);
2512
2513 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
2514 @end smallexample
2515
2516 @noindent
2517 The first argument is a pattern that contains a single asterisk indicating
2518 the point at which the unit name is to be inserted in the pattern string
2519 to form the file name. The second argument is optional. If present it
2520 specifies the casing of the unit name in the resulting file name string.
2521 The default is lower case. Finally the third argument allows for systematic
2522 replacement of any dots in the unit name by the specified string literal.
2523
2524 For more details on the use of the @code{Source_File_Name} pragma,
2525 see the sections "Using Other File Names", and "Alternative File
2526 Naming Schemes" in the GNAT User's Guide.
2527
2528 @findex Source_Reference
2529 @item pragma Source_Reference
2530 @noindent
2531 Syntax:
2532
2533 @smallexample
2534 pragma Source_Reference (INTEGER_LITERAL,
2535                          STRING_LITERAL);
2536 @end smallexample
2537
2538 @noindent
2539 This pragma must appear as the first line of a source file.
2540 @var{integer_literal} is the logical line number of the line following
2541 the pragma line (for use in error messages and debugging
2542 information). @var{string_literal} is a static string constant that
2543 specifies the file name to be used in error messages and debugging
2544 information. This is most notably used for the output of @code{gnatchop}
2545 with the @samp{-r} switch, to make sure that the original unchopped
2546 source file is the one referred to.
2547
2548 The second argument must be a string literal, it cannot be a static
2549 string expression other than a string literal. This is because its value
2550 is needed for error messages issued by all phases of the compiler.
2551
2552 @findex Stream_Convert
2553 @item pragma Stream_Convert
2554 @noindent
2555 Syntax:
2556
2557 @smallexample
2558 pragma Stream_Convert (
2559   [Entity =>] type_LOCAL_NAME,
2560   [Read   =>] function_NAME,
2561   [Write  =>] function NAME);
2562 @end smallexample
2563
2564 @noindent
2565 This pragma provides an efficient way of providing stream functions for
2566 types defined in packages. Not only is it simpler to use than declaring
2567 the necessary functions with attribute representation clauses, but more
2568 significantly, it allows the declaration to made in such a way that the
2569 stream packages are not loaded unless they are needed. The use of
2570 the Stream_Convert pragma adds no overhead at all, unless the stream
2571 attributes are actually used on the designated type.
2572
2573 The first argument specifies the type for which stream functions are
2574 provided. The second parameter provides a function used to read values
2575 of this type. It must name a function whose argument type may be any
2576 subtype, and whose returned type must be the type given as the first
2577 argument to the pragma.
2578
2579 The meaning of the @var{Read}
2580 parameter is that if a stream attribute directly
2581 or indirectly specifies reading of the type given as the first parameter,
2582 then a value of the type given as the argument to the Read function is
2583 read from the stream, and then the Read function is used to convert this
2584 to the required target type.
2585
2586 Similarly the @var{Write} parameter specifies how to treat write attributes
2587 that directly or indirectly apply to the type given as the first parameter.
2588 It must have an input parameter of the type specified by the first parameter,
2589 and the return type must be the same as the input type of the Read function.
2590 The effect is to first call the Write function to convert to the given stream
2591 type, and then write the result type to the stream.
2592
2593 The Read and Write functions must not be overloaded subprograms. If necessary
2594 renamings can be supplied to meet this requirement.
2595 The usage of this attribute is best illustrated by a simple example, taken
2596 from the GNAT implementation of package Ada.Strings.Unbounded:
2597
2598 @smallexample
2599 function To_Unbounded (S : String)
2600            return Unbounded_String
2601   renames To_Unbounded_String;
2602
2603 pragma Stream_Convert
2604   (Unbounded_String, To_Unbounded, To_String);
2605 @end smallexample
2606
2607 @noindent
2608 The specifications of the referenced functions, as given in the Ada 95
2609 Reference Manual are:
2610
2611 @smallexample
2612 function To_Unbounded_String (Source : String)
2613   return Unbounded_String;
2614
2615 function To_String (Source : Unbounded_String)
2616   return String;
2617 @end smallexample
2618
2619 @noindent
2620 The effect is that if the value of an unbounded string is written to a
2621 stream, then the representation of the item in the stream is in the same
2622 format used for @code{Standard.String}, and this same representation is
2623 expected when a value of this type is read from the stream.
2624
2625 @findex Style_Checks
2626 @item pragma Style_Checks
2627 @noindent
2628 Syntax:
2629
2630 @smallexample
2631 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
2632                      On | Off [, LOCAL_NAME]);
2633 @end smallexample
2634
2635 @noindent
2636 This pragma is used in conjunction with compiler switches to control the
2637 built in style checking provided by GNAT. The compiler switches, if set
2638 provide an initial setting for the switches, and this pragma may be used
2639 to modify these settings, or the settings may be provided entirely by
2640 the use of the pragma. This pragma can be used anywhere that a pragma
2641 is legal, including use as a configuration pragma (including use in
2642 the @file{gnat.adc} file).
2643
2644 The form with a string literal specifies which style options are to be
2645 activated. These are additive, so they apply in addition to any previously
2646 set style check options. The codes for the options are the same as those
2647 used in the @code{-gnaty} switch on the @code{gcc} or @code{gnatmake}
2648 line. For example the following two methods can be used to enable
2649 layout checking:
2650
2651 @smallexample
2652 pragma Style_Checks ("l");
2653 gcc -c -gnatyl ...
2654 @end smallexample
2655
2656 @noindent
2657 The form ALL_CHECKS activates all standard checks (its use is equivalent
2658 to the use of the @code{gnaty} switch with no options. See GNAT User's
2659 Guide for details.
2660
2661 The forms with @code{Off} and @code{On}
2662 can be used to temporarily disable style checks
2663 as shown in the following example:
2664
2665 @smallexample
2666 @iftex
2667 @leftskip=0cm
2668 @end iftex
2669 pragma Style_Checks ("k"); -- requires keywords in lower case
2670 pragma Style_Checks (Off); -- turn off style checks
2671 NULL;                      -- this will not generate an error message
2672 pragma Style_Checks (On);  -- turn style checks back on
2673 NULL;                      -- this will generate an error message
2674 @end smallexample
2675
2676 @noindent
2677 Finally the two argument form is allowed only if the first argument is
2678 @code{On} or @code{Off}. The effect is to turn of semantic style checks
2679 for the specified entity, as shown in the following example:
2680
2681 @smallexample
2682 @iftex
2683 @leftskip=0cm
2684 @end iftex
2685 pragma Style_Checks ("r"); -- require consistency of identifier casing
2686 Arg : Integer;
2687 Rf1 : Integer := ARG;      -- incorrect, wrong case
2688 pragma Style_Checks (Off, Arg);
2689 Rf2 : Integer := ARG;      -- OK, no error
2690 @end smallexample
2691
2692 @findex Subtitle
2693 @item pragma Subtitle
2694 @noindent
2695 Syntax:
2696
2697 @smallexample
2698 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
2699 @end smallexample
2700
2701 @noindent
2702 This pragma is recognized for compatibility with other Ada compilers
2703 but is ignored by GNAT.
2704
2705 @findex Suppress_All
2706 @item pragma Suppress_All
2707 @noindent
2708 Syntax:
2709
2710 @smallexample
2711 pragma Suppress_All;
2712 @end smallexample
2713
2714 @noindent
2715 This pragma can only appear immediately following a compilation
2716 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
2717 which it follows. This pragma is implemented for compatibility with DEC
2718 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
2719 configuration pragma is the preferred usage in GNAT.
2720
2721 @findex Suppress_Initialization
2722 @cindex Suppressing initialization
2723 @cindex Initialization, suppression of
2724 @item pragma Suppress_Initialization
2725 @noindent
2726 Syntax:
2727
2728 @smallexample
2729 pragma Suppress_Initialization ([Entity =>] type_Name);
2730 @end smallexample
2731
2732 @noindent
2733 This pragma suppresses any implicit or explicit initialization
2734 associated with the given type name for all variables of this type.
2735
2736 @findex Task_Info
2737 @item pragma Task_Info
2738 @noindent
2739 Syntax
2740
2741 @smallexample
2742 pragma Task_Info (EXPRESSION);
2743 @end smallexample
2744
2745 @noindent
2746 This pragma appears within a task definition (like pragma
2747 @code{Priority}) and applies to the task in which it appears. The
2748 argument must be of type @code{System.Task_Info.Task_Info_Type}.
2749 The @code{Task_Info} pragma provides system dependent control over
2750 aspect of tasking implementation, for example, the ability to map
2751 tasks to specific processors. For details on the facilities available
2752 for the version of GNAT that you are using, see the documentation
2753 in the specification of package System.Task_Info in the runtime
2754 library.
2755
2756 @findex Task_Name
2757 @item pragma Task_Name
2758 @noindent
2759 Syntax
2760
2761 @smallexample
2762 pragma Task_Name (string_EXPRESSION);
2763 @end smallexample
2764
2765 @noindent
2766 This pragma appears within a task definition (like pragma
2767 @code{Priority}) and applies to the task in which it appears. The
2768 argument must be of type String, and provides a name to be used for
2769 the task instance when the task is created. Note that this expression
2770 is not required to be static, and in particular, it can contain
2771 references to task discriminants. This facility can be used to
2772 provide different names for different tasks as they are created,
2773 as illustrated in the example below.
2774
2775 The task name is recorded internally in the run-time structures
2776 and is accessible to tools like the debugger. In addition the
2777 routine @code{Ada.Task_Identification.Image} will return this
2778 string, with a unique task address appended.
2779
2780 @smallexample
2781 --  Example of the use of pragma Task_Name
2782
2783 with Ada.Task_Identification;
2784 use Ada.Task_Identification;
2785 with Text_IO; use Text_IO;
2786 procedure t3 is
2787
2788    type Astring is access String;
2789
2790    task type Task_Typ (Name : access String) is
2791       pragma Task_Name (Name.all);
2792    end Task_Typ;
2793    
2794    task body Task_Typ is
2795       Nam : constant String := Image (Current_Task);
2796    begin
2797       Put_Line ("-->" & Nam (1 .. 14) & "<--");
2798    end Task_Typ;
2799    
2800    type Ptr_Task is access Task_Typ;
2801    Task_Var : Ptr_Task;
2802
2803 begin
2804    Task_Var :=
2805      new Task_Typ (new String'("This is task 1"));
2806    Task_Var :=
2807      new Task_Typ (new String'("This is task 2"));
2808 end;
2809 @end smallexample
2810
2811 @findex Task_Storage
2812 @item pragma Task_Storage
2813 Syntax:
2814
2815 @smallexample
2816 pragma Task_Storage
2817   [Task_Type =>] LOCAL_NAME,
2818   [Top_Guard =>] static_integer_EXPRESSION);
2819 @end smallexample
2820
2821 This pragma specifies the length of the guard area for tasks.  The guard
2822 area is an additional storage area allocated to a task.  A value of zero
2823 means that either no guard area is created or a minimal guard area is
2824 created, depending on the target. This pragma can appear anywhere a
2825 @code{Storage_Size} attribute definition clause is allowed for a task
2826 type.
2827
2828 @findex Time_Slice
2829 @item pragma Time_Slice
2830 @noindent
2831 Syntax:
2832
2833 @smallexample
2834 pragma Time_Slice (static_duration_EXPRESSION);
2835 @end smallexample
2836
2837 @noindent
2838 For implementations of GNAT on operating systems where it is possible
2839 to supply a time slice value, this pragma may be used for this purpose.
2840 It is ignored if it is used in a system that does not allow this control,
2841 or if it appears in other than the main program unit.
2842 @cindex OpenVMS
2843 Note that the effect of this pragma is identical to the effect of the
2844 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
2845
2846 @findex Title
2847 @item pragma Title
2848 @noindent
2849 Syntax:
2850
2851 @smallexample
2852 pragma Title (TITLING_OPTION [, TITLING OPTION]);
2853
2854 TITLING_OPTION ::=
2855   [Title    =>] STRING_LITERAL,
2856 | [Subtitle =>] STRING_LITERAL
2857 @end smallexample
2858
2859 @noindent
2860 Syntax checked but otherwise ignored by GNAT. This is a listing control
2861 pragma used in DEC Ada 83 implementations to provide a title and/or
2862 subtitle for the program listing. The program listing generated by GNAT
2863 does not have titles or subtitles.
2864
2865 Unlike other pragmas, the full flexibility of named notation is allowed
2866 for this pragma, i.e. the parameters may be given in any order if named
2867 notation is used, and named and positional notation can be mixed
2868 following the normal rules for procedure calls in Ada.
2869
2870 @cindex Unions in C
2871 @findex Unchecked_Union
2872 @item pragma Unchecked_Union
2873 @noindent
2874 Syntax:
2875
2876 @smallexample
2877 pragma Unchecked_Union (first_subtype_LOCAL_NAME)
2878 @end smallexample
2879
2880 @noindent
2881 This pragma is used to declare that the specified type should be represented
2882 in a manner
2883 equivalent to a C union type, and is intended only for use in
2884 interfacing with C code that uses union types. In Ada terms, the named
2885 type must obey the following rules:
2886
2887 @itemize @bullet
2888 @item
2889 It is a non-tagged non-limited record type.
2890 @item
2891 It has a single discrete discriminant with a default value.
2892 @item
2893 The component list consists of a single variant part.
2894 @item
2895 Each variant has a component list with a single component.
2896 @item
2897 No nested variants are allowed.
2898 @item
2899 No component has an explicit default value.
2900 @item
2901 No component has a non-static constraint.
2902 @end itemize
2903
2904 In addition, given a type that meets the above requirements, the
2905 following restrictions apply to its use throughout the program:
2906
2907 @itemize @bullet
2908 @item
2909 The discriminant name can be mentioned only in an aggregate.
2910 @item
2911 No subtypes may be created of this type.
2912 @item
2913 The type may not be constrained by giving a discriminant value.
2914 @item
2915 The type cannot be passed as the actual for a generic formal with a
2916 discriminant.
2917 @end itemize
2918
2919 Equality and inequality operations on @code{unchecked_unions} are not
2920 available, since there is no discriminant to compare and the compiler
2921 does not even know how many bits to compare. It is implementation
2922 dependent whether this is detected at compile time as an illegality or
2923 whether it is undetected and considered to be an erroneous construct. In
2924 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
2925 the composite case (where two composites are compared that contain an
2926 unchecked union component), so such comparisons are simply considered
2927 erroneous.
2928
2929 The layout of the resulting type corresponds exactly to a C union, where
2930 each branch of the union corresponds to a single variant in the Ada
2931 record. The semantics of the Ada program is not changed in any way by
2932 the pragma, i.e. provided the above restrictions are followed, and no
2933 erroneous incorrect references to fields or erroneous comparisons occur,
2934 the semantics is exactly as described by the Ada reference manual.
2935 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
2936 type and the default convention is C
2937
2938 @findex Unimplemented_Unit
2939 @item pragma Unimplemented_Unit
2940 @noindent
2941 Syntax:
2942
2943 @smallexample
2944 pragma Unimplemented_Unit;
2945 @end smallexample
2946
2947 @noindent
2948 If this pragma occurs in a unit that is processed by the compiler, GNAT
2949 aborts with the message @samp{@var{xxx} not implemented}, where
2950 @var{xxx} is the name of the current compilation unit.  This pragma is
2951 intended to allow the compiler to handle unimplemented library units in
2952 a clean manner.
2953
2954 The abort only happens if code is being generated.  Thus you can use
2955 specs of unimplemented packages in syntax or semantic checking mode.
2956
2957 @findex Unreserve_All_Interrupts
2958 @item pragma Unreserve_All_Interrupts
2959 @noindent
2960 Syntax:
2961
2962 @smallexample
2963 pragma Unreserve_All_Interrupts;
2964 @end smallexample
2965
2966 @noindent
2967 Normally certain interrupts are reserved to the implementation. Any attempt
2968 to attach an interrupt causes Program_Error to be raised, as described in
2969 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2970 many systems for an @code{Ctrl-C} interrupt. Normally this interrupt is
2971 reserved to the implementation, so that @code{Ctrl-C} can be used to
2972 interrupt execution.
2973
2974 If the pragma Unreserve_All_Interrupts appears anywhere in any unit in
2975 a program, then all such interrupts are unreserved. This allows the
2976 program to handle these interrupts, but disables their standard
2977 functions. For example, if this pragma is used, then pressing
2978 @code{Ctrl-C} will not automatically interrupt execution. However,
2979 a program can then handle the @code{SIGINT} interrupt as it chooses.
2980
2981 For a full list of the interrupts handled in a specific implementation,
2982 see the source code for the specification of Ada.Interrupts.Names in
2983 file a-intnam.ads. This is a target dependent file that contains the
2984 list of interrupts recognized for a given target. The documentation in
2985 this file also specifies what interrupts are affected by the use of
2986 the Unreserve_All_Interrupts pragma.
2987
2988 @findex Unsuppress
2989 @item pragma Unsuppress
2990 @noindent
2991 Syntax:
2992
2993 @smallexample
2994 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
2995 @end smallexample
2996
2997 @noindent
2998 This pragma undoes the effect of a previous pragma @code{Suppress}. If
2999 there is no corresponding pragma @code{Suppress} in effect, it has no
3000 effect. The range of the effect is the same as for pragma
3001 @code{Suppress}. The meaning of the arguments is identical to that used
3002 in pragma @code{Suppress}.
3003
3004 One important application is to ensure that checks are on in cases where
3005 code depends on the checks for its correct functioning, so that the code
3006 will compile correctly even if the compiler switches are set to suppress
3007 checks.
3008
3009 @cindex @code{Size}, VADS compatibility
3010 @findex Use_VADS_Size
3011 @item pragma Use_VADS_Size
3012 @noindent
3013 Syntax:
3014
3015 @smallexample
3016 pragma Use_VADS_Size;
3017 @end smallexample
3018
3019 @noindent
3020 This is a configuration pragma. In a unit to which it applies, any use
3021 of the 'Size attribute is automatically interpreted as a use of the
3022 'VADS_Size attribute. Note that this may result in incorrect semantic
3023 processing of valid Ada 95 programs. This is intended to aid in the
3024 handling of legacy code which depends on the interpretation of Size
3025 as implemented in the VADS compiler. See description of the VADS_Size
3026 attribute for further details.
3027
3028 @findex Validity_Checks
3029 @item pragma Validity_Checks
3030 @noindent
3031 Syntax:
3032
3033 @smallexample
3034 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3035 @end smallexample
3036
3037 @noindent
3038 This pragma is used in conjunction with compiler switches to control the
3039 built in validity checking provided by GNAT. The compiler switches, if set
3040 provide an initial setting for the switches, and this pragma may be used
3041 to modify these settings, or the settings may be provided entirely by
3042 the use of the pragma. This pragma can be used anywhere that a pragma
3043 is legal, including use as a configuration pragma (including use in
3044 the @file{gnat.adc} file).
3045
3046 The form with a string literal specifies which validity options are to be
3047 activated. The validity checks are first set to include only the default
3048 reference manual settings, and then a string of letters in the string
3049 specifies the exact set of options required. The form of this string
3050 is exactly as described for the @code{-gnatVx} compiler switch (see the
3051 GNAT users guide for details). For example the following two methods
3052 can be used to enable validity checking for mode @code{in} and
3053 @code{in out} subprogram parameters:
3054
3055 @smallexample
3056 pragma Validity_Checks ("im");
3057 gcc -c -gnatVim ...
3058 @end smallexample
3059
3060 @noindent
3061 The form ALL_CHECKS activates all standard checks (its use is equivalent
3062 to the use of the @code{gnatva} switch.
3063
3064 The forms with @code{Off} and @code{On}
3065 can be used to temporarily disable validity checks
3066 as shown in the following example:
3067
3068 @smallexample
3069 @iftex
3070 @leftskip=0cm
3071 @end iftex
3072 pragma Validity_Checks ("c"); -- validity checks for copies
3073 pragma Validity_Checks (Off); -- turn off validity checks
3074 A := B;                       -- B will not be validity checked
3075 pragma Validity_Checks (On);  -- turn validity checks back on
3076 A := C;                       -- C will be validity checked
3077 @end smallexample
3078
3079 @findex Volatile
3080 @item pragma Volatile
3081 @noindent
3082 Syntax:
3083
3084 @smallexample
3085 pragma Volatile (local_NAME)
3086 @end smallexample
3087
3088 @noindent
3089 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3090 implementation is fully conformant with this definition. The reason it
3091 is mentioned in this section is that a pragma of the same name was supplied
3092 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation
3093 of pragma Volatile is upwards compatible with the implementation in
3094 Dec Ada 83.
3095
3096 @findex Warnings
3097 @item pragma Warnings
3098 @noindent
3099 Syntax:
3100
3101 @smallexample
3102 pragma Warnings (On | Off [, LOCAL_NAME]);
3103 @end smallexample
3104
3105 @noindent
3106 Normally warnings are enabled, with the output being controlled by
3107 the command line switch. Warnings (@code{Off}) turns off generation of
3108 warnings until a Warnings (@code{On}) is encountered or the end of the
3109 current unit. If generation of warnings is turned off using this
3110 pragma, then no warning messages are output, regardless of the
3111 setting of the command line switches.
3112
3113 The form with a single argument is a configuration pragma.
3114
3115 If the @var{local_name} parameter is present, warnings are suppressed for
3116 the specified entity. This suppression is effective from the point where
3117 it occurs till the end of the extended scope of the variable (similar to
3118 the scope of @code{Suppress}).
3119
3120 @findex Weak_External
3121 @item pragma Weak_External
3122 @noindent
3123 Syntax:
3124
3125 @smallexample
3126 pragma Weak_External ([Entity =>] LOCAL_NAME);
3127 @end smallexample
3128
3129 @noindent
3130 This pragma specifies that the given entity should be marked as a weak
3131 external (one that does not have to be resolved) for the linker. For
3132 further details, consult the GCC manual.
3133 @end table
3134
3135 @node Implementation Defined Attributes
3136 @chapter Implementation Defined Attributes
3137 Ada 95 defines (throughout the Ada 95 reference manual,
3138 summarized in annex K),
3139 a set of attributes that provide useful additional functionality in all
3140 areas of the language. These language defined attributes are implemented
3141 in GNAT and work as described in the Ada 95 Reference Manual.
3142
3143 In addition, Ada 95 allows implementations to define additional
3144 attributes whose meaning is defined by the implementation. GNAT provides
3145 a number of these implementation-dependent attributes which can be used
3146 to extend and enhance the functionality of the compiler. This section of
3147 the GNAT reference manual describes these additional attributes.
3148
3149 Note that any program using these attributes may not be portable to
3150 other compilers (although GNAT implements this set of attributes on all
3151 platforms). Therefore if portability to other compilers is an important
3152 consideration, you should minimize the use of these attributes.
3153
3154 @table @code
3155 @findex Abort_Signal
3156 @item Abort_Signal
3157 @noindent
3158 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
3159 prefix) provides the entity for the special exception used to signal
3160 task abort or asynchronous transfer of control. Normally this attribute
3161 should only be used in the tasking runtime (it is highly peculiar, and
3162 completely outside the normal semantics of Ada, for a user program to
3163 intercept the abort exception).
3164
3165 @cindex Size of @code{Address}
3166 @findex Address_Size
3167 @item Address_Size
3168 @noindent
3169 @code{Standard'Address_Size} (@code{Standard} is the only allowed
3170 prefix) is a static constant giving the number of bits in an
3171 @code{Address}. It is used primarily for constructing the definition of
3172 @code{Memory_Size} in package @code{Standard}, but may be freely used in user
3173 programs and has the advantage of being static, while a direct
3174 reference to System.Address'Size is non-static because Address
3175 is a private type.
3176
3177 @findex Asm_Input
3178 @item Asm_Input
3179 @noindent
3180 The @code{Asm_Input} attribute denotes a function that takes two
3181 parameters.  The first is a string, the second is an expression of the
3182 type designated by the prefix. The first (string) argument is required
3183 to be a static expression, and is the constraint for the parameter,
3184 (e.g. what kind of register is required). The second argument is the
3185 value to be used as the input argument. The possible values for the
3186 constant are the same as those used in the RTL, and are dependent on
3187 the configuration file used to built the GCC back end.
3188 @ref{Machine Code Insertions}
3189
3190 @findex Asm_Output
3191 @item Asm_Output
3192 @noindent
3193 The @code{Asm_Output} attribute denotes a function that takes two
3194 parameters.  The first is a string, the second is the name of a variable
3195 of the type designated by the attribute prefix. The first (string)
3196 argument is required to be a static expression and designates the
3197 constraint for the parameter (e.g. what kind of register is
3198 required). The second argument is the variable to be updated with the
3199 result. The possible values for constraint are the same as those used in
3200 the RTL, and are dependent on the configuration file used to build the
3201 GCC back end.  If there are no output operands, then this argument may
3202 either be omitted, or explicitly given as @code{No_Output_Operands}.
3203 @ref{Machine Code Insertions}
3204
3205 @cindex OpenVMS
3206 @findex AST_Entry
3207 @item AST_Entry
3208 @noindent
3209 This attribute is implemented only in OpenVMS versions of GNAT. Applied to
3210 the name of an entry, it yields a value of the predefined type AST_Handler
3211 (declared in the predefined package System, as extended by the use of
3212 pragma Extend_System (Aux_DEC)). This value enables the given entry to
3213 be called when an AST occurs. For further details, refer to the DEC Ada
3214 Language Reference Manual, section 9.12a.
3215
3216 @findex Bit
3217 @item Bit
3218 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
3219 offset within the storage unit (byte) that contains the first bit of
3220 storage allocated for the object. The value of this attribute is of the
3221 type @code{Universal_Integer}, and is always a non-negative number not
3222 exceeding the value of @code{System.Storage_Unit}.
3223
3224 For an object that is a variable or a constant allocated in a register,
3225 the value is zero. (The use of this attribute does not force the
3226 allocation of a variable to memory).
3227
3228 For an object that is a formal parameter, this attribute applies
3229 to either the matching actual parameter or to a copy of the
3230 matching actual parameter.
3231
3232 For an access object the value is zero. Note that
3233 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
3234 designated object. Similarly for a record component
3235 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
3236 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
3237 are subject to index checks.
3238
3239 This attribute is designed to be compatible with the DEC Ada 83 definition
3240 and implementation of the @code{Bit} attribute.
3241
3242 @findex Bit_Position
3243 @item Bit_Position
3244 @noindent
3245 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
3246 of the fields of the record type, yields the bit
3247 offset within the record contains the first bit of
3248 storage allocated for the object. The value of this attribute is of the
3249 type @code{Universal_Integer}. The value depends only on the field
3250 @var{C} and is independent of the alignment of
3251 the containing record @var{R}.
3252
3253 @findex Code_Address
3254 @cindex Subprogram address
3255 @cindex Address of subprogram code
3256 @item Code_Address
3257 @noindent
3258 The @code{'Address}
3259 attribute may be applied to subprograms in Ada 95, but the
3260 intended effect from the Ada 95 reference manual seems to be to provide
3261 an address value which can be used to call the subprogram by means of
3262 an address clause as in the following example:
3263
3264 @smallexample
3265 procedure K is ...
3266
3267 procedure L;
3268 for L'Address use K'Address;
3269 pragma Import (Ada, L);
3270 @end smallexample
3271
3272 @noindent
3273 A call to L is then expected to result in a call to K. In Ada 83, where
3274 there were no access-to-subprogram values, this was a common work around
3275 for getting the effect of an indirect call.
3276 GNAT implements the above use of Address and the technique illustrated
3277 by the example code works correctly.
3278
3279 However, for some purposes, it is useful to have the address of the start
3280 of the generated code for the subprogram. On some architectures, this is
3281 not necessarily the same as the Address value described above. For example,
3282 the Address value may reference a subprogram descriptor rather than the
3283 subprogram itself.
3284
3285 The @code{'Code_Address} attribute, which can only be applied to 
3286 subprogram entities, always returns the address of the start of the 
3287 generated code of the specified subprogram, which may or may not be
3288 the same value as is returned by the corresponding @code{'Address}
3289 attribute.
3290
3291 @cindex Big endian
3292 @cindex Little endian
3293 @findex Default_Bit_Order
3294 @item Default_Bit_Order
3295 @noindent
3296 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
3297 permissible prefix), provides the value @code{System.Default_Bit_Order}
3298 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
3299 @code{Low_Order_First}). This is used to construct the definition of
3300 @code{Default_Bit_Order} in package @code{System}.
3301
3302 @findex Elaborated
3303 @item Elaborated
3304 @noindent
3305 The prefix of the @code{'Elaborated} attribute must be a unit name. The
3306 value is a Boolean which indicates whether or not the given unit has been
3307 elaborated. This attribute is primarily intended for internal use by the
3308 generated code for dynamic elaboration checking, but it can also be used
3309 in user programs. The value will always be True once elaboration of all
3310 units has been completed.
3311
3312 @findex Elab_Body
3313 @item Elab_Body
3314 @noindent
3315 This attribute can only be applied to a program unit name. It returns
3316 the entity for the corresponding elaboration procedure for elaborating
3317 the body of the referenced unit. This is used in the main generated
3318 elaboration procedure by the binder and is not normally used in any
3319 other context.  However, there may be specialized situations in which it
3320 is useful to be able to call this elaboration procedure from Ada code,
3321 e.g. if it is necessary to do selective re-elaboration to fix some
3322 error.
3323
3324 @findex Elab_Spec
3325 @item Elab_Spec
3326 @noindent
3327 This attribute can only be applied to a program unit name. It returns
3328 the entity for the corresponding elaboration procedure for elaborating
3329 the specification of the referenced unit. This is used in the main
3330 generated elaboration procedure by the binder and is not normally used
3331 in any other context.  However, there may be specialized situations in
3332 which it is useful to be able to call this elaboration procedure from
3333 Ada code, e.g. if it is necessary to do selective re-elaboration to fix
3334 some error.
3335
3336 @cindex Ada 83 attributes
3337 @findex Emax
3338 @item Emax
3339 @noindent
3340 The @code{Emax} attribute is provided for compatibility with Ada 83. See
3341 the Ada 83 reference manual for an exact description of the semantics of
3342 this attribute.
3343
3344 @cindex Representation of enums
3345 @findex Enum_Rep
3346 @item Enum_Rep
3347 @noindent
3348 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
3349 function with the following specification:
3350
3351 @smallexample
3352 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
3353   return Universal_Integer;
3354 @end smallexample
3355
3356 @noindent
3357 It is also allowable to apply Enum_Rep directly to an object of an
3358 enumeration type or to a non-overloaded enumeration
3359 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to 
3360 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
3361 enumeration literal or object.
3362
3363 The function returns the representation value for the given enumeration
3364 value. This will be equal to value of the @code{Pos} attribute in the
3365 absence of an enumeration representation clause. This is a static
3366 attribute (i.e. the result is static if the argument is static).
3367
3368 @var{S}'Enum_Rep can also be used with integer types and objects, in which
3369 case it simply returns the integer value. The reason for this is to allow
3370 it to be used for (<>) discrete formal arguments in a generic unit that
3371 can be instantiated with either enumeration types or integer types. Note
3372 that if Enum_Rep is used on a modular type whose upper bound exceeds the
3373 upper bound of the largest signed integer type, and the argument is a
3374 variable, so that the universal integer calculation is done at run-time,
3375 then the call to @code{Enum_Rep} may raise @code{Constraint_Error}.
3376
3377 @cindex Ada 83 attributes
3378 @findex Epsilon
3379 @item Epsilon
3380 @noindent
3381 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
3382 the Ada 83 reference manual for an exact description of the semantics of
3383 this attribute.
3384
3385 @findex Fixed_Value
3386 @item Fixed_Value
3387 @noindent
3388 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
3389 function with the following specification:
3390
3391 @smallexample
3392 function @var{S}'Fixed_Value (Arg : Universal_Integer)
3393   return @var{S};
3394 @end smallexample
3395
3396 @noindent
3397 The value returned is the fixed-point value @var{V} such that
3398
3399 @smallexample
3400 @var{V} = Arg * @var{S}'Small
3401 @end smallexample
3402
3403 @noindent
3404 The effect is thus equivalent to first converting the argument to the
3405 integer type used to represent @var{S}, and then doing an unchecked
3406 conversion to the fixed-point type. This attribute is primarily intended
3407 for use in implementation of the input-output functions for fixed-point
3408 values.
3409
3410 @cindex Discriminants, testing for
3411 @findex Has_Discriminants
3412 @item Has_Discriminants
3413 @noindent
3414 The prefix of the @code{Has_Discriminants} attribute is a type. The result
3415 is a Boolean value which is True if the type has discriminants, and False
3416 otherwise. The intended use of this attribute is in conjunction with generic
3417 definitions. If the attribute is applied to a generic private type, it
3418 indicates whether or not the corresponding actual type has discriminants.
3419
3420 @findex Img
3421 @item Img
3422 @noindent
3423 The @code{Img} attribute differs from @code{Image} in that it may be
3424 applied to objects as well as types, in which case it gives the
3425 @code{Image} for the subtype of the object. This is convenient for
3426 debugging:
3427
3428 @smallexample
3429 Put_Line ("X = " & X'Img);
3430 @end smallexample
3431
3432 @noindent
3433 has the same meaning as the more verbose:
3434
3435 @smallexample
3436 Put_Line ("X = " & @var{type}'Image (X));
3437 @end smallexample
3438
3439 where @var{type} is the subtype of the object X.
3440
3441 @findex Integer_Value
3442 @item Integer_Value
3443 @noindent
3444 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
3445 function with the following specification:
3446
3447 @smallexample
3448 function @var{S}'Integer_Value (Arg : Universal_Fixed)
3449   return @var{S};
3450 @end smallexample
3451
3452 @noindent
3453 The value returned is the integer value @var{V}, such that
3454
3455 @smallexample
3456 Arg = @var{V} * @var{type}'Small
3457 @end smallexample
3458
3459 @noindent
3460 The effect is thus equivalent to first doing an unchecked convert from
3461 the fixed-point type to its corresponding implementation type, and then
3462 converting the result to the target integer type. This attribute is
3463 primarily intended for use in implementation of the standard
3464 input-output functions for fixed-point values.
3465
3466 @cindex Ada 83 attributes
3467 @findex Large
3468 @item Large
3469 @noindent
3470 The @code{Large} attribute is provided for compatibility with Ada 83. See
3471 the Ada 83 reference manual for an exact description of the semantics of
3472 this attribute.
3473
3474 @findex Machine_Size
3475 @item Machine_Size
3476 @noindent
3477 This attribute is identical to the @code{Object_Size} attribute. It is
3478 provided for compatibility with the DEC Ada 83 attribute of this name.
3479    
3480 @cindex Ada 83 attributes
3481 @findex Mantissa
3482 @item Mantissa
3483 @noindent
3484 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
3485 the Ada 83 reference manual for an exact description of the semantics of
3486 this attribute.
3487
3488 @cindex Interrupt priority, maximum
3489 @findex Max_Interrupt_Priority
3490 @item Max_Interrupt_Priority
3491 @noindent
3492 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
3493 permissible prefix), provides the value
3494 @code{System.Max_Interrupt_Priority} and is intended primarily for
3495 constructing this definition in package @code{System}.
3496
3497 @cindex Priority, maximum
3498 @findex Max_Priority
3499 @item Max_Priority
3500 @noindent
3501 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
3502 prefix) provides the value @code{System.Max_Priority} and is intended
3503 primarily for constructing this definition in package @code{System}.
3504
3505 @cindex Alignment, maximum
3506 @findex Maximum_Alignment
3507 @item Maximum_Alignment
3508 @noindent
3509 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
3510 permissible prefix) provides the maximum useful alignment value for the
3511 target. This is a static value that can be used to specify the alignment
3512 for an object, guaranteeing that it is properly aligned in all
3513 cases. This is useful when an external object is imported and its
3514 alignment requirements are unknown.
3515
3516 @cindex Return values, passing mechanism
3517 @cindex Parameters, passing mechanism
3518 @findex Mechanism_Code
3519 @item Mechanism_Code
3520 @noindent
3521 @code{@var{function}'Mechanism_Code} yields an integer code for the
3522 mechanism used for the result of function, and
3523 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
3524 used for formal parameter number @var{n} (a static integer value with 1
3525 meaning the first parameter) of @var{subprogram}. The code returned is:
3526
3527 @table @asis
3528 @item 1
3529 by copy (value)
3530 @item 2
3531 by reference
3532 @item 3
3533 by descriptor (default descriptor class)
3534 @item 4
3535 by descriptor (UBS: unaligned bit string)
3536 @item 5
3537 by descriptor (UBSB: aligned bit string with arbitrary bounds)
3538 @item 6
3539 by descriptor (UBA: unaligned bit array)
3540 @item 7
3541 by descriptor (S: string, also scalar access type parameter)
3542 @item 8
3543 by descriptor (SB: string with arbitrary bounds)
3544 @item 9
3545 by descriptor (A: contiguous array)
3546 @item 10
3547 by descriptor (NCA: non-contiguous array)
3548 @end table
3549
3550 @cindex OpenVMS
3551 Values from 3-10 are only relevant to Digital OpenVMS implementations.
3552
3553 @cindex Zero address, passing
3554 @findex Null_Parameter
3555 @item Null_Parameter
3556 @noindent
3557 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
3558 type or subtype @var{T} allocated at machine address zero. The attribute
3559 is allowed only as the default expression of a formal parameter, or as
3560 an actual expression of a subprogram call. In either case, the
3561 subprogram must be imported.
3562
3563 The identity of the object is represented by the address zero in the
3564 argument list, independent of the passing mechanism (explicit or
3565 default).
3566
3567 This capability is needed to specify that a zero address should be
3568 passed for a record or other composite object passed by reference.
3569 There is no way of indicating this without the @code{Null_Parameter}
3570 attribute.
3571
3572 @cindex Size, used for objects
3573 @findex Object_Size
3574 @item Object_Size
3575 @noindent
3576 The size of an object is not necessarily the same as the size of the type
3577 of an object. This is because by default object sizes are increased to be
3578 a multiple of the alignment of the object. For example, 
3579 @code{Natural'Size} is
3580 31, but by default objects of type @code{Natural} will have a size of 32 bits.
3581 Similarly, a record containing an integer and a character:
3582
3583 @smallexample
3584 type Rec is record
3585    I : Integer;
3586    C : Character;
3587 end record;
3588 @end smallexample
3589
3590 @noindent
3591 will have a size of 40 (that is @code{Rec'Size} will be 40. The 
3592 alignment will be 4, because of the
3593 integer field, and so the default size of record objects for this type
3594 will be 64 (8 bytes).
3595
3596 The @code{@var{type}'Object_Size} attribute
3597 has been added to GNAT to allow the
3598 default object size of a type to be easily determined. For example,
3599 @code{Natural'Object_Size} is 32, and
3600 @code{Rec'Object_Size} (for the record type in the above example) will be
3601 64. Note also that, unlike the situation with the
3602 @code{Size} attribute as defined in the Ada RM, the 
3603 @code{Object_Size} attribute can be specified individually
3604 for different subtypes. For example:
3605
3606 @smallexample
3607 type R is new Integer;
3608 subtype R1 is R range 1 .. 10;
3609 subtype R2 is R range 1 .. 10;
3610 for R2'Object_Size use 8;
3611 @end smallexample
3612
3613 @noindent
3614 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
3615 32 since the default object size for a subtype is the same as the object size
3616 for the parent subtype. This means that objects of type @code{R}
3617 or @code{R1} will
3618 by default be 32 bits (four bytes). But objects of type
3619 @code{R2} will be only
3620 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
3621
3622 @cindex Parameters, when passed by reference
3623 @findex Passed_By_Reference
3624 @item Passed_By_Reference
3625 @noindent
3626 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
3627 a value of type @code{Boolean} value that is @code{True} if the type is
3628 normally passed by reference and @code{False} if the type is normally
3629 passed by copy in calls. For scalar types, the result is always @code{False}
3630 and is static. For non-scalar types, the result is non-static.
3631
3632 @findex Range_Length
3633 @item Range_Length
3634 @noindent
3635 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
3636 the number of values represented by the subtype (zero for a null
3637 range). The result is static for static subtypes. @code{Range_Length}
3638 applied to the index subtype of a one dimensional array always gives the
3639 same result as @code{Range} applied to the array itself.
3640
3641 @cindex Ada 83 attributes
3642 @findex Safe_Emax
3643 @item Safe_Emax
3644 @noindent
3645 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
3646 the Ada 83 reference manual for an exact description of the semantics of
3647 this attribute.
3648
3649 @cindex Ada 83 attributes
3650 @findex Safe_Large
3651 @item Safe_Large
3652 @noindent
3653 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
3654 the Ada 83 reference manual for an exact description of the semantics of
3655 this attribute.
3656
3657 @cindex Ada 83 attributes
3658 @findex Safe_Large
3659 @item Safe_Large
3660 @noindent
3661 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
3662 the Ada 83 reference manual for an exact description of the semantics of
3663 this attribute.
3664
3665 @cindex Ada 83 attributes
3666 @findex Small
3667 @item Small
3668 @noindent
3669 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
3670 GNAT also allows this attribute to be applied to floating-point types
3671 for compatibility with Ada 83. See
3672 the Ada 83 reference manual for an exact description of the semantics of
3673 this attribute when applied to floating-point types.
3674
3675 @findex Storage_Unit
3676 @item Storage_Unit
3677 @noindent
3678 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
3679 prefix) provides the value @code{System.Storage_Unit} and is intended
3680 primarily for constructing this definition in package @code{System}.
3681
3682 @findex Tick
3683 @item Tick
3684 @noindent
3685 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
3686 provides the value of @code{System.Tick} and is intended primarily for
3687 constructing this definition in package @code{System}.
3688
3689 @findex To_Address
3690 @item To_Address
3691 @noindent
3692 The @code{System'To_Address}
3693 (@code{System} is the only permissible prefix)
3694 denotes a function identical to 
3695 @code{System.Storage_Elements.To_Address} except that
3696 it is a static attribute. This means that if its argument is
3697 a static expression, then the result of the attribute is a
3698 static expression. The result is that such an expression can be
3699 used in contexts (e.g. preelaborable packages) which require a
3700 static expression and where the function call could not be used
3701 (since the function call is always non-static, even if its 
3702 argument is static).
3703
3704 @findex Type_Class
3705 @item Type_Class
3706 @noindent
3707 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
3708 the value of the type class for the full type of @var{type}. If
3709 @var{type} is a generic formal type, the value is the value for the
3710 corresponding actual subtype.  The value of this attribute is of type
3711 @code{System.Aux_DEC.Type_Class}, which has the following definition:
3712
3713 @smallexample
3714   type Type_Class is
3715     (Type_Class_Enumeration,
3716      Type_Class_Integer,
3717      Type_Class_Fixed_Point,
3718      Type_Class_Floating_Point,
3719      Type_Class_Array,
3720      Type_Class_Record,
3721      Type_Class_Access,
3722      Type_Class_Task,
3723      Type_Class_Address);
3724 @end smallexample
3725
3726 @noindent
3727 Protected types yield the value @code{Type_Class_Task}, which thus
3728 applies to all concurrent types. This attribute is designed to
3729 be compatible with the DEC Ada 83 attribute of the same name.
3730
3731 @findex UET_Address
3732 @item UET_Address
3733 @noindent
3734 The @code{UET_Address} attribute can only be used for a prefix which
3735 denotes a library package. It yields the address of the unit exception
3736 table when zero cost exception handling is used. This attribute is
3737 intended only for use within the GNAT implementation. See the unit
3738 @code{Ada.Exceptions} in files @file{a-except.ads,a-except.adb}
3739 for details on how this attribute is used in the implementation.
3740
3741 @cindex Named numbers, representation of
3742 @findex Universal_Literal_String
3743 @item Universal_Literal_String
3744 @noindent
3745 The prefix of @code{Universal_Literal_String} must be a named
3746 number. The static result is the string consisting of the characters of
3747 the number as defined in the original source. This allows the user
3748 program to access the actual text of named numbers without intermediate
3749 conversions and without the need to enclose the strings in quotes (which
3750 would preclude their use as numbers). This is used internally for the
3751 construction of values of the floating-point attributes from the file
3752 @file{ttypef.ads}, but may also be used by user programs.
3753
3754 @cindex @code{Access}, unrestricted
3755 @findex Unrestricted_Access
3756 @item Unrestricted_Access
3757 @noindent
3758 The @code{Unrestricted_Access} attribute is similar to @code{Access}
3759 except that all accessibility and aliased view checks are omitted. This
3760 is a user-beware attribute.  It is similar to
3761 @code{Address}, for which it is a desirable replacement where the value
3762 desired is an access type. In other words, its effect is identical to
3763 first applying the @code{Address} attribute and then doing an unchecked
3764 conversion to a desired access type. In GNAT, but not necessarily in
3765 other implementations, the use of static chains for inner level
3766 subprograms means that @code{Unrestricted_Access} applied to a
3767 subprogram yields a value that can be called as long as the subprogram
3768 is in scope (normal Ada 95 accessibility rules restrict this usage).
3769
3770 @cindex @code{Size}, VADS compatibility
3771 @findex VADS_Size
3772 @item VADS_Size
3773 @noindent
3774 The @code{'VADS_Size} attribute is intended to make it easier to port
3775 legacy code which relies on the semantics of @code{'Size} as implemented
3776 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
3777 same semantic interpretation. In particular, @code{'VADS_Size} applied
3778 to a predefined or other primitive type with no Size clause yields the
3779 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
3780 typical machines). In addition @code{'VADS_Size} applied to an object
3781 gives the result that would be obtained by applying the attribute to
3782 the corresponding type.
3783
3784 @cindex @code{Size}, setting for not-first subtype
3785 @findex Value_Size
3786 @item Value_Size
3787 @code{@var{type}'Value_Size} is the number of bits required to represent
3788 a value of the given subtype. It is the same as @code{@var{type}'Size},
3789 but, unlike @code{Size}, may be set for non-first subtypes.
3790
3791 @findex Wchar_T_Size
3792 @item Wchar_T_Size
3793 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
3794 prefix) provides the size in bits of the C @code{wchar_t} type 
3795 primarily for constructing the definition of this type in 
3796 package @code{Interfaces.C}.
3797
3798 @findex Word_Size
3799 @item Word_Size
3800 @code{Standard'Word_Size} (@code{Standard} is the only permissible
3801 prefix) provides the value @code{System.Word_Size} and is intended
3802 primarily for constructing this definition in package @code{System}.
3803 @end table
3804 @node Implementation Advice
3805 @chapter Implementation Advice
3806 The main text of the Ada 95 Reference Manual describes the required
3807 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
3808 these requirements.
3809
3810 In addition, there are sections throughout the Ada 95
3811 reference manual headed
3812 by the phrase ``implementation advice''. These sections are not normative,
3813 i.e. they do not specify requirements that all compilers must
3814 follow. Rather they provide advice on generally desirable behavior. You
3815 may wonder why they are not requirements. The most typical answer is
3816 that they describe behavior that seems generally desirable, but cannot
3817 be provided on all systems, or which may be undesirable on some systems.
3818
3819 As far as practical, GNAT follows the implementation advice sections in
3820 the Ada 95 Reference Manual. This chapter contains a table giving the
3821 reference manual section number, paragraph number and several keywords
3822 for each advice.  Each entry consists of the text of the advice followed
3823 by the GNAT interpretation of this advice. Most often, this simply says
3824 ``followed'', which means that GNAT follows the advice. However, in a
3825 number of cases, GNAT deliberately deviates from this advice, in which
3826 case the text describes what GNAT does and why.
3827
3828 @table @strong
3829 @cindex Error detection
3830 @item 1.1.3(20): Error Detection
3831 @sp 1
3832 @cartouche
3833 If an implementation detects the use of an unsupported Specialized Needs
3834 Annex feature at run time, it should raise @code{Program_Error} if
3835 feasible.
3836 @end cartouche
3837 Not relevant. All specialized needs annex features are either supported,
3838 or diagnosed at compile time.
3839
3840 @cindex Child Units
3841 @item 1.1.3(31): Child Units
3842 @sp 1
3843 @cartouche
3844 If an implementation wishes to provide implementation-defined
3845 extensions to the functionality of a language-defined library unit, it
3846 should normally do so by adding children to the library unit.
3847 @end cartouche
3848 Followed.
3849
3850 @cindex Bounded errors
3851 @item 1.1.5(12): Bounded Errors
3852 @sp 1
3853 @cartouche
3854 If an implementation detects a bounded error or erroneous
3855 execution, it should raise @code{Program_Error}.
3856 @end cartouche
3857 Followed in all cases in which the implementation detects a bounded
3858 error or erroneous execution. Not all such situations are detected at
3859 runtime.
3860
3861 @cindex Pragmas
3862 @item 2.8(16): Pragmas
3863 @sp 1
3864 @cartouche
3865 Normally, implementation-defined pragmas should have no semantic effect
3866 for error-free programs; that is, if the implementation-defined pragmas
3867 are removed from a working program, the program should still be legal,
3868 and should still have the same semantics.
3869 @end cartouche
3870 The following implementation defined pragmas are exceptions to this
3871 rule:
3872
3873 @table @code
3874 @item Abort_Defer
3875 Affects semantics
3876 @item Ada_83
3877 Affects legality
3878 @item Assert
3879 Affects semantics
3880 @item CPP_Class
3881 Affects semantics
3882 @item CPP_Constructor
3883 Affects semantics
3884 @item CPP_Virtual
3885 Affects semantics
3886 @item CPP_Vtable
3887 Affects semantics
3888 @item Debug
3889 Affects semantics
3890 @item Interface_Name
3891 Affects semantics
3892 @item Machine_Attribute
3893 Affects semantics
3894 @item Unimplemented_Unit
3895 Affects legality
3896 @item Unchecked_Union
3897 Affects semantics
3898 @end table
3899
3900 In each of the above cases, it is essential to the purpose of the pragma
3901 that this advice not be followed. For details see the separate section
3902 on implementation defined pragmas.
3903
3904 @item 2.8(17-19): Pragmas
3905 @sp 1
3906 @cartouche
3907 Normally, an implementation should not define pragmas that can
3908 make an illegal program legal, except as follows:
3909 @end cartouche
3910 @sp 1
3911 @cartouche
3912 A pragma used to complete a declaration, such as a pragma @code{Import};
3913 @end cartouche
3914 @sp 1
3915 @cartouche
3916 A pragma used to configure the environment by adding, removing, or
3917 replacing @code{library_items}.
3918 @end cartouche
3919 See response to paragraph 16 of this same section.
3920
3921 @cindex Character Sets
3922 @cindex Alternative Character Sets
3923 @item 3.5.2(5): Alternative Character Sets
3924 @sp 1
3925 @cartouche
3926 If an implementation supports a mode with alternative interpretations
3927 for @code{Character} and @code{Wide_Character}, the set of graphic
3928 characters of @code{Character} should nevertheless remain a proper
3929 subset of the set of graphic characters of @code{Wide_Character}. Any
3930 character set ``localizations'' should be reflected in the results of
3931 the subprograms defined in the language-defined package
3932 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
3933 an alternative interpretation of @code{Character}, the implementation should
3934 also support a corresponding change in what is a legal
3935 @code{identifier_letter}.
3936 @end cartouche
3937 Not all wide character modes follow this advice, in particular the JIS
3938 and IEC modes reflect standard usage in Japan, and in these encoding,
3939 the upper half of the Latin-1 set is not part of the wide-character
3940 subset, since the most significant bit is used for wide character
3941 encoding. However, this only applies to the external forms. Internally
3942 there is no such restriction.
3943
3944 @cindex Integer types
3945 @item 3.5.4(28): Integer Types
3946
3947 @sp 1
3948 @cartouche
3949 An implementation should support @code{Long_Integer} in addition to
3950 @code{Integer} if the target machine supports 32-bit (or longer)
3951 arithmetic. No other named integer subtypes are recommended for package
3952 @code{Standard}. Instead, appropriate named integer subtypes should be
3953 provided in the library package @code{Interfaces} (see B.2).
3954 @end cartouche
3955 @code{Long_Integer} is supported. Other standard integer types are supported
3956 so this advice is not fully followed. These types
3957 are supported for convenient interface to C, and so that all hardware
3958 types of the machine are easily available.
3959 @item 3.5.4(29): Integer Types
3960
3961 @sp 1
3962 @cartouche
3963 An implementation for a two's complement machine should support
3964 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
3965 implementation should support a non-binary modules up to @code{Integer'Last}.
3966 @end cartouche
3967 Followed.
3968
3969 @cindex Enumeration values
3970 @item 3.5.5(8): Enumeration Values
3971 @sp 1
3972 @cartouche
3973 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
3974 subtype, if the value of the operand does not correspond to the internal
3975 code for any enumeration literal of its type (perhaps due to an
3976 un-initialized variable), then the implementation should raise
3977 @code{Program_Error}. This is particularly important for enumeration
3978 types with noncontiguous internal codes specified by an
3979 enumeration_representation_clause.
3980 @end cartouche
3981 Followed.
3982
3983 @cindex Float types
3984 @item 3.5.7(17): Float Types
3985 @sp 1
3986 @cartouche
3987 An implementation should support @code{Long_Float} in addition to
3988 @code{Float} if the target machine supports 11 or more digits of
3989 precision. No other named floating point subtypes are recommended for
3990 package @code{Standard}. Instead, appropriate named floating point subtypes
3991 should be provided in the library package @code{Interfaces} (see B.2).
3992 @end cartouche
3993 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
3994 former provides improved compatibility with other implementations
3995 supporting this type. The latter corresponds to the highest precision
3996 floating-point type supported by the hardware. On most machines, this
3997 will be the same as @code{Long_Float}, but on some machines, it will
3998 correspond to the IEEE extended form. The notable case is all ia32
3999 (x86) implementations, where @code{Long_Long_Float} corresponds to
4000 the 80-bit extended precision format supported in hardware on this
4001 processor. Note that the 128-bit format on SPARC is not supported,
4002 since this is a software rather than a hardware format.
4003
4004 @cindex Multidimensional arrays
4005 @cindex Arrays, multidimensional
4006 @item 3.6.2(11): Multidimensional Arrays
4007 @sp 1
4008 @cartouche
4009 An implementation should normally represent multidimensional arrays in
4010 row-major order, consistent with the notation used for multidimensional
4011 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
4012 (@code{Fortran}, ...) applies to a multidimensional array type, then
4013 column-major order should be used instead (see B.5, ``Interfacing with
4014 Fortran'').
4015 @end cartouche
4016 Followed.
4017
4018 @findex Duration'Small
4019 @item 9.6(30-31): Duration'Small
4020 @sp 1
4021 @cartouche
4022 Whenever possible in an implementation, the value of @code{Duration'Small}
4023 should be no greater than 100 microseconds.
4024 @end cartouche
4025 Followed. (@code{Duration'Small} = 10**(-9)).
4026
4027 @sp 1
4028 @cartouche
4029 The time base for @code{delay_relative_statements} should be monotonic;
4030 it need not be the same time base as used for @code{Calendar.Clock}.
4031 @end cartouche
4032 Followed.
4033
4034 @item 10.2.1(12): Consistent Representation
4035 @sp 1
4036 @cartouche
4037 In an implementation, a type declared in a pre-elaborated package should
4038 have the same representation in every elaboration of a given version of
4039 the package, whether the elaborations occur in distinct executions of
4040 the same program, or in executions of distinct programs or partitions
4041 that include the given version.
4042 @end cartouche
4043 Followed, except in the case of tagged types. Tagged types involve
4044 implicit pointers to a local copy of a dispatch table, and these pointers
4045 have representations which thus depend on a particular elaboration of the
4046 package. It is not easy to see how it would be possible to follow this
4047 advice without severely impacting efficiency of execution.
4048
4049 @cindex Exception information
4050 @item 11.4.1(19): Exception Information
4051 @sp 1
4052 @cartouche
4053 @code{Exception_Message} by default and @code{Exception_Information}
4054 should produce information useful for
4055 debugging. @code{Exception_Message} should be short, about one
4056 line. @code{Exception_Information} can be long. @code{Exception_Message}
4057 should not include the
4058 @code{Exception_Name}. @code{Exception_Information} should include both
4059 the @code{Exception_Name} and the @code{Exception_Message}.
4060 @end cartouche
4061 Followed. For each exception that doesn't have a specified
4062 @code{Exception_Message}, the compiler generates one containing the location
4063 of the raise statement. This location has the form "file:line", where
4064 file is the short file name (without path information) and line is the line
4065 number in the file. Note that in the case of the Zero Cost Exception
4066 mechanism, these messages become redundant with the Exception_Information that
4067 contains a full backtrace of the calling sequence, so they are disabled.
4068 To disable explicitly the generation of the source location message, use the
4069 Pragma @code{Discard_Names}.
4070
4071 @cindex Suppression of checks
4072 @cindex Checks, suppression of
4073 @item 11.5(28): Suppression of Checks
4074 @sp 1
4075 @cartouche
4076 The implementation should minimize the code executed for checks that
4077 have been suppressed.
4078 @end cartouche
4079 Followed.
4080
4081 @cindex Representation clauses
4082 @item 13.1 (21-24): Representation Clauses
4083 @sp 1
4084 @cartouche
4085 The recommended level of support for all representation items is
4086 qualified as follows:
4087 @end cartouche
4088 @sp 1
4089 @cartouche
4090 An implementation need not support representation items containing
4091 non-static expressions, except that an implementation should support a
4092 representation item for a given entity if each non-static expression in
4093 the representation item is a name that statically denotes a constant
4094 declared before the entity.
4095 @end cartouche
4096 Followed. GNAT does not support non-static expressions in representation
4097 clauses unless they are constants declared before the entity. For
4098 example:
4099
4100 @smallexample
4101 X : typ;
4102 for X'Address use To_address (16#2000#); 
4103 @end smallexample
4104
4105 @noindent
4106 will be rejected, since the To_Address expression is non-static. Instead
4107 write: 
4108
4109 @smallexample
4110 X_Address : constant Address : = 
4111 To_Address    ((16#2000#); 
4112 X : typ;
4113 for X'Address use X_Address;
4114 @end smallexample
4115
4116 @sp 1
4117 @cartouche
4118 An implementation need not support a specification for the @code{Size}
4119 for a given composite subtype, nor the size or storage place for an
4120 object (including a component) of a given composite subtype, unless the
4121 constraints on the subtype and its composite subcomponents (if any) are
4122 all static constraints.
4123 @end cartouche
4124 Followed. Size Clauses are not permitted on non-static components, as
4125 described above.
4126
4127 @sp 1
4128 @cartouche
4129 An aliased component, or a component whose type is by-reference, should
4130 always be allocated at an addressable location.
4131 @end cartouche
4132 Followed.
4133
4134 @cindex Packed types
4135 @item 13.2(6-8): Packed Types
4136 @sp 1
4137 @cartouche
4138 If a type is packed, then the implementation should try to minimize
4139 storage allocated to objects of the type, possibly at the expense of
4140 speed of accessing components, subject to reasonable complexity in
4141 addressing calculations.
4142 @end cartouche
4143 @sp 1
4144 @cartouche
4145 The recommended level of support pragma @code{Pack} is:
4146
4147 For a packed record type, the components should be packed as tightly as
4148 possible subject to the Sizes of the component subtypes, and subject to
4149 any @code{record_representation_clause} that applies to the type; the
4150 implementation may, but need not, reorder components or cross aligned
4151 word boundaries to improve the packing. A component whose @code{Size} is
4152 greater than the word size may be allocated an integral number of words.
4153 @end cartouche
4154 Followed. Tight packing of arrays is supported for all component sizes
4155 up to 64-bits.
4156
4157 @sp 1
4158 @cartouche
4159 An implementation should support Address clauses for imported
4160 subprograms.
4161 @end cartouche
4162 Followed.
4163 @cindex @code{Address} clauses
4164 @item 13.3(14-19): Address Clauses
4165
4166 @sp 1
4167 @cartouche
4168 For an array @var{X}, @code{@var{X}'Address} should point at the first
4169 component of the array, and not at the array bounds.
4170 @end cartouche
4171 Followed.
4172
4173 @sp 1
4174 @cartouche
4175 The recommended level of support for the @code{Address} attribute is:
4176
4177 @code{@var{X}'Address} should produce a useful result if @var{X} is an
4178 object that is aliased or of a by-reference type, or is an entity whose
4179 @code{Address} has been specified.
4180 @end cartouche
4181 Followed.  A valid address will be produced even if none of those
4182 conditions have been met.  If necessary, the object is forced into
4183 memory to ensure the address is valid.
4184
4185 @sp 1
4186 @cartouche
4187 An implementation should support @code{Address} clauses for imported
4188 subprograms.
4189 @end cartouche
4190 Followed.
4191             
4192 @sp 1
4193 @cartouche
4194 Objects (including subcomponents) that are aliased or of a by-reference
4195 type should be allocated on storage element boundaries.
4196 @end cartouche
4197 Followed.
4198           
4199 @sp 1
4200 @cartouche
4201 If the @code{Address} of an object is specified, or it is imported or exported,
4202 then the implementation should not perform optimizations based on
4203 assumptions of no aliases.
4204 @end cartouche
4205 Followed.
4206
4207 @cindex @code{Alignment} clauses
4208 @item 13.3(29-35): Alignment Clauses
4209 @sp 1
4210 @cartouche
4211 The recommended level of support for the @code{Alignment} attribute for
4212 subtypes is:
4213
4214 An implementation should support specified Alignments that are factors
4215 and multiples of the number of storage elements per word, subject to the
4216 following:
4217 @end cartouche
4218 Followed.
4219           
4220 @sp 1
4221 @cartouche
4222 An implementation need not support specified @code{Alignment}s for
4223 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
4224 loaded and stored by available machine instructions.
4225 @end cartouche
4226 Followed.
4227             
4228 @sp 1
4229 @cartouche
4230 An implementation need not support specified @code{Alignment}s that are
4231 greater than the maximum @code{Alignment} the implementation ever returns by
4232 default.
4233 @end cartouche
4234 Followed.
4235
4236 @sp 1
4237 @cartouche
4238 The recommended level of support for the @code{Alignment} attribute for
4239 objects is:
4240
4241 Same as above, for subtypes, but in addition:
4242 @end cartouche
4243 Followed.
4244            
4245 @sp 1
4246 @cartouche
4247 For stand-alone library-level objects of statically constrained
4248 subtypes, the implementation should support all @code{Alignment}s
4249 supported by the target linker. For example, page alignment is likely to
4250 be supported for such objects, but not for subtypes.
4251 @end cartouche
4252 Followed.
4253
4254 @cindex @code{Size} clauses
4255 @item 13.3(42-43): Size Clauses
4256 @sp 1
4257 @cartouche
4258 The recommended level of support for the @code{Size} attribute of
4259 objects is:
4260
4261 A @code{Size} clause should be supported for an object if the specified
4262 @code{Size} is at least as large as its subtype's @code{Size}, and
4263 corresponds to a size in storage elements that is a multiple of the
4264 object's @code{Alignment} (if the @code{Alignment} is nonzero).
4265 @end cartouche
4266 Followed.
4267
4268 @item 13.3(50-56): Size Clauses
4269 @sp 1
4270 @cartouche
4271 If the @code{Size} of a subtype is specified, and allows for efficient
4272 independent addressability (see 9.10) on the target architecture, then
4273 the @code{Size} of the following objects of the subtype should equal the
4274 @code{Size} of the subtype:
4275
4276 Aliased objects (including components).
4277 @end cartouche
4278 Followed.
4279
4280 @sp 1
4281 @cartouche
4282 @code{Size} clause on a composite subtype should not affect the
4283 internal layout of components.
4284 @end cartouche
4285 Followed.
4286
4287 @sp 1
4288 @cartouche
4289 The recommended level of support for the @code{Size} attribute of subtypes is:
4290 @end cartouche
4291 @sp 1
4292 @cartouche
4293 The @code{Size} (if not specified) of a static discrete or fixed point
4294 subtype should be the number of bits needed to represent each value
4295 belonging to the subtype using an unbiased representation, leaving space
4296 for a sign bit only if the subtype contains negative values. If such a
4297 subtype is a first subtype, then an implementation should support a
4298 specified @code{Size} for it that reflects this representation.
4299 @end cartouche
4300 Followed.
4301
4302 @sp 1
4303 @cartouche
4304 For a subtype implemented with levels of indirection, the @code{Size}
4305 should include the size of the pointers, but not the size of what they
4306 point at.
4307 @end cartouche
4308 Followed.
4309
4310 @cindex @code{Component_Size} clauses
4311 @item 13.3(71-73): Component Size Clauses
4312 @sp 1
4313 @cartouche
4314 The recommended level of support for the @code{Component_Size}
4315 attribute is:
4316 @end cartouche
4317 @sp 1
4318 @cartouche
4319 An implementation need not support specified @code{Component_Sizes} that are
4320 less than the @code{Size} of the component subtype.
4321 @end cartouche
4322 Followed.
4323
4324 @sp 1
4325 @cartouche
4326 An implementation should support specified @code{Component_Size}s that
4327 are factors and multiples of the word size. For such
4328 @code{Component_Size}s, the array should contain no gaps between
4329 components. For other @code{Component_Size}s (if supported), the array
4330 should contain no gaps between components when packing is also
4331 specified; the implementation should forbid this combination in cases
4332 where it cannot support a no-gaps representation.
4333 @end cartouche
4334 Followed.
4335
4336 @cindex Enumeration representation clauses
4337 @cindex Representation clauses, enumeration
4338 @item 13.4(9-10): Enumeration Representation Clauses
4339 @sp 1
4340 @cartouche
4341 The recommended level of support for enumeration representation clauses
4342 is:
4343
4344 An implementation need not support enumeration representation clauses
4345 for boolean types, but should at minimum support the internal codes in
4346 the range @code{System.Min_Int.System.Max_Int}.
4347 @end cartouche
4348 Followed.
4349
4350 @cindex Record representation clauses
4351 @cindex Representation clauses, records
4352 @item 13.5.1(17-22): Record Representation Clauses
4353 @sp 1
4354 @cartouche
4355 The recommended level of support for
4356 @*@code{record_representation_clauses} is:
4357
4358 An implementation should support storage places that can be extracted
4359 with a load, mask, shift sequence of machine code, and set with a load,
4360 shift, mask, store sequence, given the available machine instructions
4361 and run-time model.
4362 @end cartouche
4363 Followed.
4364
4365 @sp 1
4366 @cartouche
4367 A storage place should be supported if its size is equal to the
4368 @code{Size} of the component subtype, and it starts and ends on a
4369 boundary that obeys the @code{Alignment} of the component subtype.
4370 @end cartouche
4371 Followed.
4372            
4373 @sp 1
4374 @cartouche
4375 If the default bit ordering applies to the declaration of a given type,
4376 then for a component whose subtype's @code{Size} is less than the word
4377 size, any storage place that does not cross an aligned word boundary
4378 should be supported.
4379 @end cartouche
4380 Followed.
4381
4382 @sp 1
4383 @cartouche
4384 An implementation may reserve a storage place for the tag field of a
4385 tagged type, and disallow other components from overlapping that place.
4386 @end cartouche
4387 Followed. The storage place for the tag field is the beginning of the tagged
4388 record, and its size is Address'Size. GNAT will reject an explicit component
4389 clause for the tag field.
4390
4391 @sp 1
4392 @cartouche
4393 An implementation need not support a @code{component_clause} for a
4394 component of an extension part if the storage place is not after the
4395 storage places of all components of the parent type, whether or not
4396 those storage places had been specified.
4397 @end cartouche
4398 Followed. The above advice on record representation clauses is followed,
4399 and all mentioned features are implemented.
4400
4401 @cindex Storage place attributes
4402 @item 13.5.2(5): Storage Place Attributes
4403 @sp 1
4404 @cartouche
4405 If a component is represented using some form of pointer (such as an
4406 offset) to the actual data of the component, and this data is contiguous
4407 with the rest of the object, then the storage place attributes should
4408 reflect the place of the actual data, not the pointer. If a component is
4409 allocated discontinuously from the rest of the object, then a warning
4410 should be generated upon reference to one of its storage place
4411 attributes.
4412 @end cartouche
4413 Followed. There are no such components in GNAT.
4414
4415 @cindex Bit ordering
4416 @item 13.5.3(7-8): Bit Ordering
4417 @sp 1
4418 @cartouche
4419 The recommended level of support for the non-default bit ordering is:
4420 @end cartouche
4421 @sp 1
4422 @cartouche
4423 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
4424 should support the non-default bit ordering in addition to the default
4425 bit ordering.
4426 @end cartouche
4427 Followed. Word size does not equal storage size in this implementation.
4428 Thus non-default bit ordering is not supported.
4429
4430 @cindex @code{Address}, as private type
4431 @item 13.7(37): Address as Private
4432 @sp 1
4433 @cartouche
4434 @code{Address} should be of a private type.
4435 @end cartouche
4436 Followed.
4437
4438 @cindex Operations, on @code{Address}
4439 @cindex @code{Address}, operations of
4440 @item 13.7.1(16): Address Operations
4441 @sp 1
4442 @cartouche
4443 Operations in @code{System} and its children should reflect the target
4444 environment semantics as closely as is reasonable. For example, on most
4445 machines, it makes sense for address arithmetic to ``wrap around.''
4446 Operations that do not make sense should raise @code{Program_Error}.
4447 @end cartouche
4448 Followed. Address arithmetic is modular arithmetic that wraps around. No
4449 operation raises @code{Program_Error}, since all operations make sense.
4450
4451 @cindex Unchecked conversion
4452 @item 13.9(14-17): Unchecked Conversion
4453 @sp 1
4454 @cartouche
4455 The @code{Size} of an array object should not include its bounds; hence,
4456 the bounds should not be part of the converted data.
4457 @end cartouche
4458 Followed. 
4459
4460 @sp 1
4461 @cartouche
4462 The implementation should not generate unnecessary run-time checks to
4463 ensure that the representation of @var{S} is a representation of the
4464 target type. It should take advantage of the permission to return by
4465 reference when possible. Restrictions on unchecked conversions should be
4466 avoided unless required by the target environment.
4467 @end cartouche
4468 Followed. There are no restrictions on unchecked conversion. A warning is
4469 generated if the source and target types do not have the same size since
4470 the semantics in this case may be target dependent.
4471
4472 @sp 1
4473 @cartouche
4474 The recommended level of support for unchecked conversions is:
4475 @end cartouche
4476 @sp 1
4477 @cartouche
4478 Unchecked conversions should be supported and should be reversible in
4479 the cases where this clause defines the result. To enable meaningful use
4480 of unchecked conversion, a contiguous representation should be used for
4481 elementary subtypes, for statically constrained array subtypes whose
4482 component subtype is one of the subtypes described in this paragraph,
4483 and for record subtypes without discriminants whose component subtypes
4484 are described in this paragraph.
4485 @end cartouche
4486 Followed. 
4487
4488 @cindex Heap usage, implicit
4489 @item 13.11(23-25): Implicit Heap Usage
4490 @sp 1
4491 @cartouche
4492 An implementation should document any cases in which it dynamically
4493 allocates heap storage for a purpose other than the evaluation of an
4494 allocator.
4495 @end cartouche
4496 Followed, the only other points at which heap storage is dynamically
4497 allocated are as follows:
4498
4499 @itemize @bullet
4500 @item
4501 At initial elaboration time, to allocate dynamically sized global
4502 objects.
4503
4504 @item
4505 To allocate space for a task when a task is created.
4506
4507 @item
4508 To extend the secondary stack dynamically when needed. The secondary
4509 stack is used for returning variable length results.
4510 @end itemize
4511
4512 @sp 1
4513 @cartouche
4514 A default (implementation-provided) storage pool for an access-to-
4515 constant type should not have overhead to support de-allocation of
4516 individual objects.
4517 @end cartouche
4518 Followed. 
4519
4520 @sp 1
4521 @cartouche
4522 A storage pool for an anonymous access type should be created at the
4523 point of an allocator for the type, and be reclaimed when the designated
4524 object becomes inaccessible.
4525 @end cartouche
4526 Followed. 
4527
4528 @cindex Unchecked deallocation
4529 @item 13.11.2(17): Unchecked De-allocation
4530 @sp 1
4531 @cartouche
4532 For a standard storage pool, @code{Free} should actually reclaim the
4533 storage.
4534 @end cartouche
4535 Followed. 
4536
4537 @cindex Stream oriented attributes
4538 @item 13.13.2(17): Stream Oriented Attributes
4539 @sp 1
4540 @cartouche
4541 If a stream element is the same size as a storage element, then the
4542 normal in-memory representation should be used by @code{Read} and
4543 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
4544 should use the smallest number of stream elements needed to represent
4545 all values in the base range of the scalar type.
4546 @end cartouche
4547 Followed. In particular, the interpretation chosen is that of AI-195,
4548 which specifies that the size to be used is that of the first subtype.
4549
4550 @item A.1(52): Implementation Advice
4551 @sp 1
4552 @cartouche
4553 If an implementation provides additional named predefined integer types,
4554 then the names should end with @samp{Integer} as in
4555 @samp{Long_Integer}. If an implementation provides additional named
4556 predefined floating point types, then the names should end with
4557 @samp{Float} as in @samp{Long_Float}.
4558 @end cartouche
4559 Followed. 
4560
4561 @findex Ada.Characters.Handling
4562 @item A.3.2(49): @code{Ada.Characters.Handling}
4563 @sp 1
4564 @cartouche
4565 If an implementation provides a localized definition of @code{Character}
4566 or @code{Wide_Character}, then the effects of the subprograms in
4567 @code{Characters.Handling} should reflect the localizations. See also
4568 3.5.2.
4569 @end cartouche
4570 Followed. GNAT provides no such localized definitions. 
4571
4572 @cindex Bounded-length strings
4573 @item A.4.4(106): Bounded-Length String Handling
4574 @sp 1
4575 @cartouche
4576 Bounded string objects should not be implemented by implicit pointers
4577 and dynamic allocation.
4578 @end cartouche
4579 Followed. No implicit pointers or dynamic allocation are used. 
4580
4581 @cindex Random number generation
4582 @item A.5.2(46-47): Random Number Generation
4583 @sp 1
4584 @cartouche
4585 Any storage associated with an object of type @code{Generator} should be
4586 reclaimed on exit from the scope of the object.
4587 @end cartouche
4588 Followed. 
4589
4590 @sp 1
4591 @cartouche
4592 If the generator period is sufficiently long in relation to the number
4593 of distinct initiator values, then each possible value of
4594 @code{Initiator} passed to @code{Reset} should initiate a sequence of
4595 random numbers that does not, in a practical sense, overlap the sequence
4596 initiated by any other value. If this is not possible, then the mapping
4597 between initiator values and generator states should be a rapidly
4598 varying function of the initiator value.
4599 @end cartouche
4600 Followed. The generator period is sufficiently long for the first
4601 condition here to hold true. 
4602
4603 @findex Get_Immediate
4604 @item A.10.7(23): @code{Get_Immediate}
4605 @sp 1
4606 @cartouche
4607 The @code{Get_Immediate} procedures should be implemented with
4608 unbuffered input. For a device such as a keyboard, input should be
4609 @dfn{available} if a key has already been typed, whereas for a disk
4610 file, input should always be available except at end of file. For a file
4611 associated with a keyboard-like device, any line-editing features of the
4612 underlying operating system should be disabled during the execution of
4613 @code{Get_Immediate}.
4614 @end cartouche
4615 Followed.
4616
4617 @findex Export
4618 @item B.1(39-41): Pragma @code{Export}
4619 @sp 1
4620 @cartouche
4621 If an implementation supports pragma @code{Export} to a given language,
4622 then it should also allow the main subprogram to be written in that
4623 language. It should support some mechanism for invoking the elaboration
4624 of the Ada library units included in the system, and for invoking the
4625 finalization of the environment task. On typical systems, the
4626 recommended mechanism is to provide two subprograms whose link names are
4627 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
4628 elaboration code for library units. @code{adafinal} should contain the
4629 finalization code. These subprograms should have no effect the second
4630 and subsequent time they are called.
4631 @end cartouche
4632 Followed. 
4633
4634 @sp 1
4635 @cartouche
4636 Automatic elaboration of pre-elaborated packages should be
4637 provided when pragma Export is supported.
4638 @end cartouche
4639 Followed when the main program is in Ada. If the main program is in a
4640 foreign language, then
4641 @code{adainit} must be called to elaborate pre-elaborated
4642 packages.
4643
4644 @sp 1
4645 @cartouche
4646 For each supported convention @var{L} other than @code{Intrinsic}, an
4647 implementation should support @code{Import} and @code{Export} pragmas
4648 for objects of @var{L}-compatible types and for subprograms, and pragma
4649 @code{Convention} for @var{L}-eligible types and for subprograms,
4650 presuming the other language has corresponding features. Pragma
4651 @code{Convention} need not be supported for scalar types.
4652 @end cartouche
4653 Followed. 
4654
4655 @cindex Package @code{Interfaces}
4656 @findex Interfaces
4657 @item B.2(12-13): Package @code{Interfaces}
4658 @sp 1
4659 @cartouche
4660 For each implementation-defined convention identifier, there should be a
4661 child package of package Interfaces with the corresponding name. This
4662 package should contain any declarations that would be useful for
4663 interfacing to the language (implementation) represented by the
4664 convention. Any declarations useful for interfacing to any language on
4665 the given hardware architecture should be provided directly in
4666 @code{Interfaces}.
4667 @end cartouche
4668 Followed. An additional package not defined
4669 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
4670 for interfacing to C++.
4671
4672 @sp 1
4673 @cartouche
4674 An implementation supporting an interface to C, COBOL, or Fortran should
4675 provide the corresponding package or packages described in the following
4676 clauses.
4677 @end cartouche
4678 Followed. GNAT provides all the packages described in this section. 
4679
4680 @cindex C, interfacing with
4681 @item B.3(63-71): Interfacing with C
4682 @sp 1
4683 @cartouche
4684 An implementation should support the following interface correspondences
4685 between Ada and C.
4686 @end cartouche
4687 Followed.
4688
4689 @sp 1
4690 @cartouche
4691 An Ada procedure corresponds to a void-returning C function.
4692 @end cartouche
4693 Followed. 
4694
4695 @sp 1
4696 @cartouche
4697 An Ada function corresponds to a non-void C function.
4698 @end cartouche
4699 Followed. 
4700
4701 @sp 1
4702 @cartouche
4703 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
4704 function.
4705 @end cartouche
4706 Followed. 
4707
4708 @sp 1
4709 @cartouche
4710 An Ada @code{in} parameter of an access-to-object type with designated
4711 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
4712 where @var{t} is the C type corresponding to the Ada type @var{T}.
4713 @end cartouche
4714 Followed. 
4715
4716 @sp 1
4717 @cartouche
4718 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
4719 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
4720 argument to a C function, where @var{t} is the C type corresponding to
4721 the Ada type @var{T}. In the case of an elementary @code{out} or
4722 @code{in out} parameter, a pointer to a temporary copy is used to
4723 preserve by-copy semantics.
4724 @end cartouche
4725 Followed. 
4726
4727 @sp 1
4728 @cartouche
4729 An Ada parameter of a record type @var{T}, of any mode, is passed as a
4730 @code{@var{t}*} argument to a C function, where @var{t} is the C
4731 structure corresponding to the Ada type @var{T}.
4732 @end cartouche
4733 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
4734 pragma, or Convention, or by explicitly specifying the mechanism for a given
4735 call using an extended import or export pragma.
4736
4737 @sp 1
4738 @cartouche
4739 An Ada parameter of an array type with component type @var{T}, of any
4740 mode, is passed as a @code{@var{t}*} argument to a C function, where
4741 @var{t} is the C type corresponding to the Ada type @var{T}.
4742 @end cartouche
4743 Followed. 
4744
4745 @sp 1
4746 @cartouche
4747 An Ada parameter of an access-to-subprogram type is passed as a pointer
4748 to a C function whose prototype corresponds to the designated
4749 subprogram's specification.
4750 @end cartouche
4751 Followed. 
4752
4753 @cindex COBOL, interfacing with
4754 @item B.4(95-98): Interfacing with COBOL
4755 @sp 1
4756 @cartouche
4757 An Ada implementation should support the following interface
4758 correspondences between Ada and COBOL.
4759 @end cartouche
4760 Followed.
4761
4762 @sp 1
4763 @cartouche
4764 An Ada access @var{T} parameter is passed as a ``BY REFERENCE'' data item of
4765 the COBOL type corresponding to @var{T}.
4766 @end cartouche
4767 Followed. 
4768
4769 @sp 1
4770 @cartouche
4771 An Ada in scalar parameter is passed as a ``BY CONTENT'' data item of
4772 the corresponding COBOL type.
4773 @end cartouche
4774 Followed. 
4775
4776 @sp 1
4777 @cartouche
4778 Any other Ada parameter is passed as a ``BY REFERENCE'' data item of the
4779 COBOL type corresponding to the Ada parameter type; for scalars, a local
4780 copy is used if necessary to ensure by-copy semantics.
4781 @end cartouche
4782 Followed. 
4783
4784 @cindex Fortran, interfacing with
4785 @item B.5(22-26): Interfacing with Fortran
4786 @sp 1
4787 @cartouche
4788 An Ada implementation should support the following interface
4789 correspondences between Ada and Fortran:
4790 @end cartouche
4791 Followed.
4792
4793 @sp 1
4794 @cartouche
4795 An Ada procedure corresponds to a Fortran subroutine.
4796 @end cartouche
4797 Followed.
4798
4799 @sp 1
4800 @cartouche
4801 An Ada function corresponds to a Fortran function.
4802 @end cartouche
4803 Followed.
4804
4805 @sp 1
4806 @cartouche
4807 An Ada parameter of an elementary, array, or record type @var{T} is
4808 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
4809 the Fortran type corresponding to the Ada type @var{T}, and where the
4810 INTENT attribute of the corresponding dummy argument matches the Ada
4811 formal parameter mode; the Fortran implementation's parameter passing
4812 conventions are used. For elementary types, a local copy is used if
4813 necessary to ensure by-copy semantics.
4814 @end cartouche
4815 Followed.
4816
4817 @sp 1
4818 @cartouche
4819 An Ada parameter of an access-to-subprogram type is passed as a
4820 reference to a Fortran procedure whose interface corresponds to the
4821 designated subprogram's specification.
4822 @end cartouche
4823 Followed.
4824
4825 @cindex Machine operations
4826 @item C.1(3-5): Access to Machine Operations
4827 @sp 1
4828 @cartouche
4829 The machine code or intrinsic support should allow access to all
4830 operations normally available to assembly language programmers for the
4831 target environment, including privileged instructions, if any.
4832 @end cartouche
4833 Followed.
4834
4835 @sp 1
4836 @cartouche
4837 The interfacing pragmas (see Annex B) should support interface to
4838 assembler; the default assembler should be associated with the
4839 convention identifier @code{Assembler}.
4840 @end cartouche
4841 Followed. 
4842
4843 @sp 1
4844 @cartouche
4845 If an entity is exported to assembly language, then the implementation
4846 should allocate it at an addressable location, and should ensure that it
4847 is retained by the linking process, even if not otherwise referenced
4848 from the Ada code. The implementation should assume that any call to a
4849 machine code or assembler subprogram is allowed to read or update every
4850 object that is specified as exported.
4851 @end cartouche
4852 Followed. 
4853
4854 @item C.1(10-16): Access to Machine Operations
4855 @sp 1
4856 @cartouche
4857 The implementation should ensure that little or no overhead is
4858 associated with calling intrinsic and machine-code subprograms.
4859 @end cartouche
4860 Followed for both intrinsics and machine-code subprograms.
4861
4862 @sp 1
4863 @cartouche
4864 It is recommended that intrinsic subprograms be provided for convenient
4865 access to any machine operations that provide special capabilities or
4866 efficiency and that are not otherwise available through the language
4867 constructs.
4868 @end cartouche
4869 Followed. A full set of machine operation intrinsic subprograms is provided.
4870
4871 @sp 1
4872 @cartouche
4873 Atomic read-modify-write operations -- e.g., test and set, compare and
4874 swap, decrement and test, enqueue/dequeue.
4875 @end cartouche
4876 Followed on any target supporting such operations.
4877
4878 @sp 1
4879 @cartouche
4880 Standard numeric functions -- e.g., sin, log.
4881 @end cartouche
4882 Followed on any target supporting such operations.
4883
4884 @sp 1
4885 @cartouche
4886 String manipulation operations -- e.g., translate and test.
4887 @end cartouche
4888 Followed on any target supporting such operations.
4889
4890 @sp 1
4891 @cartouche
4892 Vector operations -- e.g., compare vector against thresholds.
4893 @end cartouche
4894 Followed on any target supporting such operations.
4895
4896 @sp 1
4897 @cartouche
4898 Direct operations on I/O ports.
4899 @end cartouche
4900 Followed on any target supporting such operations.
4901
4902 @cindex Interrupt support
4903 @item C.3(28): Interrupt Support
4904 @sp 1
4905 @cartouche
4906 If the @code{Ceiling_Locking} policy is not in effect, the
4907 implementation should provide means for the application to specify which
4908 interrupts are to be blocked during protected actions, if the underlying
4909 system allows for a finer-grain control of interrupt blocking.
4910 @end cartouche
4911 Followed. The underlying system does not allow for finer-grain control
4912 of interrupt blocking.
4913
4914 @cindex Protected procedure handlers
4915 @item C.3.1(20-21): Protected Procedure Handlers
4916 @sp 1
4917 @cartouche
4918 Whenever possible, the implementation should allow interrupt handlers to
4919 be called directly by the hardware.
4920 @end cartouche
4921 @c SGI info:
4922 @ignore
4923 This is never possible under IRIX, so this is followed by default. 
4924 @end ignore
4925 Followed on any target where the underlying operating system permits
4926 such direct calls.
4927
4928 @sp 1
4929 @cartouche
4930 Whenever practical, violations of any
4931 implementation-defined restrictions should be detected before run time.
4932 @end cartouche
4933 Followed. Compile time warnings are given when possible. 
4934
4935 @cindex Package @code{Interrupts}
4936 @findex Interrupts
4937 @item C.3.2(25): Package @code{Interrupts}
4938
4939 @sp 1
4940 @cartouche
4941 If implementation-defined forms of interrupt handler procedures are
4942 supported, such as protected procedures with parameters, then for each
4943 such form of a handler, a type analogous to @code{Parameterless_Handler}
4944 should be specified in a child package of @code{Interrupts}, with the
4945 same operations as in the predefined package Interrupts.
4946 @end cartouche
4947 Followed. 
4948
4949 @cindex Pre-elaboration requirements
4950 @item C.4(14): Pre-elaboration Requirements
4951 @sp 1
4952 @cartouche
4953 It is recommended that pre-elaborated packages be implemented in such a
4954 way that there should be little or no code executed at run time for the
4955 elaboration of entities not already covered by the Implementation
4956 Requirements.
4957 @end cartouche
4958 Followed. Executable code is generated in some cases, e.g. loops
4959 to initialize large arrays.
4960
4961 @item C.5(8): Pragma @code{Discard_Names}
4962
4963 @sp 1
4964 @cartouche
4965 If the pragma applies to an entity, then the implementation should
4966 reduce the amount of storage used for storing names associated with that
4967 entity.
4968 @end cartouche
4969 Followed.
4970
4971 @cindex Package @code{Task_Attributes}
4972 @findex Task_Attributes
4973 @item C.7.2(30): The Package Task_Attributes
4974 @sp 1
4975 @cartouche
4976 Some implementations are targeted to domains in which memory use at run
4977 time must be completely deterministic. For such implementations, it is
4978 recommended that the storage for task attributes will be pre-allocated
4979 statically and not from the heap. This can be accomplished by either
4980 placing restrictions on the number and the size of the task's
4981 attributes, or by using the pre-allocated storage for the first @var{N}
4982 attribute objects, and the heap for the others. In the latter case,
4983 @var{N} should be documented.
4984 @end cartouche
4985 Not followed. This implementation is not targeted to such a domain. 
4986
4987 @cindex Locking Policies
4988 @item D.3(17): Locking Policies
4989
4990 @sp 1
4991 @cartouche
4992 The implementation should use names that end with @samp{_Locking} for
4993 locking policies defined by the implementation.
4994 @end cartouche
4995 Followed. A single implementation-defined locking policy is defined,
4996 whose name (@code{Inheritance_Locking}) follows this suggestion.
4997
4998 @cindex Entry queuing policies
4999 @item D.4(16): Entry Queuing Policies
5000 @sp 1
5001 @cartouche
5002 Names that end with @samp{_Queuing} should be used
5003 for all implementation-defined queuing policies.
5004 @end cartouche
5005 Followed. No such implementation-defined queueing policies exist. 
5006
5007 @cindex Preemptive abort
5008 @item D.6(9-10): Preemptive Abort
5009 @sp 1
5010 @cartouche
5011 Even though the @code{abort_statement} is included in the list of
5012 potentially blocking operations (see 9.5.1), it is recommended that this
5013 statement be implemented in a way that never requires the task executing
5014 the @code{abort_statement} to block.
5015 @end cartouche
5016 Followed. 
5017
5018 @sp 1
5019 @cartouche
5020 On a multi-processor, the delay associated with aborting a task on
5021 another processor should be bounded; the implementation should use
5022 periodic polling, if necessary, to achieve this.
5023 @end cartouche
5024 Followed. 
5025
5026 @cindex Tasking restrictions
5027 @item D.7(21): Tasking Restrictions
5028 @sp 1
5029 @cartouche
5030 When feasible, the implementation should take advantage of the specified
5031 restrictions to produce a more efficient implementation.
5032 @end cartouche
5033 GNAT currently takes advantage of these restrictions by providing an optimized
5034 run time when the Ravenscar profile and the GNAT restricted run time set
5035 of restrictions are specified. See pragma @code{Ravenscar} and pragma
5036 @code{Restricted_Run_Time} for more details.
5037
5038 @cindex Time, monotonic
5039 @item D.8(47-49): Monotonic Time
5040 @sp 1
5041 @cartouche
5042 When appropriate, implementations should provide configuration
5043 mechanisms to change the value of @code{Tick}.
5044 @end cartouche
5045 Such configuration mechanisms are not appropriate to this implementation
5046 and are thus not supported.
5047
5048 @sp 1
5049 @cartouche
5050 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
5051 be implemented as transformations of the same time base.
5052 @end cartouche
5053 Followed. 
5054
5055 @sp 1
5056 @cartouche
5057 It is recommended that the @dfn{best} time base which exists in
5058 the underlying system be available to the application through
5059 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
5060 @end cartouche
5061 Followed. 
5062
5063 @cindex Partition communication subsystem
5064 @cindex PCS
5065 @item E.5(28-29): Partition Communication Subsystem
5066 @sp 1
5067 @cartouche
5068 Whenever possible, the PCS on the called partition should allow for
5069 multiple tasks to call the RPC-receiver with different messages and
5070 should allow them to block until the corresponding subprogram body
5071 returns.
5072 @end cartouche
5073 Followed by GLADE, a separately supplied PCS that can be used with
5074 GNAT. For information on GLADE, contact Ada Core Technologies.
5075
5076 @sp 1
5077 @cartouche
5078 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
5079 should raise @code{Storage_Error} if it runs out of space trying to
5080 write the @code{Item} into the stream.
5081 @end cartouche
5082 Followed by GLADE, a separately supplied PCS that can be used with
5083 GNAT. For information on GLADE, contact Ada Core Technologies.
5084
5085 @cindex COBOL support
5086 @item F(7): COBOL Support
5087 @sp 1
5088 @cartouche
5089 If COBOL (respectively, C) is widely supported in the target
5090 environment, implementations supporting the Information Systems Annex
5091 should provide the child package @code{Interfaces.COBOL} (respectively,
5092 @code{Interfaces.C}) specified in Annex B and should support a
5093 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
5094 pragmas (see Annex B), thus allowing Ada programs to interface with
5095 programs written in that language.
5096 @end cartouche
5097 Followed. 
5098
5099 @cindex Decimal radix support
5100 @item F.1(2): Decimal Radix Support
5101 @sp 1
5102 @cartouche
5103 Packed decimal should be used as the internal representation for objects
5104 of subtype @var{S} when @var{S}'Machine_Radix = 10.
5105 @end cartouche
5106 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
5107 representations.
5108
5109 @cindex Numerics
5110 @item G: Numerics
5111 @sp 2
5112 @cartouche
5113 If Fortran (respectively, C) is widely supported in the target
5114 environment, implementations supporting the Numerics Annex
5115 should provide the child package @code{Interfaces.Fortran} (respectively,
5116 @code{Interfaces.C}) specified in Annex B and should support a
5117 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
5118 pragmas (see Annex B), thus allowing Ada programs to interface with
5119 programs written in that language.
5120 @end cartouche
5121 Followed.
5122
5123 @cindex Complex types
5124 @item G.1.1(56-58): Complex Types
5125 @sp 2
5126 @cartouche
5127 Because the usual mathematical meaning of multiplication of a complex
5128 operand and a real operand is that of the scaling of both components of
5129 the former by the latter, an implementation should not perform this
5130 operation by first promoting the real operand to complex type and then
5131 performing a full complex multiplication. In systems that, in the
5132 future, support an Ada binding to IEC 559:1989, the latter technique
5133 will not generate the required result when one of the components of the
5134 complex operand is infinite. (Explicit multiplication of the infinite
5135 component by the zero component obtained during promotion yields a NaN
5136 that propagates into the final result.) Analogous advice applies in the
5137 case of multiplication of a complex operand and a pure-imaginary
5138 operand, and in the case of division of a complex operand by a real or
5139 pure-imaginary operand.
5140 @end cartouche
5141 Not followed. 
5142
5143 @sp 1
5144 @cartouche
5145 Similarly, because the usual mathematical meaning of addition of a
5146 complex operand and a real operand is that the imaginary operand remains
5147 unchanged, an implementation should not perform this operation by first
5148 promoting the real operand to complex type and then performing a full
5149 complex addition. In implementations in which the @code{Signed_Zeros}
5150 attribute of the component type is @code{True} (and which therefore
5151 conform to IEC 559:1989 in regard to the handling of the sign of zero in
5152 predefined arithmetic operations), the latter technique will not
5153 generate the required result when the imaginary component of the complex
5154 operand is a negatively signed zero. (Explicit addition of the negative
5155 zero to the zero obtained during promotion yields a positive zero.)
5156 Analogous advice applies in the case of addition of a complex operand
5157 and a pure-imaginary operand, and in the case of subtraction of a
5158 complex operand and a real or pure-imaginary operand.
5159 @end cartouche
5160 Not followed. 
5161
5162 @sp 1
5163 @cartouche
5164 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
5165 attempt to provide a rational treatment of the signs of zero results and
5166 result components. As one example, the result of the @code{Argument}
5167 function should have the sign of the imaginary component of the
5168 parameter @code{X} when the point represented by that parameter lies on
5169 the positive real axis; as another, the sign of the imaginary component
5170 of the @code{Compose_From_Polar} function should be the same as
5171 (respectively, the opposite of) that of the @code{Argument} parameter when that
5172 parameter has a value of zero and the @code{Modulus} parameter has a
5173 nonnegative (respectively, negative) value.
5174 @end cartouche
5175 Followed. 
5176
5177 @cindex Complex elementary functions
5178 @item G.1.2(49): Complex Elementary Functions
5179 @sp 1
5180 @cartouche
5181 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
5182 @code{True} should attempt to provide a rational treatment of the signs
5183 of zero results and result components. For example, many of the complex
5184 elementary functions have components that are odd functions of one of
5185 the parameter components; in these cases, the result component should
5186 have the sign of the parameter component at the origin. Other complex
5187 elementary functions have zero components whose sign is opposite that of
5188 a parameter component at the origin, or is always positive or always
5189 negative.
5190 @end cartouche
5191 Followed. 
5192
5193 @cindex Accuracy requirements
5194 @item G.2.4(19): Accuracy Requirements
5195 @sp 1
5196 @cartouche
5197 The versions of the forward trigonometric functions without a
5198 @code{Cycle} parameter should not be implemented by calling the
5199 corresponding version with a @code{Cycle} parameter of
5200 @code{2.0*Numerics.Pi}, since this will not provide the required
5201 accuracy in some portions of the domain. For the same reason, the
5202 version of @code{Log} without a @code{Base} parameter should not be
5203 implemented by calling the corresponding version with a @code{Base}
5204 parameter of @code{Numerics.e}.
5205 @end cartouche
5206 Followed. 
5207
5208 @cindex Complex arithmetic accuracy
5209 @cindex Accuracy, complex arithmetic
5210 @item G.2.6(15): Complex Arithmetic Accuracy
5211
5212 @sp 1
5213 @cartouche
5214 The version of the @code{Compose_From_Polar} function without a
5215 @code{Cycle} parameter should not be implemented by calling the
5216 corresponding version with a @code{Cycle} parameter of
5217 @code{2.0*Numerics.Pi}, since this will not provide the required
5218 accuracy in some portions of the domain.
5219 @end cartouche
5220 Followed.
5221
5222 @end table
5223 @node Implementation Defined Characteristics
5224 @chapter Implementation Defined Characteristics
5225 In addition to the implementation dependent pragmas and attributes, and
5226 the implementation advice, there are a number of other features of Ada
5227 95 that are potentially implementation dependent. These are mentioned
5228 throughout the Ada 95 Reference Manual, and are summarized in annex M.
5229
5230 A requirement for conforming Ada compilers is that they provide
5231 documentation describing how the implementation deals with each of these
5232 issues. In this chapter, you will find each point in annex M listed
5233 followed by a description in italic font of how GNAT
5234 @c SGI info:
5235 @ignore
5236 in the ProDev Ada
5237 implementation on IRIX 5.3 operating system or greater 
5238 @end ignore
5239 handles the implementation dependence.
5240
5241 You can use this chapter as a guide to minimizing implementation
5242 dependent features in your programs if portability to other compilers
5243 and other operating systems is an important consideration.  The numbers
5244 in each section below correspond to the paragraph number in the Ada 95
5245 Reference Manual.
5246
5247 @sp 1
5248 @cartouche
5249 @noindent
5250 @strong{2}.  Whether or not each recommendation given in Implementation
5251 Advice is followed. See 1.1.2(37).
5252 @end cartouche
5253 @noindent
5254 @xref{Implementation Advice}.
5255
5256 @sp 1
5257 @cartouche
5258 @noindent
5259 @strong{3}.  Capacity limitations of the implementation. See 1.1.3(3).
5260 @end cartouche
5261 @noindent
5262 The complexity of programs that can be processed is limited only by the
5263 total amount of available virtual memory, and disk space for the
5264 generated object files.
5265
5266 @sp 1
5267 @cartouche
5268 @noindent
5269 @strong{4}.  Variations from the standard that are impractical to avoid
5270 given the implementation's execution environment. See 1.1.3(6).
5271 @end cartouche
5272 @noindent
5273 There are no variations from the standard.
5274
5275 @sp 1
5276 @cartouche
5277 @noindent
5278 @strong{5}.  Which @code{code_statement}s cause external
5279 interactions. See 1.1.3(10).
5280 @end cartouche
5281 @noindent
5282 Any @code{code_statement} can potentially cause external interactions.
5283
5284 @sp 1
5285 @cartouche
5286 @noindent
5287 @strong{6}.  The coded representation for the text of an Ada
5288 program. See 2.1(4).
5289 @end cartouche
5290 @noindent
5291 See separate section on source representation.
5292
5293 @sp 1
5294 @cartouche
5295 @noindent
5296 @strong{7}.  The control functions allowed in comments. See 2.1(14).
5297 @end cartouche
5298 @noindent
5299 See separate section on source representation.
5300
5301 @sp 1
5302 @cartouche
5303 @noindent
5304 @strong{8}.  The representation for an end of line. See 2.2(2).
5305 @end cartouche
5306 @noindent
5307 See separate section on source representation.
5308
5309 @sp 1
5310 @cartouche
5311 @noindent
5312 @strong{9}.  Maximum supported line length and lexical element
5313 length. See 2.2(15).
5314 @end cartouche
5315 @noindent
5316 The maximum line length is 255 characters an the maximum length of a
5317 lexical element is also 255 characters.
5318
5319 @sp 1
5320 @cartouche
5321 @noindent
5322 @strong{10}.  Implementation defined pragmas. See 2.8(14).
5323 @end cartouche
5324 @noindent
5325
5326 @xref{Implementation Defined Pragmas}.
5327
5328 @sp 1
5329 @cartouche
5330 @noindent
5331 @strong{11}.  Effect of pragma @code{Optimize}. See 2.8(27).
5332 @end cartouche
5333 @noindent
5334 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
5335 parameter, checks that the optimization flag is set, and aborts if it is
5336 not.
5337
5338 @sp 1
5339 @cartouche
5340 @noindent
5341 @strong{12}.  The sequence of characters of the value returned by
5342 @code{@var{S}'Image} when some of the graphic characters of
5343 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
5344 3.5(37).
5345 @end cartouche
5346 @noindent
5347 The sequence of characters is as defined by the wide character encoding
5348 method used for the source. See section on source representation for
5349 further details.
5350
5351 @sp 1
5352 @cartouche
5353 @noindent
5354 @strong{13}.  The predefined integer types declared in
5355 @code{Standard}. See 3.5.4(25).
5356 @end cartouche
5357 @noindent
5358 @table @code
5359 @item Short_Short_Integer
5360 8 bit signed
5361 @item Short_Integer
5362 (Short) 16 bit signed
5363 @item Integer
5364 32 bit signed
5365 @item Long_Integer
5366 64 bit signed (Alpha OpenVMS only)
5367 32 bit signed (all other targets)
5368 @item Long_Long_Integer
5369 64 bit signed
5370 @end table
5371
5372 @sp 1
5373 @cartouche
5374 @noindent
5375 @strong{14}.  Any nonstandard integer types and the operators defined
5376 for them. See 3.5.4(26).
5377 @end cartouche
5378 @noindent
5379 There are no nonstandard integer types. 
5380
5381 @sp 1
5382 @cartouche
5383 @noindent
5384 @strong{15}.  Any nonstandard real types and the operators defined for
5385 them. See 3.5.6(8).
5386 @end cartouche
5387 @noindent
5388 There are no nonstandard real types. 
5389
5390 @sp 1
5391 @cartouche
5392 @noindent
5393 @strong{16}.  What combinations of requested decimal precision and range
5394 are supported for floating point types. See 3.5.7(7).
5395 @end cartouche
5396 @noindent
5397 The precision and range is as defined by the IEEE standard. 
5398
5399 @sp 1
5400 @cartouche
5401 @noindent
5402 @strong{17}.  The predefined floating point types declared in
5403 @code{Standard}. See 3.5.7(16).
5404 @end cartouche
5405 @noindent
5406 @table @code
5407 @item Short_Float 
5408 32 bit IEEE short
5409 @item Float 
5410 (Short) 32 bit IEEE short 
5411 @item Long_Float 
5412 64 bit IEEE long 
5413 @item Long_Long_Float 
5414 64 bit IEEE long (80 bit IEEE long on x86 processors)
5415 @end table
5416
5417 @sp 1
5418 @cartouche
5419 @noindent
5420 @strong{18}.  The small of an ordinary fixed point type. See 3.5.9(8).
5421 @end cartouche
5422 @noindent
5423 @code{Fine_Delta} is 2**(-63) 
5424
5425 @sp 1
5426 @cartouche
5427 @noindent
5428 @strong{19}.  What combinations of small, range, and digits are
5429 supported for fixed point types. See 3.5.9(10).
5430 @end cartouche
5431 @noindent
5432 Any combinations are permitted that do not result in a small less than
5433 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
5434 If the mantissa is larger than 53 bits on machines where Long_Long_Float
5435 is 64 bits (true of all architectures except ia32), then the output from
5436 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
5437 is because floating-point conversions are used to convert fixed point.
5438
5439 @sp 1
5440 @cartouche
5441 @noindent
5442 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
5443 within an unnamed @code{block_statement}. See 3.9(10).
5444 @end cartouche
5445 @noindent
5446 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
5447 decimal integer are allocated.
5448
5449 @sp 1
5450 @cartouche
5451 @noindent
5452 @strong{21}.  Implementation-defined attributes. See 4.1.4(12).
5453 @end cartouche
5454 @noindent
5455 @xref{Implementation Defined Attributes}.
5456
5457 @sp 1
5458 @cartouche
5459 @noindent
5460 @strong{22}.  Any implementation-defined time types. See 9.6(6).
5461 @end cartouche
5462 @noindent
5463 There are no implementation-defined time types. 
5464
5465 @sp 1
5466 @cartouche
5467 @noindent
5468 @strong{23}.  The time base associated with relative delays.
5469 @end cartouche
5470 @noindent
5471 See 9.6(20). The time base used is that provided by the C library
5472 function @code{gettimeofday}.
5473
5474 @sp 1
5475 @cartouche
5476 @noindent
5477 @strong{24}.  The time base of the type @code{Calendar.Time}. See
5478 9.6(23).
5479 @end cartouche
5480 @noindent
5481 The time base used is that provided by the C library function
5482 @code{gettimeofday}.
5483
5484 @sp 1
5485 @cartouche
5486 @noindent
5487 @strong{25}.  The time zone used for package @code{Calendar}
5488 operations. See 9.6(24).
5489 @end cartouche
5490 @noindent
5491 The time zone used by package @code{Calendar} is the current system time zone
5492 setting for local time, as accessed by the C library function
5493 @code{localtime}.
5494
5495 @sp 1
5496 @cartouche
5497 @noindent
5498 @strong{26}.  Any limit on @code{delay_until_statements} of
5499 @code{select_statements}. See 9.6(29).
5500 @end cartouche
5501 @noindent
5502 There are no such limits. 
5503
5504 @sp 1
5505 @cartouche
5506 @noindent
5507 @strong{27}.  Whether or not two non overlapping parts of a composite
5508 object are independently addressable, in the case where packing, record
5509 layout, or @code{Component_Size} is specified for the object. See
5510 9.10(1).
5511 @end cartouche
5512 @noindent
5513 Separate components are independently addressable if they do not share
5514 overlapping storage units.
5515
5516 @sp 1
5517 @cartouche
5518 @noindent
5519 @strong{28}.  The representation for a compilation. See 10.1(2).
5520 @end cartouche
5521 @noindent
5522 A compilation is represented by a sequence of files presented to the
5523 compiler in a single invocation of the @file{gcc} command.
5524
5525 @sp 1
5526 @cartouche
5527 @noindent
5528 @strong{29}.  Any restrictions on compilations that contain multiple
5529 compilation_units. See 10.1(4).
5530 @end cartouche
5531 @noindent
5532 No single file can contain more than one compilation unit, but any
5533 sequence of files can be presented to the compiler as a single
5534 compilation.
5535
5536 @sp 1
5537 @cartouche
5538 @noindent
5539 @strong{30}.  The mechanisms for creating an environment and for adding
5540 and replacing compilation units. See 10.1.4(3).
5541 @end cartouche
5542 @noindent
5543 See separate section on compilation model. 
5544
5545 @sp 1
5546 @cartouche
5547 @noindent
5548 @strong{31}.  The manner of explicitly assigning library units to a
5549 partition. See 10.2(2).
5550 @end cartouche
5551 @noindent
5552 If a unit contains an Ada main program, then the Ada units for the partition
5553 are determined by recursive application of the rules in the Ada Reference
5554 Manual section 10.2(2-6). In other words, the Ada units will be those that
5555 are needed by the main program, and then this definition of need is applied
5556 recursively to those units, and the partition contains the transitive
5557 closure determined by this relationship. In short, all the necessary units
5558 are included, with no need to explicitly specify the list. If additional
5559 units are required, e.g. by foreign language units, then all units must be
5560 mentioned in the context clause of one of the needed Ada units.
5561
5562 If the partition contains no main program, or if the main program is in
5563 a language other than Ada, then GNAT 
5564 provides the binder options -z and -n respectively, and in this case a
5565 list of units can be explicitly supplied to the binder for inclusion in
5566 the partition (all units needed by these units will also be included
5567 automatically). For full details on the use of these options, refer to
5568 the User Guide sections on Binding and Linking.
5569
5570 @sp 1
5571 @cartouche
5572 @noindent
5573 @strong{32}.  The implementation-defined means, if any, of specifying
5574 which compilation units are needed by a given compilation unit. See
5575 10.2(2).
5576 @end cartouche
5577 @noindent
5578 The units needed by a given compilation unit are as defined in
5579 the Ada Reference Manual section 10.2(2-6). There are no 
5580 implementation-defined pragmas or other implementation-defined
5581 means for specifying needed units.
5582
5583 @sp 1
5584 @cartouche
5585 @noindent
5586 @strong{33}.  The manner of designating the main subprogram of a
5587 partition. See 10.2(7).
5588 @end cartouche
5589 @noindent
5590 The main program is designated by providing the name of the
5591 corresponding ali file as the input parameter to the binder.
5592
5593 @sp 1
5594 @cartouche
5595 @noindent
5596 @strong{34}.  The order of elaboration of @code{library_items}. See
5597 10.2(18).
5598 @end cartouche
5599 @noindent
5600 The first constraint on ordering is that it meets the requirements of
5601 chapter 10 of the Ada 95 Reference Manual. This still leaves some
5602 implementation dependent choices, which are resolved by first
5603 elaborating bodies as early as possible (i.e. in preference to specs
5604 where there is a choice), and second by evaluating the immediate with
5605 clauses of a unit to determine the probably best choice, and
5606 third by elaborating in alphabetical order of unit names
5607 where a choice still remains.
5608
5609 @sp 1
5610 @cartouche
5611 @noindent
5612 @strong{35}.  Parameter passing and function return for the main
5613 subprogram. See 10.2(21).
5614 @end cartouche
5615 @noindent
5616 The main program has no parameters. It may be a procedure, or a function
5617 returning an integer type. In the latter case, the returned integer
5618 value is the return code of the program.
5619
5620 @sp 1
5621 @cartouche
5622 @noindent
5623 @strong{36}.  The mechanisms for building and running partitions. See
5624 10.2(24).
5625 @end cartouche
5626 @noindent
5627 GNAT itself supports programs with only a single partition. The GNATDIST
5628 tool provided with the GLADE package (which also includes an implementation
5629 of the PCS) provides a completely flexible method for building and running
5630 programs consisting of multiple partitions. See the separate GLADE manual
5631 for details.
5632
5633 @sp 1
5634 @cartouche
5635 @noindent
5636 @strong{37}.  The details of program execution, including program
5637 termination. See 10.2(25).
5638 @end cartouche
5639 @noindent
5640 See separate section on compilation model.
5641
5642 @sp 1
5643 @cartouche
5644 @noindent
5645 @strong{38}.  The semantics of any non-active partitions supported by the
5646 implementation. See 10.2(28).
5647 @end cartouche
5648 @noindent
5649 Passive partitions are supported on targets where shared memory is
5650 provided by the operating system. See the GLADE reference manual for
5651 further details.
5652
5653 @sp 1
5654 @cartouche
5655 @noindent
5656 @strong{39}.  The information returned by @code{Exception_Message}. See
5657 11.4.1(10).
5658 @end cartouche
5659 @noindent
5660 Exception message returns the null string unless a specific message has
5661 been passed by the program.
5662
5663 @sp 1
5664 @cartouche
5665 @noindent
5666 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
5667 declared within an unnamed @code{block_statement}. See 11.4.1(12).
5668 @end cartouche
5669 @noindent
5670 Blocks have implementation defined names of the form @code{B@var{nnn}}
5671 where @var{nnn} is an integer.
5672
5673 @sp 1
5674 @cartouche
5675 @noindent
5676 @strong{41}.  The information returned by
5677 @code{Exception_Information}. See 11.4.1(13).
5678 @end cartouche
5679 @noindent
5680 @code{Exception_Information} contains the expanded name of the exception
5681 in upper case, and no other information.
5682
5683 @sp 1
5684 @cartouche
5685 @noindent
5686 @strong{42}.  Implementation-defined check names. See 11.5(27).
5687 @end cartouche
5688 @noindent
5689 No implementation-defined check names are supported. 
5690
5691 @sp 1
5692 @cartouche
5693 @noindent
5694 @strong{43}.  The interpretation of each aspect of representation. See
5695 13.1(20).
5696 @end cartouche
5697 @noindent
5698 See separate section on data representations.
5699
5700 @sp 1
5701 @cartouche
5702 @noindent
5703 @strong{44}.  Any restrictions placed upon representation items. See
5704 13.1(20).
5705 @end cartouche
5706 @noindent
5707 See separate section on data representations.
5708
5709 @sp 1
5710 @cartouche
5711 @noindent
5712 @strong{45}.  The meaning of @code{Size} for indefinite subtypes. See
5713 13.3(48).
5714 @end cartouche
5715 @noindent
5716 Size for an indefinite subtype is the maximum possible size, except that
5717 for the case of a subprogram parameter, the size of the parameter object
5718 is the actual size.
5719
5720 @sp 1
5721 @cartouche
5722 @noindent
5723 @strong{46}.  The default external representation for a type tag. See
5724 13.3(75).
5725 @end cartouche
5726 @noindent
5727 The default external representation for a type tag is the fully expanded
5728 name of the type in upper case letters.
5729
5730 @sp 1
5731 @cartouche
5732 @noindent
5733 @strong{47}.  What determines whether a compilation unit is the same in
5734 two different partitions. See 13.3(76).
5735 @end cartouche
5736 @noindent
5737 A compilation unit is the same in two different partitions if and only
5738 if it derives from the same source file.
5739
5740 @sp 1
5741 @cartouche
5742 @noindent
5743 @strong{48}.  Implementation-defined components. See 13.5.1(15).
5744 @end cartouche
5745 @noindent
5746 The only implementation defined component is the tag for a tagged type,
5747 which contains a pointer to the dispatching table.
5748
5749 @sp 1
5750 @cartouche
5751 @noindent
5752 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
5753 ordering. See 13.5.3(5).
5754 @end cartouche
5755 @noindent
5756 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
5757 implementation, so no non-default bit ordering is supported. The default
5758 bit ordering corresponds to the natural endianness of the target architecture.
5759
5760 @sp 1
5761 @cartouche
5762 @noindent
5763 @strong{50}.  The contents of the visible part of package @code{System}
5764 and its language-defined children. See 13.7(2).
5765 @end cartouche
5766 @noindent
5767 See the definition of these packages in files @file{system.ads} and
5768 @file{s-stoele.ads}.
5769
5770 @sp 1
5771 @cartouche
5772 @noindent
5773 @strong{51}.  The contents of the visible part of package
5774 @code{System.Machine_Code}, and the meaning of
5775 @code{code_statements}. See 13.8(7).
5776 @end cartouche
5777 @noindent
5778 See the definition and documentation in file @file{s-maccod.ads}.
5779
5780 @sp 1
5781 @cartouche
5782 @noindent
5783 @strong{52}.  The effect of unchecked conversion. See 13.9(11).
5784 @end cartouche
5785 @noindent
5786 Unchecked conversion between types of the same size
5787 and results in an uninterpreted transmission of the bits from one type
5788 to the other. If the types are of unequal sizes, then in the case of
5789 discrete types, a shorter source is first zero or sign extended as
5790 necessary, and a shorter target is simply truncated on the left.
5791 For all non-discrete types, the source is first copied if necessary
5792 to ensure that the alignment requirements of the target are met, then
5793 a pointer is constructed to the source value, and the result is obtained
5794 by dereferencing this pointer after converting it to be a pointer to the
5795 target type.
5796
5797 @sp 1
5798 @cartouche
5799 @noindent
5800 @strong{53}.  The manner of choosing a storage pool for an access type
5801 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
5802 @end cartouche
5803 @noindent
5804 There are 3 different standard pools used by the compiler when
5805 @code{Storage_Pool} is not specified depending whether the type is local
5806 to a subprogram or defined at the library level and whether
5807 @code{Storage_Size}is specified or not. See documentation in the runtime
5808 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
5809 @code{System.Pool_Local} in files @file{s-poosiz.ads},
5810 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
5811 default pools used.
5812
5813 @sp 1
5814 @cartouche
5815 @noindent
5816 @strong{54}.  Whether or not the implementation provides user-accessible
5817 names for the standard pool type(s). See 13.11(17).
5818 @end cartouche
5819 @noindent
5820
5821 See documentation in the sources of the run time mentioned in paragraph
5822 @strong{53} . All these pools are accessible by means of @code{with}'ing
5823 these units.
5824
5825 @sp 1
5826 @cartouche
5827 @noindent
5828 @strong{55}.  The meaning of @code{Storage_Size}. See 13.11(18).
5829 @end cartouche
5830 @noindent
5831 @code{Storage_Size} is measured in storage units, and refers to the
5832 total space available for an access type collection, or to the primary
5833 stack space for a task.
5834
5835 @sp 1
5836 @cartouche
5837 @noindent
5838 @strong{56}.  Implementation-defined aspects of storage pools. See
5839 13.11(22).
5840 @end cartouche
5841 @noindent
5842 See documentation in the sources of the run time mentioned in paragraph
5843 @strong{53} for details on GNAT-defined aspects of storage pools.
5844
5845 @sp 1
5846 @cartouche
5847 @noindent
5848 @strong{57}.  The set of restrictions allowed in a pragma
5849 @code{Restrictions}. See 13.12(7).
5850 @end cartouche
5851 @noindent
5852 All RM defined Restriction identifiers are implemented. The following
5853 additional restriction identifiers are provided. There are two separate
5854 lists of implementation dependent restriction identifiers. The first
5855 set requires consistency throughout a partition (in other words, if the
5856 restriction identifier is used for any compilation unit in the partition,
5857 then all compilation units in the partition must obey the restriction.
5858
5859 @table @code
5860
5861 @item Boolean_Entry_Barriers
5862 @findex Boolean_Entry_Barriers
5863 This restriction ensures at compile time that barriers in entry declarations
5864 for protected types are restricted to references to simple boolean variables
5865 defined in the private part of the protected type. No other form of entry
5866 barriers is permitted. This is one of the restrictions of the Ravenscar
5867 profile for limited tasking (see also pragma Ravenscar).
5868
5869 @item Max_Entry_Queue_Depth => Expr
5870 @findex Max_Entry_Queue_Depth
5871 This restriction is a declaration that any protected entry compiled in
5872 the scope of the restriction has at most the specified number of
5873 tasks waiting on the entry
5874 at any one time, and so no queue is required. This restriction is not
5875 checked at compile time. A program execution is erroneous if an attempt
5876 is made to queue more than the specified number of tasks on such an entry.
5877
5878 @item No_Calendar
5879 @findex No_Calendar
5880 This restriction ensures at compile time that there is no implicit or
5881 explicit dependence on the package @code{Ada.Calendar}.
5882
5883 @item No_Dynamic_Interrupts
5884 @findex No_Dynamic_Interrupts
5885 This restriction ensures at compile time that there is no attempt to
5886 dynamically associate interrupts. Only static association is allowed.
5887
5888 @item No_Enumeration_Maps
5889 @findex No_Enumeration_Maps
5890 This restriction ensures at compile time that no operations requiring
5891 enumeration maps are used (that is Image and Value attributes applied
5892 to enumeration types).
5893
5894 @item No_Entry_Calls_In_Elaboration_Code
5895 @findex No_Entry_Calls_In_Elaboration_Code
5896 This restriction ensures at compile time that no task or protected entry
5897 calls are made during elaboration code. As a result of the use of this
5898 restriction, the compiler can assume that no code past an accept statement
5899 in a task can be executed at elaboration time.
5900
5901 @item No_Exception_Handlers
5902 @findex No_Exception_Handlers
5903 This restriction ensures at compile time that there are no explicit
5904 exception handlers.
5905
5906 @item No_Implicit_Conditionals
5907 @findex No_Implicit_Conditionals
5908 This restriction ensures that the generated code does not contain any
5909 implicit conditionals, either by modifying the generated code where possible,
5910 or by rejecting any construct that would otherwise generate an implicit
5911 conditional. The details and use of this restriction are described in
5912 more detail in the High Integrity product documentation.
5913
5914 @item No_Implicit_Loops
5915 @findex No_Implicit_Loops
5916 This restriction ensures that the generated code does not contain any
5917 implicit @code{for} loops, either by modifying
5918 the generated code where possible,
5919 or by rejecting any construct that would otherwise generate an implicit
5920 @code{for} loop. The details and use of this restriction are described in
5921 more detail in the GNORT Reference Manual.
5922
5923 @item No_Local_Protected_Objects
5924 @findex No_Local_Protected_Objects
5925 This restriction ensures at compile time that protected objects are
5926 only declared at the library level.
5927
5928 @item No_Protected_Type_Allocators
5929 @findex No_Protected_Type_Allocators
5930 This restriction ensures at compile time that there are no allocator
5931 expressions that attempt to allocate protected objects.
5932
5933 @item No_Select_Statements
5934 @findex No_Select_Statements
5935 This restriction ensures at compile time no select statements of any kind
5936 are permitted, that is the keyword @code{select} may not appear. 
5937 This is one of the restrictions of the Ravenscar
5938 profile for limited tasking (see also pragma Ravenscar).
5939
5940 @item No_Standard_Storage_Pools
5941 @findex No_Standard_Storage_Pools
5942 This restriction ensures at compile time that no access types
5943 use the standard default storage pool. Any access type declared must
5944 have an explicit Storage_Pool attribute defined specifying a
5945 user-defined storage pool.
5946
5947 @item No_Streams
5948 @findex No_Streams
5949 This restriction ensures at compile time that there are no implicit or
5950 explicit dependencies on the package @code{Ada.Streams}.
5951
5952 @item No_Task_Attributes
5953 @findex No_Task_Attributes
5954 This restriction ensures at compile time that there are no implicit or
5955 explicit dependencies on the package @code{Ada.Task_Attributes}.
5956
5957 @item No_Task_Termination
5958 @findex No_Task_Termination
5959 This restriction ensures at compile time that no terminate alternatives
5960 appear in any task body.
5961
5962 @item No_Wide_Characters
5963 @findex No_Wide_Characters
5964 This restriction ensures at compile time that no uses of the types
5965 @code{Wide_Character} or @code{Wide_String}
5966 appear, and that no wide character literals
5967 appear in the program (that is literals representing characters not in
5968 type @code{Character}.
5969
5970 @item Static_Priorities
5971 @findex Static_Priorities
5972 This restriction ensures at compile time that all priority expressions
5973 are static, and that there are no dependencies on the package
5974 @code{Ada.Dynamic_Priorities}.
5975
5976 @item Static_Storage_Size
5977 @findex Static_Storage_Size
5978 This restriction ensures at compile time that any expression appearing
5979 in a Storage_Size pragma or attribute definition clause is static.
5980
5981 @end table
5982
5983 @noindent
5984 The second set of implementation dependent restriction identifiers
5985 does not require partition-wide consistency.
5986 The restriction may be enforced for a single
5987 compilation unit without any effect on any of the
5988 other compilation units in the partition.
5989
5990 @table @code
5991
5992 @item No_Elaboration_Code
5993 @findex No_Elaboration_Code
5994 This restriction ensures at compile time that no elaboration code is
5995 generated. Note that this is not the same condition as is enforced
5996 by pragma Preelaborate. There are cases in which pragma Preelaborate
5997 still permits code to be generated (e.g. code to initialize a large
5998 array to all zeroes), and there are cases of units which do not meet
5999 the requirements for pragma Preelaborate, but for which no elaboration
6000 code is generated. Generally, it is the case that preelaborable units
6001 will meet the restrictions, with the exception of large aggregates
6002 initialized with an others_clause, and exception declarations (which
6003 generate calls to a run-time registry procedure). Note that this restriction
6004 is enforced on a unit by unit basis, it need not be obeyed consistently
6005 throughout a partition.
6006
6007 @item No_Entry_Queue
6008 @findex No_Entry_Queue
6009 This restriction is a declaration that any protected entry compiled in
6010 the scope of the restriction has at most one task waiting on the entry
6011 at any one time, and so no queue is required. This restriction is not
6012 checked at compile time. A program execution is erroneous if an attempt
6013 is made to queue a second task on such an entry.
6014
6015 @item No_Implementation_Attributes
6016 @findex No_Implementation_Attributes
6017 This restriction checks at compile time that no GNAT-defined attributes
6018 are present. With this restriction, the only attributes that can be used
6019 are those defined in the Ada 95 Reference Manual.
6020
6021 @item No_Implementation_Pragmas
6022 @findex No_Implementation_Pragmas
6023 This restriction checks at compile time that no GNAT-defined pragmas
6024 are present. With this restriction, the only pragmas that can be used
6025 are those defined in the Ada 95 Reference Manual.
6026
6027 @item No_Implementation_Restrictions
6028 @findex No_Implementation_Restrictions
6029 This restriction checks at compile time that no GNAT-defined restriction
6030 identifiers (other than @code{No_Implementation_Restrictions} itself)
6031 are present. With this restriction, the only other restriction identifiers
6032 that can be used are those defined in the Ada 95 Reference Manual.
6033
6034 @end table
6035
6036 @sp 1
6037 @cartouche
6038 @noindent
6039 @strong{58}.  The consequences of violating limitations on
6040 @code{Restrictions} pragmas. See 13.12(9).
6041 @end cartouche
6042 @noindent
6043 Restrictions that can be checked at compile time result in illegalities
6044 if violated. Currently there are no other consequences of violating
6045 restrictions.
6046
6047 @sp 1
6048 @cartouche
6049 @noindent
6050 @strong{59}.  The representation used by the @code{Read} and
6051 @code{Write} attributes of elementary types in terms of stream
6052 elements. See 13.13.2(9).
6053 @end cartouche
6054 @noindent
6055 The representation is the in-memory representation of the base type of
6056 the type, using the number of bits corresponding to the
6057 @code{@var{type}'Size} value, and the natural ordering of the machine.
6058
6059 @sp 1
6060 @cartouche
6061 @noindent
6062 @strong{60}.  The names and characteristics of the numeric subtypes
6063 declared in the visible part of package @code{Standard}. See A.1(3).
6064 @end cartouche
6065 @noindent
6066 See items describing the integer and floating-point types supported.
6067
6068 @sp 1
6069 @cartouche
6070 @noindent
6071 @strong{61}.  The accuracy actually achieved by the elementary
6072 functions. See A.5.1(1).
6073 @end cartouche
6074 @noindent
6075 The elementary functions correspond to the functions available in the C
6076 library. Only fast math mode is implemented.
6077
6078 @sp 1
6079 @cartouche
6080 @noindent
6081 @strong{62}.  The sign of a zero result from some of the operators or
6082 functions in @code{Numerics.Generic_Elementary_Functions}, when
6083 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
6084 @end cartouche
6085 @noindent
6086 The sign of zeroes follows the requirements of the IEEE 754 standard on
6087 floating-point.
6088
6089 @sp 1
6090 @cartouche
6091 @noindent
6092 @strong{63}.  The value of
6093 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
6094 @end cartouche
6095 @noindent
6096 Maximum image width is 649, see library file @file{a-numran.ads}.
6097
6098 @sp 1
6099 @cartouche
6100 @noindent
6101 @strong{64}.  The value of
6102 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
6103 @end cartouche
6104 @noindent
6105 Maximum image width is 80, see library file @file{a-nudira.ads}.
6106
6107 @sp 1
6108 @cartouche
6109 @noindent
6110 @strong{65}.  The algorithms for random number generation. See
6111 A.5.2(32).
6112 @end cartouche
6113 @noindent
6114 The algorithm is documented in the source files @file{a-numran.ads} and
6115 @file{a-numran.adb}.
6116
6117 @sp 1
6118 @cartouche
6119 @noindent
6120 @strong{66}.  The string representation of a random number generator's
6121 state. See A.5.2(38).
6122 @end cartouche
6123 @noindent
6124 See the documentation contained in the file @file{a-numran.adb}. 
6125
6126 @sp 1
6127 @cartouche
6128 @noindent
6129 @strong{67}.  The minimum time interval between calls to the
6130 time-dependent Reset procedure that are guaranteed to initiate different
6131 random number sequences. See A.5.2(45).
6132 @end cartouche
6133 @noindent
6134 The minimum period between reset calls to guarantee distinct series of
6135 random numbers is one microsecond.
6136
6137 @sp 1
6138 @cartouche
6139 @noindent
6140 @strong{68}.  The values of the @code{Model_Mantissa},
6141 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
6142 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
6143 Annex is not supported. See A.5.3(72).
6144 @end cartouche
6145 @noindent
6146 See the source file @file{ttypef.ads} for the values of all numeric
6147 attributes.
6148
6149 @sp 1
6150 @cartouche
6151 @noindent
6152 @strong{69}.  Any implementation-defined characteristics of the
6153 input-output packages. See A.7(14).
6154 @end cartouche
6155 @noindent
6156 There are no special implementation defined characteristics for these
6157 packages.
6158
6159 @sp 1
6160 @cartouche
6161 @noindent
6162 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}. See
6163 A.9(10).
6164 @end cartouche
6165 @noindent
6166 All type representations are contiguous, and the @code{Buffer_Size} is
6167 the value of @code{@var{type}'Size} rounded up to the next storage unit
6168 boundary.
6169
6170 @sp 1
6171 @cartouche
6172 @noindent
6173 @strong{71}.  External files for standard input, standard output, and
6174 standard error See A.10(5).
6175 @end cartouche
6176 @noindent
6177 These files are mapped onto the files provided by the C streams
6178 libraries. See source file @file{i-cstrea.ads} for further details.
6179
6180 @sp 1
6181 @cartouche
6182 @noindent
6183 @strong{72}.  The accuracy of the value produced by @code{Put}. See
6184 A.10.9(36).
6185 @end cartouche
6186 @noindent
6187 If more digits are requested in the output than are represented by the
6188 precision of the value, zeroes are output in the corresponding least
6189 significant digit positions.
6190
6191 @sp 1
6192 @cartouche
6193 @noindent
6194 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
6195 @code{Command_Name}. See A.15(1).
6196 @end cartouche
6197 @noindent
6198 These are mapped onto the @code{argv} and @code{argc} parameters of the
6199 main program in the natural manner.
6200
6201 @sp 1
6202 @cartouche
6203 @noindent
6204 @strong{74}.  Implementation-defined convention names. See B.1(11).
6205 @end cartouche
6206 @noindent
6207 The following convention names are supported
6208
6209 @table @code
6210 @item  Ada
6211 Ada
6212 @item Asm 
6213 Assembly language 
6214 @item Assembler 
6215 Assembly language 
6216 @item C
6217 C
6218 @item C_Pass_By_Copy
6219 Treated like C, except for record types
6220 @item COBOL 
6221 COBOL 
6222 @item CPP 
6223 C++ 
6224 @item Default
6225 Treated the same as C
6226 @item DLL
6227 DLL (used for Windows implementations only) is handled like the Stdcall
6228 convention. This convention is used to access variables and functions
6229 (with Stdcall convention) in a DLL.
6230 @item Win32
6231 Win32 (used for Windows implementations only) is handled like the Stdcall
6232 convention. This convention is used to access variables and functions
6233 (with Stdcall convention) in a DLL.
6234 @item External
6235 Treated the same as C
6236 @item Fortran 
6237 Fortran 
6238 @item Intrinsic 
6239 For support of pragma @code{Import} with convention Intrinsic, see
6240 separate section on Intrinsic Subprograms.
6241 @item Stdcall 
6242 Stdcall (used for Windows implementations only). This convention correspond
6243 to the WINAPI (previously called Pascal convention) C/C++ convention under
6244 Windows. A function with this convention clean the stack before exit.
6245 @item Stubbed
6246 Stubbed is a special convention used to indicate that the body of the
6247 subprogram will be entirely ignored. Any call to the subprogram
6248 is converted into a raise of the @code{Program_Error} exception. If a
6249 pragma @code{Import} specifies convention @code{stubbed} then no body need
6250 be present at all. This convention is useful during development for the
6251 inclusion of subprograms whose body has not yet been written.
6252
6253 @end table
6254 @noindent
6255 In addition, all otherwise unrecognized convention names are also
6256 treated as being synonymous with convention C. In all implementations
6257 except for VMS, use of such other names results in a warning. In VMS
6258 implementations, these names are accepted silently.
6259
6260 @sp 1
6261 @cartouche
6262 @noindent
6263 @strong{75}.  The meaning of link names. See B.1(36).
6264 @end cartouche
6265 @noindent
6266 Link names are the actual names used by the linker.
6267
6268 @sp 1
6269 @cartouche
6270 @noindent
6271 @strong{76}.  The manner of choosing link names when neither the link
6272 name nor the address of an imported or exported entity is specified. See
6273 B.1(36).
6274 @end cartouche
6275 @noindent
6276 The default linker name is that which would be assigned by the relevant
6277 external language, interpreting the Ada name as being in all lower case
6278 letters.
6279
6280 @sp 1
6281 @cartouche
6282 @noindent
6283 @strong{77}.  The effect of pragma @code{Linker_Options}. See B.1(37).
6284 @end cartouche
6285 @noindent
6286 The string passed to @code{Linker_Options} is presented uninterpreted as
6287 an argument to the link command, unless it contains Ascii.NUL characters.
6288 NUL characters if they appear act as argument separators, so for example
6289
6290 @smallexample
6291 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
6292 @end smallexample
6293
6294 @noindent
6295 causes two separate arguments "-labc" and "-ldef" to be passed to the
6296 linker with a guarantee that the order is preserved (no such guarantee
6297 exists for the use of separate Linker_Options pragmas).
6298
6299 In addition, GNAT allow multiple arguments to @code{Linker_Options}
6300 with exactly the same meaning, so the above pragma could also be
6301 written as:
6302
6303 @smallexample
6304 pragma Linker_Options ("-labc", "-ldef");
6305 @end smallexample
6306
6307 @noindent
6308 The above multiple argument form is a GNAT extension.
6309
6310 @sp 1
6311 @cartouche
6312 @noindent
6313 @strong{78}.  The contents of the visible part of package
6314 @code{Interfaces} and its language-defined descendants. See B.2(1).
6315 @end cartouche
6316 @noindent
6317 See files with prefix @file{i-} in the distributed library.
6318
6319 @sp 1
6320 @cartouche
6321 @noindent
6322 @strong{79}.  Implementation-defined children of package
6323 @code{Interfaces}. The contents of the visible part of package
6324 @code{Interfaces}. See B.2(11).
6325 @end cartouche
6326 @noindent
6327 See files with prefix @file{i-} in the distributed library.
6328
6329 @sp 1
6330 @cartouche
6331 @noindent
6332 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
6333 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
6334 @code{COBOL_Character}; and the initialization of the variables
6335 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
6336 @code{Interfaces.COBOL}. See B.4(50).
6337 @end cartouche
6338 @noindent
6339 @table @code
6340 @item Floating
6341 Float
6342 @item Long_Floating 
6343 (Floating) Long_Float 
6344 @item Binary 
6345 Integer 
6346 @item Long_Binary 
6347 Long_Long_Integer 
6348 @item Decimal_Element 
6349 Character 
6350 @item COBOL_Character 
6351 Character 
6352 @end table
6353
6354 For initialization, see the file @file{i-cobol.ads} in the distributed library.
6355
6356 @sp 1
6357 @cartouche
6358 @noindent
6359 @strong{81}.  Support for access to machine instructions. See C.1(1).
6360 @end cartouche
6361 @noindent
6362 See documentation in file @file{s-maccod.ads} in the distributed library.
6363
6364 @sp 1
6365 @cartouche
6366 @noindent
6367 @strong{82}.  Implementation-defined aspects of access to machine
6368 operations. See C.1(9).
6369 @end cartouche
6370 @noindent
6371 See documentation in file @file{s-maccod.ads} in the distributed library.
6372
6373 @sp 1
6374 @cartouche
6375 @noindent
6376 @strong{83}.  Implementation-defined aspects of interrupts. See C.3(2).
6377 @end cartouche
6378 @noindent
6379 Interrupts are mapped to signals or conditions as appropriate. See
6380 definition of unit
6381 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
6382 on the interrupts supported on a particular target.
6383
6384 @sp 1
6385 @cartouche
6386 @noindent
6387 @strong{84}.  Implementation-defined aspects of pre-elaboration. See
6388 C.4(13).
6389 @end cartouche
6390 @noindent
6391 GNAT does not permit a partition to be restarted without reloading,
6392 except under control of the debugger.
6393
6394 @sp 1
6395 @cartouche
6396 @noindent
6397 @strong{85}.  The semantics of pragma @code{Discard_Names}. See C.5(7).
6398 @end cartouche
6399 @noindent
6400 Pragma @code{Discard_Names} causes names of enumeration literals to
6401 be suppressed. In the presence of this pragma, the Image attribute 
6402 provides the image of the Pos of the literal, and Value accepts
6403 Pos values.
6404
6405 @sp 1
6406 @cartouche
6407 @noindent
6408 @strong{86}.  The result of the @code{Task_Identification.Image}
6409 attribute. See C.7.1(7).
6410 @end cartouche
6411 @noindent
6412 The result of this attribute is an 8-digit hexadecimal string
6413 representing the virtual address of the task control block.
6414
6415 @sp 1
6416 @cartouche
6417 @noindent
6418 @strong{87}.  The value of @code{Current_Task} when in a protected entry
6419 or interrupt handler. See C.7.1(17).
6420 @end cartouche
6421 @noindent
6422 Protected entries or interrupt handlers can be executed by any
6423 convenient thread, so the value of @code{Current_Task} is undefined.
6424
6425 @sp 1
6426 @cartouche
6427 @noindent
6428 @strong{88}.  The effect of calling @code{Current_Task} from an entry
6429 body or interrupt handler. See C.7.1(19).
6430 @end cartouche
6431 @noindent
6432 The effect of calling @code{Current_Task} from an entry body or
6433 interrupt handler is to return the identification of the task currently
6434 executing the code.
6435
6436 @sp 1
6437 @cartouche
6438 @noindent
6439 @strong{89}.  Implementation-defined aspects of
6440 @code{Task_Attributes}. See C.7.2(19).
6441 @end cartouche
6442 @noindent
6443 There are no implementation-defined aspects of @code{Task_Attributes}.
6444
6445 @sp 1
6446 @cartouche
6447 @noindent
6448 @strong{90}.  Values of all @code{Metrics}. See D(2).
6449 @end cartouche
6450 @noindent
6451 The metrics information for GNAT depends on the performance of the
6452 underlying operating system. The sources of the run-time for tasking
6453 implementation, together with the output from @code{-gnatG} can be
6454 used to determine the exact sequence of operating systems calls made
6455 to implement various tasking constructs. Together with appropriate
6456 information on the performance of the underlying operating system,
6457 on the exact target in use, this information can be used to determine
6458 the required metrics.
6459
6460 @sp 1
6461 @cartouche
6462 @noindent
6463 @strong{91}.  The declarations of @code{Any_Priority} and
6464 @code{Priority}. See D.1(11).
6465 @end cartouche
6466 @noindent
6467 See declarations in file @file{system.ads}.
6468
6469 @sp 1
6470 @cartouche
6471 @noindent
6472 @strong{92}.  Implementation-defined execution resources. See D.1(15).
6473 @end cartouche
6474 @noindent
6475 There are no implementation-defined execution resources.
6476
6477 @sp 1
6478 @cartouche
6479 @noindent
6480 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
6481 access to a protected object keeps its processor busy. See D.2.1(3).
6482 @end cartouche
6483 @noindent
6484 On a multi-processor, a task that is waiting for access to a protected
6485 object does not keep its processor busy.
6486
6487 @sp 1
6488 @cartouche
6489 @noindent
6490 @strong{94}.  The affect of implementation defined execution resources
6491 on task dispatching. See D.2.1(9).
6492 @end cartouche
6493 @noindent
6494 @c SGI info
6495 @ignore
6496 Tasks map to IRIX threads, and the dispatching policy is as defined by
6497 the IRIX implementation of threads.
6498 @end ignore
6499 Tasks map to threads in the threads package used by GNAT. Where possible
6500 and appropriate, these threads correspond to native threads of the
6501 underlying operating system.
6502
6503 @sp 1
6504 @cartouche
6505 @noindent
6506 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
6507 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
6508 @end cartouche
6509 @noindent
6510 There are no implementation-defined policy-identifiers allowed in this
6511 pragma.
6512
6513 @sp 1
6514 @cartouche
6515 @noindent
6516 @strong{96}.  Implementation-defined aspects of priority inversion. See
6517 D.2.2(16).
6518 @end cartouche
6519 @noindent
6520 Execution of a task cannot be preempted by the implementation processing
6521 of delay expirations for lower priority tasks.
6522
6523 @sp 1
6524 @cartouche
6525 @noindent
6526 @strong{97}.  Implementation defined task dispatching. See D.2.2(18).
6527 @end cartouche
6528 @noindent
6529 @c SGI info:
6530 @ignore
6531 Tasks map to IRIX threads, and the dispatching policy is as defied by
6532 the IRIX implementation of threads.
6533 @end ignore
6534 The policy is the same as that of the underlying threads implementation.
6535
6536 @sp 1
6537 @cartouche
6538 @noindent
6539 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
6540 in a pragma @code{Locking_Policy}. See D.3(4).
6541 @end cartouche
6542 @noindent
6543 The only implementation defined policy permitted in GNAT is
6544 @code{Inheritance_Locking}. On targets that support this policy, locking
6545 is implemented by inheritance, i.e. the task owning the lock operates
6546 at a priority equal to the highest priority of any task currently
6547 requesting the lock.
6548
6549 @sp 1
6550 @cartouche
6551 @noindent
6552 @strong{99}.  Default ceiling priorities. See D.3(10).
6553 @end cartouche
6554 @noindent
6555 The ceiling priority of protected objects of the type
6556 @code{System.Interrupt_Priority'Last} as described in the Ada 95
6557 Reference Manual D.3(10),
6558
6559 @sp 1
6560 @cartouche
6561 @noindent
6562 @strong{100}.  The ceiling of any protected object used internally by
6563 the implementation. See D.3(16).
6564 @end cartouche
6565 @noindent
6566 The ceiling priority of internal protected objects is
6567 @code{System.Priority'Last}.
6568
6569 @sp 1
6570 @cartouche
6571 @noindent
6572 @strong{101}.  Implementation-defined queuing policies. See D.4(1).
6573 @end cartouche
6574 @noindent
6575 There are no implementation-defined queueing policies. 
6576
6577 @sp 1
6578 @cartouche
6579 @noindent
6580 @strong{102}.  On a multiprocessor, any conditions that cause the
6581 completion of an aborted construct to be delayed later than what is
6582 specified for a single processor. See D.6(3).
6583 @end cartouche
6584 @noindent
6585 The semantics for abort on a multi-processor is the same as on a single
6586 processor, there are no further delays.
6587
6588 @sp 1
6589 @cartouche
6590 @noindent
6591 @strong{103}.  Any operations that implicitly require heap storage
6592 allocation. See D.7(8).
6593 @end cartouche
6594 @noindent
6595 The only operation that implicitly requires heap storage allocation is
6596 task creation.
6597
6598 @sp 1
6599 @cartouche
6600 @noindent
6601 @strong{104}.  Implementation-defined aspects of pragma
6602 @code{Restrictions}. See D.7(20).
6603 @end cartouche
6604 @noindent
6605 There are no such implementation-defined aspects. 
6606
6607 @sp 1
6608 @cartouche
6609 @noindent
6610 @strong{105}.  Implementation-defined aspects of package
6611 @code{Real_Time}. See D.8(17).
6612 @end cartouche
6613 @noindent
6614 There are no implementation defined aspects of package @code{Real_Time}.
6615
6616 @sp 1
6617 @cartouche
6618 @noindent
6619 @strong{106}.  Implementation-defined aspects of
6620 @code{delay_statements}. See D.9(8).
6621 @end cartouche
6622 @noindent
6623 Any difference greater than one microsecond will cause the task to be
6624 delayed (see D.9(7)).
6625
6626 @sp 1
6627 @cartouche
6628 @noindent
6629 @strong{107}.  The upper bound on the duration of interrupt blocking
6630 caused by the implementation. See D.12(5).
6631 @end cartouche
6632 @noindent
6633 The upper bound is determined by the underlying operating system. In
6634 no cases is it more than 10 milliseconds.
6635
6636 @sp 1
6637 @cartouche
6638 @noindent
6639 @strong{108}.  The means for creating and executing distributed
6640 programs. See E(5).
6641 @end cartouche
6642 @noindent
6643 The GLADE package provides a utility GNATDIST for creating and executing
6644 distributed programs. See the GLADE reference manual for further details.
6645
6646 @sp 1
6647 @cartouche
6648 @noindent
6649 @strong{109}.  Any events that can result in a partition becoming
6650 inaccessible. See E.1(7).
6651 @end cartouche
6652 @noindent
6653 See the GLADE reference manual for full details on such events.
6654
6655 @sp 1
6656 @cartouche
6657 @noindent
6658 @strong{110}.  The scheduling policies, treatment of priorities, and
6659 management of shared resources between partitions in certain cases. See
6660 E.1(11).
6661 @end cartouche
6662 @noindent
6663 See the GLADE reference manual for full details on these aspects of
6664 multi-partition execution.
6665
6666 @sp 1
6667 @cartouche
6668 @noindent
6669 @strong{111}.  Events that cause the version of a compilation unit to
6670 change. See E.3(5).
6671 @end cartouche
6672 @noindent
6673 Editing the source file of a compilation unit, or the source files of
6674 any units on which it is dependent in a significant way cause the version
6675 to change. No other actions cause the version number to change. All changes
6676 are significant except those which affect only layout, capitalization or
6677 comments.
6678
6679 @sp 1
6680 @cartouche
6681 @noindent
6682 @strong{112}.  Whether the execution of the remote subprogram is
6683 immediately aborted as a result of cancellation. See E.4(13).
6684 @end cartouche
6685 @noindent
6686 See the GLADE reference manual for details on the effect of abort in
6687 a distributed application.
6688
6689 @sp 1
6690 @cartouche
6691 @noindent
6692 @strong{113}.  Implementation-defined aspects of the PCS. See E.5(25).
6693 @end cartouche
6694 @noindent
6695 See the GLADE reference manual for a full description of all implementation
6696 defined aspects of the PCS.
6697
6698 @sp 1
6699 @cartouche
6700 @noindent
6701 @strong{114}.  Implementation-defined interfaces in the PCS. See
6702 E.5(26).
6703 @end cartouche
6704 @noindent
6705 See the GLADE reference manual for a full description of all
6706 implementation defined interfaces.
6707
6708 @sp 1
6709 @cartouche
6710 @noindent
6711 @strong{115}.  The values of named numbers in the package
6712 @code{Decimal}. See F.2(7).
6713 @end cartouche
6714 @noindent
6715 @table @code
6716 @item Max_Scale
6717 +18
6718 @item Min_Scale
6719 -18
6720 @item Min_Delta
6721 1.0E-18
6722 @item Max_Delta
6723 1.0E+18
6724 @item Max_Decimal_Digits
6725 18
6726 @end table
6727
6728 @sp 1
6729 @cartouche
6730 @noindent
6731 @strong{116}.  The value of @code{Max_Picture_Length} in the package
6732 @code{Text_IO.Editing}. See F.3.3(16).
6733 @end cartouche
6734 @noindent
6735 64
6736
6737 @sp 1
6738 @cartouche
6739 @noindent
6740 @strong{117}.  The value of @code{Max_Picture_Length} in the package
6741 @code{Wide_Text_IO.Editing}. See F.3.4(5).
6742 @end cartouche
6743 @noindent
6744 64
6745
6746 @sp 1
6747 @cartouche
6748 @noindent
6749 @strong{118}.  The accuracy actually achieved by the complex elementary
6750 functions and by other complex arithmetic operations. See G.1(1).
6751 @end cartouche
6752 @noindent
6753 Standard library functions are used for the complex arithmetic
6754 operations. Only fast math mode is currently supported.
6755
6756 @sp 1
6757 @cartouche
6758 @noindent
6759 @strong{119}.  The sign of a zero result (or a component thereof) from
6760 any operator or function in @code{Numerics.Generic_Complex_Types}, when
6761 @code{Real'Signed_Zeros} is True. See G.1.1(53).
6762 @end cartouche
6763 @noindent
6764 The signs of zero values are as recommended by the relevant
6765 implementation advice.
6766
6767 @sp 1
6768 @cartouche
6769 @noindent
6770 @strong{120}.  The sign of a zero result (or a component thereof) from
6771 any operator or function in
6772 @code{Numerics.Generic_Complex_Elementary_Functions}, when
6773 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
6774 @end cartouche
6775 @noindent
6776 The signs of zero values are as recommended by the relevant
6777 implementation advice.
6778
6779 @sp 1
6780 @cartouche
6781 @noindent
6782 @strong{121}.  Whether the strict mode or the relaxed mode is the
6783 default. See G.2(2).
6784 @end cartouche
6785 @noindent
6786 The strict mode is the default. There is no separate relaxed mode. GNAT
6787 provides a highly efficient implementation of strict mode.
6788
6789 @sp 1
6790 @cartouche
6791 @noindent
6792 @strong{122}.  The result interval in certain cases of fixed-to-float
6793 conversion. See G.2.1(10).
6794 @end cartouche
6795 @noindent
6796 For cases where the result interval is implementation dependent, the
6797 accuracy is that provided by performing all operations in 64-bit IEEE
6798 floating-point format.
6799
6800 @sp 1
6801 @cartouche
6802 @noindent
6803 @strong{123}.  The result of a floating point arithmetic operation in
6804 overflow situations, when the @code{Machine_Overflows} attribute of the
6805 result type is @code{False}. See G.2.1(13).
6806 @end cartouche
6807 @noindent
6808 Infinite and Nan values are produced as dictated by the IEEE
6809 floating-point standard.
6810
6811 @sp 1
6812 @cartouche
6813 @noindent
6814 @strong{124}.  The result interval for division (or exponentiation by a
6815 negative exponent), when the floating point hardware implements division
6816 as multiplication by a reciprocal. See G.2.1(16).
6817 @end cartouche
6818 @noindent
6819 Not relevant, division is IEEE exact. 
6820
6821 @sp 1
6822 @cartouche
6823 @noindent
6824 @strong{125}.  The definition of close result set, which determines the
6825 accuracy of certain fixed point multiplications and divisions. See
6826 G.2.3(5).
6827 @end cartouche
6828 @noindent
6829 Operations in the close result set are performed using IEEE long format
6830 floating-point arithmetic. The input operands are converted to
6831 floating-point, the operation is done in floating-point, and the result
6832 is converted to the target type.
6833
6834 @sp 1
6835 @cartouche
6836 @noindent
6837 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
6838 point multiplication or division for which the result shall be in the
6839 perfect result set. See G.2.3(22).
6840 @end cartouche
6841 @noindent
6842 The result is only defined to be in the perfect result set if the result
6843 can be computed by a single scaling operation involving a scale factor
6844 representable in 64-bits.
6845
6846 @sp 1
6847 @cartouche
6848 @noindent
6849 @strong{127}.  The result of a fixed point arithmetic operation in
6850 overflow situations, when the @code{Machine_Overflows} attribute of the
6851 result type is @code{False}. See G.2.3(27).
6852 @end cartouche
6853 @noindent
6854 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
6855 types.
6856
6857 @sp 1
6858 @cartouche
6859 @noindent
6860 @strong{128}.  The result of an elementary function reference in
6861 overflow situations, when the @code{Machine_Overflows} attribute of the
6862 result type is @code{False}. See G.2.4(4).
6863 @end cartouche
6864 @noindent
6865 IEEE infinite and Nan values are produced as appropriate.
6866
6867 @sp 1
6868 @cartouche
6869 @noindent
6870 @strong{129}.  The value of the angle threshold, within which certain
6871 elementary functions, complex arithmetic operations, and complex
6872 elementary functions yield results conforming to a maximum relative
6873 error bound. See G.2.4(10).
6874 @end cartouche
6875 @noindent
6876 Information on this subject is not yet available.
6877
6878 @sp 1
6879 @cartouche
6880 @noindent
6881 @strong{130}.  The accuracy of certain elementary functions for
6882 parameters beyond the angle threshold. See G.2.4(10).
6883 @end cartouche
6884 @noindent
6885 Information on this subject is not yet available.
6886
6887 @sp 1
6888 @cartouche
6889 @noindent
6890 @strong{131}.  The result of a complex arithmetic operation or complex
6891 elementary function reference in overflow situations, when the
6892 @code{Machine_Overflows} attribute of the corresponding real type is
6893 @code{False}. See G.2.6(5).
6894 @end cartouche
6895 @noindent
6896 IEEE infinite and Nan values are produced as appropriate. 
6897
6898 @sp 1
6899 @cartouche
6900 @noindent
6901 @strong{132}.  The accuracy of certain complex arithmetic operations and
6902 certain complex elementary functions for parameters (or components
6903 thereof) beyond the angle threshold. See G.2.6(8).
6904 @end cartouche
6905 @noindent
6906 Information on those subjects is not yet available.
6907
6908 @sp 1
6909 @cartouche
6910 @noindent
6911 @strong{133}.  Information regarding bounded errors and erroneous
6912 execution. See H.2(1).
6913 @end cartouche
6914 @noindent
6915 Information on this subject is not yet available.
6916
6917 @sp 1
6918 @cartouche
6919 @noindent
6920 @strong{134}.  Implementation-defined aspects of pragma
6921 @code{Inspection_Point}. See H.3.2(8).
6922 @end cartouche
6923 @noindent
6924 Pragma @code{Inspection_Point} ensures that the variable is live and can
6925 be examined by the debugger at the inspection point.
6926
6927 @sp 1
6928 @cartouche
6929 @noindent
6930 @strong{135}.  Implementation-defined aspects of pragma
6931 @code{Restrictions}. See H.4(25).
6932 @end cartouche
6933 @noindent
6934 There are no implementation-defined aspects of pragma @code{Restrictions}. The
6935 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
6936 generated code. Checks must suppressed by use of pragma @code{Suppress}.
6937
6938 @sp 1
6939 @cartouche
6940 @noindent
6941 @strong{136}.  Any restrictions on pragma @code{Restrictions}. See
6942 H.4(27).
6943 @end cartouche
6944 @noindent
6945 There are no restrictions on pragma @code{Restrictions}.
6946
6947 @node Intrinsic Subprograms
6948 @chapter Intrinsic Subprograms
6949 @cindex Intrinsic Subprograms
6950
6951 @menu
6952 * Intrinsic Operators::
6953 * Enclosing_Entity::
6954 * Exception_Information::
6955 * Exception_Message::
6956 * Exception_Name::
6957 * File::
6958 * Line::
6959 * Rotate_Left::
6960 * Rotate_Right::
6961 * Shift_Left::
6962 * Shift_Right::
6963 * Shift_Right_Arithmetic::
6964 * Source_Location::
6965 @end menu
6966
6967 GNAT allows a user application program to write the declaration:
6968
6969 @smallexample
6970    pragma Import (Intrinsic, name);
6971 @end smallexample
6972
6973 @noindent
6974 providing that the name corresponds to one of the implemented intrinsic
6975 subprograms in GNAT, and that the parameter profile of the referenced
6976 subprogram meets the requirements. This chapter describes the set of
6977 implemented intrinsic subprograms, and the requirements on parameter profiles.
6978 Note that no body is supplied; as with other uses of pragma Import, the
6979 body is supplied elsewhere (in this case by the compiler itself). Note
6980 that any use of this feature is potentially non-portable, since the
6981 Ada standard does not require Ada compilers to implement this feature.
6982
6983 @node Intrinsic Operators
6984 @section Intrinsic Operators
6985 @cindex Intrinsic operator
6986
6987 @noindent
6988 All predefined operators can be used in @code{pragma Import (Intrinsic,..)}
6989 declarations. In the binary operator case, the operands must have the same
6990 size. The operand or operands must also be appropriate for
6991 the operator. For example, for addition, the operands must 
6992 both be floating-point or both be fixed-point. You can use an intrinsic
6993 operator declaration as in the following example:
6994
6995 @smallexample
6996    type Int1 is new Integer;
6997    type Int2 is new Integer;
6998
6999    function "+" (X1 : Int1; X2 : Int2) return Int1;
7000    function "+" (X1 : Int1; X2 : Int2) return Int2;
7001    pragma Import (Intrinsic, "+");
7002 @end smallexample
7003
7004 @noindent
7005 This declaration would permit "mixed mode" arithmetic on items
7006 of the differing types Int1 and Int2.
7007
7008 @node Enclosing_Entity
7009 @section Enclosing_Entity
7010 @cindex Enclosing_Entity
7011 @noindent
7012 This intrinsic subprogram is used in the implementation of the
7013 library routine @code{GNAT.Source_Info}. The only useful use of the
7014 intrinsic import in this case is the one in this unit, so an
7015 application program should simply call the function
7016 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
7017 the current subprogram, package, task, entry, or protected subprogram.
7018
7019 @node Exception_Information
7020 @section Exception_Information
7021 @cindex Exception_Information'
7022 @noindent
7023 This intrinsic subprogram is used in the implementation of the
7024 library routine @code{GNAT.Current_Exception}. The only useful
7025 use of the intrinsic import in this case is the one in this unit,
7026 so an application program should simply call the function
7027 @code{GNAT.Current_Exception.Exception_Information} to obtain
7028 the exception information associated with the current exception.
7029
7030 @node Exception_Message
7031 @section Exception_Message
7032 @cindex Exception_Message
7033 @noindent
7034 This intrinsic subprogram is used in the implementation of the
7035 library routine @code{GNAT.Current_Exception}. The only useful
7036 use of the intrinsic import in this case is the one in this unit,
7037 so an application program should simply call the function
7038 @code{GNAT.Current_Exception.Exception_Message} to obtain
7039 the message associated with the current exception.
7040
7041 @node Exception_Name
7042 @section Exception_Name
7043 @cindex Exception_Name
7044 @noindent
7045 This intrinsic subprogram is used in the implementation of the
7046 library routine @code{GNAT.Current_Exception}. The only useful
7047 use of the intrinsic import in this case is the one in this unit,
7048 so an application program should simply call the function
7049 @code{GNAT.Current_Exception.Exception_Name} to obtain
7050 the name of the current exception.
7051
7052 @node File
7053 @section File
7054 @cindex File
7055 @noindent
7056 This intrinsic subprogram is used in the implementation of the
7057 library routine @code{GNAT.Source_Info}. The only useful use of the
7058 intrinsic import in this case is the one in this unit, so an
7059 application program should simply call the function
7060 @code{GNAT.Source_Info.File} to obtain the name of the current
7061 file.
7062
7063 @node Line
7064 @section Line
7065 @cindex Line
7066 @noindent
7067 This intrinsic subprogram is used in the implementation of the
7068 library routine @code{GNAT.Source_Info}. The only useful use of the
7069 intrinsic import in this case is the one in this unit, so an
7070 application program should simply call the function
7071 @code{GNAT.Source_Info.Line} to obtain the number of the current
7072 source line.
7073
7074 @node Rotate_Left
7075 @section Rotate_Left
7076 @cindex Rotate_Left
7077 @noindent
7078 In standard Ada 95, the @code{Rotate_Left} function is available only
7079 for the predefined modular types in package @code{Interfaces}. However, in
7080 GNAT it is possible to define a Rotate_Left function for a user
7081 defined modular type or any signed integer type as in this example:
7082
7083 @smallexample
7084    function Shift_Left
7085      (Value  : My_Modular_Type;
7086       Amount : Natural)
7087       return   My_Modular_Type;
7088 @end smallexample
7089
7090 @noindent
7091 The requirements are that the profile be exactly as in the example
7092 above. The only modifications allowed are in the formal parameter
7093 names, and in the type of @code{Value} and the return type, which
7094 must be the same, and must be either a signed integer type, or
7095 a modular integer type with a binary modulus, and the size must
7096 be 8. 16, 32 or 64 bits.
7097
7098 @node Rotate_Right
7099 @section Rotate_Right
7100 @cindex Rotate_Right
7101 @noindent
7102 A @code{Rotate_Right} function can be defined for any user defined
7103 binary modular integer type, or signed integer type, as described
7104 above for @code{Rotate_Left}.
7105
7106 @node Shift_Left
7107 @section Shift_Left
7108 @cindex Shift_Left
7109 @noindent
7110 A @code{Shift_Left} function can be defined for any user defined
7111 binary modular integer type, or signed integer type, as described
7112 above for @code{Rotate_Left}.
7113
7114 @node Shift_Right
7115 @section Shift_Right
7116 @cindex Shift_Right
7117 @noindent
7118 A @code{Shift_Right} function can be defined for any user defined
7119 binary modular integer type, or signed integer type, as described
7120 above for @code{Rotate_Left}.
7121
7122 @node Shift_Right_Arithmetic
7123 @section Shift_Right_Arithmetic
7124 @cindex Shift_Right_Arithmetic
7125 @noindent
7126 A @code{Shift_Right_Arithmetic} function can be defined for any user
7127 defined binary modular integer type, or signed integer type, as described
7128 above for @code{Rotate_Left}.
7129
7130 @node Source_Location
7131 @section Source_Location
7132 @cindex Source_Location
7133 @noindent
7134 This intrinsic subprogram is used in the implementation of the
7135 library routine @code{GNAT.Source_Info}. The only useful use of the
7136 intrinsic import in this case is the one in this unit, so an
7137 application program should simply call the function
7138 @code{GNAT.Source_Info.Source_Location} to obtain the current
7139 source file location.
7140
7141 @node Representation Clauses and Pragmas
7142 @chapter Representation Clauses and Pragmas
7143 @cindex Representation Clauses
7144
7145 @menu
7146 * Alignment Clauses::
7147 * Size Clauses::
7148 * Storage_Size Clauses::
7149 * Size of Variant Record Objects::
7150 * Biased Representation ::
7151 * Value_Size and Object_Size Clauses::
7152 * Component_Size Clauses::
7153 * Bit_Order Clauses::
7154 * Effect of Bit_Order on Byte Ordering::
7155 * Pragma Pack for Arrays::
7156 * Pragma Pack for Records::
7157 * Record Representation Clauses::
7158 * Enumeration Clauses::
7159 * Address Clauses::
7160 * Effect of Convention on Representation::
7161 * Determining the Representations chosen by GNAT::
7162 @end menu
7163
7164 @noindent
7165 @cindex Representation Clause
7166 @cindex Representation Pragma
7167 @cindex Pragma, representation
7168 This section describes the representation clauses accepted by GNAT, and
7169 their effect on the representation of corresponding data objects.
7170
7171 GNAT fully implements Annex C (Systems Programming). This means that all
7172 the implementation advice sections in chapter 13 are fully implemented.
7173 However, these sections only require a minimal level of support for
7174 representation clauses. GNAT provides much more extensive capabilities,
7175 and this section describes the additional capabilities provided.
7176
7177 @node Alignment Clauses
7178 @section Alignment Clauses
7179 @cindex Alignment Clause
7180
7181 @noindent
7182 GNAT requires that all alignment clauses specify a power of 2, and all
7183 default alignments are always a power of 2. The default alignment
7184 values are as follows:
7185
7186 @itemize @bullet
7187 @item Primitive Types
7188 For primitive types, the alignment is the maximum of the actual size of
7189 objects of the type, and the maximum alignment supported by the target.
7190 For example, for type Long_Float, the object size is 8 bytes, and the
7191 default alignment will be 8 on any target that supports alignments
7192 this large, but on some targets, the maximum alignment may be smaller
7193 than 8, in which case objects of type Long_Float will be maximally
7194 aligned.
7195
7196 @item Arrays
7197 For arrays, the alignment is equal to the alignment of the component type
7198 for the normal case where no packing or component size is given. If the
7199 array is packed, and the packing is effective (see separate section on
7200 packed arrays), then the alignment will be one for long packed arrays,
7201 or arrays whose length is not known at compile time. For short packed
7202 arrays, which are handled internally as modular types, the alignment
7203 will be as described for primitive types, e.g. a packed array of length
7204 31 bits will have an object size of four bytes, and an alignment of 4.
7205
7206 @item Records
7207 For the normal non-packed case, the alignment of a record is equal to
7208 the maximum alignment of any of its components. For tagged records, this
7209 includes the implicit access type used for the tag. If a pragma Pack is
7210 used and all fields are packable (see separate section on pragma Pack),
7211 then the resulting alignment is 1.
7212
7213 @end itemize
7214
7215 @noindent
7216 An alignment clause may
7217 always specify a larger alignment than the default value, up to some
7218 maximum value dependent on the target (obtainable by using the
7219 attribute reference System'Maximum_Alignment). The only case in which
7220 it is permissible to specify a smaller alignment than the default value
7221 is in the case of a record for which a record representation clause is
7222 given. In this case, packable fields for which a component clause is
7223 given still result in a default alignment corresponding to the original
7224 type, but this may be overridden, since these components in fact only
7225 require an alignment of one byte. For example, given
7226
7227 @smallexample
7228   type v is record
7229      a : integer;
7230   end record;
7231
7232   for v use record
7233      a at 0  range 0 .. 31;
7234   end record;
7235
7236   for v'alignment use 1;
7237 @end smallexample
7238
7239 @noindent
7240 @cindex Alignment, default
7241 The default alignment for the type @code{v} is 4, as a result of the
7242 integer field in the record, but since this field is placed with a
7243 component clause, it is permissible, as shown, to override the default
7244 alignment of the record to a smaller value.
7245
7246 @node Size Clauses
7247 @section Size Clauses
7248 @cindex Size Clause
7249
7250 @noindent
7251 The default size of types is as specified in the reference manual. For
7252 objects, GNAT will generally increase the type size so that the object
7253 size is a multiple of storage units, and also a multiple of the
7254 alignment. For example
7255
7256 @smallexample
7257    type Smallint is range 1 .. 6;
7258
7259    type Rec is record
7260       y1 : integer;
7261       y2 : boolean;
7262    end record;
7263 @end smallexample
7264
7265 @noindent
7266 In this example, @code{Smallint}
7267 has a size of 3, as specified by the RM rules,
7268 but objects of this type will have a size of 8, 
7269 since objects by default occupy an integral number
7270 of storage units. On some targets, notably older
7271 versions of the Digital Alpha, the size of stand
7272 alone objects of this type may be 32, reflecting
7273 the inability of the hardware to do byte load/stores.
7274
7275 Similarly, the size of type @code{Rec} is 40 bits, but
7276 the alignment is 4, so objects of this type will have
7277 their size increased to 64 bits so that it is a multiple
7278 of the alignment. The reason for this decision, which is
7279 in accordance with the specific note in RM 13.3(43):
7280
7281 @smallexample
7282 A Size clause should be supported for an object if the specified
7283 Size is at least as large as its subtype's Size, and corresponds
7284 to a size in storage elements that is a multiple of the object's
7285 Alignment (if the Alignment is nonzero).
7286 @end smallexample
7287
7288 @noindent
7289 An explicit size clause may be used to override the default size by
7290 increasing it. For example, if we have:
7291
7292 @smallexample
7293    type My_Boolean is new Boolean;
7294    for My_Boolean'Size use 32;
7295 @end smallexample
7296
7297 @noindent
7298 then objects of this type will always be 32 bits long. In the case of
7299 discrete types, the size can be increased up to 64 bits, with the effect
7300 that the entire specified field is used to hold the value, sign- or
7301 zero-extended as appropriate. If more than 64 bits is specified, then
7302 padding space is allocated after the value, and a warning is issued that
7303 there are unused bits.
7304
7305 Similarly the size of records and arrays may be increased, and the effect
7306 is to add padding bits after the value. This also causes a warning message
7307 to be generated.
7308
7309 The largest Size value permitted in GNAT is 2**32-1. Since this is a
7310 Size in bits, this corresponds to an object of size 256 megabytes (minus
7311 one). This limitation is true on all targets. The reason for this
7312 limitation is that it improves the quality of the code in many cases
7313 if it is known that a Size value can be accommodated in an object of
7314 type Integer.
7315
7316 @node Storage_Size Clauses
7317 @section Storage_Size Clauses
7318 @cindex Storage_Size Clause
7319
7320 @noindent
7321 For tasks, the @code{Storage_Size} clause specifies the amount of space
7322 to be allocated for the task stack. This cannot be extended, and if the
7323 stack is exhausted, then @code{Storage_Error} will be raised if stack
7324 checking is enabled. If the default size of 20K bytes is insufficient,  
7325 then you need to use a @code{Storage_Size} attribute definition clause,
7326 or a @code{Storage_Size} pragma in the task definition to set the
7327 appropriate required size. A useful technique is to include in every
7328 task definition a pragma of the form:
7329
7330 @smallexample
7331    pragma Storage_Size (Default_Stack_Size);
7332 @end smallexample
7333
7334 @noindent
7335 Then Default_Stack_Size can be defined in a global package, and modified
7336 as required. Any tasks requiring different task stack sizes from the
7337 default can have an appropriate alternative reference in the pragma.
7338
7339 For access types, the @code{Storage_Size} clause specifies the maximum
7340 space available for allocation of objects of the type. If this space is
7341 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
7342 In the case where the access type is declared local to a subprogram, the
7343 use of a @code{Storage_Size} clause triggers automatic use of a special
7344 predefined storage pool (@code{System.Pool_Size}) that ensures that all
7345 space for the pool is automatically reclaimed on exit from the scope in
7346 which the type is declared.
7347
7348 A special case recognized by the compiler is the specification of a
7349 @code{Storage_Size} of zero for an access type. This means that no
7350 items can be allocated from the pool, and this is recognized at compile
7351 time, and all the overhead normally associated with maintaining a fixed
7352 size storage pool is eliminated. Consider the following example:
7353
7354 @smallexample
7355    procedure p is
7356       type R is array (Natural) of Character;
7357       type P is access all R;
7358       for P'Storage_Size use 0;
7359       --  Above access type intended only for interfacing purposes
7360    
7361       y : P;
7362    
7363       procedure g (m : P);
7364       pragma Import (C, g);
7365    
7366       --  ...
7367    
7368    begin
7369       --  ...
7370       y := new R;
7371    end;
7372 @end smallexample
7373
7374 @noindent
7375 As indicated in this example, these dummy storage pools are often useful in
7376 connection with interfacing where no object will ever be allocated. If you
7377 compile the above example, you get the warning:
7378
7379 @smallexample
7380    p.adb:16:09: warning: allocation from empty storage pool
7381    p.adb:16:09: warning: Storage_Error will be raised at run time
7382 @end smallexample
7383
7384 @noindent
7385 Of course in practice, there will not be any explicit allocators in the
7386 case of such an access declaration.
7387
7388 @node Size of Variant Record Objects
7389 @section Size of Variant Record Objects
7390 @cindex Size, variant record objects
7391 @cindex Variant record objects, size
7392
7393 @noindent
7394 An issue arises in the case of variant record objects of whether Size gives
7395 information about a particular variant, or the maximum size required
7396 for any variant. Consider the following program
7397
7398 @smallexample
7399 with Text_IO; use Text_IO;
7400 procedure q is
7401    type R1 (A : Boolean := False) is record
7402      case A is
7403        when True  => X : Character;
7404        when False => null;
7405      end case;
7406    end record;
7407    
7408    V1 : R1 (False);
7409    V2 : R1;
7410
7411 begin
7412    Put_Line (Integer'Image (V1'Size));
7413    Put_Line (Integer'Image (V2'Size));
7414 end q;
7415 @end smallexample
7416
7417 @noindent
7418 Here we are dealing with a variant record, where the True variant
7419 requires 16 bits, and the False variant requires 8 bits.
7420 In the above example, both V1 and V2 contain the False variant,
7421 which is only 8 bits long. However, the result of running the
7422 program is:
7423
7424 @smallexample
7425 8
7426 16
7427 @end smallexample
7428
7429 @noindent
7430 The reason for the difference here is that the discriminant value of
7431 V1 is fixed, and will always be False. It is not possible to assign
7432 a True variant value to V1, therefore 8 bits is sufficient. On the
7433 other hand, in the case of V2, the initial discriminant value is
7434 False (from the default), but it is possible to assign a True
7435 variant value to V2, therefore 16 bits must be allocated for V2
7436 in the general case, even fewer bits may be needed at any particular
7437 point during the program execution.
7438
7439 As can be seen from the output of this program, the @code{'Size}
7440 attribute applied to such an object in GNAT gives the actual allocated
7441 size of the variable, which is the largest size of any of the variants.
7442 The Ada Reference Manual is not completely clear on what choice should
7443 be made here, but the GNAT behavior seems most consistent with the
7444 language in the RM.
7445
7446 In some cases, it may be desirable to obtain the size of the current
7447 variant, rather than the size of the largest variant. This can be
7448 achieved in GNAT by making use of the fact that in the case of a
7449 subprogram parameter, GNAT does indeed return the size of the current
7450 variant (because a subprogram has no way of knowing how much space
7451 is actually allocated for the actual).
7452
7453 Consider the following modified version of the above program:
7454
7455 @smallexample
7456 with Text_IO; use Text_IO;
7457 procedure q is
7458    type R1 (A : Boolean := False) is record
7459      case A is
7460        when True  => X : Character;
7461        when False => null;
7462      end case;
7463    end record;
7464    
7465    V2 : R1;
7466
7467    function Size (V : R1) return Integer is
7468    begin
7469       return V'Size;
7470    end Size;
7471
7472 begin
7473    Put_Line (Integer'Image (V2'Size));
7474    Put_Line (Integer'IMage (Size (V2)));
7475    V2 := (True, 'x');
7476    Put_Line (Integer'Image (V2'Size));
7477    Put_Line (Integer'IMage (Size (V2)));
7478 end q;
7479 @end smallexample
7480
7481 @noindent
7482 The output from this program is
7483
7484 @smallexample
7485 16
7486 8
7487 16
7488 16
7489 @end smallexample
7490
7491 @noindent
7492 Here we see that while the @code{'Size} attribute always returns
7493 the maximum size, regardless of the current variant value, the
7494 @code{Size} function does indeed return the size of the current
7495 variant value.
7496
7497 @node Biased Representation
7498 @section Biased Representation
7499 @cindex Size for biased representation
7500 @cindex Biased representation
7501
7502 @noindent
7503 In the case of scalars with a range starting at other than zero, it is
7504 possible in some cases to specify a size smaller than the default minimum
7505 value, and in such cases, @code{GNAT} uses an unsigned biased representation,
7506 in which zero is used to represent the lower bound, and successive values
7507 represent successive values of the type.
7508
7509 For example, suppose we have the declaration:
7510
7511 @smallexample
7512    type Small is range -7 .. -4;
7513    for Small'Size use 2;
7514 @end smallexample
7515
7516 @noindent
7517 Although the default size of type @code{Small} is 4, the @code{Size}
7518 clause is accepted by GNAT and results in the following representation
7519 scheme:
7520
7521 @smallexample
7522   -7 is represented as 2#00#
7523   -6 is represented as 2#01#
7524   -5 is represented as 2#10#
7525   -4 is represented as 2#11#
7526 @end smallexample
7527
7528 @noindent
7529 Biased representation is only used if the specified @code{Size} clause
7530 cannot be accepted in any other manner. These reduced sizes that force
7531 biased representation can be used for all discrete types except for 
7532 enumeration types for which a representation clause is given.
7533
7534 @node Value_Size and Object_Size Clauses
7535 @section Value_Size and Object_Size Clauses
7536 @findex Value_Size
7537 @findex Object_Size
7538 @cindex Size, of objects
7539
7540 @noindent
7541 In Ada 95, the @code{Size} of a discrete type is the minimum number of bits
7542 required to hold values of the type. Although this interpretation was
7543 allowed in Ada 83, it was not required, and this requirement in practice
7544 can cause some significant difficulties. For example, in most Ada 83
7545 compilers, @code{Natural'Size} was 32. However, in Ada-95,
7546 @code{Natural'Size} is
7547 typically 31. This means that code may change in behavior when moving
7548 from Ada 83 to Ada 95. For example, consider:
7549
7550 @smallexample
7551    type Rec is record;
7552       A : Natural;
7553       B : Natural;
7554    end record;
7555
7556    for Rec use record
7557       for A use at 0  range 0 .. Natural'Size - 1;
7558       for B use at 0  range Natural'Size .. 2 * Natural'Size - 1;
7559    end record;
7560 @end smallexample
7561
7562 @noindent
7563 In the above code, since the typical size of @code{Natural} objects
7564 is 32 bits and @code{Natural'Size} is 31, the above code can cause
7565 unexpected inefficient packing in Ada 95, and in general there are
7566 surprising cases where the fact that the object size can exceed the
7567 size of the type causes surprises.
7568
7569 To help get around this problem GNAT provides two implementation
7570 dependent attributes @code{Value_Size} and @code{Object_Size}. When 
7571 applied to a type, these attributes yield the size of the type
7572 (corresponding to the RM defined size attribute), and the size of
7573 objects of the type respectively.
7574
7575 The @code{Object_Size} is used for determining the default size of
7576 objects and components. This size value can be referred to using the
7577 @code{Object_Size} attribute. The phrase "is used" here means that it is
7578 the basis of the determination of the size. The backend is free to
7579 pad this up if necessary for efficiency, e.g. an 8-bit stand-alone
7580 character might be stored in 32 bits on a machine with no efficient
7581 byte access instructions such as the Alpha.
7582
7583 The default rules for the value of @code{Object_Size} for fixed-point and
7584 discrete types are as follows:
7585
7586 @itemize @bullet
7587 @item
7588 The @code{Object_Size} for base subtypes reflect the natural hardware
7589 size in bits (run the utility gnatpsta to find those values for numeric types). 
7590 Enumeration types and fixed-point base subtypes have 8. 16. 32 or 64
7591 bits for this size, depending on the range of values to be stored.
7592
7593 @item
7594 The @code{Object_Size} of a subtype is the same as the
7595 @code{Object_Size} of
7596 the type from which it is obtained.
7597
7598 @item
7599 The @code{Object_Size} of a derived base type is copied from the parent
7600 base type, and the @code{Object_Size} of a derived first subtype is copied
7601 from the parent first subtype.
7602 @end itemize
7603
7604 @noindent
7605 The @code{Value_Size} attribute
7606 is the number of bits required to store a value
7607 of the type. This size can be referred to using the @code{Value_Size}
7608 attribute. This value is used to determine how tightly to pack
7609 records or arrays with components of this type, and also affects
7610 the semantics of unchecked conversion (unchecked conversions where
7611 the @code{Value_Size} values differ generate a warning, and are potentially
7612 target dependent).
7613
7614 The default rules for the value of @code{Value_Size} are as follows:
7615
7616 @itemize @bullet
7617 @item
7618 The @code{Value_Size} for a base subtype is the minimum number of bits
7619 required to store all values of the type (including the sign bit
7620 only if negative values are possible).
7621
7622 @item
7623 If a subtype statically matches the first subtype of a given type, then it has
7624 by default the same @code{Value_Size} as the first subtype. This is a
7625 consequence of RM 13.1(14) ("if two subtypes statically match,
7626 then their subtype-specific aspects are the same".)
7627
7628 @item
7629 All other subtypes have a @code{Value_Size} corresponding to the minimum
7630 number of bits required to store all values of the subtype. For
7631 dynamic bounds, it is assumed that the value can range down or up
7632 to the corresponding bound of the ancestor
7633 @end itemize
7634
7635 @noindent
7636 The RM defined attribute @code{Size} corresponds to the
7637 @code{Value_Size} attribute.
7638
7639 The @code{Size} attribute may be defined for a first-named subtype. This sets
7640 the @code{Value_Size} of
7641 the first-named subtype to the given value, and the
7642 @code{Object_Size} of this first-named subtype to the given value padded up
7643 to an appropriate boundary. It is a consequence of the default rules
7644 above that this @code{Object_Size} will apply to all further subtypes. On the
7645 other hand, @code{Value_Size} is affected only for the first subtype, any
7646 dynamic subtypes obtained from it directly, and any statically matching
7647 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
7648
7649 @code{Value_Size} and
7650 @code{Object_Size} may be explicitly set for any subtype using
7651 an attribute definition clause. Note that the use of these attributes
7652 can cause the RM 13.1(14) rule to be violated. If two access types
7653 reference aliased objects whose subtypes have differing @code{Object_Size}
7654 values as a result of explicit attribute definition clauses, then it
7655 is erroneous to convert from one access subtype to the other.
7656
7657 At the implementation level, Esize stores the Object_SIze and the
7658 RM_Size field stores the @code{Value_Size} (and hence the value of the
7659 @code{Size} attribute,
7660 which, as noted above, is equivalent to @code{Value_Size}).
7661
7662 To get a feel for the difference, consider the following examples (note
7663 that in each case the base is short_short_integer with a size of 8):
7664
7665 @smallexample
7666                                        Object_Size     Value_Size
7667
7668 type x1 is range 0..5;                      8               3
7669
7670 type x2 is range 0..5;
7671 for x2'size use 12;                        12              12
7672
7673 subtype x3 is x2 range 0 .. 3;             12               2
7674
7675 subtype x4 is x2'base range 0 .. 10;        8               4
7676
7677 subtype x5 is x2 range 0 .. dynamic;       12              (7)
7678
7679 subtype x6 is x2'base range 0 .. dynamic;   8              (7)
7680
7681 @end smallexample
7682
7683 @noindent
7684 Note: the entries marked (7) are not actually specified by the Ada 95 RM,
7685 but it seems in the spirit of the RM rules to allocate the minimum number
7686 of bits known to be large enough to hold the given range of values.
7687
7688 So far, so good, but GNAT has to obey the RM rules, so the question is
7689 under what conditions must the RM @code{Size} be used.
7690 The following is a list
7691 of the occasions on which the RM @code{Size} must be used:
7692
7693 @itemize @bullet
7694 @item
7695 Component size for packed arrays or records
7696
7697 @item
7698 Value of the attribute @code{Size} for a type
7699
7700 @item
7701 Warning about sizes not matching for unchecked conversion
7702 @end itemize
7703
7704 @noindent
7705 For types other than discrete and fixed-point types, the @code{Object_Size}
7706 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
7707 Only @code{Size} may be specified for such types.
7708
7709 @node Component_Size Clauses
7710 @section Component_Size Clauses
7711 @cindex Component_Size Clause
7712
7713 @noindent
7714 Normally, the value specified in a component clause must be consistent
7715 with the subtype of the array component with regard to size and alignment.
7716 In other words, the value specified must be at least equal to the size
7717 of this subtype, and must be a multiple of the alignment value.
7718
7719 In addition, component size clauses are allowed which cause the array
7720 to be packed, by specifying a smaller value. The cases in which this
7721 is allowed are for component size values in the range 1-63. The value
7722 specified must not be smaller than the Size of the subtype. GNAT will
7723 accurately honor all packing requests in this range. For example, if
7724 we have:
7725
7726 @smallexample
7727 type r is array (1 .. 8) of Natural;
7728 for r'Size use 31;
7729 @end smallexample
7730
7731 @noindent
7732 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
7733 Of course access to the components of such an array is considerably
7734 less efficient than if the natural component size of 32 is used.
7735
7736 @node Bit_Order Clauses
7737 @section Bit_Order Clauses
7738 @cindex Bit_Order Clause
7739 @cindex bit ordering
7740 @cindex ordering, of bits
7741
7742 @noindent
7743 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
7744 attribute. The specification may either correspond to the default bit
7745 order for the target, in which case the specification has no effect and
7746 places no additional restrictions, or it may be for the non-standard
7747 setting (that is the opposite of the default).
7748
7749 In the case where the non-standard value is specified, the effect is
7750 to renumber bits within each byte, but the ordering of bytes is not
7751 affected. There are certain
7752 restrictions placed on component clauses as follows:
7753
7754 @itemize @bullet
7755
7756 @item Components fitting within a single storage unit.
7757 @noindent
7758 These are unrestricted, and the effect is merely to renumber bits. For
7759 example if we are on a little-endian machine with @code{Low_Order_First}
7760 being the default, then the following two declarations have exactly
7761 the same effect:
7762
7763 @smallexample
7764    type R1 is record
7765       A : Boolean;
7766       B : Integer range 1 .. 120;
7767    end record;
7768
7769    for R1 use record
7770       A at 0 range 0 .. 0;
7771       B at 0 range 1 .. 7;
7772    end record;
7773
7774    type R2 is record
7775       A : Boolean;
7776       B : Integer range 1 .. 120;
7777    end record;
7778
7779    for R2'Bit_Order use High_Order_First;
7780
7781    for R2 use record
7782       A at 0 range 7 .. 7;
7783       B at 0 range 0 .. 6;
7784    end record;
7785 @end smallexample
7786
7787 @noindent
7788 The useful application here is to write the second declaration with the
7789 @code{Bit_Order} attribute definition clause, and know that it will be treated
7790 the same, regardless of whether the target is little-endian or big-endian.
7791
7792 @item Components occupying an integral number of bytes.
7793 @noindent
7794 These are components that exactly fit in two or more bytes. Such component
7795 declarations are allowed, but have no effect, since it is important to realize
7796 that the @code{Bit_Order} specification does not affect the ordering of bytes.
7797 In particular, the following attempt at getting an endian-independent integer
7798 does not work:
7799
7800 @smallexample
7801    type R2 is record
7802       A : Integer;
7803    end record;
7804
7805    for R2'Bit_Order use High_Order_First;
7806
7807    for R2 use record
7808       A at 0 range 0 .. 31;
7809    end record;
7810 @end smallexample
7811
7812 @noindent
7813 This declaration will result in a little-endian integer on a
7814 little-endian machine, and a big-endian integer on a big-endian machine.
7815 If byte flipping is required for interoperability between big- and
7816 little-endian machines, this must be explicitly programmed. This capability
7817 is not provided by @code{Bit_Order}.
7818
7819 @item Components that are positioned across byte boundaries
7820 @noindent
7821 but do not occupy an integral number of bytes. Given that bytes are not
7822 reordered, such fields would occupy a non-contiguous sequence of bits
7823 in memory, requiring non-trivial code to reassemble. They are for this
7824 reason not permitted, and any component clause specifying such a layout
7825 will be flagged as illegal by GNAT.
7826
7827 @end itemize
7828
7829 @noindent
7830 Since the misconception that Bit_Order automatically deals with all
7831 endian-related incompatibilities is a common one, the specification of
7832 a component field that is an integral number of bytes will always
7833 generate a warning This warning may be suppressed using
7834 @code{pragma Suppress} if desired. The following section contains additional
7835 details regarding the issue of byte ordering.
7836
7837 @node Effect of Bit_Order on Byte Ordering
7838 @section Effect of Bit_Order on Byte Ordering
7839 @cindex byte ordering
7840 @cindex ordering, of bytes
7841
7842 @noindent
7843 In this section we will review the effec of the @code{Bit_Order} attribute
7844 definition clause on byte ordering. Briefly, it has no effect at all, but
7845 a detailed example will be helpful. Before giving this
7846 example, let us review the precise
7847 definition of the effect of defining @code{Bit_Order}. The effect of a
7848 non-standard bit order is described in section 15.5.3 of the Ada
7849 Reference Manual:
7850
7851 @smallexample
7852 2   A bit ordering is a method of interpreting the meaning of
7853 the storage place attributes.
7854 @end smallexample
7855
7856 @noindent
7857 To understand the precise definition of storage place attributes in
7858 this context, we visit section 13.5.1 of the manual:
7859
7860 @smallexample
7861 13   A record_representation_clause (without the mod_clause)
7862 specifies the layout. The storage place attributes (see 13.5.2)
7863 are taken from the values of the position, first_bit, and last_bit
7864 expressions after normalizing those values so that first_bit is
7865 less than Storage_Unit.
7866 @end smallexample
7867
7868 @noindent
7869 The critical point here is that storage places are taken from
7870 the values after normalization, not before. So the @code{Bit_Order}
7871 interpretation applies to normalized values. The interpretation
7872 is described in the later part of the 15.5.3 paragraph:
7873
7874 @smallexample
7875 2   A bit ordering is a method of interpreting the meaning of
7876 the storage place attributes.  High_Order_First (known in the
7877 vernacular as "big endian") means that the first bit of a
7878 storage element (bit 0) is the most significant bit (interpreting
7879 the sequence of bits that represent a component as an unsigned
7880 integer value). Low_Order_First (known in the vernacular as
7881 "little endian") means the opposite: the first bit is the
7882 least significant.
7883 @end smallexample
7884
7885 @noindent
7886 Note that the numbering is with respect to the bits of a storage
7887 unit. In other words, the specification affects only the numbering
7888 of bits within a single storage unit.
7889
7890 We can make the effect clearer by giving an example.
7891
7892 Suppose that we have an external device which presents two bytes, the first
7893 byte presented, which is the first (low addressed byte) of the two byte
7894 record is called Master, and the second byte is called Slave.
7895
7896 The left most (most significant bit is called Control for each byte, and
7897 the remaing 7 bits are called V1, V2 .. V7, where V7 is the right most
7898 (least significant bit).
7899
7900 On a big-endian machine, we can write the following representation clause
7901
7902 @smallexample
7903    type Data is record
7904       Master_Control : Bit;
7905       Master_V1      : Bit;
7906       Master_V2      : Bit;
7907       Master_V3      : Bit;
7908       Master_V4      : Bit;
7909       Master_V5      : Bit;
7910       Master_V6      : Bit;
7911       Master_V7      : Bit;
7912       Slave_Control  : Bit;
7913       Slave_V1       : Bit;
7914       Slave_V2       : Bit;
7915       Slave_V3       : Bit;
7916       Slave_V4       : Bit;
7917       Slave_V5       : Bit;
7918       Slave_V6       : Bit;
7919       Slave_V7       : Bit;
7920    end record;
7921
7922    for Data use record
7923       Master_Control at 0 range 0 .. 0;
7924       Master_V1      at 0 range 1 .. 1;
7925       Master_V2      at 0 range 2 .. 2;
7926       Master_V3      at 0 range 3 .. 3;
7927       Master_V4      at 0 range 4 .. 4;
7928       Master_V5      at 0 range 5 .. 5;
7929       Master_V6      at 0 range 6 .. 6;
7930       Master_V7      at 0 range 7 .. 7;
7931       Slave_Control  at 1 range 0 .. 0;
7932       Slave_V1       at 1 range 1 .. 1;
7933       Slave_V2       at 1 range 2 .. 2;
7934       Slave_V3       at 1 range 3 .. 3;
7935       Slave_V4       at 1 range 4 .. 4;
7936       Slave_V5       at 1 range 5 .. 5;
7937       Slave_V6       at 1 range 6 .. 6;
7938       Slave_V7       at 1 range 7 .. 7;
7939    end record;
7940 @end smallexample
7941
7942 @noindent
7943 Now if we move this to a little endian machine, then the bit ordering within
7944 the byte is backwards, so we have to rewrite the record rep clause as:
7945
7946 @smallexample
7947    for Data use record
7948       Master_Control at 0 range 7 .. 7;
7949       Master_V1      at 0 range 6 .. 6;
7950       Master_V2      at 0 range 5 .. 5;
7951       Master_V3      at 0 range 4 .. 4;
7952       Master_V4      at 0 range 3 .. 3;
7953       Master_V5      at 0 range 2 .. 2;
7954       Master_V6      at 0 range 1 .. 1;
7955       Master_V7      at 0 range 0 .. 0;
7956       Slave_Control  at 1 range 7 .. 7;
7957       Slave_V1       at 1 range 6 .. 6;
7958       Slave_V2       at 1 range 5 .. 5;
7959       Slave_V3       at 1 range 4 .. 4;
7960       Slave_V4       at 1 range 3 .. 3;
7961       Slave_V5       at 1 range 2 .. 2;
7962       Slave_V6       at 1 range 1 .. 1;
7963       Slave_V7       at 1 range 0 .. 0;
7964    end record;
7965 @end smallexample
7966
7967 It is a nuisance to have to rewrite the clause, especially if
7968 the code has to be maintained on both machines. However,
7969 this is a case that we can handle with the
7970 @code{Bit_Order} attribute if it is implemented.
7971 Note that the implementation is not required on byte addressed
7972 machines, but it is indeed implemented in @code{GNAT}.
7973 This means that we can simply use the
7974 first record clause, together with the declaration
7975
7976 @smallexample
7977    for Data'Bit_Order use High_Order_First;
7978 @end smallexample
7979
7980 @noindent
7981 and the effect is what is desired, namely the layout is exactly the same,
7982 independent of whether the code is compiled on a big-endial or little-endian
7983 machine.
7984
7985 The important point to understand is that byte ordering is not affected.
7986 A @code{Bit_Order} attribute definition never affects which byte a field
7987 ends up in, only where it ends up in that byte.
7988 To make this clear, let us rewrite the record rep clause of the previous
7989 example as:
7990
7991 @smallexample
7992    for Data'Bit_Order use High_Order_First;
7993    for Data use record
7994       Master_Control at 0 range  0 ..  0;
7995       Master_V1      at 0 range  1 ..  1;
7996       Master_V2      at 0 range  2 ..  2;
7997       Master_V3      at 0 range  3 ..  3;
7998       Master_V4      at 0 range  4 ..  4;
7999       Master_V5      at 0 range  5 ..  5;
8000       Master_V6      at 0 range  6 ..  6;
8001       Master_V7      at 0 range  7 ..  7;
8002       Slave_Control  at 0 range  8 ..  8;
8003       Slave_V1       at 0 range  9 ..  9;
8004       Slave_V2       at 0 range 10 .. 10;
8005       Slave_V3       at 0 range 11 .. 11;
8006       Slave_V4       at 0 range 12 .. 12;
8007       Slave_V5       at 0 range 13 .. 13;
8008       Slave_V6       at 0 range 14 .. 14;
8009       Slave_V7       at 0 range 15 .. 15;
8010    end record;
8011 @end smallexample
8012
8013 @noindent
8014 This is exactly equivalent to saying (a repeat of the first example):
8015
8016 @smallexample
8017    for Data'Bit_Order use High_Order_First;
8018    for Data use record
8019       Master_Control at 0 range 0 .. 0;
8020       Master_V1      at 0 range 1 .. 1;
8021       Master_V2      at 0 range 2 .. 2;
8022       Master_V3      at 0 range 3 .. 3;
8023       Master_V4      at 0 range 4 .. 4;
8024       Master_V5      at 0 range 5 .. 5;
8025       Master_V6      at 0 range 6 .. 6;
8026       Master_V7      at 0 range 7 .. 7;
8027       Slave_Control  at 1 range 0 .. 0;
8028       Slave_V1       at 1 range 1 .. 1;
8029       Slave_V2       at 1 range 2 .. 2;
8030       Slave_V3       at 1 range 3 .. 3;
8031       Slave_V4       at 1 range 4 .. 4;
8032       Slave_V5       at 1 range 5 .. 5;
8033       Slave_V6       at 1 range 6 .. 6;
8034       Slave_V7       at 1 range 7 .. 7;
8035    end record;
8036 @end smallexample
8037
8038 @noindent
8039 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
8040 field. The storage place attributes are obtained by normalizing the
8041 values given so that the @code{First_Bit} value is less than 8. After
8042 nromalizing the values (0,10,10) we get (1,2,2) which is exactly what
8043 we specified in the other case.
8044
8045 Now one might expect that the @code{Bit_Order} attribute might affect
8046 bit numbering within the entire record component (two bytes in this
8047 case, thus affecting which byte fields end up in), but that is not
8048 the way this feature is defined, it only affects numbering of bits,
8049 not which byte they end up in.
8050
8051 Consequently it never makes sense to specify a starting bit number
8052 greater than 7 (for a byte addressable field) if an attribute
8053 definition for @code{Bit_Order} has been given, and indeed it
8054 may be actively confusing to specify such a value, so the compiler
8055 generates a warning for such usage.
8056
8057 If you do need to control byte ordering then appropriate conditional
8058 values must be used. If in our example, the slave byte came first on
8059 some machines we might write:
8060
8061 @smallexample
8062    Master_Byte_First constant Boolean := ...;
8063
8064    Master_Byte : constant Natural :=
8065                    1 - Boolean'Pos (Master_Byte_First);
8066    Slave_Byte  : constant Natural :=
8067                    Boolean'Pos (Master_Byte_First);
8068
8069    for Data'Bit_Order use High_Order_First;
8070    for Data use record
8071       Master_Control at Master_Byte range 0 .. 0;
8072       Master_V1      at Master_Byte range 1 .. 1;
8073       Master_V2      at Master_Byte range 2 .. 2;
8074       Master_V3      at Master_Byte range 3 .. 3;
8075       Master_V4      at Master_Byte range 4 .. 4;
8076       Master_V5      at Master_Byte range 5 .. 5;
8077       Master_V6      at Master_Byte range 6 .. 6;
8078       Master_V7      at Master_Byte range 7 .. 7;
8079       Slave_Control  at Slave_Byte  range 0 .. 0;
8080       Slave_V1       at Slave_Byte  range 1 .. 1;
8081       Slave_V2       at Slave_Byte  range 2 .. 2;
8082       Slave_V3       at Slave_Byte  range 3 .. 3;
8083       Slave_V4       at Slave_Byte  range 4 .. 4;
8084       Slave_V5       at Slave_Byte  range 5 .. 5;
8085       Slave_V6       at Slave_Byte  range 6 .. 6;
8086       Slave_V7       at Slave_Byte  range 7 .. 7;
8087    end record;
8088 @end smallexample
8089
8090 @noindent
8091 Now to switch between machines, all that is necessary is
8092 to set the boolean constant @code{Master_Byte_First} in
8093 an appropriate manner.
8094
8095 @node Pragma Pack for Arrays
8096 @section Pragma Pack for Arrays
8097 @cindex Pragma Pack (for arrays)
8098
8099 @noindent
8100 Pragma Pack applied to an array has no effect unless the component type
8101 is packable. For a component type to be packable, it must be one of the
8102 following cases:
8103
8104 @itemize @bullet
8105 @item
8106 Any scalar type
8107 @item
8108 Any fixed-point type
8109 @item
8110 Any type whose size is specified with a size clause
8111 @item
8112 Any packed array type with a static size
8113 @end itemize
8114
8115 @noindent
8116 For all these cases, if the component subtype size is in the range
8117 1- 63, then the effect of the pragma Pack is exactly as though a
8118 component size were specified giving the component subtype size.
8119 For example if we have:
8120
8121 @smallexample
8122    type r is range 0 .. 17;
8123  
8124    type ar is array (1 .. 8) of r;
8125    pragma Pack (ar);
8126 @end smallexample
8127
8128 @noindent
8129 Then the component size of @code{ar} will be set to 5 (i.e. to @code{r'size},
8130 and the size of the array @code{ar} will be exactly 40 bits.
8131
8132 Note that in some cases this rather fierce approach to packing can produce
8133 unexpected effects. For example, in Ada 95, type Natural typically has a
8134 size of 31, meaning that if you pack an array of Natural, you get 31-bit
8135 close packing, which saves a few bits, but results in far less efficient
8136 access. Since many other Ada compilers will ignore such a packing request,
8137 GNAT will generate a warning on some uses of pragma Pack that it guesses
8138 might not be what is intended. You can easily remove this warning by
8139 using an explicit Component_Size setting instead, which never generates
8140 a warning, since the intention of the programmer is clear in this case.
8141
8142 GNAT treats packed arrays in one of two ways. If the size of the array is
8143 known at compile time and is less than 64 bits, then internally the array
8144 is represented as a single modular type, of exactly the appropriate number
8145 of bits. If the length is greater than 63 bits, or is not known at compile
8146 time, then the packed array is represented as an array of bytes, and the
8147 length is always a multiple of 8 bits.
8148
8149 @node Pragma Pack for Records
8150 @section Pragma Pack for Records
8151 @cindex Pragma Pack (for records)
8152
8153 @noindent
8154 Pragma Pack applied to a record will pack the components to reduce wasted
8155 space from alignment gaps and by reducing the amount of space taken by
8156 components. We distinguish between package components and non-packable
8157 components. Components of the following types are considered packable:
8158
8159 @itemize @bullet
8160 @item
8161 All scalar types are packable.
8162
8163 @item
8164 All fixed-point types are represented internally as integers, and
8165 are packable.
8166
8167 @item
8168 Small packed arrays, whose size does not exceed 64 bits, and where the
8169 size is statically known at compile time, are represented internally
8170 as modular integers, and so they are also packable.
8171
8172 @end itemize
8173
8174 @noindent
8175 All packable components occupy the exact number of bits corresponding to
8176 their @code{Size} value, and are packed with no padding bits, i.e. they
8177 can start on an arbitrary bit boundary.
8178
8179 All other types are non-packable, they occupy an integral number of
8180 storage units, and 
8181 are placed at a boundary corresponding to their alignment requirements.
8182
8183 For example, consider the record
8184
8185 @smallexample
8186    type Rb1 is array (1 .. 13) of Boolean;
8187    pragma Pack (rb1);
8188
8189    type Rb2 is array (1 .. 65) of Boolean;
8190    pragma Pack (rb2);
8191
8192    type x2 is record
8193       l1 : Boolean;
8194       l2 : Duration;
8195       l3 : Float;
8196       l4 : Boolean;
8197       l5 : Rb1;
8198       l6 : Rb2;
8199    end record;
8200    pragma Pack (x2);
8201 @end smallexample
8202
8203 @noindent
8204 The representation for the record x2 is as follows:
8205
8206 @smallexample
8207 for x2'Size use 224;
8208 for x2 use record
8209    l1 at  0 range  0 ..  0;
8210    l2 at  0 range  1 .. 64;
8211    l3 at 12 range  0 .. 31;
8212    l4 at 16 range  0 ..  0;
8213    l5 at 16 range  1 .. 13;
8214    l6 at 18 range  0 .. 71;
8215 end record;
8216 @end smallexample
8217
8218 @noindent
8219 Studying this example, we see that the packable fields @code{l1}
8220 and @code{l2} are
8221 of length equal to their sizes, and placed at specific bit boundaries (and
8222 not byte boundaries) to
8223 eliminate padding. But @code{l3} is of a non-packable float type, so
8224 it is on the next appropriate alignment boundary. 
8225
8226 The next two fields are fully packable, so @code{l4} and @code{l5} are
8227 minimally packed with no gaps. However, type @code{Rb2} is a packed
8228 array that is longer than 64 bits, so it is itself non-packable. Thus
8229 the @code{l6} field is aligned to the next byte boundary, and takes an
8230 integral number of bytes, i.e. 72 bits.
8231
8232 @node Record Representation Clauses
8233 @section Record Representation Clauses
8234 @cindex Record Representation Clause
8235
8236 @noindent
8237 Record representation clauses may be given for all record types, including
8238 types obtained by record extension. Component clauses are allowed for any
8239 static component. The restrictions on component clauses depend on the type
8240 of the component.
8241
8242 @cindex Component Clause
8243 For all components of an elementary type, the only restriction on component
8244 clauses is that the size must be at least the 'Size value of the type
8245 (actually the Value_Size). There are no restrictions due to alignment,
8246 and such components may freely cross storage boundaries.
8247
8248 Packed arrays with a size up to and including 64-bits are represented
8249 internally using a modular type with the appropriate number of bits, and
8250 thus the same lack of restriction applies. For example, if you declare:
8251
8252 @smallexample
8253    type R is array (1 .. 49) of Boolean;
8254    pragma Pack (R);
8255    for R'Size use 49;
8256 @end smallexample
8257
8258 @noindent
8259 then a component clause for a component of type R may start on any
8260 specified bit boundary, and may specify a value of 49 bits or greater.
8261
8262 For non-primitive types, including packed arrays with a size greater than
8263 64-bits, component clauses must respect the alignment requirement of the
8264 type, in particular, always starting on a byte boundary, and the length
8265 must be a multiple of the storage unit.
8266
8267 The tag field of a tagged type always occupies an address sized field at
8268 the start of the record. No component clause may attempt to overlay this
8269 tag.
8270
8271 In the case of a record extension T1, of a type T, no component clause applied
8272 to the type T1 can specify a storage location that would overlap the first
8273 T'Size bytes of the record.
8274
8275 @node Enumeration Clauses
8276 @section Enumeration Clauses
8277
8278 The only restriction on enumeration clauses is that the range of values
8279 must be representable. For the signed case, if one or more of the
8280 representation values are negative, all values must be in the range:
8281
8282 @smallexample
8283    System.Min_Int .. System.Max_Int
8284 @end smallexample
8285
8286 @noindent
8287 For the unsigned case, where all values are non negative, the values must
8288 be in the range:
8289
8290 @smallexample
8291    0 .. System.Max_Binary_Modulus;
8292 @end smallexample
8293
8294 @noindent
8295 A "confirming" representation clause is one in which the values range
8296 from 0 in sequence, i.e. a clause that confirms the default representation
8297 for an enumeration type.
8298 Such a confirming representation
8299 is permitted by these rules, and is specially recognized by the compiler so
8300 that no extra overhead results from the use of such a clause.
8301
8302 If an array has an index type which is an enumeration type to which an
8303 enumeration clause has been applied, then the array is stored in a compact
8304 manner. Consider the declarations:
8305
8306 @smallexample
8307    type r is (A, B, C);
8308    for r use (A => 1, B => 5, C => 10);
8309    type t is array (r) of Character;
8310 @end smallexample
8311
8312 @noindent
8313 The array type t corresponds to a vector with exactly three elements and
8314 has a default size equal to @code{3*Character'Size}. This ensures efficient
8315 use of space, but means that accesses to elements of the array will incur
8316 the overhead of converting representation values to the corresponding
8317 positional values, (i.e. the value delivered by the  @code{Pos} attribute).
8318
8319 @node Address Clauses
8320 @section Address Clauses
8321 @cindex Address Clause
8322
8323 The reference manual allows a general restriction on representation clauses,
8324 as found in RM 13.1(22):
8325
8326 @smallexample
8327    An implementation need not support representation
8328    items containing nonstatic expressions, except that
8329    an implementation should support a representation item
8330    for a given entity if each nonstatic expression in the
8331    representation item is a name that statically denotes
8332    a constant declared before the entity.
8333 @end smallexample
8334
8335 @noindent
8336 In practice this is applicable only to address clauses, since this is the
8337 only case in which a non-static expression is permitted by the syntax. As
8338 the AARM notes in sections 13.1 (22.a-22.h):
8339
8340 @smallexample
8341   22.a   Reason: This is to avoid the following sort
8342          of thing:
8343
8344   22.b        X : Integer := F(...);
8345               Y : Address := G(...);
8346               for X'Address use Y;
8347
8348   22.c   In the above, we have to evaluate the
8349          initialization expression for X before we
8350          know where to put the result. This seems
8351          like an unreasonable implementation burden.
8352
8353   22.d   The above code should instead be written
8354          like this:
8355
8356   22.e        Y : constant Address := G(...);
8357               X : Integer := F(...);
8358               for X'Address use Y;
8359
8360   22.f   This allows the expression ``Y'' to be safely
8361          evaluated before X is created.
8362
8363   22.g   The constant could be a formal parameter of mode in.
8364
8365   22.h   An implementation can support other nonstatic
8366          expressions if it wants to. Expressions of type
8367          Address are hardly ever static, but their value
8368          might be known at compile time anyway in many
8369          cases.
8370 @end smallexample
8371
8372 @noindent
8373 GNAT does indeed permit many additional cases of non-static expressions. In
8374 particular, if the type involved is elementary there are no restrictions
8375 (since in this case, holding a temporary copy of the initialization value,
8376 if one is present, is inexpensive). In addition, if there is no implicit or
8377 explicit initialization, then there are no restrictions. GNAT will reject
8378 only the case where all three of these conditions hold:
8379
8380 @itemize @bullet
8381
8382 @item
8383 The type of the item is non-elementary (e.g. a record or array).
8384
8385 @item
8386 There is explicit or implicit initialization required for the object.
8387
8388 @item
8389 The address value is non-static. Here GNAT is more permissive than the
8390 RM, and allows the address value to be the address of a previously declared
8391 stand-alone variable, as long as it does not itself have an address clause.
8392
8393 @smallexample
8394            Anchor : Some_Initialized_Type;
8395            Overlay : Some_Initialized_Type;
8396            for Overlay'Address use Anchor'Address;
8397 @end smallexample
8398
8399 However, the prefix of the address clause cannot be an array component, or
8400 a component of a discriminated record.
8401
8402 @end itemize
8403
8404 @noindent
8405 As noted above in section 22.h, address values are typically non-static. In
8406 particular the To_Address function, even if applied to a literal value, is
8407 a non-static function call. To avoid this minor annoyance, GNAT provides
8408 the implementation defined attribute 'To_Address. The following two 
8409 expressions have identical values:
8410
8411 @findex Attribute
8412 @findex To_Address
8413 @smallexample
8414    To_Address (16#1234_0000#)
8415    System'To_Address (16#1234_0000#);
8416 @end smallexample
8417
8418 @noindent
8419 except that the second form is considered to be a static expression, and
8420 thus when used as an address clause value is always permitted.
8421
8422 @noindent
8423 Additionally, GNAT treats as static an address clause that is an
8424 unchecked_conversion of a static integer value. This simplifies the porting
8425 of legacy code, and provides a portable equivalent to the GNAT attribute
8426 To_Address.
8427
8428 @findex Export
8429 An address clause cannot be given for an exported object. More
8430 understandably the real restriction is that objects with an address
8431 clause cannot be exported. This is because such variables are not
8432 defined by the Ada program, so there is no external object so export.
8433
8434 @findex Import
8435 It is permissible to give an address clause and a pragma Import for the
8436 same object. In this case, the variable is not really defined by the
8437 Ada program, so there is no external symbol to be linked. The link name
8438 and the external name are ignored in this case. The reason that we allow this
8439 combination is that it provides a useful idiom to avoid unwanted
8440 initializations on objects with address clauses.
8441
8442 When an address clause is given for an object that has implicit or
8443 explicit initialization, then by default initialization takes place. This
8444 means that the effect of the object declaration is to overwrite the
8445 memory at the specified address. This is almost always not what the
8446 programmer wants, so GNAT will output a warning:
8447
8448 @smallexample
8449   with System;
8450   package G is
8451      type R is record
8452         M : Integer := 0;
8453      end record;
8454   
8455      Ext : R;
8456      for Ext'Address use System'To_Address (16#1234_1234#);
8457          |
8458   >>> warning: implicit initialization of "Ext" may
8459       modify overlaid storage
8460   >>> warning: use pragma Import for "Ext" to suppress
8461       initialization (RM B(24))
8462   
8463   end G;
8464 @end smallexample
8465
8466 @noindent
8467 As indicated by the warning message, the solution is to use a (dummy) pragma
8468 Import to suppress this initialization. The pragma tell the compiler that the
8469 object is declared and initialized elsewhere. The following package compiles
8470 without warnings (and the initialization is suppressed):
8471
8472 @smallexample
8473    with System;
8474    package G is
8475       type R is record
8476          M : Integer := 0;
8477       end record;
8478    
8479       Ext : R;
8480       for Ext'Address use System'To_Address (16#1234_1234#);
8481       pragma Import (Ada, Ext);
8482    end G;
8483 @end smallexample
8484
8485 @node Effect of Convention on Representation
8486 @section Effect of Convention on Representation
8487 @cindex Convention, effect on representation
8488
8489 @noindent
8490 Normally the specification of a foreign language convention for a type or
8491 an object has no effect on the chosen representation. In particular, the
8492 representation chosen for data in GNAT generally meets the standard system
8493 conventions, and for example records are laid out in a manner that is
8494 consistent with C. This means that specifying convention C (for example)
8495 has no effect.
8496
8497 There are three exceptions to this general rule:
8498
8499 @itemize @bullet
8500
8501 @item Convention Fortran and array subtypes
8502 If pragma Convention Fortran is specified for an array subtype, then in
8503 accordance with the implementation advice in section 3.6.2(11) of the
8504 Ada Reference Manual, the array will be stored in a Fortran-compatible
8505 column-major manner, instead of the normal default row-major order.
8506
8507 @item Convention C and enumeration types
8508 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
8509 to accommodate all values of the type. For example, for the enumeration
8510 type declared by:
8511
8512 @smallexample
8513    type Color is (Red, Green, Blue);
8514 @end smallexample
8515
8516 @noindent
8517 8 bits is sufficient to store all values of the type, so by default, objects
8518 of type @code{Color} will be represented using 8 bits. However, normal C
8519 convention is to use 32-bits for all enum values in C, since enum values
8520 are essentially of type int. If pragma Convention C is specified for an
8521 Ada enumeration type, then the size is modified as necessary (usually to
8522 32 bits) to be consistent with the C convention for enum values.
8523
8524 @item Convention C/Fortran and Boolean types
8525 In C, the usual convention for boolean values, that is values used for
8526 conditions, is that zero represents false, and nonzero values represent
8527 true. In Ada, the normal convention is that two specific values, typically
8528 0/1, are used to represent false/true respectively.
8529
8530 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
8531 value represents true).
8532
8533 To accommodate the Fortran and C conventions, if a pragma Convention specifies
8534 C or Fortran convention for a derived Boolean, as in the following example:
8535
8536 @smallexample
8537    type C_Switch is new Boolean;
8538    pragma Convention (C, C_Switch);
8539 @end smallexample
8540
8541 @noindent
8542 then the GNAT generated code will treat any nonzero value as true. For truth
8543 values generated by GNAT, the conventional value 1 will be used for True, but
8544 when one of these values is read, any nonzero value is treated as True.
8545
8546 @end itemize
8547
8548 @node Determining the Representations chosen by GNAT
8549 @section Determining the Representations chosen by GNAT
8550 @cindex Representation, determination of
8551 @cindex -gnatR switch
8552
8553 @noindent
8554 Although the descriptions in this section are intended to be complete, it is
8555 often easier to simply experiment to see what GNAT accepts and what the
8556 effect is on the layout of types and objects.
8557
8558 As required by the Ada RM, if a representation clause is not accepted, then
8559 it must be rejected as illegal by the compiler. However, when a representation
8560 clause or pragma is accepted, there can still be questions of what the
8561 compiler actually does. For example, if a partial record representation
8562 clause specifies the location of some components and not others, then where
8563 are the non-specified components placed? Or if pragma pack is used on a
8564 record, then exactly where are the resulting fields placed? The section
8565 on pragma Pack in this chapter can be used to answer the second question,
8566 but it is often easier to just see what the compiler does.
8567
8568 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
8569 with this option, then the compiler will output information on the actual
8570 representations chosen, in a format similar to source representation
8571 clauses. For example, if we compile the package:
8572
8573 @smallexample
8574 package q is
8575    type r (x : boolean) is tagged record
8576       case x is
8577          when True => S : String (1 .. 100);
8578          when False => null;
8579       end case;
8580    end record;
8581
8582    type r2 is new r (false) with record
8583       y2 : integer;
8584    end record;
8585
8586    for r2 use record
8587       y2 at 16 range 0 .. 31;
8588    end record;
8589
8590    type x is record
8591       y : character;
8592    end record;
8593
8594    type x1 is array (1 .. 10) of x;
8595    for x1'component_size use 11;
8596
8597    type ia is access integer;
8598
8599    type Rb1 is array (1 .. 13) of Boolean;
8600    pragma Pack (rb1);
8601
8602    type Rb2 is array (1 .. 65) of Boolean;
8603    pragma Pack (rb2);
8604
8605    type x2 is record
8606       l1 : Boolean;
8607       l2 : Duration;
8608       l3 : Float;
8609       l4 : Boolean;
8610       l5 : Rb1;
8611       l6 : Rb2;
8612    end record;
8613    pragma Pack (x2);
8614 end q;
8615 @end smallexample
8616
8617 @noindent
8618 using the switch @code{-gnatR} we obtain the following output:
8619
8620 @smallexample
8621 Representation information for unit q
8622 -------------------------------------
8623
8624 for r'Size use ??;
8625 for r'Alignment use 4;
8626 for r use record
8627    x    at 4 range  0 ..  7;
8628    _tag at 0 range  0 .. 31;
8629    s    at 5 range  0 .. 799;
8630 end record;
8631
8632 for r2'Size use 160;
8633 for r2'Alignment use 4;
8634 for r2 use record
8635    x       at  4 range  0 ..  7;
8636    _tag    at  0 range  0 .. 31;
8637    _parent at  0 range  0 .. 63;
8638    y2      at 16 range  0 .. 31;
8639 end record;
8640
8641 for x'Size use 8;
8642 for x'Alignment use 1;
8643 for x use record
8644    y at 0 range  0 ..  7;
8645 end record;
8646
8647 for x1'Size use 112;
8648 for x1'Alignment use 1;
8649 for x1'Component_Size use 11;
8650
8651 for rb1'Size use 13;
8652 for rb1'Alignment use 2;
8653 for rb1'Component_Size use 1;
8654
8655 for rb2'Size use 72;
8656 for rb2'Alignment use 1;
8657 for rb2'Component_Size use 1;
8658
8659 for x2'Size use 224;
8660 for x2'Alignment use 4;
8661 for x2 use record
8662    l1 at  0 range  0 ..  0;
8663    l2 at  0 range  1 .. 64;
8664    l3 at 12 range  0 .. 31;
8665    l4 at 16 range  0 ..  0;
8666    l5 at 16 range  1 .. 13;
8667    l6 at 18 range  0 .. 71;
8668 end record;
8669 @end smallexample
8670
8671 @noindent
8672 The Size values are actually the Object_Size, i.e. the default size that
8673 will be allocated for objects of the type.
8674 The ?? size for type r indicates that we have a variant record, and the
8675 actual size of objects will depend on the discriminant value.
8676
8677 The Alignment values show the actual alignment chosen by the compiler
8678 for each record or array type.
8679
8680 The record representation clause for type r shows where all fields
8681 are placed, including the compiler generated tag field (whose location
8682 cannot be controlled by the programmer).
8683
8684 The record representation clause for the type extension r2 shows all the
8685 fields present, including the parent field, which is a copy of the fields
8686 of the parent type of r2, i.e. r1.
8687
8688 The component size and size clauses for types rb1 and rb2 show
8689 the exact effect of pragma Pack on these arrays, and the record
8690 representation clause for type x2 shows how pragma Pack affects
8691 this record type.
8692
8693 In some cases, it may be useful to cut and paste the representation clauses
8694 generated by the compiler into the original source to fix and guarantee
8695 the actual representation to be used.
8696
8697 @node Standard Library Routines
8698 @chapter Standard Library Routines
8699
8700 @noindent
8701 The Ada 95 Reference Manual contains in Annex A a full description of an
8702 extensive set of standard library routines that can be used in any Ada
8703 program, and which must be provided by all Ada compilers. They are
8704 analogous to the standard C library used by C programs.
8705
8706 GNAT implements all of the facilities described in annex A, and for most
8707 purposes the description in the Ada 95
8708 reference manual, or appropriate Ada
8709 text book, will be sufficient for making use of these facilities.
8710
8711 In the case of the input-output facilities, @xref{The Implementation of
8712 Standard I/O}, gives details on exactly how GNAT interfaces to the
8713 file system. For the remaining packages, the Ada 95 reference manual
8714 should be sufficient. The following is a list of the packages included,
8715 together with a brief description of the functionality that is provided.
8716
8717 For completeness, references are included to other predefined library
8718 routines defined in other sections of the Ada 95 reference manual (these are
8719 cross-indexed from annex A).
8720
8721 @table @code
8722 @item Ada (A.2)
8723 This is a parent package for all the standard library packages. It is
8724 usually included implicitly in your program, and itself contains no
8725 useful data or routines.
8726
8727 @item Ada.Calendar (9.6)
8728 @code{Calendar} provides time of day access, and routines for
8729 manipulating times and durations.
8730
8731 @item Ada.Characters (A.3.1)
8732 This is a dummy parent package that contains no useful entities
8733
8734 @item Ada.Characters.Handling (A.3.2)
8735 This package provides some basic character handling capabilities,
8736 including classification functions for classes of characters (e.g. test
8737 for letters, or digits).
8738
8739 @item Ada.Characters.Latin_1 (A.3.3)
8740 This package includes a complete set of definitions of the characters
8741 that appear in type CHARACTER. It is useful for writing programs that
8742 will run in international environments. For example, if you want an
8743 upper case E with an acute accent in a string, it is often better to use
8744 the definition of @code{UC_E_Acute} in this package. Then your program
8745 will print in an understandable manner even if your environment does not
8746 support these extended characters.
8747
8748 @item Ada.Command_Line (A.15)
8749 This package provides access to the command line parameters and the name
8750 of the current program (analogous to the use of argc and argv in C), and
8751 also allows the exit status for the program to be set in a
8752 system-independent manner.
8753
8754 @item Ada.Decimal (F.2)
8755 This package provides constants describing the range of decimal numbers
8756 implemented, and also a decimal divide routine (analogous to the COBOL
8757 verb DIVIDE .. GIVING .. REMAINDER ..)
8758
8759 @item Ada.Direct_IO (A.8.4)
8760 This package provides input-output using a model of a set of records of
8761 fixed-length, containing an arbitrary definite Ada type, indexed by an
8762 integer record number.
8763
8764 @item Ada.Dynamic_Priorities (D.5)
8765 This package allows the priorities of a task to be adjusted dynamically
8766 as the task is running.
8767
8768 @item Ada.Exceptions (11.4.1)
8769 This package provides additional information on exceptions, and also
8770 contains facilities for treating exceptions as data objects, and raising
8771 exceptions with associated messages.
8772
8773 @item Ada.Finalization (7.6)
8774 This package contains the declarations and subprograms to support the
8775 use of controlled types, providing for automatic initialization and
8776 finalization (analogous to the constructors and destructors of C++)
8777
8778 @item Ada.Interrupts (C.3.2)
8779 This package provides facilities for interfacing to interrupts, which
8780 includes the set of signals or conditions that can be raised and
8781 recognized as interrupts.
8782
8783 @item Ada.Interrupts.Names (C.3.2)
8784 This package provides the set of interrupt names (actually signal
8785 or condition names) that can be handled by GNAT.
8786
8787 @item Ada.IO_Exceptions (A.13)
8788 This package defines the set of exceptions that can be raised by use of
8789 the standard IO packages.
8790
8791 @item Ada.Numerics
8792 This package contains some standard constants and exceptions used
8793 throughout the numerics packages. Note that the constants pi and e are
8794 defined here, and it is better to use these definitions than rolling
8795 your own.
8796
8797 @item Ada.Numerics.Complex_Elementary_Functions
8798 Provides the implementation of standard elementary functions (such as
8799 log and trigonometric functions) operating on complex numbers using the
8800 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
8801 created by the package @code{Numerics.Complex_Types}.
8802
8803 @item Ada.Numerics.Complex_Types
8804 This is a predefined instantiation of
8805 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
8806 build the type @code{Complex} and @code{Imaginary}.
8807
8808 @item Ada.Numerics.Discrete_Random
8809 This package provides a random number generator suitable for generating
8810 random integer values from a specified range.
8811
8812 @item Ada.Numerics.Float_Random
8813 This package provides a random number generator suitable for generating
8814 uniformly distributed floating point values.
8815
8816 @item Ada.Numerics.Generic_Complex_Elementary_Functions
8817 This is a generic version of the package that provides the
8818 implementation of standard elementary functions (such as log an
8819 trigonometric functions) for an arbitrary complex type.
8820
8821 The following predefined instantiations of this package exist
8822
8823 @table @code
8824 @item Short_Float
8825 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
8826 @item Float
8827 @code{Ada.Numerics.Complex_Elementary_Functions}
8828 @item Long_Float
8829 @code{Ada.Numerics.
8830  Long_Complex_Elementary_Functions}
8831 @end table
8832
8833 @item Ada.Numerics.Generic_Complex_Types
8834 This is a generic package that allows the creation of complex types,
8835 with associated complex arithmetic operations.
8836
8837 The following predefined instantiations of this package exist
8838 @table @code
8839 @item Short_Float
8840 @code{Ada.Numerics.Short_Complex_Complex_Types}
8841 @item Float
8842 @code{Ada.Numerics.Complex_Complex_Types}
8843 @item Long_Float
8844 @code{Ada.Numerics.Long_Complex_Complex_Types}
8845 @end table
8846
8847 @item Ada.Numerics.Generic_Elementary_Functions
8848 This is a generic package that provides the implementation of standard
8849 elementary functions (such as log an trigonometric functions) for an
8850 arbitrary float type.
8851
8852 The following predefined instantiations of this package exist
8853
8854 @table @code
8855 @item Short_Float
8856 @code{Ada.Numerics.Short_Elementary_Functions}
8857 @item Float
8858 @code{Ada.Numerics.Elementary_Functions}
8859 @item Long_Float
8860 @code{Ada.Numerics.Long_Elementary_Functions}
8861 @end table
8862
8863 @item Ada.Real_Time (D.8)
8864 This package provides facilities similar to those of @code{Calendar}, but
8865 operating with a finer clock suitable for real time control.
8866
8867 @item Ada.Sequential_IO (A.8.1)
8868 This package provides input-output facilities for sequential files,
8869 which can contain a sequence of values of a single type, which can be
8870 any Ada type, including indefinite (unconstrained) types.
8871
8872 @item Ada.Storage_IO (A.9)
8873 This package provides a facility for mapping arbitrary Ada types to and
8874 from a storage buffer. It is primarily intended for the creation of new
8875 IO packages.
8876
8877 @item Ada.Streams (13.13.1)
8878 This is a generic package that provides the basic support for the
8879 concept of streams as used by the stream attributes (@code{Input},
8880 @code{Output}, @code{Read} and @code{Write}).
8881
8882 @item Ada.Streams.Stream_IO (A.12.1)
8883 This package is a specialization of the type @code{Streams} defined in
8884 package @code{Streams} together with a set of operations providing
8885 Stream_IO capability. The Stream_IO model permits both random and
8886 sequential access to a file which can contain an arbitrary set of values
8887 of one or more Ada types.
8888
8889 @item Ada.Strings (A.4.1)
8890 This package provides some basic constants used by the string handling
8891 packages.
8892
8893 @item Ada.Strings.Bounded (A.4.4)
8894 This package provides facilities for handling variable length
8895 strings. The bounded model requires a maximum length. It is thus
8896 somewhat more limited than the unbounded model, but avoids the use of
8897 dynamic allocation or finalization.
8898
8899 @item Ada.Strings.Fixed (A.4.3)
8900 This package provides facilities for handling fixed length strings.
8901
8902 @item Ada.Strings.Maps (A.4.2)
8903 This package provides facilities for handling character mappings and
8904 arbitrarily defined subsets of characters. For instance it is useful in
8905 defining specialized translation tables.
8906
8907 @item Ada.Strings.Maps.Constants (A.4.6)
8908 This package provides a standard set of predefined mappings and
8909 predefined character sets. For example, the standard upper to lower case
8910 conversion table is found in this package. Note that upper to lower case
8911 conversion is non-trivial if you want to take the entire set of
8912 characters, including extended characters like E with an acute accent,
8913 into account. You should use the mappings in this package (rather than
8914 adding 32 yourself) to do case mappings.
8915
8916 @item Ada.Strings.Unbounded (A.4.5)
8917 This package provides facilities for handling variable length
8918 strings. The unbounded model allows arbitrary length strings, but
8919 requires the use of dynamic allocation and finalization.
8920
8921 @item Ada.Strings.Wide_Bounded (A.4.7)
8922 @itemx Ada.Strings.Wide_Fixed (A.4.7)
8923 @itemx Ada.Strings.Wide_Maps (A.4.7)
8924 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
8925 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
8926 These package provide analogous capabilities to the corresponding
8927 packages without @samp{Wide_} in the name, but operate with the types
8928 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
8929 and @code{Character}.
8930
8931 @item Ada.Synchronous_Task_Control (D.10)
8932 This package provides some standard facilities for controlling task
8933 communication in a synchronous manner.
8934
8935 @item Ada.Tags
8936 This package contains definitions for manipulation of the tags of tagged
8937 values.
8938
8939 @item Ada.Task_Attributes
8940 This package provides the capability of associating arbitrary
8941 task-specific data with separate tasks.
8942
8943 @item Ada.Text_IO
8944 This package provides basic text input-output capabilities for
8945 character, string and numeric data. The subpackages of this
8946 package are listed next.
8947
8948 @item Ada.Text_IO.Decimal_IO
8949 Provides input-output facilities for decimal fixed-point types
8950
8951 @item Ada.Text_IO.Enumeration_IO 
8952 Provides input-output facilities for enumeration types.
8953
8954 @item Ada.Text_IO.Fixed_IO
8955 Provides input-output facilities for ordinary fixed-point types.
8956
8957 @item Ada.Text_IO.Float_IO
8958 Provides input-output facilities for float types. The following
8959 predefined instantiations of this generic package are available:
8960
8961 @table @code
8962 @item Short_Float
8963 @code{Short_Float_Text_IO}
8964 @item Float
8965 @code{Float_Text_IO}
8966 @item Long_Float
8967 @code{Long_Float_Text_IO}
8968 @end table
8969
8970 @item Ada.Text_IO.Integer_IO
8971 Provides input-output facilities for integer types. The following
8972 predefined instantiations of this generic package are available:
8973
8974 @table @code
8975 @item Short_Short_Integer
8976 @code{Ada.Short_Short_Integer_Text_IO}
8977 @item Short_Integer
8978 @code{Ada.Short_Integer_Text_IO}
8979 @item Integer
8980 @code{Ada.Integer_Text_IO}
8981 @item Long_Integer
8982 @code{Ada.Long_Integer_Text_IO}
8983 @item Long_Long_Integer
8984 @code{Ada.Long_Long_Integer_Text_IO}
8985 @end table
8986
8987 @item Ada.Text_IO.Modular_IO
8988 Provides input-output facilities for modular (unsigned) types
8989
8990 @item Ada.Text_IO.Complex_IO (G.1.3)
8991 This package provides basic text input-output capabilities for complex
8992 data.
8993
8994 @item Ada.Text_IO.Editing (F.3.3)
8995 This package contains routines for edited output, analogous to the use
8996 of pictures in COBOL. The picture formats used by this package are a
8997 close copy of the facility in COBOL.
8998
8999 @item Ada.Text_IO.Text_Streams (A.12.2)
9000 This package provides a facility that allows Text_IO files to be treated
9001 as streams, so that the stream attributes can be used for writing
9002 arbitrary data, including binary data, to Text_IO files.
9003
9004 @item Ada.Unchecked_Conversion (13.9)
9005 This generic package allows arbitrary conversion from one type to
9006 another of the same size, providing for breaking the type safety in
9007 special circumstances.
9008
9009 If the types have the same Size (more accurately the same Value_Size),
9010 then the effect is simply to transfer the bits from the source to the
9011 target type without any modification. This usage is well defined, and
9012 for simple types whose representation is typically the same across
9013 all implementations, gives a portable method of performing such
9014 conversions.
9015
9016 If the types do not have the same size, then the result is implementation
9017 defined, and thus may be non-portable. The following describes how GNAT
9018 handles such unchecked conversion cases.
9019
9020 If the types are of different sizes, and are both discrete types, then
9021 the effect is of a normal type conversion without any constraint checking.
9022 In particular if the result type has a larger size, the result will be
9023 zero or sign extended. If the result type has a smaller size, the result
9024 will be truncated by ignoring high order bits.
9025
9026 If the types are of different sizes, and are not both discrete types,
9027 then the conversion works as though pointers were created to the source
9028 and target, and the pointer value is converted. The effect is that bits
9029 are copied from successive low order storage units and bits of the source
9030 up to the length of the target type.
9031
9032 A warning is issued if the lengths differ, since the effect in this
9033 case is implementation dependent, and the above behavior may not match
9034 that of some other compiler.
9035
9036 A pointer to one type may be converted to a pointer to another type using
9037 unchecked conversion. The only case in which the effect is undefined is
9038 when one or both pointers are pointers to unconstrained array types. In
9039 this case, the bounds information may get incorrectly transferred, and in
9040 particular, GNAT uses double size pointers for such types, and it is
9041 meaningless to convert between such pointer types. GNAT will issue a
9042 warning if the alignment of the target designated type is more strict
9043 than the alignment of the source designated type (since the result may
9044 be unaligned in this case).
9045
9046 A pointer other than a pointer to an unconstrained array type may be
9047 converted to and from System.Address. Such usage is common in Ada 83
9048 programs, but note that Ada.Address_To_Access_Conversions is the
9049 preferred method of performing such conversions in Ada 95. Neither
9050 unchecked conversion nor Ada.Address_To_Access_Conversions should be
9051 used in conjunction with pointers to unconstrained objects, since
9052 the bounds information cannot be handled correctly in this case.
9053
9054 @item Ada.Unchecked_Deallocation (13.11.2)
9055 This generic package allows explicit freeing of storage previously
9056 allocated by use of an allocator.
9057
9058 @item Ada.Wide_Text_IO (A.11)
9059 This package is similar to @code{Ada.Text_IO}, except that the external
9060 file supports wide character representations, and the internal types are
9061 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
9062 and @code{String}. It contains generic subpackages listed next.
9063
9064 @item Ada.Wide_Text_IO.Decimal_IO
9065 Provides input-output facilities for decimal fixed-point types
9066
9067 @item Ada.Wide_Text_IO.Enumeration_IO
9068 Provides input-output facilities for enumeration types.
9069
9070 @item Ada.Wide_Text_IO.Fixed_IO
9071 Provides input-output facilities for ordinary fixed-point types.
9072
9073 @item Ada.Wide_Text_IO.Float_IO
9074 Provides input-output facilities for float types. The following
9075 predefined instantiations of this generic package are available:
9076
9077 @table @code
9078 @item Short_Float
9079 @code{Short_Float_Wide_Text_IO}
9080 @item Float
9081 @code{Float_Wide_Text_IO}
9082 @item Long_Float
9083 @code{Long_Float_Wide_Text_IO}
9084 @end table
9085
9086 @item Ada.Wide_Text_IO.Integer_IO
9087 Provides input-output facilities for integer types. The following
9088 predefined instantiations of this generic package are available:
9089
9090 @table @code
9091 @item Short_Short_Integer
9092 @code{Ada.Short_Short_Integer_Wide_Text_IO}
9093 @item Short_Integer
9094 @code{Ada.Short_Integer_Wide_Text_IO}
9095 @item Integer
9096 @code{Ada.Integer_Wide_Text_IO}
9097 @item Long_Integer
9098 @code{Ada.Long_Integer_Wide_Text_IO}
9099 @item Long_Long_Integer
9100 @code{Ada.Long_Long_Integer_Wide_Text_IO}
9101 @end table
9102
9103 @item Ada.Wide_Text_IO.Modular_IO
9104 Provides input-output facilities for modular (unsigned) types
9105
9106 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
9107 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
9108 external file supports wide character representations.
9109
9110 @item Ada.Wide_Text_IO.Editing (F.3.4)
9111 This package is similar to @code{Ada.Text_IO.Editing}, except that the
9112 types are @code{Wide_Character} and @code{Wide_String} instead of
9113 @code{Character} and @code{String}.
9114
9115 @item Ada.Wide_Text_IO.Streams (A.12.3)
9116 This package is similar to @code{Ada.Text_IO.Streams}, except that the
9117 types are @code{Wide_Character} and @code{Wide_String} instead of
9118 @code{Character} and @code{String}.
9119 @end table
9120 @node The Implementation of Standard I/O
9121 @chapter The Implementation of Standard I/O
9122
9123 @noindent
9124 GNAT implements all the required input-output facilities described in
9125 A.6 through A.14. These sections of the Ada 95 reference manual describe the
9126 required behavior of these packages from the Ada point of view, and if
9127 you are writing a portable Ada program that does not need to know the
9128 exact manner in which Ada maps to the outside world when it comes to
9129 reading or writing external files, then you do not need to read this
9130 chapter. As long as your files are all regular files (not pipes or
9131 devices), and as long as you write and read the files only from Ada, the
9132 description in the Ada 95 reference manual is sufficient.
9133
9134 However, if you want to do input-output to pipes or other devices, such
9135 as the keyboard or screen, or if the files you are dealing with are
9136 either generated by some other language, or to be read by some other
9137 language, then you need to know more about the details of how the GNAT
9138 implementation of these input-output facilities behaves.
9139
9140 In this chapter we give a detailed description of exactly how GNAT
9141 interfaces to the file system. As always, the sources of the system are
9142 available to you for answering questions at an even more detailed level,
9143 but for most purposes the information in this chapter will suffice.
9144
9145 Another reason that you may need to know more about how input-output is
9146 implemented arises when you have a program written in mixed languages
9147 where, for example, files are shared between the C and Ada sections of
9148 the same program. GNAT provides some additional facilities, in the form
9149 of additional child library packages, that facilitate this sharing, and
9150 these additional facilities are also described in this chapter.
9151
9152 @menu
9153 * Standard I/O Packages::       
9154 * FORM Strings::                
9155 * Direct_IO::                   
9156 * Sequential_IO::               
9157 * Text_IO::                     
9158 * Wide_Text_IO::                
9159 * Stream_IO::                   
9160 * Shared Files::                
9161 * Open Modes::                  
9162 * Operations on C Streams::     
9163 * Interfacing to C Streams::    
9164 @end menu
9165
9166 @node Standard I/O Packages
9167 @section Standard I/O Packages
9168
9169 @noindent
9170 The Standard I/O packages described in Annex A for
9171
9172 @itemize @bullet
9173 @item
9174 Ada.Text_IO
9175 @item
9176 Ada.Text_IO.Complex_IO
9177 @item
9178 Ada.Text_IO.Text_Streams,
9179 @item
9180 Ada.Wide_Text_IO
9181 @item
9182 Ada.Wide_Text_IO.Complex_IO,
9183 @item
9184 Ada.Wide_Text_IO.Text_Streams
9185 @item
9186 Ada.Stream_IO
9187 @item
9188 Ada.Sequential_IO
9189 @item
9190 Ada.Direct_IO
9191 @end itemize
9192
9193 @noindent
9194 are implemented using the C
9195 library streams facility; where
9196
9197 @itemize @bullet
9198 @item
9199 All files are opened using @code{fopen}.
9200 @item
9201 All input/output operations use @code{fread}/@code{fwrite}.
9202 @end itemize
9203
9204 There is no internal buffering of any kind at the Ada library level. The
9205 only buffering is that provided at the system level in the
9206 implementation of the C library routines that support streams. This
9207 facilitates shared use of these streams by mixed language programs.
9208
9209 @node FORM Strings
9210 @section FORM Strings
9211
9212 @noindent
9213 The format of a FORM string in GNAT is:
9214
9215 @smallexample
9216 "keyword=value,keyword=value,...,keyword=value"
9217 @end smallexample
9218
9219 @noindent
9220 where letters may be in upper or lower case, and there are no spaces
9221 between values. The order of the entries is not important. Currently
9222 there are two keywords defined.
9223
9224 @smallexample
9225 SHARED=[YES|NO]
9226 WCEM=[n|h|u|s\e]
9227 @end smallexample
9228
9229 The use of these parameters is described later in this section.
9230
9231 @node Direct_IO
9232 @section Direct_IO
9233
9234 @noindent
9235 Direct_IO can only be instantiated for definite types. This is a
9236 restriction of the Ada language, which means that the records are fixed
9237 length (the length being determined by @code{@var{type}'Size}, rounded
9238 up to the next storage unit boundary if necessary).
9239
9240 The records of a Direct_IO file are simply written to the file in index
9241 sequence, with the first record starting at offset zero, and subsequent
9242 records following. There is no control information of any kind. For
9243 example, if 32-bit integers are being written, each record takes
9244 4-bytes, so the record at index @var{K} starts at offset (@var{K} -
9245 1)*4.
9246
9247 There is no limit on the size of Direct_IO files, they are expanded as
9248 necessary to accommodate whatever records are written to the file.
9249
9250 @node Sequential_IO
9251 @section Sequential_IO
9252
9253 @noindent
9254 Sequential_IO may be instantiated with either a definite (constrained)
9255 or indefinite (unconstrained) type.
9256
9257 For the definite type case, the elements written to the file are simply
9258 the memory images of the data values with no control information of any
9259 kind. The resulting file should be read using the same type, no validity
9260 checking is performed on input.
9261
9262 For the indefinite type case, the elements written consist of two
9263 parts. First is the size of the data item, written as the memory image
9264 of a @code{Interfaces.C.size_t} value, followed by the memory image of
9265 the data value. The resulting file can only be read using the same
9266 (unconstrained) type. Normal assignment checks are performed on these
9267 read operations, and if these checks fail, @code{Data_Error} is
9268 raised. In particular, in the array case, the lengths must match, and in
9269 the variant record case, if the variable for a particular read operation
9270 is constrained, the discriminants must match.
9271
9272 Note that it is not possible to use Sequential_IO to write variable
9273 length array items, and then read the data back into different length
9274 arrays. For example, the following will raise @code{Data_Error}:
9275
9276 @smallexample
9277  package IO is new Sequential_IO (String);
9278  F : IO.File_Type;
9279  S : String (1..4);
9280  ...
9281  IO.Create (F)
9282  IO.Write (F, "hello!")
9283  IO.Reset (F, Mode=>In_File);
9284  IO.Read (F, S);
9285  Put_Line (S);
9286
9287 @end smallexample
9288
9289 On some Ada implementations, this will print @samp{hell}, but the program is
9290 clearly incorrect, since there is only one element in the file, and that
9291 element is the string @samp{hello!}.
9292
9293 In Ada 95, this kind of behavior can be legitimately achieved using
9294 Stream_IO, and this is the preferred mechanism. In particular, the above
9295 program fragment rewritten to use Stream_IO will work correctly.
9296
9297 @node Text_IO
9298 @section Text_IO
9299
9300 @noindent
9301 Text_IO files consist of a stream of characters containing the following
9302 special control characters:
9303
9304 @smallexample
9305 LF (line feed, 16#0A#) Line Mark
9306 FF (form feed, 16#0C#) Page Mark
9307 @end smallexample
9308
9309 A canonical Text_IO file is defined as one in which the following
9310 conditions are met:
9311
9312 @itemize @bullet
9313 @item
9314 The character @code{LF} is used only as a line mark, i.e. to mark the end
9315 of the line.
9316
9317 @item
9318 The character @code{FF} is used only as a page mark, i.e. to mark the
9319 end of a page and consequently can appear only immediately following a
9320 @code{LF} (line mark) character.
9321
9322 @item
9323 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
9324 (line mark, page mark). In the former case, the page mark is implicitly
9325 assumed to be present.
9326 @end itemize
9327
9328 A file written using Text_IO will be in canonical form provided that no
9329 explicit @code{LF} or @code{FF} characters are written using @code{Put}
9330 or @code{Put_Line}. There will be no @code{FF} character at the end of
9331 the file unless an explicit @code{New_Page} operation was performed
9332 before closing the file.
9333
9334 A canonical Text_IO file that is a regular file, i.e. not a device or a
9335 pipe, can be read using any of the routines in Text_IO. The
9336 semantics in this case will be exactly as defined in the Ada 95 reference
9337 manual and all the routines in Text_IO are fully implemented.
9338
9339 A text file that does not meet the requirements for a canonical Text_IO
9340 file has one of the following:
9341
9342 @itemize @bullet
9343 @item
9344 The file contains @code{FF} characters not immediately following a
9345 @code{LF} character.
9346
9347 @item
9348 The file contains @code{LF} or @code{FF} characters written by
9349 @code{Put} or @code{Put_Line}, which are not logically considered to be
9350 line marks or page marks.
9351
9352 @item
9353 The file ends in a character other than @code{LF} or @code{FF},
9354 i.e. there is no explicit line mark or page mark at the end of the file.
9355 @end itemize
9356
9357 Text_IO can be used to read such non-standard text files but subprograms
9358 to do with line or page numbers do not have defined meanings. In
9359 particular, a @code{FF} character that does not follow a @code{LF}
9360 character may or may not be treated as a page mark from the point of
9361 view of page and line numbering. Every @code{LF} character is considered
9362 to end a line, and there is an implied @code{LF} character at the end of
9363 the file.
9364
9365 @menu
9366 * Text_IO Stream Pointer Positioning::  
9367 * Text_IO Reading and Writing Non-Regular Files::  
9368 * Get_Immediate::               
9369 * Treating Text_IO Files as Streams::
9370 * Text_IO Extensions::
9371 * Text_IO Facilities for Unbounded Strings::
9372 @end menu
9373 @node Text_IO Stream Pointer Positioning
9374
9375 @subsection Stream Pointer Positioning
9376
9377 @noindent
9378 @code{Ada.Text_IO} has a definition of current position for a file that
9379 is being read. No internal buffering occurs in Text_IO, and usually the
9380 physical position in the stream used to implement the file corresponds
9381 to this logical position defined by Text_IO. There are two exceptions:
9382
9383 @itemize @bullet
9384 @item
9385 After a call to @code{End_Of_Page} that returns @code{True}, the stream
9386 is positioned past the @code{LF} (line mark) that precedes the page
9387 mark. Text_IO maintains an internal flag so that subsequent read
9388 operations properly handle the logical position which is unchanged by
9389 the @code{End_Of_Page} call.
9390
9391 @item
9392 After a call to @code{End_Of_File} that returns @code{True}, if the
9393 Text_IO file was positioned before the line mark at the end of file
9394 before the call, then the logical position is unchanged, but the stream
9395 is physically positioned right at the end of file (past the line mark,
9396 and past a possible page mark following the line mark. Again Text_IO
9397 maintains internal flags so that subsequent read operations properly
9398 handle the logical position.
9399 @end itemize
9400
9401 These discrepancies have no effect on the observable behavior of
9402 Text_IO, but if a single Ada stream is shared between a C program and
9403 Ada program, or shared (using @samp{shared=yes} in the form string)
9404 between two Ada files, then the difference may be observable in some
9405 situations.
9406
9407 @node Text_IO Reading and Writing Non-Regular Files
9408 @subsection Reading and Writing Non-Regular Files
9409
9410 @noindent
9411 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
9412 can be used for reading and writing. Writing is not affected and the
9413 sequence of characters output is identical to the normal file case, but
9414 for reading, the behavior of Text_IO is modified to avoid undesirable
9415 look-ahead as follows:
9416
9417 An input file that is not a regular file is considered to have no page
9418 marks. Any @code{Ascii.FF} characters (the character normally used for a
9419 page mark) appearing in the file are considered to be data
9420 characters. In particular:
9421
9422 @itemize @bullet
9423 @item
9424 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
9425 following a line mark. If a page mark appears, it will be treated as a
9426 data character.
9427
9428 @item
9429 This avoids the need to wait for an extra character to be typed or
9430 entered from the pipe to complete one of these operations.
9431
9432 @item
9433 @code{End_Of_Page} always returns @code{False}
9434
9435 @item
9436 @code{End_Of_File} will return @code{False} if there is a page mark at
9437 the end of the file.
9438 @end itemize
9439
9440 Output to non-regular files is the same as for regular files. Page marks
9441 may be written to non-regular files using @code{New_Page}, but as noted
9442 above they will not be treated as page marks on input if the output is
9443 piped to another Ada program.
9444
9445 Another important discrepancy when reading non-regular files is that the end
9446 of file indication is not "sticky". If an end of file is entered, e.g. by
9447 pressing the @code{EOT} key,
9448 then end of file
9449 is signalled once (i.e. the test @code{End_Of_File}
9450 will yield @code{True}, or a read will
9451 raise @code{End_Error}), but then reading can resume
9452 to read data past that end of
9453 file indication, until another end of file indication is entered.
9454
9455 @node Get_Immediate
9456 @subsection Get_Immediate
9457 @cindex Get_Immediate
9458
9459 @noindent
9460 Get_Immediate returns the next character (including control characters)
9461 from the input file. In particular, Get_Immediate will return LF or FF
9462 characters used as line marks or page marks. Such operations leave the
9463 file positioned past the control character, and it is thus not treated
9464 as having its normal function. This means that page, line and column
9465 counts after this kind of Get_Immediate call are set as though the mark
9466 did not occur. In the case where a Get_Immediate leaves the file
9467 positioned between the line mark and page mark (which is not normally
9468 possible), it is undefined whether the FF character will be treated as a
9469 page mark.
9470
9471 @node Treating Text_IO Files as Streams
9472 @subsection Treating Text_IO Files as Streams
9473 @cindex Stream files
9474
9475 @noindent
9476 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
9477 as a stream. Data written to a Text_IO file in this stream mode is
9478 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
9479 16#0C# (@code{FF}), the resulting file may have non-standard
9480 format. Similarly if read operations are used to read from a Text_IO
9481 file treated as a stream, then @code{LF} and @code{FF} characters may be
9482 skipped and the effect is similar to that described above for
9483 @code{Get_Immediate}.
9484
9485 @node Text_IO Extensions
9486 @subsection Text_IO Extensions
9487 @cindex Text_IO extensions
9488
9489 @noindent
9490 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
9491 to the standard @code{Text_IO} package:
9492
9493 @itemize @bullet
9494 @item function File_Exists (Name : String) return Boolean;
9495 Determines if a file of the given name exists and can be successfully
9496 opened (without actually performing the open operation).
9497
9498 @item function Get_Line return String;
9499 Reads a string from the standard input file. The value returned is exactly
9500 the length of the line that was read.
9501
9502 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
9503 Similar, except that the parameter File specifies the file from which
9504 the string is to be read.
9505
9506 @end itemize
9507
9508 @node Text_IO Facilities for Unbounded Strings
9509 @subsection Text_IO Facilities for Unbounded Strings
9510 @cindex Text_IO for unbounded strings
9511 @cindex Unbounded_String, Text_IO operations
9512
9513 @noindent
9514 The package @code{Ada.Strings.Unbounded.Text_IO}
9515 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
9516 subprograms useful for Text_IO operations on unbounded strings:
9517
9518 @itemize @bullet
9519
9520 @item function Get_Line (File : File_Type) return Unbounded_String;
9521 Reads a line from the specified file
9522 and returns the result as an unbounded string.
9523
9524 @item procedure Put (File : File_Type; U : Unbounded_String);
9525 Writes the value of the given unbounded string to the specified file
9526 Similar to the effect of
9527 @code{Put (To_String (U))} except that an extra copy is avoided.
9528
9529 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
9530 Writes the value of the given unbounded string to the specified file,
9531 followed by a @code{New_Line}.
9532 Similar to the effect of @code{Put_Line (To_String (U))} except
9533 that an extra copy is avoided.
9534 @end itemize
9535
9536 @noindent
9537 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
9538 and is optional. If the parameter is omitted, then the standard input or
9539 output file is referenced as appropriate.
9540
9541 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
9542 files @code{a-swuwti.ads/adb} provides similar extended @code{Wide_Text_IO}
9543 functionality for unbounded wide strings.
9544
9545 @node Wide_Text_IO
9546 @section Wide_Text_IO
9547
9548 @noindent
9549 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
9550 both input and output files may contain special sequences that represent
9551 wide character values. The encoding scheme for a given file may be
9552 specified using a FORM parameter:
9553
9554 @smallexample
9555 WCEM=@var{x}
9556 @end smallexample
9557
9558 @noindent
9559 as part of the FORM string (WCEM = wide character encoding method),
9560 where @var{x} is one of the following characters
9561
9562 @table @samp
9563 @item h
9564 Hex ESC encoding
9565 @item u
9566 Upper half encoding
9567 @item s
9568 Shift-JIS encoding
9569 @item e
9570 EUC Encoding
9571 @item 8
9572 UTF-8 encoding
9573 @item b
9574 Brackets encoding
9575 @end table
9576
9577 The encoding methods match those that
9578 can be used in a source
9579 program, but there is no requirement that the encoding method used for
9580 the source program be the same as the encoding method used for files,
9581 and different files may use different encoding methods.
9582
9583 The default encoding method for the standard files, and for opened files
9584 for which no WCEM parameter is given in the FORM string matches the
9585 wide character encoding specified for the main program (the default
9586 being brackets encoding if no coding method was specified with -gnatW).
9587
9588 @table @asis
9589 @item Hex Coding
9590 In this encoding, a wide character is represented by a five character
9591 sequence:
9592
9593 @smallexample
9594 ESC a b c d
9595 @end smallexample
9596
9597 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
9598 characters (using upper case letters) of the wide character code. For
9599 example, ESC A345 is used to represent the wide character with code
9600 16#A345#. This scheme is compatible with use of the full
9601 @code{Wide_Character} set.
9602
9603 @item Upper Half Coding
9604 The wide character with encoding 16#abcd#, where the upper bit is on
9605 (i.e. a is in the range 8-F) is represented as two bytes 16#ab# and
9606 16#cd#. The second byte may never be a format control character, but is
9607 not required to be in the upper half. This method can be also used for
9608 shift-JIS or EUC where the internal coding matches the external coding. 
9609
9610 @item Shift JIS Coding
9611 A wide character is represented by a two character sequence 16#ab# and
9612 16#cd#, with the restrictions described for upper half encoding as
9613 described above. The internal character code is the corresponding JIS
9614 character according to the standard algorithm for Shift-JIS
9615 conversion. Only characters defined in the JIS code set table can be
9616 used with this encoding method.
9617
9618 @item EUC Coding
9619 A wide character is represented by a two character sequence 16#ab# and
9620 16#cd#, with both characters being in the upper half. The internal
9621 character code is the corresponding JIS character according to the EUC
9622 encoding algorithm. Only characters defined in the JIS code set table
9623 can be used with this encoding method.
9624
9625 @item UTF-8 Coding
9626 A wide character is represented using
9627 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
9628 10646-1/Am.2.  Depending on the character value, the representation
9629 is a one, two, or three byte sequence:
9630
9631 @smallexample
9632 16#0000#-16#007f#: 2#0xxxxxxx#
9633 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
9634 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
9635 @end smallexample
9636
9637 where the xxx bits correspond to the left-padded bits of the
9638 16-bit character value. Note that all lower half ASCII characters
9639 are represented as ASCII bytes and all upper half characters and
9640 other wide characters are represented as sequences of upper-half
9641 (The full UTF-8 scheme allows for encoding 31-bit characters as
9642 6-byte sequences, but in this implementation, all UTF-8 sequences
9643 of four or more bytes length will raise a Constraint_Error, as
9644 will all illegal UTF-8 sequences.)
9645
9646 @item Brackets Coding
9647 In this encoding, a wide character is represented by the following eight
9648 character sequence:
9649
9650 @smallexample
9651 [ " a b c d " ]
9652 @end smallexample
9653
9654 Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
9655 characters (using uppercase letters) of the wide character code. For
9656 example, @code{["A345"]} is used to represent the wide character with code
9657 @code{16#A345#}.
9658 This scheme is compatible with use of the full Wide_Character set.
9659 On input, brackets coding can also be used for upper half characters,
9660 e.g. @code{["C1"]} for lower case a. However, on output, brackets notation
9661 is only used for wide characters with a code greater than @code{16#FF#}.
9662
9663 @end table
9664
9665 For the coding schemes other than Hex and Brackets encoding,
9666 not all wide character
9667 values can be represented. An attempt to output a character that cannot
9668 be represented using the encoding scheme for the file causes
9669 Constraint_Error to be raised. An invalid wide character sequence on
9670 input also causes Constraint_Error to be raised.
9671
9672 @menu
9673 * Wide_Text_IO Stream Pointer Positioning::  
9674 * Wide_Text_IO Reading and Writing Non-Regular Files::  
9675 @end menu
9676
9677 @node Wide_Text_IO Stream Pointer Positioning
9678 @subsection Stream Pointer Positioning
9679
9680 @noindent
9681 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
9682 of stream pointer positioning (@pxref{Text_IO}). There is one additional
9683 case:
9684
9685 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
9686 normal lower ASCII set (i.e. a character in the range:
9687
9688 @smallexample
9689 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
9690 @end smallexample
9691
9692 @noindent
9693 then although the logical position of the file pointer is unchanged by
9694 the @code{Look_Ahead} call, the stream is physically positioned past the
9695 wide character sequence. Again this is to avoid the need for buffering
9696 or backup, and all @code{Wide_Text_IO} routines check the internal
9697 indication that this situation has occurred so that this is not visible
9698 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
9699 can be observed if the wide text file shares a stream with another file.
9700
9701 @node Wide_Text_IO Reading and Writing Non-Regular Files
9702 @subsection Reading and Writing Non-Regular Files
9703
9704 @noindent
9705 As in the case of Text_IO, when a non-regular file is read, it is
9706 assumed that the file contains no page marks (any form characters are
9707 treated as data characters), and @code{End_Of_Page} always returns
9708 @code{False}. Similarly, the end of file indication is not sticky, so
9709 it is possible to read beyond an end of file.
9710
9711 @node Stream_IO
9712 @section Stream_IO
9713
9714 @noindent
9715 A stream file is a sequence of bytes, where individual elements are
9716 written to the file as described in the Ada 95 reference manual. The type
9717 @code{Stream_Element} is simply a byte. There are two ways to read or
9718 write a stream file.
9719
9720 @itemize @bullet
9721 @item
9722 The operations @code{Read} and @code{Write} directly read or write a
9723 sequence of stream elements with no control information.
9724
9725 @item
9726 The stream attributes applied to a stream file transfer data in the
9727 manner described for stream attributes.
9728 @end itemize
9729
9730 @node Shared Files
9731 @section Shared Files
9732
9733 @noindent
9734 Section A.14 of the Ada 95 Reference Manual allows implementations to
9735 provide a wide variety of behavior if an attempt is made to access the
9736 same external file with two or more internal files.
9737
9738 To provide a full range of functionality, while at the same time
9739 minimizing the problems of portability caused by this implementation
9740 dependence, GNAT handles file sharing as follows:
9741
9742 @itemize @bullet
9743 @item
9744 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
9745 to open two or more files with the same full name is considered an error
9746 and is not supported. The exception @code{Use_Error} will be
9747 raised. Note that a file that is not explicitly closed by the program
9748 remains open until the program terminates.
9749
9750 @item
9751 If the form parameter @samp{shared=no} appears in the form string, the
9752 file can be opened or created with its own separate stream identifier,
9753 regardless of whether other files sharing the same external file are
9754 opened. The exact effect depends on how the C stream routines handle
9755 multiple accesses to the same external files using separate streams.
9756
9757 @item
9758 If the form parameter @samp{shared=yes} appears in the form string for
9759 each of two or more files opened using the same full name, the same
9760 stream is shared between these files, and the semantics are as described
9761 in Ada 95 Reference Manual, Section A.14.
9762 @end itemize
9763
9764 When a program that opens multiple files with the same name is ported
9765 from another Ada compiler to GNAT, the effect will be that
9766 @code{Use_Error} is raised.
9767
9768 The documentation of the original compiler and the documentation of the
9769 program should then be examined to determine if file sharing was
9770 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
9771 and @code{Create} calls as required.
9772
9773 When a program is ported from GNAT to some other Ada compiler, no
9774 special attention is required unless the @samp{shared=@var{xxx}} form
9775 parameter is used in the program. In this case, you must examine the
9776 documentation of the new compiler to see if it supports the required
9777 file sharing semantics, and form strings modified appropriately. Of
9778 course it may be the case that the program cannot be ported if the
9779 target compiler does not support the required functionality. The best
9780 approach in writing portable code is to avoid file sharing (and hence
9781 the use of the @samp{shared=@var{xxx}} parameter in the form string)
9782 completely.
9783
9784 One common use of file sharing in Ada 83 is the use of instantiations of
9785 Sequential_IO on the same file with different types, to achieve
9786 heterogeneous input-output. Although this approach will work in GNAT if
9787 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
9788 for this purpose (using the stream attributes)
9789
9790 @node Open Modes
9791 @section Open Modes
9792
9793 @noindent
9794 @code{Open} and @code{Create} calls result in a call to @code{fopen}
9795 using the mode shown in Table 6.1
9796
9797 @sp 2
9798 @center Table 6-1 @code{Open} and @code{Create} Call Modes
9799 @smallexample
9800                                @b{OPEN }           @b{CREATE}
9801 Append_File                    "r+"             "w+"
9802 In_File                        "r"              "w+"
9803 Out_File (Direct_IO)           "r+"             "w"
9804 Out_File (all other cases)     "w"              "w"
9805 Inout_File                     "r+"             "w+"
9806 @end smallexample
9807
9808 If text file translation is required, then either @samp{b} or @samp{t}
9809 is added to the mode, depending on the setting of Text. Text file
9810 translation refers to the mapping of CR/LF sequences in an external file
9811 to LF characters internally. This mapping only occurs in DOS and
9812 DOS-like systems, and is not relevant to other systems.
9813
9814 A special case occurs with Stream_IO. As shown in the above table, the
9815 file is initially opened in @samp{r} or @samp{w} mode for the
9816 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
9817 subsequently requires switching from reading to writing or vice-versa,
9818 then the file is reopened in @samp{r+} mode to permit the required operation.
9819
9820 @node Operations on C Streams
9821 @section Operations on C Streams
9822 The package @code{Interfaces.C_Streams} provides an Ada program with direct
9823 access to the C library functions for operations on C streams:
9824
9825 @smallexample
9826 package Interfaces.C_Streams is
9827   -- Note: the reason we do not use the types that are in
9828   -- Interfaces.C is that we want to avoid dragging in the
9829   -- code in this unit if possible.
9830   subtype chars is System.Address;
9831   -- Pointer to null-terminated array of characters
9832   subtype FILEs is System.Address;
9833   -- Corresponds to the C type FILE*
9834   subtype voids is System.Address;
9835   -- Corresponds to the C type void*
9836   subtype int is Integer;
9837   subtype long is Long_Integer;
9838   -- Note: the above types are subtypes deliberately, and it
9839   -- is part of this spec that the above correspondences are
9840   -- guaranteed. This means that it is legitimate to, for
9841   -- example, use Integer instead of int. We provide these
9842   -- synonyms for clarity, but in some cases it may be
9843   -- convenient to use the underlying types (for example to
9844   -- avoid an unnecessary dependency of a spec on the spec
9845   -- of this unit).
9846   type size_t is mod 2 ** Standard'Address_Size;
9847   NULL_Stream : constant FILEs;
9848   -- Value returned (NULL in C) to indicate an
9849   -- fdopen/fopen/tmpfile error
9850   ----------------------------------
9851   -- Constants Defined in stdio.h --
9852   ----------------------------------
9853   EOF : constant int;
9854   -- Used by a number of routines to indicate error or 
9855   -- end of file
9856   IOFBF : constant int;
9857   IOLBF : constant int;
9858   IONBF : constant int;
9859   -- Used to indicate buffering mode for setvbuf call
9860   SEEK_CUR : constant int;
9861   SEEK_END : constant int;
9862   SEEK_SET : constant int;
9863   -- Used to indicate origin for fseek call
9864   function stdin return FILEs;
9865   function stdout return FILEs;
9866   function stderr return FILEs;
9867   -- Streams associated with standard files
9868   --------------------------
9869   -- Standard C functions --
9870   --------------------------
9871   -- The functions selected below are ones that are
9872   -- available in DOS, OS/2, UNIX and Xenix (but not
9873   -- necessarily in ANSI C). These are very thin interfaces
9874   -- which copy exactly the C headers. For more
9875   -- documentation on these functions, see the Microsoft C 
9876   -- "Run-Time Library Reference" (Microsoft Press, 1990,
9877   -- ISBN 1-55615-225-6), which includes useful information
9878   -- on system compatibility.
9879   procedure clearerr (stream : FILEs);
9880   function fclose (stream : FILEs) return int;
9881   function fdopen (handle : int; mode : chars) return FILEs; 
9882   function feof (stream : FILEs) return int; 
9883   function ferror (stream : FILEs) return int; 
9884   function fflush (stream : FILEs) return int; 
9885   function fgetc (stream : FILEs) return int; 
9886   function fgets (strng : chars; n : int; stream : FILEs) 
9887       return chars; 
9888   function fileno (stream : FILEs) return int; 
9889   function fopen (filename : chars; Mode : chars) 
9890       return FILEs;
9891   -- Note: to maintain target independence, use
9892   -- text_translation_required, a boolean variable defined in
9893   -- a-sysdep.c to deal with the target dependent text
9894   -- translation requirement. If this variable is set, 
9895   -- then  b/t should be appended to the standard mode
9896   -- argument to set the text translation mode off or on 
9897   -- as required.
9898   function fputc (C : int; stream : FILEs) return int;
9899   function fputs (Strng : chars; Stream : FILEs) return int;
9900   function fread
9901      (buffer : voids;
9902       size : size_t;
9903       count : size_t;
9904       stream : FILEs)
9905       return size_t;
9906   function freopen
9907      (filename : chars;
9908       mode : chars;
9909       stream : FILEs)
9910       return FILEs;
9911   function fseek
9912      (stream : FILEs;
9913       offset : long;
9914       origin : int)
9915       return int;
9916   function ftell (stream : FILEs) return long;
9917   function fwrite
9918      (buffer : voids;
9919       size : size_t;
9920       count : size_t;
9921       stream : FILEs)
9922       return size_t; 
9923   function isatty (handle : int) return int;
9924   procedure mktemp (template : chars);
9925   -- The return value (which is just a pointer to template)
9926   -- is discarded
9927   procedure rewind (stream : FILEs);
9928   function rmtmp return int;
9929   function setvbuf
9930      (stream : FILEs;
9931       buffer : chars;
9932       mode : int;
9933       size : size_t)
9934       return int;
9935
9936   function tmpfile return FILEs;
9937   function ungetc (c : int; stream : FILEs) return int;
9938   function unlink (filename : chars) return int;
9939   ---------------------
9940   -- Extra functions --
9941   ---------------------
9942   -- These functions supply slightly thicker bindings than
9943   -- those above. They are derived from functions in the 
9944   -- C Run-Time Library, but may do a bit more work than
9945   -- just directly calling one of the Library functions.
9946   function is_regular_file (handle : int) return int;
9947   -- Tests if given handle is for a regular file (result 1)
9948   -- or for a non-regular file (pipe or device, result 0).
9949   ---------------------------------
9950   -- Control of Text/Binary Mode --
9951   ---------------------------------
9952   -- If text_translation_required is true, then the following
9953   -- functions may be used to dynamically switch a file from
9954   -- binary to text mode or vice versa. These functions have
9955   -- no effect if text_translation_required is false (i.e. in
9956   -- normal UNIX mode). Use fileno to get a stream handle.
9957   procedure set_binary_mode (handle : int);
9958   procedure set_text_mode (handle : int);
9959   ----------------------------
9960   -- Full Path Name support --
9961   ----------------------------
9962   procedure full_name (nam : chars; buffer : chars);
9963   -- Given a NUL terminated string representing a file
9964   -- name, returns in buffer a NUL terminated string
9965   -- representing the full path name for the file name. 
9966   -- On systems where it is relevant the   drive is also
9967   -- part of the full path name. It is the responsibility 
9968   -- of the caller to pass an actual parameter for buffer
9969   -- that is big enough for any full path name. Use
9970   -- max_path_len given below as the size of buffer.
9971   max_path_len : integer;
9972   -- Maximum length of an allowable full path name on the
9973   -- system, including a terminating NUL character.
9974 end Interfaces.C_Streams;
9975 @end smallexample
9976
9977 @node Interfacing to C Streams
9978 @section Interfacing to C Streams
9979
9980 @noindent
9981 The packages in this section permit interfacing Ada files to C Stream
9982 operations.
9983
9984 @smallexample
9985  with Interfaces.C_Streams;
9986  package Ada.Sequential_IO.C_Streams is
9987     function C_Stream (F : File_Type)  
9988        return Interfaces.C_Streams.FILEs;
9989     procedure Open
9990       (File : in out File_Type;
9991        Mode : in File_Mode;
9992        C_Stream : in Interfaces.C_Streams.FILEs;
9993        Form : in String := "");
9994  end Ada.Sequential_IO.C_Streams;
9995
9996   with Interfaces.C_Streams;
9997   package Ada.Direct_IO.C_Streams is
9998      function C_Stream (F : File_Type) 
9999         return Interfaces.C_Streams.FILEs;
10000      procedure Open
10001        (File : in out File_Type;
10002         Mode : in File_Mode;
10003         C_Stream : in Interfaces.C_Streams.FILEs;
10004         Form : in String := "");
10005   end Ada.Direct_IO.C_Streams;
10006
10007   with Interfaces.C_Streams;
10008   package Ada.Text_IO.C_Streams is
10009      function C_Stream (F : File_Type)
10010         return Interfaces.C_Streams.FILEs;
10011      procedure Open
10012        (File : in out File_Type;
10013         Mode : in File_Mode;
10014         C_Stream : in Interfaces.C_Streams.FILEs;
10015         Form : in String := "");
10016   end Ada.Text_IO.C_Streams;
10017
10018   with Interfaces.C_Streams;
10019   package Ada.Wide_Text_IO.C_Streams is
10020      function C_Stream (F : File_Type)  
10021         return Interfaces.C_Streams.FILEs;
10022      procedure Open
10023        (File : in out File_Type;
10024         Mode : in File_Mode;
10025         C_Stream : in Interfaces.C_Streams.FILEs;
10026         Form : in String := "");
10027  end Ada.Wide_Text_IO.C_Streams;
10028
10029  with Interfaces.C_Streams;
10030  package Ada.Stream_IO.C_Streams is
10031     function C_Stream (F : File_Type)
10032        return Interfaces.C_Streams.FILEs;
10033     procedure Open
10034       (File : in out File_Type;
10035        Mode : in File_Mode;
10036        C_Stream : in Interfaces.C_Streams.FILEs;
10037        Form : in String := "");
10038  end Ada.Stream_IO.C_Streams;
10039 @end smallexample
10040
10041 In each of these five packages, the @code{C_Stream} function obtains the
10042 @code{FILE} pointer from a currently opened Ada file. It is then
10043 possible to use the @code{Interfaces.C_Streams} package to operate on
10044 this stream, or the stream can be passed to a C program which can
10045 operate on it directly. Of course the program is responsible for
10046 ensuring that only appropriate sequences of operations are executed.
10047
10048 One particular use of relevance to an Ada program is that the
10049 @code{setvbuf} function can be used to control the buffering of the
10050 stream used by an Ada file. In the absence of such a call the standard
10051 default buffering is used.
10052
10053 The @code{Open} procedures in these packages open a file giving an
10054 existing C Stream instead of a file name. Typically this stream is
10055 imported from a C program, allowing an Ada file to operate on an
10056 existing C file.
10057
10058 @node The GNAT Library
10059 @chapter The GNAT Library
10060
10061 @noindent
10062 The GNAT library contains a number of general and special purpose packages.
10063 It represents functionality that the GNAT developers have found useful, and
10064 which is made available to GNAT users. The packages described here are fully
10065 supported, and upwards compatibility will be maintained in future releases,
10066 so you can use these facilities with the confidence that the same functionality
10067 will be available in future releases.
10068
10069 The chapter here simply gives a brief summary of the facilities available.
10070 The full documentation is found in the spec file for the package. The full
10071 sources of these library packages, including both spec and body, are provided
10072 with all GNAT releases. For example, to find out the full specifications of
10073 the SPITBOL pattern matching capability, including a full tutorial and 
10074 extensive examples, look in the g-spipat.ads file in the library.
10075
10076 For each entry here, the package name (as it would appear in a @code{with}
10077 clause) is given, followed by the name of the corresponding spec file in
10078 parentheses. The packages are children in four hierarchies, @code{Ada},
10079 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
10080 GNAT-specific hierarchy.
10081
10082 Note that an application program should only use packages in one of these
10083 four hierarchies if the package is defined in the Ada Reference Manual,
10084 or is listed in this section of the GNAT Programmers Reference Manual.
10085 All other units should be considered internal implementation units and
10086 should not be directly @code{with}'ed by application code. The use of
10087 a @code{with} statement that references one of these internal implementation
10088 units makes an application potentially dependent on changes in versions
10089 of GNAT, and will generate a warning message.
10090
10091 @menu
10092 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
10093 * Ada.Command_Line.Remove (a-colire.ads)::
10094 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
10095 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
10096 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
10097 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
10098 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
10099 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
10100 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
10101 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
10102 * GNAT.AWK (g-awk.ads)::
10103 * GNAT.Bubble_Sort_A (g-busora.ads)::
10104 * GNAT.Bubble_Sort_G (g-busorg.ads)::
10105 * GNAT.Calendar (g-calend.ads)::
10106 * GNAT.Calendar.Time_IO (g-catiio.ads)::
10107 * GNAT.CRC32 (g-crc32.ads)::
10108 * GNAT.Case_Util (g-casuti.ads)::
10109 * GNAT.CGI (g-cgi.ads)::
10110 * GNAT.CGI.Cookie (g-cgicoo.ads)::
10111 * GNAT.CGI.Debug (g-cgideb.ads)::
10112 * GNAT.Command_Line (g-comlin.ads)::
10113 * GNAT.Current_Exception (g-curexc.ads)::
10114 * GNAT.Debug_Pools (g-debpoo.ads)::
10115 * GNAT.Debug_Utilities (g-debuti.ads)::
10116 * GNAT.Directory_Operations (g-dirope.ads)::
10117 * GNAT.Dynamic_Tables (g-dyntab.ads)::
10118 * GNAT.Exception_Traces (g-exctra.ads)::
10119 * GNAT.Expect (g-expect.ads)::
10120 * GNAT.Float_Control (g-flocon.ads)::
10121 * GNAT.Heap_Sort_A (g-hesora.ads)::
10122 * GNAT.Heap_Sort_G (g-hesorg.ads)::
10123 * GNAT.HTable (g-htable.ads)::
10124 * GNAT.IO (g-io.ads)::
10125 * GNAT.IO_Aux (g-io_aux.ads)::
10126 * GNAT.Lock_Files (g-locfil.ads)::
10127 * GNAT.Most_Recent_Exception (g-moreex.ads)::
10128 * GNAT.OS_Lib (g-os_lib.ads)::
10129 * GNAT.Regexp (g-regexp.ads)::
10130 * GNAT.Registry (g-regist.ads)::
10131 * GNAT.Regpat (g-regpat.ads)::
10132 * GNAT.Sockets (g-socket.ads)::
10133 * GNAT.Source_Info (g-souinf.ads)::
10134 * GNAT.Spell_Checker (g-speche.ads)::
10135 * GNAT.Spitbol.Patterns (g-spipat.ads)::
10136 * GNAT.Spitbol (g-spitbo.ads)::
10137 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
10138 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
10139 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
10140 * GNAT.Table (g-table.ads)::
10141 * GNAT.Task_Lock (g-tasloc.ads)::
10142 * GNAT.Threads (g-thread.ads)::
10143 * GNAT.Traceback (g-traceb.ads)::
10144 * GNAT.Traceback.Symbolic (g-trasym.ads)::
10145 * Interfaces.C.Extensions (i-cexten.ads)::
10146 * Interfaces.C.Streams (i-cstrea.ads)::
10147 * Interfaces.CPP (i-cpp.ads)::
10148 * Interfaces.Os2lib (i-os2lib.ads)::
10149 * Interfaces.Os2lib.Errors (i-os2err.ads)::
10150 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
10151 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
10152 * Interfaces.Packed_Decimal (i-pacdec.ads)::
10153 * Interfaces.VxWorks (i-vxwork.ads)::
10154 * System.Address_Image (s-addima.ads)::
10155 * System.Assertions (s-assert.ads)::
10156 * System.Partition_Interface (s-parint.ads)::
10157 * System.Task_Info (s-tasinf.ads)::
10158 * System.Wch_Cnv (s-wchcnv.ads)::
10159 * System.Wch_Con (s-wchcon.ads)::
10160 @end menu
10161
10162 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
10163 @section Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
10164 @cindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
10165 @cindex  Latin_1 constants for Wide_Character
10166
10167 @noindent
10168 This child of @code{Ada.Characters}
10169 provides a set of definitions corresponding to those in the
10170 RM-defined package @code{Ada.Characters.Latin_1} but with the
10171 types of the constants being @code{Wide_Character}
10172 instead of @code{Character}. The provision of such a package
10173 is specifically authorized by the Ada Reference Manual
10174 (RM A.3(27)).
10175
10176 @node Ada.Command_Line.Remove (a-colire.ads)
10177 @section Ada.Command_Line.Remove (a-colire.ads)
10178 @cindex Ada.Command_Line.Remove (a-colire.ads)
10179 @cindex  Removing command line arguments
10180 @cindex  Command line, argument removal
10181
10182 @noindent
10183 This child of @code{Ada.Command_Line}
10184 provides a mechanism for logically removing
10185 arguments from the argument list. Once removed, an argument is not visible
10186 to further calls on the subprograms in @code{Ada.Command_Line} will not
10187 see the removed argument.
10188
10189 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
10190 @section Ada.Direct_IO.C_Streams (a-diocst.ads)
10191 @cindex Ada.Direct_IO.C_Streams (a-diocst.ads)
10192 @cindex  C Streams, Interfacing with Direct_IO
10193
10194 @noindent
10195 This package provides subprograms that allow interfacing between 
10196 C streams and @code{Direct_IO}. The stream identifier can be
10197 extracted from a file opened on the Ada side, and an Ada file
10198 can be constructed from a stream opened on the C side.
10199
10200 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
10201 @section Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
10202 @cindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
10203 @cindex  Null_Occurrence, testing for
10204
10205 @noindent
10206 This child subprogram provides a way of testing for the null 
10207 exception occurrence (@code{Null_Occurrence}) without raising
10208 an exception.
10209
10210 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
10211 @section Ada.Sequential_IO.C_Streams (a-siocst.ads)
10212 @cindex Ada.Sequential_IO.C_Streams (a-siocst.ads)
10213 @cindex  C Streams, Interfacing with Sequential_IO
10214
10215 @noindent
10216 This package provides subprograms that allow interfacing between 
10217 C streams and @code{Sequential_IO}. The stream identifier can be
10218 extracted from a file opened on the Ada side, and an Ada file
10219 can be constructed from a stream opened on the C side.
10220
10221 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
10222 @section Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
10223 @cindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
10224 @cindex  C Streams, Interfacing with Stream_IO
10225
10226 @noindent
10227 This package provides subprograms that allow interfacing between 
10228 C streams and @code{Stream_IO}. The stream identifier can be
10229 extracted from a file opened on the Ada side, and an Ada file
10230 can be constructed from a stream opened on the C side.
10231
10232 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
10233 @section Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
10234 @cindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
10235 @cindex Unbounded_String, IO support
10236 @cindex Text_IO, extensions for unbounded strings
10237
10238 @noindent
10239 This package provides subprograms for Text_IO for unbounded
10240 strings, avoiding the necessity for an intermediate operation
10241 with ordinary strings.
10242
10243 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
10244 @section Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
10245 @cindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
10246 @cindex Unbounded_Wide_String, IO support
10247 @cindex Text_IO, extensions for unbounded wide strings
10248
10249 @noindent
10250 This package provides subprograms for Text_IO for unbounded
10251 wide strings, avoiding the necessity for an intermediate operation
10252 with ordinary wide strings.
10253
10254 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
10255 @section Ada.Text_IO.C_Streams (a-tiocst.ads)
10256 @cindex Ada.Text_IO.C_Streams (a-tiocst.ads)
10257 @cindex  C Streams, Interfacing with Text_IO
10258
10259 @noindent
10260 This package provides subprograms that allow interfacing between 
10261 C streams and @code{Text_IO}. The stream identifier can be
10262 extracted from a file opened on the Ada side, and an Ada file
10263 can be constructed from a stream opened on the C side.
10264
10265 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
10266 @section Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
10267 @cindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
10268 @cindex  C Streams, Interfacing with Wide_Text_IO
10269
10270 @noindent
10271 This package provides subprograms that allow interfacing between 
10272 C streams and @code{Wide_Text_IO}. The stream identifier can be
10273 extracted from a file opened on the Ada side, and an Ada file
10274 can be constructed from a stream opened on the C side.
10275
10276 @node GNAT.AWK (g-awk.ads)
10277 @section GNAT.AWK (g-awk.ads)
10278 @cindex GNAT.AWK (g-awk.ads)
10279 @cindex Parsing
10280
10281 @noindent
10282 Provides AWK-like parsing functions, with an easy interface for parsing one
10283 or more files containing formatted data. The file is viewed as a database
10284 where each record is a line and a field is a data element in this line.
10285
10286 @node GNAT.Bubble_Sort_A (g-busora.ads)
10287 @section GNAT.Bubble_Sort_A (g-busora.ads)
10288 @cindex GNAT.Bubble_Sort_A (g-busora.ads)
10289 @cindex Sorting
10290
10291 @noindent
10292 Provides a general implementation of bubble sort usable for sorting arbitrary
10293 data items. Move and comparison procedures are provided by passing
10294 access-to-procedure values.
10295
10296 @node GNAT.Bubble_Sort_G (g-busorg.ads)
10297 @section GNAT.Bubble_Sort_G (g-busorg.ads)
10298 @cindex GNAT.Bubble_Sort_G (g-busorg.ads)
10299 @cindex Sorting
10300
10301 @noindent
10302 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
10303 are provided as generic parameters, this improves efficiency, especially
10304 if the procedures can be inlined, at the expense of duplicating code for
10305 multiple instantiations.
10306
10307 @node GNAT.Calendar (g-calend.ads)
10308 @section GNAT.Calendar (g-calend.ads)
10309 @cindex GNAT.Calendar (g-calend.ads)
10310 @cindex Calendar
10311
10312 @noindent
10313 Extends the facilities provided by @code{Ada.Calendar} to include handling
10314 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
10315 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
10316 C @code{timeval} format.
10317
10318 @node GNAT.Calendar.Time_IO (g-catiio.ads)
10319 @section GNAT.Calendar.Time_IO (g-catiio.ads)
10320 @cindex Calendar
10321 @cindex Time
10322 @cindex GNAT.Calendar.Time_IO (g-catiio.ads)
10323
10324 @node GNAT.CRC32 (g-crc32.ads)
10325 @section GNAT.CRC32 (g-crc32.ads)
10326 @cindex GNAT.CRC32 (g-crc32.ads)
10327 @cindex CRC32
10328
10329 @noindent
10330 This package implements the CRC-32 algorithm. For a full description
10331 of this algorithm you should have a look at:
10332 "Computation of Cyclic Redundancy Checks via Table Look-Up", Communications
10333 of the ACM, Vol. 31 No. 8, pp.1008-1013 Aug. 1988. Sarwate, D.V.
10334
10335 @noindent
10336 Provides an extended capability for formatted output of time values with
10337 full user control over the format. Modeled on the GNU Date specification.
10338
10339 @node GNAT.Case_Util (g-casuti.ads)
10340 @section GNAT.Case_Util (g-casuti.ads)
10341 @cindex GNAT.Case_Util (g-casuti.ads)
10342 @cindex Casing utilities
10343
10344 @noindent
10345 A set of simple routines for handling upper and lower casing of strings
10346 without the overhead of the full casing tables
10347 in @code{Ada.Characters.Handling}.
10348
10349 @node GNAT.CGI (g-cgi.ads)
10350 @section GNAT.CGI (g-cgi.ads)
10351 @cindex GNAT.CGI (g-cgi.ads)
10352 @cindex CGI (Common Gateway Interface)
10353
10354 @noindent
10355 This is a package for interfacing a GNAT program with a Web server via the
10356 Common Gateway Interface (CGI). Basically this package parse the CGI
10357 parameters which are a set of key/value pairs sent by the Web server. It
10358 builds a table whose index is the key and provides some services to deal
10359 with this table.
10360
10361 @node GNAT.CGI.Cookie (g-cgicoo.ads)
10362 @section GNAT.CGI.Cookie (g-cgicoo.ads)
10363 @cindex GNAT.CGI.Cookie (g-cgicoo.ads)
10364 @cindex CGI (Common Gateway Interface) Cookie support
10365
10366 @noindent
10367 This is a package to interface a GNAT program with a Web server via the
10368 Common Gateway Interface (CGI). It exports services to deal with Web
10369 cookies (piece of information kept in the Web client software).
10370
10371 @node GNAT.CGI.Debug (g-cgideb.ads)
10372 @section GNAT.CGI.Debug (g-cgideb.ads)
10373 @cindex GNAT.CGI.Debug (g-cgideb.ads)
10374 @cindex CGI (Common Gateway Interface) debugging
10375
10376 @noindent
10377 This is a package to help debugging CGI (Common Gateway Interface)
10378 programs written in Ada.
10379
10380 @node GNAT.Command_Line (g-comlin.ads)
10381 @section GNAT.Command_Line (g-comlin.ads)
10382 @cindex GNAT.Command_Line (g-comlin.ads)
10383 @cindex Command line
10384
10385 @noindent
10386 Provides a high level interface to @code{Ada.Command_Line} facilities,
10387 including the ability to scan for named switches with optional parameters
10388 and expand file names using wild card notations.
10389
10390 @node GNAT.Current_Exception (g-curexc.ads)
10391 @section GNAT.Current_Exception (g-curexc.ads)
10392 @cindex GNAT.Current_Exception (g-curexc.ads)
10393 @cindex Current exception
10394 @cindex Exception retrieval
10395
10396 @noindent
10397 Provides access to information on the current exception that has been raised
10398 without the need for using the Ada-95 exception choice parameter specification
10399 syntax. This is particularly useful in mimicking typical facilities for
10400 obtaining information about exceptions provided by Ada 83 compilers.
10401
10402 @node GNAT.Debug_Pools (g-debpoo.ads)
10403 @section GNAT.Debug_Pools (g-debpoo.ads)
10404 @cindex GNAT.Debug_Pools (g-debpoo.ads)
10405 @cindex Debugging
10406
10407 @noindent
10408 Provide a debugging storage pools that helps tracking memory corruption
10409 problems. See section "Finding memory problems with GNAT Debug Pool" in
10410 the GNAT User's guide.
10411
10412 @node GNAT.Debug_Utilities (g-debuti.ads)
10413 @section GNAT.Debug_Utilities (g-debuti.ads)
10414 @cindex GNAT.Debug_Utilities (g-debuti.ads)
10415 @cindex Debugging
10416
10417 @noindent
10418 Provides a few useful utilities for debugging purposes, including conversion
10419 to and from string images of address values.
10420
10421 @node GNAT.Directory_Operations (g-dirope.ads)
10422 @section GNAT.Directory_Operations (g-dirope.ads)
10423 @cindex GNAT.Directory_Operations (g-dirope.ads)
10424 @cindex Directory operations
10425
10426 @noindent
10427 Provides a set of routines for manipulating directories, including changing
10428 the current directory, making new directories, and scanning the files in a
10429 directory.
10430
10431 @node GNAT.Dynamic_Tables (g-dyntab.ads)
10432 @section GNAT.Dynamic_Tables (g-dyntab.ads)
10433 @cindex GNAT.Dynamic_Tables (g-dyntab.ads)
10434 @cindex Table implementation
10435 @cindex Arrays, extendable
10436
10437 @noindent
10438 A generic package providing a single dimension array abstraction where the
10439 length of the array can be dynamically modified.
10440
10441 @noindent
10442 This package provides a facility similar to that of GNAT.Table, except 
10443 that this package declares a type that can be used to define dynamic
10444 instances of the table, while an instantiation of GNAT.Table creates a
10445 single instance of the table type.
10446
10447 @node GNAT.Exception_Traces (g-exctra.ads)
10448 @section GNAT.Exception_Traces (g-exctra.ads)
10449 @cindex GNAT.Exception_Traces (g-exctra.ads)
10450 @cindex Exception traces
10451 @cindex Debugging
10452
10453 @noindent
10454 Provides an interface allowing to control automatic output upon exception
10455 occurrences.
10456
10457 @node GNAT.Expect (g-expect.ads)
10458 @section GNAT.Expect (g-expect.ads)
10459 @cindex GNAT.Expect (g-expect.ads)
10460
10461 @noindent
10462 Provides a set of subprograms similar to what is available
10463 with the standard Tcl Expect tool.
10464 It allows you to easily spawn and communicate with an external process.
10465 You can send commands or inputs to the process, and compare the output
10466 with some expected regular expression.
10467 Currently GNAT.Expect is implemented on all native GNAT ports except for
10468 OpenVMS. It is not implemented for cross ports, and in particular is not
10469 implemented for VxWorks or LynxOS.
10470
10471 @node GNAT.Float_Control (g-flocon.ads)
10472 @section GNAT.Float_Control (g-flocon.ads)
10473 @cindex GNAT.Float_Control (g-flocon.ads)
10474 @cindex Floating-Point Processor
10475
10476 @noindent
10477 Provides an interface for resetting the floating-point processor into the
10478 mode required for correct semantic operation in Ada. Some third party
10479 library calls may cause this mode to be modified, and the Reset procedure
10480 in this package can be used to reestablish the required mode.
10481
10482 @node GNAT.Heap_Sort_A (g-hesora.ads)
10483 @section GNAT.Heap_Sort_A (g-hesora.ads)
10484 @cindex GNAT.Heap_Sort_A (g-hesora.ads)
10485 @cindex Sorting
10486
10487 @noindent
10488 Provides a general implementation of heap sort usable for sorting arbitrary
10489 data items. Move and comparison procedures are provided by passing
10490 access-to-procedure values. The algorithm used is a modified heap sort
10491 that performs approximately N*log(N) comparisons in the worst case.
10492
10493 @node GNAT.Heap_Sort_G (g-hesorg.ads)
10494 @section GNAT.Heap_Sort_G (g-hesorg.ads)
10495 @cindex GNAT.Heap_Sort_G (g-hesorg.ads)
10496 @cindex Sorting
10497
10498 @noindent
10499 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
10500 are provided as generic parameters, this improves efficiency, especially
10501 if the procedures can be inlined, at the expense of duplicating code for
10502 multiple instantiations.
10503
10504 @node GNAT.HTable (g-htable.ads)
10505 @section GNAT.HTable (g-htable.ads)
10506 @cindex GNAT.HTable (g-htable.ads)
10507 @cindex Hash tables
10508
10509 @noindent
10510 A generic implementation of hash tables that can be used to hash arbitrary
10511 data. Provides two approaches, one a simple static approach, and the other
10512 allowing arbitrary dynamic hash tables.
10513
10514 @node GNAT.IO (g-io.ads)
10515 @section GNAT.IO (g-io.ads)
10516 @cindex GNAT.IO (g-io.ads)
10517 @cindex Simple I/O
10518 @cindex Input/Output facilities
10519
10520 @noindent
10521 A simple preealborable input-output package that provides a subset of
10522 simple Text_IO functions for reading characters and strings from
10523 Standard_Input, and writing characters, strings and integers to either
10524 Standard_Output or Standard_Error.
10525
10526 @node GNAT.IO_Aux (g-io_aux.ads)
10527 @section GNAT.IO_Aux (g-io_aux.ads)
10528 @cindex GNAT.IO_Aux (g-io_aux.ads)
10529 @cindex Text_IO
10530 @cindex Input/Output facilities
10531
10532 Provides some auxiliary functions for use with Text_IO, including a test
10533 for whether a file exists, and functions for reading a line of text.
10534
10535 @node GNAT.Lock_Files (g-locfil.ads)
10536 @section GNAT.Lock_Files (g-locfil.ads)
10537 @cindex GNAT.Lock_Files (g-locfil.ads)
10538 @cindex File locking
10539 @cindex Locking using files
10540
10541 @noindent
10542 Provides a general interface for using files as locks. Can be used for
10543 providing program level synchronization. 
10544
10545 @node GNAT.Most_Recent_Exception (g-moreex.ads)
10546 @section GNAT.Most_Recent_Exception (g-moreex.ads)
10547 @cindex GNAT.Most_Recent_Exception (g-moreex.ads)
10548 @cindex Exception, obtaining most recent
10549
10550 @noindent
10551 Provides access to the most recently raised exception. Can be used for
10552 various logging purposes, including duplicating functionality of some
10553 Ada 83 implementation dependent extensions.
10554
10555 @node GNAT.OS_Lib (g-os_lib.ads)
10556 @section GNAT.OS_Lib (g-os_lib.ads)
10557 @cindex GNAT.OS_Lib (g-os_lib.ads)
10558 @cindex Operating System interface
10559 @cindex Spawn capability
10560
10561 @noindent
10562 Provides a range of target independent operating system interface functions,
10563 including time/date management, file operations, subprocess management,
10564 including a portable spawn procedure, and access to environment variables
10565 and error return codes.
10566
10567 @node GNAT.Regexp (g-regexp.ads)
10568 @section GNAT.Regexp (g-regexp.ads)
10569 @cindex GNAT.Regexp (g-regexp.ads)
10570 @cindex Regular expressions
10571 @cindex Pattern matching
10572
10573 @noindent
10574 A simple implementation of regular expressions, using a subset of regular
10575 expression syntax copied from familiar Unix style utilities. This is the
10576 simples of the three pattern matching packages provided, and is particularly
10577 suitable for "file globbing" applications.
10578
10579 @node GNAT.Registry (g-regist.ads)
10580 @section GNAT.Registry (g-regist.ads)
10581 @cindex GNAT.Registry (g-regist.ads)
10582 @cindex Windows Registry
10583
10584 @noindent
10585 This is a high level binding to the Windows registry. It is possible to
10586 do simple things like reading a key value, creating a new key. For full
10587 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
10588 package provided with the Win32Ada binding
10589
10590 @node GNAT.Regpat (g-regpat.ads)
10591 @section GNAT.Regpat (g-regpat.ads)
10592 @cindex GNAT.Regpat (g-regpat.ads)
10593 @cindex Regular expressions
10594 @cindex Pattern matching
10595
10596 @noindent
10597 A complete implementation of Unix-style regular expression matching, copied
10598 from the original V7 style regular expression library written in C by
10599 Henry Spencer (and binary compatible with this C library).
10600
10601 @node GNAT.Sockets (g-socket.ads)
10602 @section GNAT.Sockets (g-socket.ads)
10603 @cindex GNAT.Sockets (g-socket.ads)
10604 @cindex Sockets
10605
10606 @noindent
10607 A high level and portable interface to develop sockets based applications.
10608 This package is based on the sockets thin binding found in GNAT.Sockets.Thin.
10609 Currently GNAT.Sockets is implemented on all native GNAT ports except for
10610 OpenVMS. It is not implemented for cross ports, and in particular is not
10611 implemented for VxWorks or LynxOS.
10612
10613 @node GNAT.Source_Info (g-souinf.ads)
10614 @section GNAT.Source_Info (g-souinf.ads)
10615 @cindex GNAT.Source_Info (g-souinf.ads)
10616 @cindex Source Information
10617
10618 @noindent
10619 Provides subprograms that give access to source code information known at
10620 compile time, such as the current file name and line number.
10621
10622 @node GNAT.Spell_Checker (g-speche.ads)
10623 @section GNAT.Spell_Checker (g-speche.ads)
10624 @cindex GNAT.Spell_Checker (g-speche.ads)
10625 @cindex Spell checking
10626
10627 @noindent
10628 Provides a function for determining whether one string is a plausible
10629 near misspelling of another string.
10630
10631 @node GNAT.Spitbol.Patterns (g-spipat.ads)
10632 @section GNAT.Spitbol.Patterns (g-spipat.ads)
10633 @cindex GNAT.Spitbol.Patterns (g-spipat.ads)
10634 @cindex SPITBOL pattern matching
10635 @cindex Pattern matching
10636
10637 @noindent
10638 A complete implementation of SNOBOL4 style pattern matching. This is the
10639 most elaborate of the pattern matching packages provided. It fully duplicates
10640 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
10641 efficient algorithm developed by Robert Dewar for the SPITBOL system.
10642
10643 @node GNAT.Spitbol (g-spitbo.ads)
10644 @section GNAT.Spitbol (g-spitbo.ads)
10645 @cindex GNAT.Spitbol (g-spitbo.ads)
10646 @cindex SPITBOL interface
10647
10648 @noindent
10649 The top level package of the collection of SPITBOL-style functionality, this
10650 package provides basic SNOBOL4 string manipulation functions, such as
10651 Pad, Reverse, Trim, Substr capability, as well as a generic table function
10652 useful for constructing arbitrary mappings from strings in the style of
10653 the SNOBOL4 TABLE function.
10654
10655 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
10656 @section GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
10657 @cindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
10658 @cindex Sets of strings
10659 @cindex SPITBOL Tables
10660
10661 @noindent
10662 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10663 for type @code{Standard.Boolean}, giving an implementation of sets of
10664 string values.
10665
10666 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
10667 @section GNAT.Spitbol.Table_Integer (g-sptain.ads)
10668 @cindex GNAT.Spitbol.Table_Integer (g-sptain.ads)
10669 @cindex Integer maps
10670 @cindex Maps
10671 @cindex SPITBOL Tables
10672
10673 @noindent
10674 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10675 for type @code{Standard.Integer}, giving an implementation of maps
10676 from string to integer values.
10677
10678 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
10679 @section GNAT.Spitbol.Table_VString (g-sptavs.ads)
10680 @cindex GNAT.Spitbol.Table_VString (g-sptavs.ads)
10681 @cindex String maps
10682 @cindex Maps
10683 @cindex SPITBOL Tables
10684
10685 @noindent
10686 A library level of instantiation of GNAT.Spitbol.Patterns.Table for 
10687 a variable length string type, giving an implementation of general
10688 maps from strings to strings.
10689
10690 @node GNAT.Table (g-table.ads)
10691 @section GNAT.Table (g-table.ads)
10692 @cindex GNAT.Table (g-table.ads)
10693 @cindex Table implementation
10694 @cindex Arrays, extendable
10695
10696 @noindent
10697 A generic package providing a single dimension array abstraction where the
10698 length of the array can be dynamically modified.
10699
10700 @noindent
10701 This package provides a facility similar to that of GNAT.Dynamic_Tables,
10702 except that this package declares a single instance of the table type,
10703 while an instantiation of GNAT.Dynamic_Tables creates a type that can be
10704 used to define dynamic instances of the table.
10705
10706 @node GNAT.Task_Lock (g-tasloc.ads)
10707 @section GNAT.Task_Lock (g-tasloc.ads)
10708 @cindex GNAT.Task_Lock (g-tasloc.ads)
10709 @cindex Task synchronization
10710 @cindex Task locking
10711 @cindex Locking
10712
10713 @noindent
10714 A very simple facility for locking and unlocking sections of code using a
10715 single global task lock. Appropriate for use in situations where contention
10716 between tasks is very rarely expected.
10717
10718 @node GNAT.Threads (g-thread.ads)
10719 @section GNAT.Threads (g-thread.ads)
10720 @cindex GNAT.Threads (g-thread.ads)
10721 @cindex Foreign threads
10722 @cindex Threads, foreign
10723
10724 @noindent
10725 Provides facilities for creating and destroying threads with explicit calls.
10726 These threads are known to the GNAT run-time system. These subprograms are
10727 exported C-convention procedures intended to be called from foreign code.
10728 By using these primitives rather than directly calling operating systems
10729 routines, compatibility with the Ada tasking runt-time is provided.
10730
10731 @node GNAT.Traceback (g-traceb.ads)
10732 @section GNAT.Traceback (g-traceb.ads)
10733 @cindex GNAT.Traceback (g-traceb.ads)
10734 @cindex Trace back facilities
10735
10736 @noindent
10737 Provides a facility for obtaining non-symbolic traceback information, useful
10738 in various debugging situations.
10739
10740 @node GNAT.Traceback.Symbolic (g-trasym.ads)
10741 @section GNAT.Traceback.Symbolic (g-trasym.ads)
10742 @cindex GNAT.Traceback.Symbolic (g-trasym.ads)
10743 @cindex Trace back facilities
10744
10745 @noindent
10746 Provides symbolic traceback information that includes the subprogram
10747 name and line number information.
10748
10749 @node Interfaces.C.Extensions (i-cexten.ads)
10750 @section Interfaces.C.Extensions (i-cexten.ads)
10751 @cindex Interfaces.C.Extensions (i-cexten.ads)
10752
10753 @noindent
10754 This package contains additional C-related definitions, intended
10755 for use with either manually or automatically generated bindings
10756 to C libraries.
10757
10758 @node Interfaces.C.Streams (i-cstrea.ads)
10759 @section Interfaces.C.Streams (i-cstrea.ads)
10760 @cindex Interfaces.C.Streams (i-cstrea.ads)
10761 @cindex  C streams, interfacing
10762
10763 @noindent
10764 This package is a binding for the most commonly used operations
10765 on C streams.
10766
10767 @node Interfaces.CPP (i-cpp.ads)
10768 @section Interfaces.CPP (i-cpp.ads)
10769 @cindex Interfaces.CPP (i-cpp.ads)
10770 @cindex  C++ interfacing
10771 @cindex  Interfacing, to C++
10772
10773 @noindent
10774 This package provides facilities for use in interfacing to C++. It
10775 is primarily intended to be used in connection with automated tools
10776 for the generation of C++ interfaces.
10777
10778 @node Interfaces.Os2lib (i-os2lib.ads)
10779 @section Interfaces.Os2lib (i-os2lib.ads)
10780 @cindex Interfaces.Os2lib (i-os2lib.ads)
10781 @cindex Interfacing, to OS/2
10782 @cindex OS/2 interfacing
10783
10784 @noindent
10785 This package provides interface definitions to the OS/2 library.
10786 It is a thin binding which is a direct translation of the
10787 various @file{<bse@.h>} files.
10788
10789 @node Interfaces.Os2lib.Errors (i-os2err.ads)
10790 @section Interfaces.Os2lib.Errors (i-os2err.ads)
10791 @cindex Interfaces.Os2lib.Errors (i-os2err.ads)
10792 @cindex OS/2 Error codes
10793 @cindex Interfacing, to OS/2
10794 @cindex OS/2 interfacing
10795
10796 @noindent
10797 This package provides definitions of the OS/2 error codes.
10798
10799 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
10800 @section Interfaces.Os2lib.Synchronization (i-os2syn.ads)
10801 @cindex Interfaces.Os2lib.Synchronization (i-os2syn.ads)
10802 @cindex Interfacing, to OS/2
10803 @cindex Synchronization, OS/2
10804 @cindex OS/2 synchronization primitives
10805
10806 @noindent
10807 This is a child package that provides definitions for interfacing
10808 to the @code{OS/2} synchronization primitives.
10809
10810 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
10811 @section Interfaces.Os2lib.Threads (i-os2thr.ads)
10812 @cindex Interfaces.Os2lib.Threads (i-os2thr.ads)
10813 @cindex Interfacing, to OS/2
10814 @cindex Thread control, OS/2
10815 @cindex OS/2 thread interfacing
10816
10817 @noindent
10818 This is a child package that provides definitions for interfacing
10819 to the @code{OS/2} thread primitives.
10820
10821 @node Interfaces.Packed_Decimal (i-pacdec.ads)
10822 @section Interfaces.Packed_Decimal (i-pacdec.ads)
10823 @cindex Interfaces.Packed_Decimal (i-pacdec.ads)
10824 @cindex  IBM Packed Format
10825 @cindex  Packed Decimal
10826
10827 @noindent
10828 This package provides a set of routines for conversions to and
10829 from a packed decimal format compatible with that used on IBM
10830 mainframes.
10831
10832 @node Interfaces.VxWorks (i-vxwork.ads)
10833 @section Interfaces.VxWorks (i-vxwork.ads)
10834 @cindex Interfaces.VxWorks (i-vxwork.ads)
10835 @cindex Interfacing to VxWorks
10836 @cindex VxWorks, interfacing
10837
10838 @noindent
10839 This package provides a limited binding to the VxWorks API
10840 In particular, it interfaces with the
10841 VxWorks hardware interrupt facilities
10842
10843 @node System.Address_Image (s-addima.ads)
10844 @section System.Address_Image (s-addima.ads)
10845 @cindex System.Address_Image (s-addima.ads)
10846 @cindex Address image
10847 @cindex Image, of an address
10848
10849 @noindent
10850 This function provides a useful debugging
10851 function that gives an (implementation dependent)
10852 string which identifies an address.
10853
10854 @node System.Assertions (s-assert.ads)
10855 @section System.Assertions (s-assert.ads)
10856 @cindex System.Assertions (s-assert.ads)
10857 @cindex  Assertions
10858 @cindex  Assert_Failure, exception
10859
10860 @noindent
10861 This package provides the declaration of the exception raised
10862 by an run-time assertion failure, as well as the routine that
10863 is used internally to raise this assertion.
10864
10865 @node System.Partition_Interface (s-parint.ads)
10866 @section System.Partition_Interface (s-parint.ads)
10867 @cindex System.Partition_Interface (s-parint.ads)
10868 @cindex Partition intefacing functions
10869
10870 @noindent
10871 This package provides facilities for partition interfacing. It
10872 is used primarily in a distribution context when using Annex E
10873 with @code{GLADE}.
10874
10875 @node System.Task_Info (s-tasinf.ads)
10876 @section System.Task_Info (s-tasinf.ads)
10877 @cindex System.Task_Info (s-tasinf.ads)
10878 @cindex  Task_Info pragma
10879
10880 @noindent
10881 This package provides target dependent functionality that is used
10882 to support the @code{Task_Info} pragma
10883
10884 @node System.Wch_Cnv (s-wchcnv.ads)
10885 @section System.Wch_Cnv (s-wchcnv.ads)
10886 @cindex System.Wch_Cnv (s-wchcnv.ads)
10887 @cindex Wide Character, Representation
10888 @cindex Wide String, Conversion
10889 @cindex Representation of wide characters
10890
10891 @noindent
10892 This package provides routines for converting between
10893 wide characters and a representation as a value of type
10894 @code{Standard.String}, using a specified wide character
10895 encoding method. Uses definitions in
10896 package @code{System.Wch_Con}
10897
10898 @node System.Wch_Con (s-wchcon.ads)
10899 @section System.Wch_Con (s-wchcon.ads)
10900 @cindex System.Wch_Con (s-wchcon.ads)
10901
10902 @noindent
10903 This package provides definitions and descriptions of
10904 the various methods used for encoding wide characters
10905 in ordinary strings. These definitions are used by
10906 the package @code{System.Wch_Cnv}.
10907
10908 @node Interfacing to Other Languages
10909 @chapter Interfacing to Other Languages
10910 @noindent
10911 The facilities in annex B of the Ada 95 Reference Manual are fully
10912 implemented in GNAT, and in addition, a full interface to C++ is
10913 provided.
10914
10915 @menu
10916 * Interfacing to C::          
10917 * Interfacing to C++::          
10918 * Interfacing to COBOL::        
10919 * Interfacing to Fortran::      
10920 * Interfacing to non-GNAT Ada code::
10921 @end menu
10922
10923 @node Interfacing to C
10924 @section Interfacing to C
10925
10926 @noindent
10927 Interfacing to C with GNAT can use one of two approaches:
10928
10929 @enumerate
10930 @item
10931 The types in the package @code{Interfaces.C} may be used.
10932 @item
10933 Standard Ada types may be used directly. This may be less portable to
10934 other compilers, but will work on all GNAT compilers, which guarantee
10935 correspondence between the C and Ada types.
10936 @end enumerate
10937
10938 @noindent
10939 Pragma @code{Convention C} maybe applied to Ada types, but mostly has no
10940 effect, since this is the default. The following table shows the
10941 correspondence between Ada scalar types and the corresponding C types.
10942
10943 @table @code
10944 @item Integer
10945 @code{int}
10946 @item Short_Integer
10947 @code{short}
10948 @item Short_Short_Integer
10949 @code{signed char}
10950 @item Long_Integer
10951 @code{long}
10952 @item Long_Long_Integer
10953 @code{long long}
10954 @item Short_Float
10955 @code{float}
10956 @item Float
10957 @code{float}
10958 @item Long_Float
10959 @code{double}
10960 @item Long_Long_Float
10961 This is the longest floating-point type supported by the hardware.
10962 @end table
10963
10964 @itemize @bullet
10965 @item
10966 Ada enumeration types map to C enumeration types directly if pragma
10967 @code{Convention C} is specified, which causes them to have int
10968 length. Without pragma @code{Convention C}, Ada enumeration types map to
10969 8, 16, or 32 bits (i.e. C types signed char, short, int respectively)
10970 depending on the number of values passed. This is the only case in which
10971 pragma @code{Convention C} affects the representation of an Ada type.
10972
10973 @item
10974 Ada access types map to C pointers, except for the case of pointers to
10975 unconstrained types in Ada, which have no direct C equivalent.
10976
10977 @item
10978 Ada arrays map directly to C arrays.
10979
10980 @item
10981 Ada records map directly to C structures.
10982
10983 @item
10984 Packed Ada records map to C structures where all members are bit fields
10985 of the length corresponding to the @code{@var{type}'Size} value in Ada.
10986 @end itemize
10987
10988 @node Interfacing to C++
10989 @section Interfacing to C++
10990
10991 @noindent
10992 The interface to C++ makes use of the following pragmas, which are
10993 primarily intended to be constructed automatically using a binding generator
10994 tool, although it is possible to construct them by hand. Ada Core 
10995 Technologies does not currently supply a suitable binding generator tool.
10996
10997 Using these pragmas it is possible to achieve complete
10998 inter-operability between Ada tagged types and C class definitions.
10999 See @ref{Implementation Defined Pragmas} for more details.
11000
11001 @table @code
11002 @item pragma CPP_Class ([Entity =>] @var{local_name})
11003 The argument denotes an entity in the current declarative region that is
11004 declared as a tagged or untagged record type. It indicates that the type
11005 corresponds to an externally declared C++ class type, and is to be laid
11006 out the same way that C++ would lay out the type.
11007
11008 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
11009 This pragma identifies an imported function (imported in the usual way
11010 with pragma @code{Import}) as corresponding to a C++ constructor.
11011
11012 @item pragma CPP_Vtable @dots{}
11013 One @code{CPP_Vtable} pragma can be present for each component of type
11014 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
11015 applies.
11016 @end table
11017
11018 @node Interfacing to COBOL
11019 @section Interfacing to COBOL
11020
11021 @noindent
11022 Interfacing to COBOL is achieved as described in section B.4 of
11023 the Ada 95 reference manual.
11024
11025 @node Interfacing to Fortran
11026 @section Interfacing to Fortran
11027
11028 @noindent
11029 Interfacing to Fortran is achieved as described in section B.5 of the
11030 reference manual. The pragma @code{Convention Fortran}, applied to a
11031 multi- dimensional array causes the array to be stored in column-major
11032 order as required for convenient interface to Fortran.
11033
11034 @node Interfacing to non-GNAT Ada code
11035 @section Interfacing to non-GNAT Ada code
11036
11037 It is possible to specify the convention Ada in a pragma Import or
11038 pragma Export. However this refers to the calling conventions used
11039 by GNAT, which may or may not be similar enough to those used by
11040 some other Ada 83 or Ada 95 compiler to allow interoperation.
11041
11042 If arguments types are kept simple, and if the foreign compiler generally
11043 follows system calling conventions, then it may be possible to integrate
11044 files compiled by other Ada compilers, provided that the elaboration
11045 issues are adequately addressed (for example by eliminating the 
11046 need for any load time elaboration).
11047
11048 In particular, GNAT running on VMS is designed to
11049 be highly compatible with the DEC Ada 83 compiler, so this is one
11050 case in which it is possible to import foreign units of this type,
11051 provided that the data items passed are restricted to simple scalar
11052 values or simple record types without variants, or simple array
11053 types with fixed bounds.
11054
11055 @node Machine Code Insertions
11056 @chapter Machine Code Insertions
11057
11058 @noindent
11059 Package @code{Machine_Code} provides machine code support as described
11060 in the Ada 95 Reference Manual in two separate forms:
11061 @itemize @bullet
11062 @item
11063 Machine code statements, consisting of qualified expressions that
11064 fit the requirements of RM section 13.8.
11065 @item
11066 An intrinsic callable procedure, providing an alternative mechanism of
11067 including machine instructions in a subprogram.
11068 @end itemize
11069
11070 The two features are similar, and both closely related to the mechanism
11071 provided by the asm instruction in the GNU C compiler. Full understanding
11072 and use of the facilities in this package requires understanding the asm
11073 instruction as described in @cite{Using and Porting GNU CC} by Richard
11074 Stallman.  Calls to the function @code{Asm} and the procedure @code{Asm}
11075 have identical semantic restrictions and effects as described below.
11076 Both are provided so that the procedure call can be used as a statement,
11077 and the function call can be used to form a code_statement.
11078
11079 The first example given in the GNU CC documentation is the C @code{asm}
11080 instruction:
11081 @smallexample
11082    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
11083 @end smallexample
11084
11085 @noindent
11086 The equivalent can be written for GNAT as:
11087
11088 @smallexample
11089 Asm ("fsinx %1 %0",
11090      My_Float'Asm_Output ("=f", result),
11091      My_Float'Asm_Input  ("f",  angle));
11092 @end smallexample
11093
11094 The first argument to @code{Asm} is the assembler template, and is
11095 identical to what is used in GNU CC. This string must be a static
11096 expression.  The second argument is the output operand list. It is
11097 either a single @code{Asm_Output} attribute reference, or a list of such
11098 references enclosed in parentheses (technically an array aggregate of
11099 such references).
11100
11101 The @code{Asm_Output} attribute denotes a function that takes two
11102 parameters.  The first is a string, the second is the name of a variable
11103 of the type designated by the attribute prefix. The first (string)
11104 argument is required to be a static expression and designates the
11105 constraint for the parameter (e.g. what kind of register is
11106 required). The second argument is the variable to be updated with the
11107 result. The possible values for constraint are the same as those used in
11108 the RTL, and are dependent on the configuration file used to build the
11109 GCC back end.  If there are no output operands, then this argument may
11110 either be omitted, or explicitly given as @code{No_Output_Operands}.
11111
11112 The second argument of @code{@var{my_float}'Asm_Output} functions as
11113 though it were an @code{out} parameter, which is a little curious, but
11114 all names have the form of expressions, so there is no syntactic
11115 irregularity, even though normally functions would not be permitted
11116 @code{out} parameters.  The third argument is the list of input
11117 operands. It is either a single @code{Asm_Input} attribute reference, or
11118 a list of such references enclosed in parentheses (technically an array
11119 aggregate of such references).
11120
11121 The @code{Asm_Input} attribute denotes a function that takes two
11122 parameters.  The first is a string, the second is an expression of the
11123 type designated by the prefix. The first (string) argument is required
11124 to be a static expression, and is the constraint for the parameter,
11125 (e.g. what kind of register is required). The second argument is the
11126 value to be used as the input argument. The possible values for the
11127 constant are the same as those used in the RTL, and are dependent on
11128 the configuration file used to built the GCC back end.
11129
11130 If there are no input operands, this argument may either be omitted, or
11131 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
11132 present in the above example, is a list of register names, called the
11133 @dfn{clobber} argument. This argument, if given, must be a static string
11134 expression, and is a space or comma separated list of names of registers
11135 that must be considered destroyed as a result of the @code{Asm} call. If
11136 this argument is the null string (the default value), then the code
11137 generator assumes that no additional registers are destroyed.
11138
11139 The fifth argument, not present in the above example, called the
11140 @dfn{volatile} argument, is by default @code{False}. It can be set to
11141 the literal value @code{True} to indicate to the code generator that all
11142 optimizations with respect to the instruction specified should be
11143 suppressed, and that in particular, for an instruction that has outputs,
11144 the instruction will still be generated, even if none of the outputs are
11145 used. See the full description in the GCC manual for further details.
11146
11147 The @code{Asm} subprograms may be used in two ways. First the procedure
11148 forms can be used anywhere a procedure call would be valid, and
11149 correspond to what the RM calls ``intrinsic'' routines. Such calls can
11150 be used to intersperse machine instructions with other Ada statements.
11151 Second, the function forms, which return a dummy value of the limited
11152 private type @code{Asm_Insn}, can be used in code statements, and indeed
11153 this is the only context where such calls are allowed.  Code statements
11154 appear as aggregates of the form:
11155
11156 @smallexample
11157 Asm_Insn'(Asm (@dots{}));
11158 Asm_Insn'(Asm_Volatile (@dots{}));
11159 @end smallexample
11160
11161 In accordance with RM rules, such code statements are allowed only
11162 within subprograms whose entire body consists of such statements.  It is
11163 not permissible to intermix such statements with other Ada statements.
11164
11165 Typically the form using intrinsic procedure calls is more convenient
11166 and more flexible. The code statement form is provided to meet the RM
11167 suggestion that such a facility should be made available.  The following
11168 is the exact syntax of the call to @code{Asm} (of course if named notation is
11169 used, the arguments may be given in arbitrary order, following the
11170 normal rules for use of positional and named arguments)
11171
11172 @smallexample
11173 ASM_CALL ::= Asm (
11174                  [Template =>] static_string_EXPRESSION
11175                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
11176                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
11177                [,[Clobber  =>] static_string_EXPRESSION ]
11178                [,[Volatile =>] static_boolean_EXPRESSION] )
11179 OUTPUT_OPERAND_LIST ::=
11180   No_Output_Operands
11181 | OUTPUT_OPERAND_ATTRIBUTE
11182 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
11183 OUTPUT_OPERAND_ATTRIBUTE ::=
11184   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
11185 INPUT_OPERAND_LIST ::=
11186   No_Input_Operands
11187 | INPUT_OPERAND_ATTRIBUTE
11188 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
11189 INPUT_OPERAND_ATTRIBUTE ::=
11190   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
11191 @end smallexample
11192
11193 @node GNAT Implementation of Tasking
11194 @chapter GNAT Implementation of Tasking
11195 @menu
11196 * Mapping Ada Tasks onto the Underlying Kernel Threads::
11197 * Ensuring Compliance with the Real-Time Annex::
11198 @end menu
11199
11200 @node Mapping Ada Tasks onto the Underlying Kernel Threads
11201 @section Mapping Ada Tasks onto the Underlying Kernel Threads
11202
11203 GNAT run-time system comprises two layers:
11204
11205 @itemize @bullet
11206 @item GNARL (GNAT Run-time  Layer)
11207 @item GNULL (GNAT Low-level Library)
11208 @end itemize
11209
11210 In GNAT, Ada's tasking services rely on a platform and OS independent
11211 layer known as GNARL. This code is responsible for implementing the
11212 correct semantics of Ada's task creation, rendezvous, protected
11213 operations etc.
11214
11215 GNARL decomposes Ada's tasking semantics into simpler lower level
11216 operations such as create a thread, set the priority of a thread,
11217 yield, create a lock, lock/unlock, etc. The spec for these low-level
11218 operations constitutes GNULLI, the GNULL Interface. This interface is
11219 directly inspired from the POSIX real-time API.
11220
11221 If the underlying executive or OS implements the POSIX standard
11222 faithfully, the GNULL Interface maps as is to the services offered by
11223 the underlying kernel. Otherwise, some target dependent glue code maps
11224 the services offered by the underlying kernel to the semantics expected
11225 by GNARL.
11226
11227 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
11228 key point is that each Ada task is mapped on a thread in the underlying 
11229 kernel. For example, in the case of VxWorks
11230
11231      1 Ada task = 1 VxWorks task
11232
11233 In addition Ada task priorities map onto the underlying thread priorities.
11234 Mapping Ada tasks onto the underlying kernel threads has several advantages:
11235
11236 @enumerate
11237
11238 @item
11239 The underlying scheduler is used to schedule the Ada tasks. This
11240 makes Ada tasks as efficient as kernel threads from a scheduling
11241 standpoint.  
11242
11243 @item
11244 Interaction with code written in C containing threads is eased
11245 since at the lowest level Ada tasks and C threads map onto the same
11246 underlying kernel concept.
11247
11248 @item
11249 When an Ada task is blocked during I/O the remaining Ada tasks are
11250 able to proceed.
11251
11252 @item
11253 On multi-processor systems Ada Tasks can execute in parallel.
11254 @end enumerate
11255
11256 @node Ensuring Compliance with the Real-Time Annex
11257 @section Ensuring Compliance with the Real-Time Annex
11258
11259 The reader will be quick to notice that while mapping Ada tasks onto
11260 the underlying threads has significant advantages, it does create some
11261 complications when it comes to respecting the scheduling semantics
11262 specified in the real-time annex (Annex D).
11263
11264 For instance Annex D requires that for the FIFO_Within_Priorities
11265 scheduling policy we have:
11266
11267 @smallexample
11268 When the active priority of a ready task that is not running
11269 changes, or the setting of its base priority takes effect, the
11270 task is removed from the ready queue for its old active priority
11271 and is added at the tail of the ready queue for its new active
11272 priority, except in the case where the active priority is lowered
11273 due to the loss of inherited priority, in which case the task is
11274 added at the head of the ready queue for its new active priority.
11275 @end smallexample
11276
11277 While most kernels do put tasks at the end of the priority queue when
11278 a task changes its priority, (which respects the main
11279 FIFO_Within_Priorities requirement), almost none keep a thread at the
11280 beginning of its priority queue when its priority drops from the loss
11281 of inherited priority.
11282
11283 As a result most vendors have provided incomplete Annex D implementations.
11284
11285 The GNAT run-time, has a nice cooperative solution to this problem
11286 which ensures that accurate FIFO_Within_Priorities semantics are
11287 respected.
11288
11289 The principle is as follows. When an Ada task T is about to start
11290 running, it checks whether some other Ada task R with the same
11291 priority as T has been suspended due to the loss of priority
11292 inheritance. If this is the case, T yields and is placed at the end of
11293 its priority queue. When R arrives at the front of the queue it
11294 executes. 
11295
11296 Note that this simple scheme preserves the relative order of the tasks
11297 that were ready to execute in the priority queue where R has been
11298 placed at the end.
11299
11300 @node    Code generation for array aggregates
11301 @chapter  Code generation for array aggregates
11302
11303 @menu
11304 * Static constant aggregates with static bounds::
11305 * Constant aggregates with an unconstrained nominal types::
11306 * Aggregates with static bounds::
11307 * Aggregates with non-static bounds::
11308 * Aggregates in assignments statements::
11309 @end menu
11310  
11311 Aggregate have a rich syntax and allow the user to specify the values of
11312 complex data structures by means of a single construct. As a result, the
11313 code generated for aggregates can be quite complex and involve loops, case
11314 statements and multiple assignments. In the simplest cases, however, the
11315 compiler will recognize aggregates whose components and constraints are
11316 fully static, and in those cases the compiler will generate little or no
11317 executable code. The following is an outline of the code that GNAT generates
11318 for various aggregate constructs. For further details, the user will find it
11319 useful to examine the output produced by the -gnatG flag to see the expanded
11320 source that is input to the code generator.  The user will also want to examine
11321 the assembly code generated at various levels of optimization.
11322
11323 The code generated for aggregates depends on the context, the component values,
11324 and the type. In the context of an object declaration the code generated is
11325 generally simpler than in the case of an assignment. As a general rule, static
11326 component values and static subtypes also lead to simpler code.
11327  
11328 @node Static constant aggregates with static bounds
11329 @section Static constant aggregates with static bounds
11330  
11331  For the declarations:
11332 @smallexample 
11333     type One_Dim is array (1..10) of integer;
11334     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
11335 @end smallexample 
11336
11337 GNAT generates no executable code: the constant ar0 is placed in static memory.
11338 The same is true for constant aggregates with named associations:
11339  
11340 @smallexample 
11341     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
11342     Cr3 : constant One_Dim := (others => 7777);
11343 @end smallexample 
11344  
11345  The same is true for multidimensional constant arrays such as:
11346  
11347 @smallexample 
11348     type two_dim is array (1..3, 1..3) of integer;
11349     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
11350 @end smallexample 
11351  
11352 The same is true for arrays of one-dimensional arrays: the following are
11353 static:
11354  
11355 @smallexample 
11356 type ar1b is array (1..3) of boolean;
11357 type ar_ar is array (1..3) of ar1b;
11358 None : constant ar1b := (others => false);      --  fully static
11359 None2 : constant ar_ar := (1..3 => None);       --  fully static
11360 @end smallexample 
11361  
11362 However, for multidimensional aggregates with named associations, GNAT will
11363 generate assignments and loops, even if all associations are static. The
11364 following two declarations generate a loop for the first dimension, and
11365 individual component assignments for the second dimension:
11366  
11367 @smallexample 
11368 Zero1: constant two_dim := (1..3 => (1..3 => 0));
11369 Zero2: constant two_dim := (others => (others => 0));     
11370 @end smallexample 
11371  
11372 @node Constant aggregates with an unconstrained nominal types
11373 @section Constant aggregates with an unconstrained nominal types
11374  
11375 In such cases the aggregate itself establishes the subtype, so that associations
11376 with "others" cannot be used. GNAT determines the bounds for the actual
11377 subtype of the aggregate, and allocates the aggregate statically as well. No
11378 code is generated for the following:
11379  
11380 @smallexample 
11381     type One_Unc is array (natural range <>) of integer;
11382     Cr_Unc : constant One_Unc := (12,24,36);
11383 @end smallexample 
11384  
11385 @node Aggregates with static bounds
11386 @section Aggregates with static bounds
11387  
11388 In all previous examples the aggregate was the initial (and immutable) value
11389 of a constant. If the aggregate initializes a variable, then code is generated
11390 for it as a combination of individual assignments and loops over the target
11391 object. The declarations
11392  
11393 @smallexample 
11394        Cr_Var1 : One_Dim := (2, 5, 7, 11);
11395        Cr_Var2 : One_Dim := (others > -1);
11396 @end smallexample 
11397  
11398 generate the equivalent of
11399  
11400 @smallexample 
11401        Cr_Var1 (1) := 2;
11402        Cr_Var1 (2) := 3;
11403        Cr_Var1 (3) := 5;
11404        Cr_Var1 (4) := 11;
11405  
11406        for I in Cr_Var2'range loop
11407           Cr_Var2 (I) := =-1;
11408        end loop;
11409 @end smallexample 
11410  
11411 @node Aggregates with non-static bounds
11412 @section Aggregates with non-static bounds
11413  
11414 If the bounds of the aggregate are not statically compatible with the bounds
11415 of the nominal subtype  of the target, then constraint checks have to be
11416 generated on the bounds. For a multidimensional array, constraint checks may
11417 have to be applied to sub-arrays individually, if they do not have statically
11418 compatible subtypes.
11419  
11420 @node Aggregates in assignments statements
11421 @section Aggregates in assignments statements
11422  
11423 In general, aggregate assignment requires the construction of a temporary,
11424 and a copy from the temporary to the target of the assignment. This is because
11425 it is not always possible to convert the assignment into a series of individual 
11426 component assignments. For example, consider the simple case:
11427  
11428 @smallexample 
11429 @end smallexample 
11430         A := (A(2), A(1));
11431  
11432 This cannot be converted into:
11433  
11434 @smallexample 
11435         A(1) := A(2);
11436         A(2) := A(1);
11437 @end smallexample 
11438  
11439 So the aggregate has to be built first in a separate location, and then
11440 copied into the target. GNAT recognizes simple cases where this intermediate
11441 step is not required, and the assignments can be performed in place, directly
11442 into the target. The following sufficient criteria are applied:
11443
11444 @enumerate 
11445 @item The bounds of the aggregate are static, and the associations are static.
11446 @item  The components of the aggregate are static constants, names of
11447     simple variables that are not renamings, or expressions not involving
11448     indexed components whose operands obey these rules.
11449 @end enumerate
11450  
11451 If any of these conditions are violated, the aggregate will be built in
11452 a temporary (created either by the front-end or the code generator) and then
11453 that temporary will be copied onto the target.
11454  
11455  
11456 @node Specialized Needs Annexes
11457 @chapter Specialized Needs Annexes
11458
11459 @noindent
11460 Ada 95 defines a number of specialized needs annexes, which are not
11461 required in all implementations. However, as described in this chapter,
11462 GNAT implements all of these special needs annexes:
11463
11464 @table @asis
11465 @item Systems Programming (Annex C)
11466 The systems programming annex is fully implemented.
11467
11468 @item Real-Time Systems (Annex D)
11469 The real-time systems annex is fully implemented.
11470
11471 @item Distributed Systems (Annex E)
11472 Stub generation is fully implemented in the @code{GNAT} compiler. In addition,
11473 a complete compatible PCS is available as part of the @code{GLADE} system,
11474 a separate product available from Ada Core Technologies. When the two
11475 products are used in conjunction, this annex is fully implemented.
11476
11477 @item Information Systems (Annex F)
11478 The information systems annex is fully implemented.
11479
11480 @item Numerics (Annex G)
11481 The numerics annex is fully implemented.
11482
11483 @item Safety and Security (Annex H)
11484 The safety and security annex is fully implemented.
11485
11486 @end table
11487
11488 @node Compatibility Guide
11489 @chapter Compatibility Guide
11490
11491 @noindent
11492 This chapter contains sections that describe compatibility issues between
11493 GNAT and other Ada 83 and Ada 95 compilation systems, to aid in porting
11494 applications developed in other Ada environments.
11495
11496 @menu
11497 * Compatibility with Ada 83::       
11498 * Compatibility with DEC Ada 83::
11499 * Compatibility with Other Ada 95 Systems::
11500 * Representation Clauses::
11501 @end menu
11502
11503 @node Compatibility with Ada 83
11504 @section Compatibility with Ada 83
11505
11506 @noindent
11507 Ada 95 is designed to be highly upwards compatible with Ada 83. In
11508 particular, the design intention is that the difficulties associated
11509 with moving from Ada 83 to Ada 95 should be no greater than those
11510 that occur when moving from one Ada 83 system to another.
11511
11512 However, there are a number of points at which there are minor
11513 incompatibilities. The Ada 95 Annotated Reference Manual contains
11514 full details of these issues,
11515 and should be consulted for a complete treatment.
11516 In practice the
11517 following are the most likely issues to be encountered.
11518
11519 @table @asis
11520 @item Character range
11521 The range of Standard.Character is now the full 256 characters of Latin-1,
11522 whereas in most Ada 83 implementations it was restricted to 128 characters.
11523 This may show up as compile time or runtime errors. The desirable fix is to
11524 adapt the program to accommodate the full character set, but in some cases
11525 it may be convenient to define a subtype or derived type of Character that
11526 covers only the restricted range.
11527
11528 @item New reserved words
11529 The identifiers @code{abstract}, @code{aliased}, @code{protected},
11530 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
11531 Existing Ada 83 code using any of these identifiers must be edited to
11532 use some alternative name.
11533
11534 @item Freezing rules
11535 The rules in Ada 95 are slightly different with regard to the point at
11536 which entities are frozen, and representation pragmas and clauses are
11537 not permitted past the freeze point. This shows up most typically in
11538 the form of an error message complaining that a representation item
11539 appears too late, and the appropriate corrective action is to move
11540 the item nearer to the declaration of the entity to which it refers.
11541
11542 A particular case is that representation pragmas (including the
11543 extended DEC Ada 83 compatibility pragmas such as Export_Procedure), cannot
11544 be applied to a subprogram body. If necessary, a separate subprogram 
11545 declaration must be introduced to which the pragma can be applied.
11546
11547 @item Optional bodies for library packages
11548 In Ada 83, a package that did not require a package body was nevertheless
11549 allowed to have one. This lead to certain surprises in compiling large
11550 systems (situations in which the body could be unexpectedly ignored). In
11551 Ada 95, if a package does not require a body then it is not permitted to
11552 have a body. To fix this problem, simply remove a redundant body if it
11553 is empty, or, if it is non-empty, introduce a dummy declaration into the
11554 spec that makes the body required. One approach is to add a private part
11555 to the package declaration (if necessary), and define a parameterless
11556 procedure called Requires_Body, which must then be given a dummy
11557 procedure body in the package body, which then becomes required.
11558
11559 @item Numeric_Error is now the same as Constraint_Error
11560 In Ada 95, the exception Numeric_Error is a renaming of Constraint_Error.
11561 This means that it is illegal to have separate exception handlers for
11562 the two exceptions. The fix is simply to remove the handler for the
11563 Numeric_Error case (since even in Ada 83, a compiler was free to raise
11564 Constraint_Error in place of Numeric_Error in all cases).
11565
11566 @item Indefinite subtypes in generics
11567 In Ada 83, it was permissible to pass an indefinite type (e.g. String) as
11568 the actual for a generic formal private type, but then the instantiation
11569 would be illegal if there were any instances of declarations of variables
11570 of this type in the generic body. In Ada 95, to avoid this clear violation
11571 of the contract model, the generic declaration clearly indicates whether
11572 or not such instantiations are permitted. If a generic formal parameter
11573 has explicit unknown discriminants, indicated by using (<>) after the
11574 type name, then it can be instantiated with indefinite types, but no
11575 variables can be declared of this type. Any attempt to declare a variable
11576 will result in an illegality at the time the generic is declared. If the
11577 (<>) notation is not used, then it is illegal to instantiate the generic
11578 with an indefinite type. This will show up as a compile time error, and
11579 the fix is usually simply to add the (<>) to the generic declaration.
11580 @end table
11581
11582 All implementations of GNAT provide a switch that causes GNAT to operate
11583 in Ada 83 mode. In this mode, some but not all compatibility problems
11584 of the type described above are handled automatically. For example, the
11585 new Ada 95 protected keywords are not recognized in this mode. However,
11586 in practice, it is usually advisable to make the necessary modifications
11587 to the program to remove the need for using this switch.
11588
11589 @node Compatibility with Other Ada 95 Systems
11590 @section Compatibility with Other Ada 95 Systems
11591
11592 @noindent
11593 Providing that programs avoid the use of implementation dependent and
11594 implementation defined features of Ada 95, as documented in the Ada 95
11595 reference manual, there should be a high degree of portability between
11596 GNAT and other Ada 95 systems. The following are specific items which
11597 have proved troublesome in moving GNAT programs to other Ada 95
11598 compilers, but do not affect porting code to GNAT.
11599
11600 @table @asis
11601 @item Ada 83 Pragmas and Attributes
11602 Ada 95 compilers are allowed, but not required, to implement the missing
11603 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
11604 GNAT implements all such pragmas and attributes, eliminating this as
11605 a compatibility concern, but some other Ada 95 compilers reject these
11606 pragmas and attributes.
11607
11608 @item Special-needs Annexes
11609 GNAT implements the full set of special needs annexes. At the
11610 current time, it is the only Ada 95 compiler to do so. This means that
11611 programs making use of these features may not be portable to other Ada
11612 95 compilation systems.
11613
11614 @item Representation Clauses
11615 Some other Ada 95 compilers implement only the minimal set of
11616 representation clauses required by the Ada 95 reference manual. GNAT goes
11617 far beyond this minimal set, as described in the next section.
11618 @end table
11619
11620 @node Representation Clauses
11621 @section Representation Clauses
11622
11623 @noindent
11624 The Ada 83 reference manual was quite vague in describing both the minimal
11625 required implementation of representation clauses, and also their precise
11626 effects. The Ada 95 reference manual is much more explicit, but the minimal
11627 set of capabilities required in Ada 95 is quite limited.
11628
11629 GNAT implements the full required set of capabilities described in the
11630 Ada 95 reference manual, but also goes much beyond this, and in particular
11631 an effort has been made to be compatible with existing Ada 83 usage to the
11632 greatest extent possible.
11633
11634 A few cases exist in which Ada 83 compiler behavior is incompatible with
11635 requirements in the Ada 95 reference manual. These are instances of
11636 intentional or accidental dependence on specific implementation dependent
11637 characteristics of these Ada 83 compilers. The following is a list of
11638 the cases most likely to arise in existing legacy Ada 83 code.
11639
11640 @table @asis
11641 @item Implicit Packing
11642 Some Ada 83 compilers allowed a Size specification to cause implicit
11643 packing of an array or record. This could cause expensive implicit
11644 conversions for change of representation in the presence of derived
11645 types, and the Ada design intends to avoid this possibility.
11646 Subsequent AI's were issued to make it clear that such implicit
11647 change of representation in response to a Size clause is inadvisable,
11648 and this recommendation is represented explicitly in the Ada 95 RM
11649 as implementation advice that is followed by GNAT.
11650 The problem will show up as an error
11651 message rejecting the size clause. The fix is simply to provide
11652 the explicit pragma Pack, or for more fine tuned control, provide
11653 a Component_Size clause.
11654
11655 @item Meaning of Size Attribute
11656 The Size attribute in Ada 95 for discrete types is defined as being the
11657 minimal number of bits required to hold values of the type. For example,
11658 on a 32-bit machine, the size of Natural will typically be 31 and not
11659 32 (since no sign bit is required). Some Ada 83 compilers gave 31, and
11660 some 32 in this situation. This problem will usually show up as a compile
11661 time error, but not always. It is a good idea to check all uses of the
11662 'Size attribute when porting Ada 83 code. The GNAT specific attribute
11663 Object_Size can provide a useful way of duplicating the behavior of
11664 some Ada 83 compiler systems.
11665
11666 @item Size of Access Types
11667 A common assumption in Ada 83 code is that an access type is in fact a pointer,
11668 and that therefore it will be the same size as a System.Address value. This
11669 assumption is true for GNAT in most cases with one exception. For the case of
11670 a pointer to an unconstrained array type (where the bounds may vary from one
11671 value of the access type to another), the default is to use a "fat pointer",
11672 which is represented as two separate pointers, one to the bounds, and one to
11673 the array. This representation has a number of advantages, including improved
11674 efficiency. However, it may cause some difficulties in porting existing Ada 83
11675 code which makes the assumption that, for example, pointers fit in 32 bits on
11676 a machine with 32-bit addressing.
11677
11678 To get around this problem, GNAT also permits the use of "thin pointers" for
11679 access types in this case (where the designated type is an unconstrained array
11680 type). These thin pointers are indeed the same size as a System.Address value.
11681 To specify a thin pointer, use a size clause for the type, for example:
11682
11683 @smallexample
11684 type X is access all String;
11685 for X'Size use Standard'Address_Size;
11686 @end smallexample
11687
11688 @noindent
11689 which will cause the type X to be represented using a single pointer. When using
11690 this representation, the bounds are right behind the array. This representation
11691 is slightly less efficient, and does not allow quite such flexibility in the
11692 use of foreign pointers or in using the Unrestricted_Access attribute to create
11693 pointers to non-aliased objects. But for any standard portable use of the access
11694 type it will work in a functionally correct manner and allow porting of existing
11695 code. Note that another way of forcing a thin pointer representation is to use
11696 a component size clause for the element size in an array, or a record 
11697 representation clause for an access field in a record.
11698 @end table
11699
11700 @node Compatibility with DEC Ada 83
11701 @section Compatibility with DEC Ada 83
11702
11703 @noindent
11704 The VMS version of GNAT fully implements all the pragmas and attributes
11705 provided by DEC Ada 83, as well as providing the standard DEC Ada 83
11706 libraries, including Starlet. In addition, data layouts and parameter
11707 passing conventions are highly compatible. This means that porting
11708 existing DEC Ada 83 code to GNAT in VMS systems should be easier than
11709 most other porting efforts. The following are some of the most
11710 significant differences between GNAT and DEC Ada 83.
11711
11712 @table @asis
11713 @item Default floating-point representation
11714 In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83,
11715 it is VMS format. GNAT does implement the necessary pragmas
11716 (Long_Float, Float_Representation) for changing this default.
11717
11718 @item System
11719 The package System in GNAT exactly corresponds to the definition in the
11720 Ada 95 reference manual, which means that it excludes many of the 
11721 DEC Ada 83 extensions. However, a separate package Aux_DEC is provided
11722 that contains the additional definitions, and a special pragma,
11723 Extend_System allows this package to be treated transparently as an
11724 extension of package System.
11725
11726 @item To_Address
11727 The definitions provided by Aux_DEC are exactly compatible with those
11728 in the DEC Ada 83 version of System, with one exception. DEC Ada provides
11729 the following declarations:
11730
11731 @smallexample
11732 TO_ADDRESS(INTEGER)
11733 TO_ADDRESS(UNSIGNED_LONGWORD)
11734 TO_ADDRESS(universal_integer)
11735 @end smallexample
11736
11737 @noindent
11738 The version of TO_ADDRESS taking a universal integer argument is in fact
11739 an extension to Ada 83 not strictly compatible with the reference manual.
11740 In GNAT, we are constrained to be exactly compatible with the standard,
11741 and this means we cannot provide this capability. In DEC Ada 83, the
11742 point of this definition is to deal with a call like:
11743
11744 @smallexample
11745    TO_ADDRESS (16#12777#);
11746 @end smallexample
11747
11748 @noindent
11749 Normally, according to the Ada 83 standard, one would expect this to be
11750 ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms
11751 of TO_ADDRESS. However, in DEC Ada 83, there is no ambiguity, since the
11752 definition using universal_integer takes precedence.
11753
11754 In GNAT, since the version with universal_integer cannot be supplied, it is
11755 not possible to be 100% compatible. Since there are many programs using
11756 numeric constants for the argument to TO_ADDRESS, the decision in GNAT was
11757 to change the name of the function in the UNSIGNED_LONGWORD case, so the
11758 declarations provided in the GNAT version of AUX_Dec are:
11759
11760 @smallexample
11761 function To_Address (X : Integer) return Address;
11762 pragma Pure_Function (To_Address);
11763
11764 function To_Address_Long (X : Unsigned_Longword)
11765  return Address;
11766 pragma Pure_Function (To_Address_Long);
11767 @end smallexample
11768
11769 @noindent
11770 This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must
11771 change the name to TO_ADDRESS_LONG.
11772
11773 @item Task_Id values
11774 The Task_Id values assigned will be different in the two systems, and GNAT
11775 does not provide a specified value for the Task_Id of the environment task,
11776 which in GNAT is treated like any other declared task.
11777 @end table
11778
11779 For full details on these and other less significant compatibility issues,
11780 see appendix E of the Digital publication entitled "DEC Ada, Technical
11781 Overview and Comparison on DIGITAL Platforms".
11782
11783 For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and
11784 attributes are recognized, although only a subset of them can sensibly
11785 be implemented. The description of pragmas in this reference manual
11786 indicates whether or not they are applicable to non-VMS systems.
11787
11788 @include gfdl.texi
11789 @c GNU Free Documentation License
11790
11791 @node Index,,GNU Free Documentation License, Top
11792 @unnumbered Index
11793
11794 @printindex cp
11795
11796 @contents
11797
11798 @bye