OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [gnat_rm.texi] - Blame information for rev 283

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
\input texinfo   @c -*-texinfo-*-
2
 
3
@c %**start of header
4
 
5
@c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6
@c                                                                            o
7
@c                           GNAT DOCUMENTATION                               o
8
@c                                                                            o
9
@c                              G N A T _ RM                                  o
10
@c                                                                            o
11
@c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12
@c                                                                            o
13
@c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
 
15
@setfilename gnat_rm.info
16
 
17
@copying
18
Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
 
20
Permission is granted to copy, distribute and/or modify this document
21
under the terms of the GNU Free Documentation License, Version 1.2 or
22
any later version published by the Free Software Foundation; with no
23
Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24
Manual'', and with no Back-Cover Texts.  A copy of the license is
25
included in the section entitled ``GNU Free Documentation License''.
26
@end copying
27
 
28
@set EDITION GNAT
29
@set DEFAULTLANGUAGEVERSION Ada 2005
30
@set NONDEFAULTLANGUAGEVERSION Ada 95
31
 
32
@settitle GNAT Reference Manual
33
 
34
@setchapternewpage odd
35
@syncodeindex fn cp
36
 
37
@include gcc-common.texi
38
 
39
@dircategory GNU Ada tools
40
@direntry
41
* GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42
@end direntry
43
 
44
@titlepage
45
@title GNAT Reference Manual
46
@subtitle GNAT, The GNU Ada Compiler
47
@versionsubtitle
48
@author AdaCore
49
@page
50
@vskip 0pt plus 1filll
51
 
52
@insertcopying
53
 
54
@end titlepage
55
 
56
@ifnottex
57
@node Top, About This Guide, (dir), (dir)
58
@top GNAT Reference Manual
59
 
60
@noindent
61
GNAT Reference Manual
62
 
63
@noindent
64
GNAT, The GNU Ada Compiler@*
65
GCC version @value{version-GCC}@*
66
 
67
@noindent
68
AdaCore
69
 
70
@menu
71
* About This Guide::
72
* Implementation Defined Pragmas::
73
* Implementation Defined Attributes::
74
* Implementation Advice::
75
* Implementation Defined Characteristics::
76
* Intrinsic Subprograms::
77
* Representation Clauses and Pragmas::
78
* Standard Library Routines::
79
* The Implementation of Standard I/O::
80
* The GNAT Library::
81
* Interfacing to Other Languages::
82
* Specialized Needs Annexes::
83
* Implementation of Specific Ada Features::
84
* Project File Reference::
85
* Obsolescent Features::
86
* GNU Free Documentation License::
87
* Index::
88
 
89
 --- The Detailed Node Listing ---
90
 
91
About This Guide
92
 
93
* What This Reference Manual Contains::
94
* Related Information::
95
 
96
Implementation Defined Pragmas
97
 
98
* Pragma Abort_Defer::
99
* Pragma Ada_83::
100
* Pragma Ada_95::
101
* Pragma Ada_05::
102
* Pragma Ada_2005::
103
* Pragma Annotate::
104
* Pragma Assert::
105
* Pragma Assume_No_Invalid_Values::
106
* Pragma Ast_Entry::
107
* Pragma C_Pass_By_Copy::
108
* Pragma Check::
109
* Pragma Check_Name::
110
* Pragma Check_Policy::
111
* Pragma Comment::
112
* Pragma Common_Object::
113
* Pragma Compile_Time_Error::
114
* Pragma Compile_Time_Warning::
115
* Pragma Compiler_Unit::
116
* Pragma Complete_Representation::
117
* Pragma Complex_Representation::
118
* Pragma Component_Alignment::
119
* Pragma Convention_Identifier::
120
* Pragma CPP_Class::
121
* Pragma CPP_Constructor::
122
* Pragma CPP_Virtual::
123
* Pragma CPP_Vtable::
124
* Pragma Debug::
125
* Pragma Debug_Policy::
126
* Pragma Detect_Blocking::
127
* Pragma Elaboration_Checks::
128
* Pragma Eliminate::
129
* Pragma Export_Exception::
130
* Pragma Export_Function::
131
* Pragma Export_Object::
132
* Pragma Export_Procedure::
133
* Pragma Export_Value::
134
* Pragma Export_Valued_Procedure::
135
* Pragma Extend_System::
136
* Pragma External::
137
* Pragma External_Name_Casing::
138
* Pragma Fast_Math::
139
* Pragma Favor_Top_Level::
140
* Pragma Finalize_Storage_Only::
141
* Pragma Float_Representation::
142
* Pragma Ident::
143
* Pragma Implemented_By_Entry::
144
* Pragma Implicit_Packing::
145
* Pragma Import_Exception::
146
* Pragma Import_Function::
147
* Pragma Import_Object::
148
* Pragma Import_Procedure::
149
* Pragma Import_Valued_Procedure::
150
* Pragma Initialize_Scalars::
151
* Pragma Inline_Always::
152
* Pragma Inline_Generic::
153
* Pragma Interface::
154
* Pragma Interface_Name::
155
* Pragma Interrupt_Handler::
156
* Pragma Interrupt_State::
157
* Pragma Keep_Names::
158
* Pragma License::
159
* Pragma Link_With::
160
* Pragma Linker_Alias::
161
* Pragma Linker_Constructor::
162
* Pragma Linker_Destructor::
163
* Pragma Linker_Section::
164
* Pragma Long_Float::
165
* Pragma Machine_Attribute::
166
* Pragma Main::
167
* Pragma Main_Storage::
168
* Pragma No_Body::
169
* Pragma No_Return::
170
* Pragma No_Strict_Aliasing ::
171
* Pragma Normalize_Scalars::
172
* Pragma Obsolescent::
173
* Pragma Optimize_Alignment::
174
* Pragma Passive::
175
* Pragma Persistent_BSS::
176
* Pragma Polling::
177
* Pragma Postcondition::
178
* Pragma Precondition::
179
* Pragma Profile (Ravenscar)::
180
* Pragma Profile (Restricted)::
181
* Pragma Psect_Object::
182
* Pragma Pure_Function::
183
* Pragma Restriction_Warnings::
184
* Pragma Shared::
185
* Pragma Short_Circuit_And_Or::
186
* Pragma Source_File_Name::
187
* Pragma Source_File_Name_Project::
188
* Pragma Source_Reference::
189
* Pragma Stream_Convert::
190
* Pragma Style_Checks::
191
* Pragma Subtitle::
192
* Pragma Suppress::
193
* Pragma Suppress_All::
194
* Pragma Suppress_Exception_Locations::
195
* Pragma Suppress_Initialization::
196
* Pragma Task_Info::
197
* Pragma Task_Name::
198
* Pragma Task_Storage::
199
* Pragma Thread_Local_Storage::
200
* Pragma Time_Slice::
201
* Pragma Title::
202
* Pragma Unchecked_Union::
203
* Pragma Unimplemented_Unit::
204
* Pragma Universal_Aliasing ::
205
* Pragma Universal_Data::
206
* Pragma Unmodified::
207
* Pragma Unreferenced::
208
* Pragma Unreferenced_Objects::
209
* Pragma Unreserve_All_Interrupts::
210
* Pragma Unsuppress::
211
* Pragma Use_VADS_Size::
212
* Pragma Validity_Checks::
213
* Pragma Volatile::
214
* Pragma Warnings::
215
* Pragma Weak_External::
216
* Pragma Wide_Character_Encoding::
217
 
218
Implementation Defined Attributes
219
 
220
* Abort_Signal::
221
* Address_Size::
222
* Asm_Input::
223
* Asm_Output::
224
* AST_Entry::
225
* Bit::
226
* Bit_Position::
227
* Compiler_Version::
228
* Code_Address::
229
* Default_Bit_Order::
230
* Elaborated::
231
* Elab_Body::
232
* Elab_Spec::
233
* Emax::
234
* Enabled::
235
* Enum_Rep::
236
* Enum_Val::
237
* Epsilon::
238
* Fixed_Value::
239
* Has_Access_Values::
240
* Has_Discriminants::
241
* Img::
242
* Integer_Value::
243
* Invalid_Value::
244
* Large::
245
* Machine_Size::
246
* Mantissa::
247
* Max_Interrupt_Priority::
248
* Max_Priority::
249
* Maximum_Alignment::
250
* Mechanism_Code::
251
* Null_Parameter::
252
* Object_Size::
253
* Old::
254
* Passed_By_Reference::
255
* Pool_Address::
256
* Range_Length::
257
* Result::
258
* Safe_Emax::
259
* Safe_Large::
260
* Small::
261
* Storage_Unit::
262
* Stub_Type::
263
* Target_Name::
264
* Tick::
265
* To_Address::
266
* Type_Class::
267
* UET_Address::
268
* Unconstrained_Array::
269
* Universal_Literal_String::
270
* Unrestricted_Access::
271
* VADS_Size::
272
* Value_Size::
273
* Wchar_T_Size::
274
* Word_Size::
275
 
276
The Implementation of Standard I/O
277
 
278
* Standard I/O Packages::
279
* FORM Strings::
280
* Direct_IO::
281
* Sequential_IO::
282
* Text_IO::
283
* Wide_Text_IO::
284
* Wide_Wide_Text_IO::
285
* Stream_IO::
286
* Text Translation::
287
* Shared Files::
288
* Filenames encoding::
289
* Open Modes::
290
* Operations on C Streams::
291
* Interfacing to C Streams::
292
 
293
The GNAT Library
294
 
295
* Ada.Characters.Latin_9 (a-chlat9.ads)::
296
* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
297
* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
298
* Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
299
* Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
300
* Ada.Command_Line.Environment (a-colien.ads)::
301
* Ada.Command_Line.Remove (a-colire.ads)::
302
* Ada.Command_Line.Response_File (a-clrefi.ads)::
303
* Ada.Direct_IO.C_Streams (a-diocst.ads)::
304
* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
305
* Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
306
* Ada.Exceptions.Traceback (a-exctra.ads)::
307
* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
308
* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
309
* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
310
* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
311
* Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
312
* Ada.Text_IO.C_Streams (a-tiocst.ads)::
313
* Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
314
* Ada.Wide_Characters.Unicode (a-wichun.ads)::
315
* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
316
* Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
317
* Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
318
* Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
319
* Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
320
* GNAT.Altivec (g-altive.ads)::
321
* GNAT.Altivec.Conversions (g-altcon.ads)::
322
* GNAT.Altivec.Vector_Operations (g-alveop.ads)::
323
* GNAT.Altivec.Vector_Types (g-alvety.ads)::
324
* GNAT.Altivec.Vector_Views (g-alvevi.ads)::
325
* GNAT.Array_Split (g-arrspl.ads)::
326
* GNAT.AWK (g-awk.ads)::
327
* GNAT.Bounded_Buffers (g-boubuf.ads)::
328
* GNAT.Bounded_Mailboxes (g-boumai.ads)::
329
* GNAT.Bubble_Sort (g-bubsor.ads)::
330
* GNAT.Bubble_Sort_A (g-busora.ads)::
331
* GNAT.Bubble_Sort_G (g-busorg.ads)::
332
* GNAT.Byte_Order_Mark (g-byorma.ads)::
333
* GNAT.Byte_Swapping (g-bytswa.ads)::
334
* GNAT.Calendar (g-calend.ads)::
335
* GNAT.Calendar.Time_IO (g-catiio.ads)::
336
* GNAT.Case_Util (g-casuti.ads)::
337
* GNAT.CGI (g-cgi.ads)::
338
* GNAT.CGI.Cookie (g-cgicoo.ads)::
339
* GNAT.CGI.Debug (g-cgideb.ads)::
340
* GNAT.Command_Line (g-comlin.ads)::
341
* GNAT.Compiler_Version (g-comver.ads)::
342
* GNAT.Ctrl_C (g-ctrl_c.ads)::
343
* GNAT.CRC32 (g-crc32.ads)::
344
* GNAT.Current_Exception (g-curexc.ads)::
345
* GNAT.Debug_Pools (g-debpoo.ads)::
346
* GNAT.Debug_Utilities (g-debuti.ads)::
347
* GNAT.Decode_String (g-decstr.ads)::
348
* GNAT.Decode_UTF8_String (g-deutst.ads)::
349
* GNAT.Directory_Operations (g-dirope.ads)::
350
* GNAT.Directory_Operations.Iteration (g-diopit.ads)::
351
* GNAT.Dynamic_HTables (g-dynhta.ads)::
352
* GNAT.Dynamic_Tables (g-dyntab.ads)::
353
* GNAT.Encode_String (g-encstr.ads)::
354
* GNAT.Encode_UTF8_String (g-enutst.ads)::
355
* GNAT.Exception_Actions (g-excact.ads)::
356
* GNAT.Exception_Traces (g-exctra.ads)::
357
* GNAT.Exceptions (g-except.ads)::
358
* GNAT.Expect (g-expect.ads)::
359
* GNAT.Float_Control (g-flocon.ads)::
360
* GNAT.Heap_Sort (g-heasor.ads)::
361
* GNAT.Heap_Sort_A (g-hesora.ads)::
362
* GNAT.Heap_Sort_G (g-hesorg.ads)::
363
* GNAT.HTable (g-htable.ads)::
364
* GNAT.IO (g-io.ads)::
365
* GNAT.IO_Aux (g-io_aux.ads)::
366
* GNAT.Lock_Files (g-locfil.ads)::
367
* GNAT.MD5 (g-md5.ads)::
368
* GNAT.Memory_Dump (g-memdum.ads)::
369
* GNAT.Most_Recent_Exception (g-moreex.ads)::
370
* GNAT.OS_Lib (g-os_lib.ads)::
371
* GNAT.Perfect_Hash_Generators (g-pehage.ads)::
372
* GNAT.Random_Numbers (g-rannum.ads)::
373
* GNAT.Regexp (g-regexp.ads)::
374
* GNAT.Registry (g-regist.ads)::
375
* GNAT.Regpat (g-regpat.ads)::
376
* GNAT.Secondary_Stack_Info (g-sestin.ads)::
377
* GNAT.Semaphores (g-semaph.ads)::
378
* GNAT.Serial_Communications (g-sercom.ads)::
379
* GNAT.SHA1 (g-sha1.ads)::
380
* GNAT.SHA224 (g-sha224.ads)::
381
* GNAT.SHA256 (g-sha256.ads)::
382
* GNAT.SHA384 (g-sha384.ads)::
383
* GNAT.SHA512 (g-sha512.ads)::
384
* GNAT.Signals (g-signal.ads)::
385
* GNAT.Sockets (g-socket.ads)::
386
* GNAT.Source_Info (g-souinf.ads)::
387
* GNAT.Spelling_Checker (g-speche.ads)::
388
* GNAT.Spelling_Checker_Generic (g-spchge.ads)::
389
* GNAT.Spitbol.Patterns (g-spipat.ads)::
390
* GNAT.Spitbol (g-spitbo.ads)::
391
* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
392
* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
393
* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
394
* GNAT.SSE (g-sse.ads)::
395
* GNAT.SSE.Vector_Types (g-ssvety.ads)::
396
* GNAT.Strings (g-string.ads)::
397
* GNAT.String_Split (g-strspl.ads)::
398
* GNAT.Table (g-table.ads)::
399
* GNAT.Task_Lock (g-tasloc.ads)::
400
* GNAT.Threads (g-thread.ads)::
401
* GNAT.Time_Stamp (g-timsta.ads)::
402
* GNAT.Traceback (g-traceb.ads)::
403
* GNAT.Traceback.Symbolic (g-trasym.ads)::
404
* GNAT.UTF_32 (g-utf_32.ads)::
405
* GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
406
* GNAT.Wide_Spelling_Checker (g-wispch.ads)::
407
* GNAT.Wide_String_Split (g-wistsp.ads)::
408
* GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
409
* GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
410
* Interfaces.C.Extensions (i-cexten.ads)::
411
* Interfaces.C.Streams (i-cstrea.ads)::
412
* Interfaces.CPP (i-cpp.ads)::
413
* Interfaces.Packed_Decimal (i-pacdec.ads)::
414
* Interfaces.VxWorks (i-vxwork.ads)::
415
* Interfaces.VxWorks.IO (i-vxwoio.ads)::
416
* System.Address_Image (s-addima.ads)::
417
* System.Assertions (s-assert.ads)::
418
* System.Memory (s-memory.ads)::
419
* System.Partition_Interface (s-parint.ads)::
420
* System.Pool_Global (s-pooglo.ads)::
421
* System.Pool_Local (s-pooloc.ads)::
422
* System.Restrictions (s-restri.ads)::
423
* System.Rident (s-rident.ads)::
424
* System.Strings.Stream_Ops (s-ststop.ads)::
425
* System.Task_Info (s-tasinf.ads)::
426
* System.Wch_Cnv (s-wchcnv.ads)::
427
* System.Wch_Con (s-wchcon.ads)::
428
 
429
Text_IO
430
 
431
* Text_IO Stream Pointer Positioning::
432
* Text_IO Reading and Writing Non-Regular Files::
433
* Get_Immediate::
434
* Treating Text_IO Files as Streams::
435
* Text_IO Extensions::
436
* Text_IO Facilities for Unbounded Strings::
437
 
438
Wide_Text_IO
439
 
440
* Wide_Text_IO Stream Pointer Positioning::
441
* Wide_Text_IO Reading and Writing Non-Regular Files::
442
 
443
Wide_Wide_Text_IO
444
 
445
* Wide_Wide_Text_IO Stream Pointer Positioning::
446
* Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
447
 
448
Interfacing to Other Languages
449
 
450
* Interfacing to C::
451
* Interfacing to C++::
452
* Interfacing to COBOL::
453
* Interfacing to Fortran::
454
* Interfacing to non-GNAT Ada code::
455
 
456
Specialized Needs Annexes
457
 
458
Implementation of Specific Ada Features
459
* Machine Code Insertions::
460
* GNAT Implementation of Tasking::
461
* GNAT Implementation of Shared Passive Packages::
462
* Code Generation for Array Aggregates::
463
* The Size of Discriminated Records with Default Discriminants::
464
* Strict Conformance to the Ada Reference Manual::
465
 
466
Project File Reference
467
 
468
Obsolescent Features
469
 
470
GNU Free Documentation License
471
 
472
Index
473
@end menu
474
 
475
@end ifnottex
476
 
477
@node About This Guide
478
@unnumbered About This Guide
479
 
480
@noindent
481
This manual contains useful information in writing programs using the
482
@value{EDITION} compiler.  It includes information on implementation dependent
483
characteristics of @value{EDITION}, including all the information required by
484
Annex M of the Ada language standard.
485
 
486
@value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
487
Ada 83 compatibility mode.
488
By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
489
but you can override with a compiler switch
490
to explicitly specify the language version.
491
(Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
492
@value{EDITION} User's Guide}, for details on these switches.)
493
Throughout this manual, references to ``Ada'' without a year suffix
494
apply to both the Ada 95 and Ada 2005 versions of the language.
495
 
496
Ada is designed to be highly portable.
497
In general, a program will have the same effect even when compiled by
498
different compilers on different platforms.
499
However, since Ada is designed to be used in a
500
wide variety of applications, it also contains a number of system
501
dependent features to be used in interfacing to the external world.
502
@cindex Implementation-dependent features
503
@cindex Portability
504
 
505
Note: Any program that makes use of implementation-dependent features
506
may be non-portable.  You should follow good programming practice and
507
isolate and clearly document any sections of your program that make use
508
of these features in a non-portable manner.
509
 
510
@ifset PROEDITION
511
For ease of exposition, ``GNAT Pro'' will be referred to simply as
512
``GNAT'' in the remainder of this document.
513
@end ifset
514
 
515
@menu
516
* What This Reference Manual Contains::
517
* Conventions::
518
* Related Information::
519
@end menu
520
 
521
@node What This Reference Manual Contains
522
@unnumberedsec What This Reference Manual Contains
523
 
524
@noindent
525
This reference manual contains the following chapters:
526
 
527
@itemize @bullet
528
@item
529
@ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
530
pragmas, which can be used to extend and enhance the functionality of the
531
compiler.
532
 
533
@item
534
@ref{Implementation Defined Attributes}, lists GNAT
535
implementation-dependent attributes which can be used to extend and
536
enhance the functionality of the compiler.
537
 
538
@item
539
@ref{Implementation Advice}, provides information on generally
540
desirable behavior which are not requirements that all compilers must
541
follow since it cannot be provided on all systems, or which may be
542
undesirable on some systems.
543
 
544
@item
545
@ref{Implementation Defined Characteristics}, provides a guide to
546
minimizing implementation dependent features.
547
 
548
@item
549
@ref{Intrinsic Subprograms}, describes the intrinsic subprograms
550
implemented by GNAT, and how they can be imported into user
551
application programs.
552
 
553
@item
554
@ref{Representation Clauses and Pragmas}, describes in detail the
555
way that GNAT represents data, and in particular the exact set
556
of representation clauses and pragmas that is accepted.
557
 
558
@item
559
@ref{Standard Library Routines}, provides a listing of packages and a
560
brief description of the functionality that is provided by Ada's
561
extensive set of standard library routines as implemented by GNAT@.
562
 
563
@item
564
@ref{The Implementation of Standard I/O}, details how the GNAT
565
implementation of the input-output facilities.
566
 
567
@item
568
@ref{The GNAT Library}, is a catalog of packages that complement
569
the Ada predefined library.
570
 
571
@item
572
@ref{Interfacing to Other Languages}, describes how programs
573
written in Ada using GNAT can be interfaced to other programming
574
languages.
575
 
576
@ref{Specialized Needs Annexes}, describes the GNAT implementation of all
577
of the specialized needs annexes.
578
 
579
@item
580
@ref{Implementation of Specific Ada Features}, discusses issues related
581
to GNAT's implementation of machine code insertions, tasking, and several
582
other features.
583
 
584
@item
585
@ref{Project File Reference}, presents the syntax and semantics
586
of project files.
587
 
588
@item
589
@ref{Obsolescent Features} documents implementation dependent features,
590
including pragmas and attributes, which are considered obsolescent, since
591
there are other preferred ways of achieving the same results. These
592
obsolescent forms are retained for backwards compatibility.
593
 
594
@end itemize
595
 
596
@cindex Ada 95 Language Reference Manual
597
@cindex Ada 2005 Language Reference Manual
598
@noindent
599
This reference manual assumes a basic familiarity with the Ada 95 language, as
600
described in the International Standard ANSI/ISO/IEC-8652:1995,
601
January 1995.
602
It does not require knowledge of the new features introduced by Ada 2005,
603
(officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
604
and Amendment 1).
605
Both reference manuals are included in the GNAT documentation
606
package.
607
 
608
@node Conventions
609
@unnumberedsec Conventions
610
@cindex Conventions, typographical
611
@cindex Typographical conventions
612
 
613
@noindent
614
Following are examples of the typographical and graphic conventions used
615
in this guide:
616
 
617
@itemize @bullet
618
@item
619
@code{Functions}, @code{utility program names}, @code{standard names},
620
and @code{classes}.
621
 
622
@item
623
@code{Option flags}
624
 
625
@item
626
@file{File names}, @samp{button names}, and @samp{field names}.
627
 
628
@item
629
@code{Variables}, @env{environment variables}, and @var{metasyntactic
630
variables}.
631
 
632
@item
633
@emph{Emphasis}.
634
 
635
@item
636
[optional information or parameters]
637
 
638
@item
639
Examples are described by text
640
@smallexample
641
and then shown this way.
642
@end smallexample
643
@end itemize
644
 
645
@noindent
646
Commands that are entered by the user are preceded in this manual by the
647
characters @samp{$ } (dollar sign followed by space).  If your system uses this
648
sequence as a prompt, then the commands will appear exactly as you see them
649
in the manual.  If your system uses some other prompt, then the command will
650
appear with the @samp{$} replaced by whatever prompt character you are using.
651
 
652
@node Related Information
653
@unnumberedsec Related Information
654
@noindent
655
See the following documents for further information on GNAT:
656
 
657
@itemize @bullet
658
@item
659
@xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
660
@value{EDITION} User's Guide}, which provides information on how to use the
661
GNAT compiler system.
662
 
663
@item
664
@cite{Ada 95 Reference Manual}, which contains all reference
665
material for the Ada 95 programming language.
666
 
667
@item
668
@cite{Ada 95 Annotated Reference Manual}, which is an annotated version
669
of the Ada 95 standard.  The annotations describe
670
detailed aspects of the design decision, and in particular contain useful
671
sections on Ada 83 compatibility.
672
 
673
@item
674
@cite{Ada 2005 Reference Manual}, which contains all reference
675
material for the Ada 2005 programming language.
676
 
677
@item
678
@cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
679
of the Ada 2005 standard.  The annotations describe
680
detailed aspects of the design decision, and in particular contain useful
681
sections on Ada 83 and Ada 95 compatibility.
682
 
683
@item
684
@cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
685
which contains specific information on compatibility between GNAT and
686
DEC Ada 83 systems.
687
 
688
@item
689
@cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
690
describes in detail the pragmas and attributes provided by the DEC Ada 83
691
compiler system.
692
 
693
@end itemize
694
 
695
@node Implementation Defined Pragmas
696
@chapter Implementation Defined Pragmas
697
 
698
@noindent
699
Ada defines a set of pragmas that can be used to supply additional
700
information to the compiler.  These language defined pragmas are
701
implemented in GNAT and work as described in the Ada Reference Manual.
702
 
703
In addition, Ada allows implementations to define additional pragmas
704
whose meaning is defined by the implementation.  GNAT provides a number
705
of these implementation-defined pragmas, which can be used to extend
706
and enhance the functionality of the compiler.  This section of the GNAT
707
Reference Manual describes these additional pragmas.
708
 
709
Note that any program using these pragmas might not be portable to other
710
compilers (although GNAT implements this set of pragmas on all
711
platforms).  Therefore if portability to other compilers is an important
712
consideration, the use of these pragmas should be minimized.
713
 
714
@menu
715
* Pragma Abort_Defer::
716
* Pragma Ada_83::
717
* Pragma Ada_95::
718
* Pragma Ada_05::
719
* Pragma Ada_2005::
720
* Pragma Annotate::
721
* Pragma Assert::
722
* Pragma Assume_No_Invalid_Values::
723
* Pragma Ast_Entry::
724
* Pragma C_Pass_By_Copy::
725
* Pragma Check::
726
* Pragma Check_Name::
727
* Pragma Check_Policy::
728
* Pragma Comment::
729
* Pragma Common_Object::
730
* Pragma Compile_Time_Error::
731
* Pragma Compile_Time_Warning::
732
* Pragma Compiler_Unit::
733
* Pragma Complete_Representation::
734
* Pragma Complex_Representation::
735
* Pragma Component_Alignment::
736
* Pragma Convention_Identifier::
737
* Pragma CPP_Class::
738
* Pragma CPP_Constructor::
739
* Pragma CPP_Virtual::
740
* Pragma CPP_Vtable::
741
* Pragma Debug::
742
* Pragma Debug_Policy::
743
* Pragma Detect_Blocking::
744
* Pragma Elaboration_Checks::
745
* Pragma Eliminate::
746
* Pragma Export_Exception::
747
* Pragma Export_Function::
748
* Pragma Export_Object::
749
* Pragma Export_Procedure::
750
* Pragma Export_Value::
751
* Pragma Export_Valued_Procedure::
752
* Pragma Extend_System::
753
* Pragma External::
754
* Pragma External_Name_Casing::
755
* Pragma Fast_Math::
756
* Pragma Favor_Top_Level::
757
* Pragma Finalize_Storage_Only::
758
* Pragma Float_Representation::
759
* Pragma Ident::
760
* Pragma Implemented_By_Entry::
761
* Pragma Implicit_Packing::
762
* Pragma Import_Exception::
763
* Pragma Import_Function::
764
* Pragma Import_Object::
765
* Pragma Import_Procedure::
766
* Pragma Import_Valued_Procedure::
767
* Pragma Initialize_Scalars::
768
* Pragma Inline_Always::
769
* Pragma Inline_Generic::
770
* Pragma Interface::
771
* Pragma Interface_Name::
772
* Pragma Interrupt_Handler::
773
* Pragma Interrupt_State::
774
* Pragma Keep_Names::
775
* Pragma License::
776
* Pragma Link_With::
777
* Pragma Linker_Alias::
778
* Pragma Linker_Constructor::
779
* Pragma Linker_Destructor::
780
* Pragma Linker_Section::
781
* Pragma Long_Float::
782
* Pragma Machine_Attribute::
783
* Pragma Main::
784
* Pragma Main_Storage::
785
* Pragma No_Body::
786
* Pragma No_Return::
787
* Pragma No_Strict_Aliasing::
788
* Pragma Normalize_Scalars::
789
* Pragma Obsolescent::
790
* Pragma Optimize_Alignment::
791
* Pragma Passive::
792
* Pragma Persistent_BSS::
793
* Pragma Polling::
794
* Pragma Postcondition::
795
* Pragma Precondition::
796
* Pragma Profile (Ravenscar)::
797
* Pragma Profile (Restricted)::
798
* Pragma Psect_Object::
799
* Pragma Pure_Function::
800
* Pragma Restriction_Warnings::
801
* Pragma Shared::
802
* Pragma Short_Circuit_And_Or::
803
* Pragma Source_File_Name::
804
* Pragma Source_File_Name_Project::
805
* Pragma Source_Reference::
806
* Pragma Stream_Convert::
807
* Pragma Style_Checks::
808
* Pragma Subtitle::
809
* Pragma Suppress::
810
* Pragma Suppress_All::
811
* Pragma Suppress_Exception_Locations::
812
* Pragma Suppress_Initialization::
813
* Pragma Task_Info::
814
* Pragma Task_Name::
815
* Pragma Task_Storage::
816
* Pragma Thread_Local_Storage::
817
* Pragma Time_Slice::
818
* Pragma Title::
819
* Pragma Unchecked_Union::
820
* Pragma Unimplemented_Unit::
821
* Pragma Universal_Aliasing ::
822
* Pragma Universal_Data::
823
* Pragma Unmodified::
824
* Pragma Unreferenced::
825
* Pragma Unreferenced_Objects::
826
* Pragma Unreserve_All_Interrupts::
827
* Pragma Unsuppress::
828
* Pragma Use_VADS_Size::
829
* Pragma Validity_Checks::
830
* Pragma Volatile::
831
* Pragma Warnings::
832
* Pragma Weak_External::
833
* Pragma Wide_Character_Encoding::
834
@end menu
835
 
836
@node Pragma Abort_Defer
837
@unnumberedsec Pragma Abort_Defer
838
@findex Abort_Defer
839
@cindex Deferring aborts
840
@noindent
841
Syntax:
842
@smallexample
843
pragma Abort_Defer;
844
@end smallexample
845
 
846
@noindent
847
This pragma must appear at the start of the statement sequence of a
848
handled sequence of statements (right after the @code{begin}).  It has
849
the effect of deferring aborts for the sequence of statements (but not
850
for the declarations or handlers, if any, associated with this statement
851
sequence).
852
 
853
@node Pragma Ada_83
854
@unnumberedsec Pragma Ada_83
855
@findex Ada_83
856
@noindent
857
Syntax:
858
@smallexample @c ada
859
pragma Ada_83;
860
@end smallexample
861
 
862
@noindent
863
A configuration pragma that establishes Ada 83 mode for the unit to
864
which it applies, regardless of the mode set by the command line
865
switches.  In Ada 83 mode, GNAT attempts to be as compatible with
866
the syntax and semantics of Ada 83, as defined in the original Ada
867
83 Reference Manual as possible.  In particular, the keywords added by Ada 95
868
and Ada 2005 are not recognized, optional package bodies are allowed,
869
and generics may name types with unknown discriminants without using
870
the @code{(<>)} notation.  In addition, some but not all of the additional
871
restrictions of Ada 83 are enforced.
872
 
873
Ada 83 mode is intended for two purposes.  Firstly, it allows existing
874
Ada 83 code to be compiled and adapted to GNAT with less effort.
875
Secondly, it aids in keeping code backwards compatible with Ada 83.
876
However, there is no guarantee that code that is processed correctly
877
by GNAT in Ada 83 mode will in fact compile and execute with an Ada
878
83 compiler, since GNAT does not enforce all the additional checks
879
required by Ada 83.
880
 
881
@node Pragma Ada_95
882
@unnumberedsec Pragma Ada_95
883
@findex Ada_95
884
@noindent
885
Syntax:
886
@smallexample @c ada
887
pragma Ada_95;
888
@end smallexample
889
 
890
@noindent
891
A configuration pragma that establishes Ada 95 mode for the unit to which
892
it applies, regardless of the mode set by the command line switches.
893
This mode is set automatically for the @code{Ada} and @code{System}
894
packages and their children, so you need not specify it in these
895
contexts.  This pragma is useful when writing a reusable component that
896
itself uses Ada 95 features, but which is intended to be usable from
897
either Ada 83 or Ada 95 programs.
898
 
899
@node Pragma Ada_05
900
@unnumberedsec Pragma Ada_05
901
@findex Ada_05
902
@noindent
903
Syntax:
904
@smallexample @c ada
905
pragma Ada_05;
906
@end smallexample
907
 
908
@noindent
909
A configuration pragma that establishes Ada 2005 mode for the unit to which
910
it applies, regardless of the mode set by the command line switches.
911
This mode is set automatically for the @code{Ada} and @code{System}
912
packages and their children, so you need not specify it in these
913
contexts.  This pragma is useful when writing a reusable component that
914
itself uses Ada 2005 features, but which is intended to be usable from
915
either Ada 83 or Ada 95 programs.
916
 
917
@node Pragma Ada_2005
918
@unnumberedsec Pragma Ada_2005
919
@findex Ada_2005
920
@noindent
921
Syntax:
922
@smallexample @c ada
923
pragma Ada_2005;
924
@end smallexample
925
 
926
@noindent
927
This configuration pragma is a synonym for pragma Ada_05 and has the
928
same syntax and effect.
929
 
930
@node Pragma Annotate
931
@unnumberedsec Pragma Annotate
932
@findex Annotate
933
@noindent
934
Syntax:
935
@smallexample @c ada
936
pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
937
 
938
ARG ::= NAME | EXPRESSION
939
@end smallexample
940
 
941
@noindent
942
This pragma is used to annotate programs.  @var{identifier} identifies
943
the type of annotation.  GNAT verifies that it is an identifier, but does
944
not otherwise analyze it. The second optional identifier is also left
945
unanalyzed, and by convention is used to control the action of the tool to
946
which the annotation is addressed.  The remaining @var{arg} arguments
947
can be either string literals or more generally expressions.
948
String literals are assumed to be either of type
949
@code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
950
depending on the character literals they contain.
951
All other kinds of arguments are analyzed as expressions, and must be
952
unambiguous.
953
 
954
The analyzed pragma is retained in the tree, but not otherwise processed
955
by any part of the GNAT compiler.  This pragma is intended for use by
956
external tools, including ASIS@.
957
 
958
@node Pragma Assert
959
@unnumberedsec Pragma Assert
960
@findex Assert
961
@noindent
962
Syntax:
963
@smallexample @c ada
964
pragma Assert (
965
  boolean_EXPRESSION
966
  [, string_EXPRESSION]);
967
@end smallexample
968
 
969
@noindent
970
The effect of this pragma depends on whether the corresponding command
971
line switch is set to activate assertions.  The pragma expands into code
972
equivalent to the following:
973
 
974
@smallexample @c ada
975
if assertions-enabled then
976
   if not boolean_EXPRESSION then
977
      System.Assertions.Raise_Assert_Failure
978
        (string_EXPRESSION);
979
   end if;
980
end if;
981
@end smallexample
982
 
983
@noindent
984
The string argument, if given, is the message that will be associated
985
with the exception occurrence if the exception is raised.  If no second
986
argument is given, the default message is @samp{@var{file}:@var{nnn}},
987
where @var{file} is the name of the source file containing the assert,
988
and @var{nnn} is the line number of the assert.  A pragma is not a
989
statement, so if a statement sequence contains nothing but a pragma
990
assert, then a null statement is required in addition, as in:
991
 
992
@smallexample @c ada
993
@dots{}
994
if J > 3 then
995
   pragma Assert (K > 3, "Bad value for K");
996
   null;
997
end if;
998
@end smallexample
999
 
1000
@noindent
1001
Note that, as with the @code{if} statement to which it is equivalent, the
1002
type of the expression is either @code{Standard.Boolean}, or any type derived
1003
from this standard type.
1004
 
1005
If assertions are disabled (switch @option{-gnata} not used), then there
1006
is no run-time effect (and in particular, any side effects from the
1007
expression will not occur at run time).  (The expression is still
1008
analyzed at compile time, and may cause types to be frozen if they are
1009
mentioned here for the first time).
1010
 
1011
If assertions are enabled, then the given expression is tested, and if
1012
it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1013
which results in the raising of @code{Assert_Failure} with the given message.
1014
 
1015
You should generally avoid side effects in the expression arguments of
1016
this pragma, because these side effects will turn on and off with the
1017
setting of the assertions mode, resulting in assertions that have an
1018
effect on the program.  However, the expressions are analyzed for
1019
semantic correctness whether or not assertions are enabled, so turning
1020
assertions on and off cannot affect the legality of a program.
1021
 
1022
@node Pragma Assume_No_Invalid_Values
1023
@unnumberedsec Pragma Assume_No_Invalid_Values
1024
@findex Assume_No_Invalid_Values
1025
@cindex Invalid representations
1026
@cindex Invalid values
1027
@noindent
1028
Syntax:
1029
@smallexample @c ada
1030
pragma Assume_No_Invalid_Values (On | Off);
1031
@end smallexample
1032
 
1033
@noindent
1034
This is a configuration pragma that controls the assumptions made by the
1035
compiler about the occurrence of invalid representations (invalid values)
1036
in the code.
1037
 
1038
The default behavior (corresponding to an Off argument for this pragma), is
1039
to assume that values may in general be invalid unless the compiler can
1040
prove they are valid. Consider the following example:
1041
 
1042
@smallexample @c ada
1043
V1 : Integer range 1 .. 10;
1044
V2 : Integer range 11 .. 20;
1045
...
1046
for J in V2 .. V1 loop
1047
   ...
1048
end loop;
1049
@end smallexample
1050
 
1051
@noindent
1052
if V1 and V2 have valid values, then the loop is known at compile
1053
time not to execute since the lower bound must be greater than the
1054
upper bound. However in default mode, no such assumption is made,
1055
and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1056
is given, the compiler will assume that any occurrence of a variable
1057
other than in an explicit @code{'Valid} test always has a valid
1058
value, and the loop above will be optimized away.
1059
 
1060
The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1061
you know your code is free of uninitialized variables and other
1062
possible sources of invalid representations, and may result in
1063
more efficient code. A program that accesses an invalid representation
1064
with this pragma in effect is erroneous, so no guarantees can be made
1065
about its behavior.
1066
 
1067
It is peculiar though permissible to use this pragma in conjunction
1068
with validity checking (-gnatVa). In such cases, accessing invalid
1069
values will generally give an exception, though formally the program
1070
is erroneous so there are no guarantees that this will always be the
1071
case, and it is recommended that these two options not be used together.
1072
 
1073
@node Pragma Ast_Entry
1074
@unnumberedsec Pragma Ast_Entry
1075
@cindex OpenVMS
1076
@findex Ast_Entry
1077
@noindent
1078
Syntax:
1079
@smallexample @c ada
1080
pragma AST_Entry (entry_IDENTIFIER);
1081
@end smallexample
1082
 
1083
@noindent
1084
This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1085
argument is the simple name of a single entry; at most one @code{AST_Entry}
1086
pragma is allowed for any given entry.  This pragma must be used in
1087
conjunction with the @code{AST_Entry} attribute, and is only allowed after
1088
the entry declaration and in the same task type specification or single task
1089
as the entry to which it applies.  This pragma specifies that the given entry
1090
may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1091
resulting from an OpenVMS system service call.  The pragma does not affect
1092
normal use of the entry.  For further details on this pragma, see the
1093
DEC Ada Language Reference Manual, section 9.12a.
1094
 
1095
@node Pragma C_Pass_By_Copy
1096
@unnumberedsec Pragma C_Pass_By_Copy
1097
@cindex Passing by copy
1098
@findex C_Pass_By_Copy
1099
@noindent
1100
Syntax:
1101
@smallexample @c ada
1102
pragma C_Pass_By_Copy
1103
  ([Max_Size =>] static_integer_EXPRESSION);
1104
@end smallexample
1105
 
1106
@noindent
1107
Normally the default mechanism for passing C convention records to C
1108
convention subprograms is to pass them by reference, as suggested by RM
1109
B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1110
this default, by requiring that record formal parameters be passed by
1111
copy if all of the following conditions are met:
1112
 
1113
@itemize @bullet
1114
@item
1115
The size of the record type does not exceed the value specified for
1116
@code{Max_Size}.
1117
@item
1118
The record type has @code{Convention C}.
1119
@item
1120
The formal parameter has this record type, and the subprogram has a
1121
foreign (non-Ada) convention.
1122
@end itemize
1123
 
1124
@noindent
1125
If these conditions are met the argument is passed by copy, i.e.@: in a
1126
manner consistent with what C expects if the corresponding formal in the
1127
C prototype is a struct (rather than a pointer to a struct).
1128
 
1129
You can also pass records by copy by specifying the convention
1130
@code{C_Pass_By_Copy} for the record type, or by using the extended
1131
@code{Import} and @code{Export} pragmas, which allow specification of
1132
passing mechanisms on a parameter by parameter basis.
1133
 
1134
@node Pragma Check
1135
@unnumberedsec Pragma Check
1136
@cindex Assertions
1137
@cindex Named assertions
1138
@findex Check
1139
@noindent
1140
Syntax:
1141
@smallexample @c ada
1142
pragma Check (
1143
     [Name    =>] Identifier,
1144
     [Check   =>] Boolean_EXPRESSION
1145
  [, [Message =>] string_EXPRESSION] );
1146
@end smallexample
1147
 
1148
@noindent
1149
This pragma is similar to the predefined pragma @code{Assert} except that an
1150
extra identifier argument is present. In conjunction with pragma
1151
@code{Check_Policy}, this can be used to define groups of assertions that can
1152
be independently controlled. The identifier @code{Assertion} is special, it
1153
refers to the normal set of pragma @code{Assert} statements. The identifiers
1154
@code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1155
names, so these three names would normally not be used directly in a pragma
1156
@code{Check}.
1157
 
1158
Checks introduced by this pragma are normally deactivated by default. They can
1159
be activated either by the command line option @option{-gnata}, which turns on
1160
all checks, or individually controlled using pragma @code{Check_Policy}.
1161
 
1162
@node Pragma Check_Name
1163
@unnumberedsec Pragma Check_Name
1164
@cindex Defining check names
1165
@cindex Check names, defining
1166
@findex Check_Name
1167
@noindent
1168
Syntax:
1169
@smallexample @c ada
1170
pragma Check_Name (check_name_IDENTIFIER);
1171
@end smallexample
1172
 
1173
@noindent
1174
This is a configuration pragma that defines a new implementation
1175
defined check name (unless IDENTIFIER matches one of the predefined
1176
check names, in which case the pragma has no effect). Check names
1177
are global to a partition, so if two or more configuration pragmas
1178
are present in a partition mentioning the same name, only one new
1179
check name is introduced.
1180
 
1181
An implementation defined check name introduced with this pragma may
1182
be used in only three contexts: @code{pragma Suppress},
1183
@code{pragma Unsuppress},
1184
and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1185
any of these three cases, the check name must be visible. A check
1186
name is visible if it is in the configuration pragmas applying to
1187
the current unit, or if it appears at the start of any unit that
1188
is part of the dependency set of the current unit (e.g., units that
1189
are mentioned in @code{with} clauses).
1190
 
1191
@node Pragma Check_Policy
1192
@unnumberedsec Pragma Check_Policy
1193
@cindex Controlling assertions
1194
@cindex Assertions, control
1195
@cindex Check pragma control
1196
@cindex Named assertions
1197
@findex Check
1198
@noindent
1199
Syntax:
1200
@smallexample @c ada
1201
pragma Check_Policy
1202
 ([Name   =>] Identifier,
1203
  [Policy =>] POLICY_IDENTIFIER);
1204
 
1205
POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1206
@end smallexample
1207
 
1208
@noindent
1209
This pragma is similar to the predefined pragma @code{Assertion_Policy},
1210
except that it controls sets of named assertions introduced using the
1211
@code{Check} pragmas. It can be used as a configuration pragma or (unlike
1212
@code{Assertion_Policy}) can be used within a declarative part, in which case
1213
it controls the status to the end of the corresponding construct (in a manner
1214
identical to pragma @code{Suppress)}.
1215
 
1216
The identifier given as the first argument corresponds to a name used in
1217
associated @code{Check} pragmas. For example, if the pragma:
1218
 
1219
@smallexample @c ada
1220
pragma Check_Policy (Critical_Error, Off);
1221
@end smallexample
1222
 
1223
@noindent
1224
is given, then subsequent @code{Check} pragmas whose first argument is also
1225
@code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1226
controls the behavior of normal @code{Assert} pragmas (thus a pragma
1227
@code{Check_Policy} with this identifier is similar to the normal
1228
@code{Assertion_Policy} pragma except that it can appear within a
1229
declarative part).
1230
 
1231
The special identifiers @code{Precondition} and @code{Postcondition} control
1232
the status of preconditions and postconditions. If a @code{Precondition} pragma
1233
is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1234
that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1235
of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1236
are recognized.
1237
 
1238
The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1239
to turn on corresponding checks. The default for a set of checks for which no
1240
@code{Check_Policy} is given is @code{Off} unless the compiler switch
1241
@option{-gnata} is given, which turns on all checks by default.
1242
 
1243
The check policy settings @code{Check} and @code{Ignore} are also recognized
1244
as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1245
compatibility with the standard @code{Assertion_Policy} pragma.
1246
 
1247
@node Pragma Comment
1248
@unnumberedsec Pragma Comment
1249
@findex Comment
1250
@noindent
1251
Syntax:
1252
 
1253
@smallexample @c ada
1254
pragma Comment (static_string_EXPRESSION);
1255
@end smallexample
1256
 
1257
@noindent
1258
This is almost identical in effect to pragma @code{Ident}.  It allows the
1259
placement of a comment into the object file and hence into the
1260
executable file if the operating system permits such usage.  The
1261
difference is that @code{Comment}, unlike @code{Ident}, has
1262
no limitations on placement of the pragma (it can be placed
1263
anywhere in the main source unit), and if more than one pragma
1264
is used, all comments are retained.
1265
 
1266
@node Pragma Common_Object
1267
@unnumberedsec Pragma Common_Object
1268
@findex Common_Object
1269
@noindent
1270
Syntax:
1271
 
1272
@smallexample @c ada
1273
pragma Common_Object (
1274
     [Internal =>] LOCAL_NAME
1275
  [, [External =>] EXTERNAL_SYMBOL]
1276
  [, [Size     =>] EXTERNAL_SYMBOL] );
1277
 
1278
EXTERNAL_SYMBOL ::=
1279
  IDENTIFIER
1280
| static_string_EXPRESSION
1281
@end smallexample
1282
 
1283
@noindent
1284
This pragma enables the shared use of variables stored in overlaid
1285
linker areas corresponding to the use of @code{COMMON}
1286
in Fortran.  The single
1287
object @var{LOCAL_NAME} is assigned to the area designated by
1288
the @var{External} argument.
1289
You may define a record to correspond to a series
1290
of fields.  The @var{Size} argument
1291
is syntax checked in GNAT, but otherwise ignored.
1292
 
1293
@code{Common_Object} is not supported on all platforms.  If no
1294
support is available, then the code generator will issue a message
1295
indicating that the necessary attribute for implementation of this
1296
pragma is not available.
1297
 
1298
@node Pragma Compile_Time_Error
1299
@unnumberedsec Pragma Compile_Time_Error
1300
@findex Compile_Time_Error
1301
@noindent
1302
Syntax:
1303
 
1304
@smallexample @c ada
1305
pragma Compile_Time_Error
1306
         (boolean_EXPRESSION, static_string_EXPRESSION);
1307
@end smallexample
1308
 
1309
@noindent
1310
This pragma can be used to generate additional compile time
1311
error messages. It
1312
is particularly useful in generics, where errors can be issued for
1313
specific problematic instantiations. The first parameter is a boolean
1314
expression. The pragma is effective only if the value of this expression
1315
is known at compile time, and has the value True. The set of expressions
1316
whose values are known at compile time includes all static boolean
1317
expressions, and also other values which the compiler can determine
1318
at compile time (e.g., the size of a record type set by an explicit
1319
size representation clause, or the value of a variable which was
1320
initialized to a constant and is known not to have been modified).
1321
If these conditions are met, an error message is generated using
1322
the value given as the second argument. This string value may contain
1323
embedded ASCII.LF characters to break the message into multiple lines.
1324
 
1325
@node Pragma Compile_Time_Warning
1326
@unnumberedsec Pragma Compile_Time_Warning
1327
@findex Compile_Time_Warning
1328
@noindent
1329
Syntax:
1330
 
1331
@smallexample @c ada
1332
pragma Compile_Time_Warning
1333
         (boolean_EXPRESSION, static_string_EXPRESSION);
1334
@end smallexample
1335
 
1336
@noindent
1337
Same as pragma Compile_Time_Error, except a warning is issued instead
1338
of an error message. Note that if this pragma is used in a package that
1339
is with'ed by a client, the client will get the warning even though it
1340
is issued by a with'ed package (normally warnings in with'ed units are
1341
suppressed, but this is a special exception to that rule).
1342
 
1343
One typical use is within a generic where compile time known characteristics
1344
of formal parameters are tested, and warnings given appropriately. Another use
1345
with a first parameter of True is to warn a client about use of a package,
1346
for example that it is not fully implemented.
1347
 
1348
@node Pragma Compiler_Unit
1349
@unnumberedsec Pragma Compiler_Unit
1350
@findex Compiler_Unit
1351
@noindent
1352
Syntax:
1353
 
1354
@smallexample @c ada
1355
pragma Compiler_Unit;
1356
@end smallexample
1357
 
1358
@noindent
1359
This pragma is intended only for internal use in the GNAT run-time library.
1360
It indicates that the unit is used as part of the compiler build. The effect
1361
is to disallow constructs (raise with message, conditional expressions etc)
1362
that would cause trouble when bootstrapping using an older version of GNAT.
1363
For the exact list of restrictions, see the compiler sources and references
1364
to Is_Compiler_Unit.
1365
 
1366
@node Pragma Complete_Representation
1367
@unnumberedsec Pragma Complete_Representation
1368
@findex Complete_Representation
1369
@noindent
1370
Syntax:
1371
 
1372
@smallexample @c ada
1373
pragma Complete_Representation;
1374
@end smallexample
1375
 
1376
@noindent
1377
This pragma must appear immediately within a record representation
1378
clause. Typical placements are before the first component clause
1379
or after the last component clause. The effect is to give an error
1380
message if any component is missing a component clause. This pragma
1381
may be used to ensure that a record representation clause is
1382
complete, and that this invariant is maintained if fields are
1383
added to the record in the future.
1384
 
1385
@node Pragma Complex_Representation
1386
@unnumberedsec Pragma Complex_Representation
1387
@findex Complex_Representation
1388
@noindent
1389
Syntax:
1390
 
1391
@smallexample @c ada
1392
pragma Complex_Representation
1393
        ([Entity =>] LOCAL_NAME);
1394
@end smallexample
1395
 
1396
@noindent
1397
The @var{Entity} argument must be the name of a record type which has
1398
two fields of the same floating-point type.  The effect of this pragma is
1399
to force gcc to use the special internal complex representation form for
1400
this record, which may be more efficient.  Note that this may result in
1401
the code for this type not conforming to standard ABI (application
1402
binary interface) requirements for the handling of record types.  For
1403
example, in some environments, there is a requirement for passing
1404
records by pointer, and the use of this pragma may result in passing
1405
this type in floating-point registers.
1406
 
1407
@node Pragma Component_Alignment
1408
@unnumberedsec Pragma Component_Alignment
1409
@cindex Alignments of components
1410
@findex Component_Alignment
1411
@noindent
1412
Syntax:
1413
 
1414
@smallexample @c ada
1415
pragma Component_Alignment (
1416
     [Form =>] ALIGNMENT_CHOICE
1417
  [, [Name =>] type_LOCAL_NAME]);
1418
 
1419
ALIGNMENT_CHOICE ::=
1420
  Component_Size
1421
| Component_Size_4
1422
| Storage_Unit
1423
| Default
1424
@end smallexample
1425
 
1426
@noindent
1427
Specifies the alignment of components in array or record types.
1428
The meaning of the @var{Form} argument is as follows:
1429
 
1430
@table @code
1431
@findex Component_Size
1432
@item Component_Size
1433
Aligns scalar components and subcomponents of the array or record type
1434
on boundaries appropriate to their inherent size (naturally
1435
aligned).  For example, 1-byte components are aligned on byte boundaries,
1436
2-byte integer components are aligned on 2-byte boundaries, 4-byte
1437
integer components are aligned on 4-byte boundaries and so on.  These
1438
alignment rules correspond to the normal rules for C compilers on all
1439
machines except the VAX@.
1440
 
1441
@findex Component_Size_4
1442
@item Component_Size_4
1443
Naturally aligns components with a size of four or fewer
1444
bytes.  Components that are larger than 4 bytes are placed on the next
1445
4-byte boundary.
1446
 
1447
@findex Storage_Unit
1448
@item Storage_Unit
1449
Specifies that array or record components are byte aligned, i.e.@:
1450
aligned on boundaries determined by the value of the constant
1451
@code{System.Storage_Unit}.
1452
 
1453
@cindex OpenVMS
1454
@item Default
1455
Specifies that array or record components are aligned on default
1456
boundaries, appropriate to the underlying hardware or operating system or
1457
both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1458
the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1459
the @code{Default} choice is the same as @code{Component_Size} (natural
1460
alignment).
1461
@end table
1462
 
1463
@noindent
1464
If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1465
refer to a local record or array type, and the specified alignment
1466
choice applies to the specified type.  The use of
1467
@code{Component_Alignment} together with a pragma @code{Pack} causes the
1468
@code{Component_Alignment} pragma to be ignored.  The use of
1469
@code{Component_Alignment} together with a record representation clause
1470
is only effective for fields not specified by the representation clause.
1471
 
1472
If the @code{Name} parameter is absent, the pragma can be used as either
1473
a configuration pragma, in which case it applies to one or more units in
1474
accordance with the normal rules for configuration pragmas, or it can be
1475
used within a declarative part, in which case it applies to types that
1476
are declared within this declarative part, or within any nested scope
1477
within this declarative part.  In either case it specifies the alignment
1478
to be applied to any record or array type which has otherwise standard
1479
representation.
1480
 
1481
If the alignment for a record or array type is not specified (using
1482
pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1483
clause), the GNAT uses the default alignment as described previously.
1484
 
1485
@node Pragma Convention_Identifier
1486
@unnumberedsec Pragma Convention_Identifier
1487
@findex Convention_Identifier
1488
@cindex Conventions, synonyms
1489
@noindent
1490
Syntax:
1491
 
1492
@smallexample @c ada
1493
pragma Convention_Identifier (
1494
         [Name =>]       IDENTIFIER,
1495
         [Convention =>] convention_IDENTIFIER);
1496
@end smallexample
1497
 
1498
@noindent
1499
This pragma provides a mechanism for supplying synonyms for existing
1500
convention identifiers. The @code{Name} identifier can subsequently
1501
be used as a synonym for the given convention in other pragmas (including
1502
for example pragma @code{Import} or another @code{Convention_Identifier}
1503
pragma). As an example of the use of this, suppose you had legacy code
1504
which used Fortran77 as the identifier for Fortran. Then the pragma:
1505
 
1506
@smallexample @c ada
1507
pragma Convention_Identifier (Fortran77, Fortran);
1508
@end smallexample
1509
 
1510
@noindent
1511
would allow the use of the convention identifier @code{Fortran77} in
1512
subsequent code, avoiding the need to modify the sources. As another
1513
example, you could use this to parametrize convention requirements
1514
according to systems. Suppose you needed to use @code{Stdcall} on
1515
windows systems, and @code{C} on some other system, then you could
1516
define a convention identifier @code{Library} and use a single
1517
@code{Convention_Identifier} pragma to specify which convention
1518
would be used system-wide.
1519
 
1520
@node Pragma CPP_Class
1521
@unnumberedsec Pragma CPP_Class
1522
@findex CPP_Class
1523
@cindex Interfacing with C++
1524
@noindent
1525
Syntax:
1526
 
1527
@smallexample @c ada
1528
pragma CPP_Class ([Entity =>] LOCAL_NAME);
1529
@end smallexample
1530
 
1531
@noindent
1532
The argument denotes an entity in the current declarative region that is
1533
declared as a record type. It indicates that the type corresponds to an
1534
externally declared C++ class type, and is to be laid out the same way
1535
that C++ would lay out the type. If the C++ class has virtual primitives
1536
then the record must be declared as a tagged record type.
1537
 
1538
Types for which @code{CPP_Class} is specified do not have assignment or
1539
equality operators defined (such operations can be imported or declared
1540
as subprograms as required). Initialization is allowed only by constructor
1541
functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1542
limited if not explicitly declared as limited or derived from a limited
1543
type, and an error is issued in that case.
1544
 
1545
Pragma @code{CPP_Class} is intended primarily for automatic generation
1546
using an automatic binding generator tool.
1547
See @ref{Interfacing to C++} for related information.
1548
 
1549
Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1550
for backward compatibility but its functionality is available
1551
using pragma @code{Import} with @code{Convention} = @code{CPP}.
1552
 
1553
@node Pragma CPP_Constructor
1554
@unnumberedsec Pragma CPP_Constructor
1555
@cindex Interfacing with C++
1556
@findex CPP_Constructor
1557
@noindent
1558
Syntax:
1559
 
1560
@smallexample @c ada
1561
pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1562
  [, [External_Name =>] static_string_EXPRESSION ]
1563
  [, [Link_Name     =>] static_string_EXPRESSION ]);
1564
@end smallexample
1565
 
1566
@noindent
1567
This pragma identifies an imported function (imported in the usual way
1568
with pragma @code{Import}) as corresponding to a C++ constructor. If
1569
@code{External_Name} and @code{Link_Name} are not specified then the
1570
@code{Entity} argument is a name that must have been previously mentioned
1571
in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1572
must be of one of the following forms:
1573
 
1574
@itemize @bullet
1575
@item
1576
@code{function @var{Fname} return @var{T}}
1577
 
1578
@itemize @bullet
1579
@item
1580
@code{function @var{Fname} return @var{T}'Class}
1581
 
1582
@item
1583
@code{function @var{Fname} (@dots{}) return @var{T}}
1584
@end itemize
1585
 
1586
@item
1587
@code{function @var{Fname} (@dots{}) return @var{T}'Class}
1588
@end itemize
1589
 
1590
@noindent
1591
where @var{T} is a limited record type imported from C++ with pragma
1592
@code{Import} and @code{Convention} = @code{CPP}.
1593
 
1594
The first two forms import the default constructor, used when an object
1595
of type @var{T} is created on the Ada side with no explicit constructor.
1596
The latter two forms cover all the non-default constructors of the type.
1597
See the GNAT users guide for details.
1598
 
1599
If no constructors are imported, it is impossible to create any objects
1600
on the Ada side and the type is implicitly declared abstract.
1601
 
1602
Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1603
using an automatic binding generator tool.
1604
See @ref{Interfacing to C++} for more related information.
1605
 
1606
Note: The use of functions returning class-wide types for constructors is
1607
currently obsolete. They are supported for backward compatibility. The
1608
use of functions returning the type T leave the Ada sources more clear
1609
because the imported C++ constructors always return an object of type T;
1610
that is, they never return an object whose type is a descendant of type T.
1611
 
1612
@node Pragma CPP_Virtual
1613
@unnumberedsec Pragma CPP_Virtual
1614
@cindex Interfacing to C++
1615
@findex CPP_Virtual
1616
@noindent
1617
This pragma is now obsolete has has no effect because GNAT generates
1618
the same object layout than the G++ compiler.
1619
 
1620
See @ref{Interfacing to C++} for related information.
1621
 
1622
@node Pragma CPP_Vtable
1623
@unnumberedsec Pragma CPP_Vtable
1624
@cindex Interfacing with C++
1625
@findex CPP_Vtable
1626
@noindent
1627
This pragma is now obsolete has has no effect because GNAT generates
1628
the same object layout than the G++ compiler.
1629
 
1630
See @ref{Interfacing to C++} for related information.
1631
 
1632
@node Pragma Debug
1633
@unnumberedsec Pragma Debug
1634
@findex Debug
1635
@noindent
1636
Syntax:
1637
 
1638
@smallexample @c ada
1639
pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1640
 
1641
PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1642
  PROCEDURE_NAME
1643
| PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1644
@end smallexample
1645
 
1646
@noindent
1647
The procedure call argument has the syntactic form of an expression, meeting
1648
the syntactic requirements for pragmas.
1649
 
1650
If debug pragmas are not enabled or if the condition is present and evaluates
1651
to False, this pragma has no effect. If debug pragmas are enabled, the
1652
semantics of the pragma is exactly equivalent to the procedure call statement
1653
corresponding to the argument with a terminating semicolon. Pragmas are
1654
permitted in sequences of declarations, so you can use pragma @code{Debug} to
1655
intersperse calls to debug procedures in the middle of declarations. Debug
1656
pragmas can be enabled either by use of the command line switch @option{-gnata}
1657
or by use of the configuration pragma @code{Debug_Policy}.
1658
 
1659
@node Pragma Debug_Policy
1660
@unnumberedsec Pragma Debug_Policy
1661
@findex Debug_Policy
1662
@noindent
1663
Syntax:
1664
 
1665
@smallexample @c ada
1666
pragma Debug_Policy (CHECK | IGNORE);
1667
@end smallexample
1668
 
1669
@noindent
1670
If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1671
If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1672
This pragma overrides the effect of the @option{-gnata} switch on the
1673
command line.
1674
 
1675
@node Pragma Detect_Blocking
1676
@unnumberedsec Pragma Detect_Blocking
1677
@findex Detect_Blocking
1678
@noindent
1679
Syntax:
1680
 
1681
@smallexample @c ada
1682
pragma Detect_Blocking;
1683
@end smallexample
1684
 
1685
@noindent
1686
This is a configuration pragma that forces the detection of potentially
1687
blocking operations within a protected operation, and to raise Program_Error
1688
if that happens.
1689
 
1690
@node Pragma Elaboration_Checks
1691
@unnumberedsec Pragma Elaboration_Checks
1692
@cindex Elaboration control
1693
@findex Elaboration_Checks
1694
@noindent
1695
Syntax:
1696
 
1697
@smallexample @c ada
1698
pragma Elaboration_Checks (Dynamic | Static);
1699
@end smallexample
1700
 
1701
@noindent
1702
This is a configuration pragma that provides control over the
1703
elaboration model used by the compilation affected by the
1704
pragma.  If the parameter is @code{Dynamic},
1705
then the dynamic elaboration
1706
model described in the Ada Reference Manual is used, as though
1707
the @option{-gnatE} switch had been specified on the command
1708
line.  If the parameter is @code{Static}, then the default GNAT static
1709
model is used.  This configuration pragma overrides the setting
1710
of the command line.  For full details on the elaboration models
1711
used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1712
gnat_ugn, @value{EDITION} User's Guide}.
1713
 
1714
@node Pragma Eliminate
1715
@unnumberedsec Pragma Eliminate
1716
@cindex Elimination of unused subprograms
1717
@findex Eliminate
1718
@noindent
1719
Syntax:
1720
 
1721
@smallexample @c ada
1722
pragma Eliminate (
1723
    [Unit_Name =>] IDENTIFIER |
1724
                   SELECTED_COMPONENT);
1725
 
1726
pragma Eliminate (
1727
    [Unit_Name       =>]  IDENTIFIER |
1728
                          SELECTED_COMPONENT,
1729
    [Entity          =>]  IDENTIFIER |
1730
                          SELECTED_COMPONENT |
1731
                          STRING_LITERAL
1732
    [,OVERLOADING_RESOLUTION]);
1733
 
1734
OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1735
                           SOURCE_LOCATION
1736
 
1737
PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1738
                                      FUNCTION_PROFILE
1739
 
1740
PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1741
 
1742
FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1743
                      Result_Type => result_SUBTYPE_NAME]
1744
 
1745
PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1746
SUBTYPE_NAME    ::= STRING_VALUE
1747
 
1748
SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1749
SOURCE_TRACE    ::= STRING_VALUE
1750
 
1751
STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1752
@end smallexample
1753
 
1754
@noindent
1755
This pragma indicates that the given entity is not used outside the
1756
compilation unit it is defined in. The entity must be an explicitly declared
1757
subprogram; this includes  generic subprogram instances and
1758
subprograms declared in generic package instances.
1759
 
1760
If the entity to be eliminated is a library level subprogram, then
1761
the first form of pragma @code{Eliminate} is used with only a single argument.
1762
In this form, the @code{Unit_Name} argument specifies the name of the
1763
library  level unit to be eliminated.
1764
 
1765
In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1766
are required. If item is an entity of a library package, then the first
1767
argument specifies the unit name, and the second argument specifies
1768
the particular entity.  If the second argument is in string form, it must
1769
correspond to the internal manner in which GNAT stores entity names (see
1770
compilation unit Namet in the compiler sources for details).
1771
 
1772
The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1773
to distinguish between overloaded subprograms. If a pragma does not contain
1774
the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1775
subprograms denoted by the first two parameters.
1776
 
1777
Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1778
to be eliminated in a manner similar to that used for the extended
1779
@code{Import} and @code{Export} pragmas, except that the subtype names are
1780
always given as strings. At the moment, this form of distinguishing
1781
overloaded subprograms is implemented only partially, so we do not recommend
1782
using it for practical subprogram elimination.
1783
 
1784
Note that in case of a parameterless procedure its profile is represented
1785
as @code{Parameter_Types => ("")}
1786
 
1787
Alternatively, the @code{Source_Location} parameter is used to specify
1788
which overloaded alternative is to be eliminated by pointing to the
1789
location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1790
source text. The string literal (or concatenation of string literals)
1791
given as SOURCE_TRACE must have the following format:
1792
 
1793
@smallexample @c ada
1794
SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1795
 
1796
LBRACKET ::= [
1797
RBRACKET ::= ]
1798
 
1799
SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1800
FILE_NAME       ::= STRING_LITERAL
1801
LINE_NUMBER     ::= DIGIT @{DIGIT@}
1802
@end smallexample
1803
 
1804
SOURCE_TRACE should be the short name of the source file (with no directory
1805
information), and LINE_NUMBER is supposed to point to the line where the
1806
defining name of the subprogram is located.
1807
 
1808
For the subprograms that are not a part of generic instantiations, only one
1809
SOURCE_LOCATION is used. If a subprogram is declared in a package
1810
instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1811
the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1812
second one denotes the declaration of the corresponding subprogram in the
1813
generic package. This approach is recursively used to create SOURCE_LOCATIONs
1814
in case of nested instantiations.
1815
 
1816
The effect of the pragma is to allow the compiler to eliminate
1817
the code or data associated with the named entity.  Any reference to
1818
an eliminated entity outside the compilation unit it is defined in,
1819
causes a compile time or link time error.
1820
 
1821
The intention of pragma @code{Eliminate} is to allow a program to be compiled
1822
in a system independent manner, with unused entities eliminated, without
1823
the requirement of modifying the source text.  Normally the required set
1824
of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1825
tool. Elimination of unused entities local to a compilation unit is
1826
automatic, without requiring the use of pragma @code{Eliminate}.
1827
 
1828
Note that the reason this pragma takes string literals where names might
1829
be expected is that a pragma @code{Eliminate} can appear in a context where the
1830
relevant names are not visible.
1831
 
1832
Note that any change in the source files that includes removing, splitting of
1833
adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1834
parameter illegal.
1835
 
1836
It is legal to use pragma Eliminate where the referenced entity is a
1837
dispatching operation, but it is not clear what this would mean, since
1838
in general the call does not know which entity is actually being called.
1839
Consequently, a pragma Eliminate for a dispatching operation is ignored.
1840
 
1841
@node Pragma Export_Exception
1842
@unnumberedsec Pragma Export_Exception
1843
@cindex OpenVMS
1844
@findex Export_Exception
1845
@noindent
1846
Syntax:
1847
 
1848
@smallexample @c ada
1849
pragma Export_Exception (
1850
     [Internal =>] LOCAL_NAME
1851
  [, [External =>] EXTERNAL_SYMBOL]
1852
  [, [Form     =>] Ada | VMS]
1853
  [, [Code     =>] static_integer_EXPRESSION]);
1854
 
1855
EXTERNAL_SYMBOL ::=
1856
  IDENTIFIER
1857
| static_string_EXPRESSION
1858
@end smallexample
1859
 
1860
@noindent
1861
This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1862
causes the specified exception to be propagated outside of the Ada program,
1863
so that it can be handled by programs written in other OpenVMS languages.
1864
This pragma establishes an external name for an Ada exception and makes the
1865
name available to the OpenVMS Linker as a global symbol.  For further details
1866
on this pragma, see the
1867
DEC Ada Language Reference Manual, section 13.9a3.2.
1868
 
1869
@node Pragma Export_Function
1870
@unnumberedsec Pragma Export_Function
1871
@cindex Argument passing mechanisms
1872
@findex Export_Function
1873
 
1874
@noindent
1875
Syntax:
1876
 
1877
@smallexample @c ada
1878
pragma Export_Function (
1879
     [Internal         =>] LOCAL_NAME
1880
  [, [External         =>] EXTERNAL_SYMBOL]
1881
  [, [Parameter_Types  =>] PARAMETER_TYPES]
1882
  [, [Result_Type      =>] result_SUBTYPE_MARK]
1883
  [, [Mechanism        =>] MECHANISM]
1884
  [, [Result_Mechanism =>] MECHANISM_NAME]);
1885
 
1886
EXTERNAL_SYMBOL ::=
1887
  IDENTIFIER
1888
| static_string_EXPRESSION
1889
| ""
1890
 
1891
PARAMETER_TYPES ::=
1892
  null
1893
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1894
 
1895
TYPE_DESIGNATOR ::=
1896
  subtype_NAME
1897
| subtype_Name ' Access
1898
 
1899
MECHANISM ::=
1900
  MECHANISM_NAME
1901
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1902
 
1903
MECHANISM_ASSOCIATION ::=
1904
  [formal_parameter_NAME =>] MECHANISM_NAME
1905
 
1906
MECHANISM_NAME ::=
1907
  Value
1908
| Reference
1909
| Descriptor [([Class =>] CLASS_NAME)]
1910
| Short_Descriptor [([Class =>] CLASS_NAME)]
1911
 
1912
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1913
@end smallexample
1914
 
1915
@noindent
1916
Use this pragma to make a function externally callable and optionally
1917
provide information on mechanisms to be used for passing parameter and
1918
result values.  We recommend, for the purposes of improving portability,
1919
this pragma always be used in conjunction with a separate pragma
1920
@code{Export}, which must precede the pragma @code{Export_Function}.
1921
GNAT does not require a separate pragma @code{Export}, but if none is
1922
present, @code{Convention Ada} is assumed, which is usually
1923
not what is wanted, so it is usually appropriate to use this
1924
pragma in conjunction with a @code{Export} or @code{Convention}
1925
pragma that specifies the desired foreign convention.
1926
Pragma @code{Export_Function}
1927
(and @code{Export}, if present) must appear in the same declarative
1928
region as the function to which they apply.
1929
 
1930
@var{internal_name} must uniquely designate the function to which the
1931
pragma applies.  If more than one function name exists of this name in
1932
the declarative part you must use the @code{Parameter_Types} and
1933
@code{Result_Type} parameters is mandatory to achieve the required
1934
unique designation.  @var{subtype_mark}s in these parameters must
1935
exactly match the subtypes in the corresponding function specification,
1936
using positional notation to match parameters with subtype marks.
1937
The form with an @code{'Access} attribute can be used to match an
1938
anonymous access parameter.
1939
 
1940
@cindex OpenVMS
1941
@cindex Passing by descriptor
1942
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1943
The default behavior for Export_Function is to accept either 64bit or
1944
32bit descriptors unless short_descriptor is specified, then only 32bit
1945
descriptors are accepted.
1946
 
1947
@cindex Suppressing external name
1948
Special treatment is given if the EXTERNAL is an explicit null
1949
string or a static string expressions that evaluates to the null
1950
string. In this case, no external name is generated. This form
1951
still allows the specification of parameter mechanisms.
1952
 
1953
@node Pragma Export_Object
1954
@unnumberedsec Pragma Export_Object
1955
@findex Export_Object
1956
@noindent
1957
Syntax:
1958
 
1959
@smallexample @c ada
1960
pragma Export_Object
1961
      [Internal =>] LOCAL_NAME
1962
   [, [External =>] EXTERNAL_SYMBOL]
1963
   [, [Size     =>] EXTERNAL_SYMBOL]
1964
 
1965
EXTERNAL_SYMBOL ::=
1966
  IDENTIFIER
1967
| static_string_EXPRESSION
1968
@end smallexample
1969
 
1970
@noindent
1971
This pragma designates an object as exported, and apart from the
1972
extended rules for external symbols, is identical in effect to the use of
1973
the normal @code{Export} pragma applied to an object.  You may use a
1974
separate Export pragma (and you probably should from the point of view
1975
of portability), but it is not required.  @var{Size} is syntax checked,
1976
but otherwise ignored by GNAT@.
1977
 
1978
@node Pragma Export_Procedure
1979
@unnumberedsec Pragma Export_Procedure
1980
@findex Export_Procedure
1981
@noindent
1982
Syntax:
1983
 
1984
@smallexample @c ada
1985
pragma Export_Procedure (
1986
     [Internal        =>] LOCAL_NAME
1987
  [, [External        =>] EXTERNAL_SYMBOL]
1988
  [, [Parameter_Types =>] PARAMETER_TYPES]
1989
  [, [Mechanism       =>] MECHANISM]);
1990
 
1991
EXTERNAL_SYMBOL ::=
1992
  IDENTIFIER
1993
| static_string_EXPRESSION
1994
| ""
1995
 
1996
PARAMETER_TYPES ::=
1997
  null
1998
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1999
 
2000
TYPE_DESIGNATOR ::=
2001
  subtype_NAME
2002
| subtype_Name ' Access
2003
 
2004
MECHANISM ::=
2005
  MECHANISM_NAME
2006
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2007
 
2008
MECHANISM_ASSOCIATION ::=
2009
  [formal_parameter_NAME =>] MECHANISM_NAME
2010
 
2011
MECHANISM_NAME ::=
2012
  Value
2013
| Reference
2014
| Descriptor [([Class =>] CLASS_NAME)]
2015
| Short_Descriptor [([Class =>] CLASS_NAME)]
2016
 
2017
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2018
@end smallexample
2019
 
2020
@noindent
2021
This pragma is identical to @code{Export_Function} except that it
2022
applies to a procedure rather than a function and the parameters
2023
@code{Result_Type} and @code{Result_Mechanism} are not permitted.
2024
GNAT does not require a separate pragma @code{Export}, but if none is
2025
present, @code{Convention Ada} is assumed, which is usually
2026
not what is wanted, so it is usually appropriate to use this
2027
pragma in conjunction with a @code{Export} or @code{Convention}
2028
pragma that specifies the desired foreign convention.
2029
 
2030
@cindex OpenVMS
2031
@cindex Passing by descriptor
2032
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2033
The default behavior for Export_Procedure is to accept either 64bit or
2034
32bit descriptors unless short_descriptor is specified, then only 32bit
2035
descriptors are accepted.
2036
 
2037
@cindex Suppressing external name
2038
Special treatment is given if the EXTERNAL is an explicit null
2039
string or a static string expressions that evaluates to the null
2040
string. In this case, no external name is generated. This form
2041
still allows the specification of parameter mechanisms.
2042
 
2043
@node Pragma Export_Value
2044
@unnumberedsec Pragma Export_Value
2045
@findex Export_Value
2046
@noindent
2047
Syntax:
2048
 
2049
@smallexample @c ada
2050
pragma Export_Value (
2051
  [Value     =>] static_integer_EXPRESSION,
2052
  [Link_Name =>] static_string_EXPRESSION);
2053
@end smallexample
2054
 
2055
@noindent
2056
This pragma serves to export a static integer value for external use.
2057
The first argument specifies the value to be exported. The Link_Name
2058
argument specifies the symbolic name to be associated with the integer
2059
value. This pragma is useful for defining a named static value in Ada
2060
that can be referenced in assembly language units to be linked with
2061
the application. This pragma is currently supported only for the
2062
AAMP target and is ignored for other targets.
2063
 
2064
@node Pragma Export_Valued_Procedure
2065
@unnumberedsec Pragma Export_Valued_Procedure
2066
@findex Export_Valued_Procedure
2067
@noindent
2068
Syntax:
2069
 
2070
@smallexample @c ada
2071
pragma Export_Valued_Procedure (
2072
     [Internal        =>] LOCAL_NAME
2073
  [, [External        =>] EXTERNAL_SYMBOL]
2074
  [, [Parameter_Types =>] PARAMETER_TYPES]
2075
  [, [Mechanism       =>] MECHANISM]);
2076
 
2077
EXTERNAL_SYMBOL ::=
2078
  IDENTIFIER
2079
| static_string_EXPRESSION
2080
| ""
2081
 
2082
PARAMETER_TYPES ::=
2083
  null
2084
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2085
 
2086
TYPE_DESIGNATOR ::=
2087
  subtype_NAME
2088
| subtype_Name ' Access
2089
 
2090
MECHANISM ::=
2091
  MECHANISM_NAME
2092
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2093
 
2094
MECHANISM_ASSOCIATION ::=
2095
  [formal_parameter_NAME =>] MECHANISM_NAME
2096
 
2097
MECHANISM_NAME ::=
2098
  Value
2099
| Reference
2100
| Descriptor [([Class =>] CLASS_NAME)]
2101
| Short_Descriptor [([Class =>] CLASS_NAME)]
2102
 
2103
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2104
@end smallexample
2105
 
2106
@noindent
2107
This pragma is identical to @code{Export_Procedure} except that the
2108
first parameter of @var{LOCAL_NAME}, which must be present, must be of
2109
mode @code{OUT}, and externally the subprogram is treated as a function
2110
with this parameter as the result of the function.  GNAT provides for
2111
this capability to allow the use of @code{OUT} and @code{IN OUT}
2112
parameters in interfacing to external functions (which are not permitted
2113
in Ada functions).
2114
GNAT does not require a separate pragma @code{Export}, but if none is
2115
present, @code{Convention Ada} is assumed, which is almost certainly
2116
not what is wanted since the whole point of this pragma is to interface
2117
with foreign language functions, so it is usually appropriate to use this
2118
pragma in conjunction with a @code{Export} or @code{Convention}
2119
pragma that specifies the desired foreign convention.
2120
 
2121
@cindex OpenVMS
2122
@cindex Passing by descriptor
2123
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2124
The default behavior for Export_Valued_Procedure is to accept either 64bit or
2125
32bit descriptors unless short_descriptor is specified, then only 32bit
2126
descriptors are accepted.
2127
 
2128
@cindex Suppressing external name
2129
Special treatment is given if the EXTERNAL is an explicit null
2130
string or a static string expressions that evaluates to the null
2131
string. In this case, no external name is generated. This form
2132
still allows the specification of parameter mechanisms.
2133
 
2134
@node Pragma Extend_System
2135
@unnumberedsec Pragma Extend_System
2136
@cindex @code{system}, extending
2137
@cindex Dec Ada 83
2138
@findex Extend_System
2139
@noindent
2140
Syntax:
2141
 
2142
@smallexample @c ada
2143
pragma Extend_System ([Name =>] IDENTIFIER);
2144
@end smallexample
2145
 
2146
@noindent
2147
This pragma is used to provide backwards compatibility with other
2148
implementations that extend the facilities of package @code{System}.  In
2149
GNAT, @code{System} contains only the definitions that are present in
2150
the Ada RM@.  However, other implementations, notably the DEC Ada 83
2151
implementation, provide many extensions to package @code{System}.
2152
 
2153
For each such implementation accommodated by this pragma, GNAT provides a
2154
package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2155
implementation, which provides the required additional definitions.  You
2156
can use this package in two ways.  You can @code{with} it in the normal
2157
way and access entities either by selection or using a @code{use}
2158
clause.  In this case no special processing is required.
2159
 
2160
However, if existing code contains references such as
2161
@code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2162
definitions provided in package @code{System}, you may use this pragma
2163
to extend visibility in @code{System} in a non-standard way that
2164
provides greater compatibility with the existing code.  Pragma
2165
@code{Extend_System} is a configuration pragma whose single argument is
2166
the name of the package containing the extended definition
2167
(e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2168
control of this pragma will be processed using special visibility
2169
processing that looks in package @code{System.Aux_@var{xxx}} where
2170
@code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2171
package @code{System}, but not found in package @code{System}.
2172
 
2173
You can use this pragma either to access a predefined @code{System}
2174
extension supplied with the compiler, for example @code{Aux_DEC} or
2175
you can construct your own extension unit following the above
2176
definition.  Note that such a package is a child of @code{System}
2177
and thus is considered part of the implementation.  To compile
2178
it you will have to use the appropriate switch for compiling
2179
system units.  @xref{Top, @value{EDITION} User's Guide, About This
2180
Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2181
 
2182
@node Pragma External
2183
@unnumberedsec Pragma External
2184
@findex External
2185
@noindent
2186
Syntax:
2187
 
2188
@smallexample @c ada
2189
pragma External (
2190
  [   Convention    =>] convention_IDENTIFIER,
2191
  [   Entity        =>] LOCAL_NAME
2192
  [, [External_Name =>] static_string_EXPRESSION ]
2193
  [, [Link_Name     =>] static_string_EXPRESSION ]);
2194
@end smallexample
2195
 
2196
@noindent
2197
This pragma is identical in syntax and semantics to pragma
2198
@code{Export} as defined in the Ada Reference Manual.  It is
2199
provided for compatibility with some Ada 83 compilers that
2200
used this pragma for exactly the same purposes as pragma
2201
@code{Export} before the latter was standardized.
2202
 
2203
@node Pragma External_Name_Casing
2204
@unnumberedsec Pragma External_Name_Casing
2205
@cindex Dec Ada 83 casing compatibility
2206
@cindex External Names, casing
2207
@cindex Casing of External names
2208
@findex External_Name_Casing
2209
@noindent
2210
Syntax:
2211
 
2212
@smallexample @c ada
2213
pragma External_Name_Casing (
2214
  Uppercase | Lowercase
2215
  [, Uppercase | Lowercase | As_Is]);
2216
@end smallexample
2217
 
2218
@noindent
2219
This pragma provides control over the casing of external names associated
2220
with Import and Export pragmas.  There are two cases to consider:
2221
 
2222
@table @asis
2223
@item Implicit external names
2224
Implicit external names are derived from identifiers.  The most common case
2225
arises when a standard Ada Import or Export pragma is used with only two
2226
arguments, as in:
2227
 
2228
@smallexample @c ada
2229
   pragma Import (C, C_Routine);
2230
@end smallexample
2231
 
2232
@noindent
2233
Since Ada is a case-insensitive language, the spelling of the identifier in
2234
the Ada source program does not provide any information on the desired
2235
casing of the external name, and so a convention is needed.  In GNAT the
2236
default treatment is that such names are converted to all lower case
2237
letters.  This corresponds to the normal C style in many environments.
2238
The first argument of pragma @code{External_Name_Casing} can be used to
2239
control this treatment.  If @code{Uppercase} is specified, then the name
2240
will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2241
then the normal default of all lower case letters will be used.
2242
 
2243
This same implicit treatment is also used in the case of extended DEC Ada 83
2244
compatible Import and Export pragmas where an external name is explicitly
2245
specified using an identifier rather than a string.
2246
 
2247
@item Explicit external names
2248
Explicit external names are given as string literals.  The most common case
2249
arises when a standard Ada Import or Export pragma is used with three
2250
arguments, as in:
2251
 
2252
@smallexample @c ada
2253
pragma Import (C, C_Routine, "C_routine");
2254
@end smallexample
2255
 
2256
@noindent
2257
In this case, the string literal normally provides the exact casing required
2258
for the external name.  The second argument of pragma
2259
@code{External_Name_Casing} may be used to modify this behavior.
2260
If @code{Uppercase} is specified, then the name
2261
will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2262
then the name will be forced to all lowercase letters.  A specification of
2263
@code{As_Is} provides the normal default behavior in which the casing is
2264
taken from the string provided.
2265
@end table
2266
 
2267
@noindent
2268
This pragma may appear anywhere that a pragma is valid.  In particular, it
2269
can be used as a configuration pragma in the @file{gnat.adc} file, in which
2270
case it applies to all subsequent compilations, or it can be used as a program
2271
unit pragma, in which case it only applies to the current unit, or it can
2272
be used more locally to control individual Import/Export pragmas.
2273
 
2274
It is primarily intended for use with OpenVMS systems, where many
2275
compilers convert all symbols to upper case by default.  For interfacing to
2276
such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2277
the pragma:
2278
 
2279
@smallexample @c ada
2280
pragma External_Name_Casing (Uppercase, Uppercase);
2281
@end smallexample
2282
 
2283
@noindent
2284
to enforce the upper casing of all external symbols.
2285
 
2286
@node Pragma Fast_Math
2287
@unnumberedsec Pragma Fast_Math
2288
@findex Fast_Math
2289
@noindent
2290
Syntax:
2291
 
2292
@smallexample @c ada
2293
pragma Fast_Math;
2294
@end smallexample
2295
 
2296
@noindent
2297
This is a configuration pragma which activates a mode in which speed is
2298
considered more important for floating-point operations than absolutely
2299
accurate adherence to the requirements of the standard. Currently the
2300
following operations are affected:
2301
 
2302
@table @asis
2303
@item Complex Multiplication
2304
The normal simple formula for complex multiplication can result in intermediate
2305
overflows for numbers near the end of the range. The Ada standard requires that
2306
this situation be detected and corrected by scaling, but in Fast_Math mode such
2307
cases will simply result in overflow. Note that to take advantage of this you
2308
must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2309
under control of the pragma, rather than use the preinstantiated versions.
2310
@end table
2311
 
2312
@node Pragma Favor_Top_Level
2313
@unnumberedsec Pragma Favor_Top_Level
2314
@findex Favor_Top_Level
2315
@noindent
2316
Syntax:
2317
 
2318
@smallexample @c ada
2319
pragma Favor_Top_Level (type_NAME);
2320
@end smallexample
2321
 
2322
@noindent
2323
The named type must be an access-to-subprogram type. This pragma is an
2324
efficiency hint to the compiler, regarding the use of 'Access or
2325
'Unrestricted_Access on nested (non-library-level) subprograms. The
2326
pragma means that nested subprograms are not used with this type, or
2327
are rare, so that the generated code should be efficient in the
2328
top-level case. When this pragma is used, dynamically generated
2329
trampolines may be used on some targets for nested subprograms.
2330
See also the No_Implicit_Dynamic_Code restriction.
2331
 
2332
@node Pragma Finalize_Storage_Only
2333
@unnumberedsec Pragma Finalize_Storage_Only
2334
@findex Finalize_Storage_Only
2335
@noindent
2336
Syntax:
2337
 
2338
@smallexample @c ada
2339
pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2340
@end smallexample
2341
 
2342
@noindent
2343
This pragma allows the compiler not to emit a Finalize call for objects
2344
defined at the library level.  This is mostly useful for types where
2345
finalization is only used to deal with storage reclamation since in most
2346
environments it is not necessary to reclaim memory just before terminating
2347
execution, hence the name.
2348
 
2349
@node Pragma Float_Representation
2350
@unnumberedsec Pragma Float_Representation
2351
@cindex OpenVMS
2352
@findex Float_Representation
2353
@noindent
2354
Syntax:
2355
 
2356
@smallexample @c ada
2357
pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2358
 
2359
FLOAT_REP ::= VAX_Float | IEEE_Float
2360
@end smallexample
2361
 
2362
@noindent
2363
In the one argument form, this pragma is a configuration pragma which
2364
allows control over the internal representation chosen for the predefined
2365
floating point types declared in the packages @code{Standard} and
2366
@code{System}. On all systems other than OpenVMS, the argument must
2367
be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2368
argument may be @code{VAX_Float} to specify the use of the VAX float
2369
format for the floating-point types in Standard. This requires that
2370
the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2371
Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2372
OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2373
 
2374
The two argument form specifies the representation to be used for
2375
the specified floating-point type. On all systems other than OpenVMS,
2376
the argument must
2377
be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2378
argument may be @code{VAX_Float} to specify the use of the VAX float
2379
format, as follows:
2380
 
2381
@itemize @bullet
2382
@item
2383
For digits values up to 6, F float format will be used.
2384
@item
2385
For digits values from 7 to 9, G float format will be used.
2386
@item
2387
For digits values from 10 to 15, F float format will be used.
2388
@item
2389
Digits values above 15 are not allowed.
2390
@end itemize
2391
 
2392
@node Pragma Ident
2393
@unnumberedsec Pragma Ident
2394
@findex Ident
2395
@noindent
2396
Syntax:
2397
 
2398
@smallexample @c ada
2399
pragma Ident (static_string_EXPRESSION);
2400
@end smallexample
2401
 
2402
@noindent
2403
This pragma provides a string identification in the generated object file,
2404
if the system supports the concept of this kind of identification string.
2405
This pragma is allowed only in the outermost declarative part or
2406
declarative items of a compilation unit. If more than one @code{Ident}
2407
pragma is given, only the last one processed is effective.
2408
@cindex OpenVMS
2409
On OpenVMS systems, the effect of the pragma is identical to the effect of
2410
the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2411
maximum allowed length is 31 characters, so if it is important to
2412
maintain compatibility with this compiler, you should obey this length
2413
limit.
2414
 
2415
@node Pragma Implemented_By_Entry
2416
@unnumberedsec Pragma Implemented_By_Entry
2417
@findex Implemented_By_Entry
2418
@noindent
2419
Syntax:
2420
 
2421
@smallexample @c ada
2422
pragma Implemented_By_Entry (LOCAL_NAME);
2423
@end smallexample
2424
 
2425
@noindent
2426
This is a representation pragma which applies to protected, synchronized and
2427
task interface primitives. If the pragma is applied to primitive operation Op
2428
of interface Iface, it is illegal to override Op in a type that implements
2429
Iface, with anything other than an entry.
2430
 
2431
@smallexample @c ada
2432
type Iface is protected interface;
2433
procedure Do_Something (Object : in out Iface) is abstract;
2434
pragma Implemented_By_Entry (Do_Something);
2435
 
2436
protected type P is new Iface with
2437
   procedure Do_Something;  --  Illegal
2438
end P;
2439
 
2440
task type T is new Iface with
2441
   entry Do_Something;      --  Legal
2442
end T;
2443
@end smallexample
2444
 
2445
@noindent
2446
NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2447
is intended to be used in conjunction with dispatching requeue statements as
2448
described in AI05-0030. Should the ARG decide on an official name and syntax,
2449
this pragma will become language-defined rather than GNAT-specific.
2450
 
2451
@node Pragma Implicit_Packing
2452
@unnumberedsec Pragma Implicit_Packing
2453
@findex Implicit_Packing
2454
@noindent
2455
Syntax:
2456
 
2457
@smallexample @c ada
2458
pragma Implicit_Packing;
2459
@end smallexample
2460
 
2461
@noindent
2462
This is a configuration pragma that requests implicit packing for packed
2463
arrays for which a size clause is given but no explicit pragma Pack or
2464
specification of Component_Size is present. It also applies to records
2465
where no record representation clause is present. Consider this example:
2466
 
2467
@smallexample @c ada
2468
type R is array (0 .. 7) of Boolean;
2469
for R'Size use 8;
2470
@end smallexample
2471
 
2472
@noindent
2473
In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2474
does not change the layout of a composite object. So the Size clause in the
2475
above example is normally rejected, since the default layout of the array uses
2476
8-bit components, and thus the array requires a minimum of 64 bits.
2477
 
2478
If this declaration is compiled in a region of code covered by an occurrence
2479
of the configuration pragma Implicit_Packing, then the Size clause in this
2480
and similar examples will cause implicit packing and thus be accepted. For
2481
this implicit packing to occur, the type in question must be an array of small
2482
components whose size is known at compile time, and the Size clause must
2483
specify the exact size that corresponds to the length of the array multiplied
2484
by the size in bits of the component type.
2485
@cindex Array packing
2486
 
2487
Similarly, the following example shows the use in the record case
2488
 
2489
@smallexample @c ada
2490
type r is record
2491
   a, b, c, d, e, f, g, h : boolean;
2492
   chr                    : character;
2493
end record;
2494
for r'size use 16;
2495
@end smallexample
2496
 
2497
@noindent
2498
Without a pragma Pack, each Boolean field requires 8 bits, so the
2499
minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2500
sufficient. The use of pragma Implciit_Packing allows this record
2501
declaration to compile without an explicit pragma Pack.
2502
@node Pragma Import_Exception
2503
@unnumberedsec Pragma Import_Exception
2504
@cindex OpenVMS
2505
@findex Import_Exception
2506
@noindent
2507
Syntax:
2508
 
2509
@smallexample @c ada
2510
pragma Import_Exception (
2511
     [Internal =>] LOCAL_NAME
2512
  [, [External =>] EXTERNAL_SYMBOL]
2513
  [, [Form     =>] Ada | VMS]
2514
  [, [Code     =>] static_integer_EXPRESSION]);
2515
 
2516
EXTERNAL_SYMBOL ::=
2517
  IDENTIFIER
2518
| static_string_EXPRESSION
2519
@end smallexample
2520
 
2521
@noindent
2522
This pragma is implemented only in the OpenVMS implementation of GNAT@.
2523
It allows OpenVMS conditions (for example, from OpenVMS system services or
2524
other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2525
The pragma specifies that the exception associated with an exception
2526
declaration in an Ada program be defined externally (in non-Ada code).
2527
For further details on this pragma, see the
2528
DEC Ada Language Reference Manual, section 13.9a.3.1.
2529
 
2530
@node Pragma Import_Function
2531
@unnumberedsec Pragma Import_Function
2532
@findex Import_Function
2533
@noindent
2534
Syntax:
2535
 
2536
@smallexample @c ada
2537
pragma Import_Function (
2538
     [Internal                 =>] LOCAL_NAME,
2539
  [, [External                 =>] EXTERNAL_SYMBOL]
2540
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2541
  [, [Result_Type              =>] SUBTYPE_MARK]
2542
  [, [Mechanism                =>] MECHANISM]
2543
  [, [Result_Mechanism         =>] MECHANISM_NAME]
2544
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2545
 
2546
EXTERNAL_SYMBOL ::=
2547
  IDENTIFIER
2548
| static_string_EXPRESSION
2549
 
2550
PARAMETER_TYPES ::=
2551
  null
2552
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2553
 
2554
TYPE_DESIGNATOR ::=
2555
  subtype_NAME
2556
| subtype_Name ' Access
2557
 
2558
MECHANISM ::=
2559
  MECHANISM_NAME
2560
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2561
 
2562
MECHANISM_ASSOCIATION ::=
2563
  [formal_parameter_NAME =>] MECHANISM_NAME
2564
 
2565
MECHANISM_NAME ::=
2566
  Value
2567
| Reference
2568
| Descriptor [([Class =>] CLASS_NAME)]
2569
| Short_Descriptor [([Class =>] CLASS_NAME)]
2570
 
2571
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2572
@end smallexample
2573
 
2574
@noindent
2575
This pragma is used in conjunction with a pragma @code{Import} to
2576
specify additional information for an imported function.  The pragma
2577
@code{Import} (or equivalent pragma @code{Interface}) must precede the
2578
@code{Import_Function} pragma and both must appear in the same
2579
declarative part as the function specification.
2580
 
2581
The @var{Internal} argument must uniquely designate
2582
the function to which the
2583
pragma applies.  If more than one function name exists of this name in
2584
the declarative part you must use the @code{Parameter_Types} and
2585
@var{Result_Type} parameters to achieve the required unique
2586
designation.  Subtype marks in these parameters must exactly match the
2587
subtypes in the corresponding function specification, using positional
2588
notation to match parameters with subtype marks.
2589
The form with an @code{'Access} attribute can be used to match an
2590
anonymous access parameter.
2591
 
2592
You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2593
parameters to specify passing mechanisms for the
2594
parameters and result.  If you specify a single mechanism name, it
2595
applies to all parameters.  Otherwise you may specify a mechanism on a
2596
parameter by parameter basis using either positional or named
2597
notation.  If the mechanism is not specified, the default mechanism
2598
is used.
2599
 
2600
@cindex OpenVMS
2601
@cindex Passing by descriptor
2602
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2603
The default behavior for Import_Function is to pass a 64bit descriptor
2604
unless short_descriptor is specified, then a 32bit descriptor is passed.
2605
 
2606
@code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2607
It specifies that the designated parameter and all following parameters
2608
are optional, meaning that they are not passed at the generated code
2609
level (this is distinct from the notion of optional parameters in Ada
2610
where the parameters are passed anyway with the designated optional
2611
parameters).  All optional parameters must be of mode @code{IN} and have
2612
default parameter values that are either known at compile time
2613
expressions, or uses of the @code{'Null_Parameter} attribute.
2614
 
2615
@node Pragma Import_Object
2616
@unnumberedsec Pragma Import_Object
2617
@findex Import_Object
2618
@noindent
2619
Syntax:
2620
 
2621
@smallexample @c ada
2622
pragma Import_Object
2623
     [Internal =>] LOCAL_NAME
2624
  [, [External =>] EXTERNAL_SYMBOL]
2625
  [, [Size     =>] EXTERNAL_SYMBOL]);
2626
 
2627
EXTERNAL_SYMBOL ::=
2628
  IDENTIFIER
2629
| static_string_EXPRESSION
2630
@end smallexample
2631
 
2632
@noindent
2633
This pragma designates an object as imported, and apart from the
2634
extended rules for external symbols, is identical in effect to the use of
2635
the normal @code{Import} pragma applied to an object.  Unlike the
2636
subprogram case, you need not use a separate @code{Import} pragma,
2637
although you may do so (and probably should do so from a portability
2638
point of view).  @var{size} is syntax checked, but otherwise ignored by
2639
GNAT@.
2640
 
2641
@node Pragma Import_Procedure
2642
@unnumberedsec Pragma Import_Procedure
2643
@findex Import_Procedure
2644
@noindent
2645
Syntax:
2646
 
2647
@smallexample @c ada
2648
pragma Import_Procedure (
2649
     [Internal                 =>] LOCAL_NAME
2650
  [, [External                 =>] EXTERNAL_SYMBOL]
2651
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2652
  [, [Mechanism                =>] MECHANISM]
2653
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2654
 
2655
EXTERNAL_SYMBOL ::=
2656
  IDENTIFIER
2657
| static_string_EXPRESSION
2658
 
2659
PARAMETER_TYPES ::=
2660
  null
2661
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2662
 
2663
TYPE_DESIGNATOR ::=
2664
  subtype_NAME
2665
| subtype_Name ' Access
2666
 
2667
MECHANISM ::=
2668
  MECHANISM_NAME
2669
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2670
 
2671
MECHANISM_ASSOCIATION ::=
2672
  [formal_parameter_NAME =>] MECHANISM_NAME
2673
 
2674
MECHANISM_NAME ::=
2675
  Value
2676
| Reference
2677
| Descriptor [([Class =>] CLASS_NAME)]
2678
| Short_Descriptor [([Class =>] CLASS_NAME)]
2679
 
2680
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2681
@end smallexample
2682
 
2683
@noindent
2684
This pragma is identical to @code{Import_Function} except that it
2685
applies to a procedure rather than a function and the parameters
2686
@code{Result_Type} and @code{Result_Mechanism} are not permitted.
2687
 
2688
@node Pragma Import_Valued_Procedure
2689
@unnumberedsec Pragma Import_Valued_Procedure
2690
@findex Import_Valued_Procedure
2691
@noindent
2692
Syntax:
2693
 
2694
@smallexample @c ada
2695
pragma Import_Valued_Procedure (
2696
     [Internal                 =>] LOCAL_NAME
2697
  [, [External                 =>] EXTERNAL_SYMBOL]
2698
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2699
  [, [Mechanism                =>] MECHANISM]
2700
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2701
 
2702
EXTERNAL_SYMBOL ::=
2703
  IDENTIFIER
2704
| static_string_EXPRESSION
2705
 
2706
PARAMETER_TYPES ::=
2707
  null
2708
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2709
 
2710
TYPE_DESIGNATOR ::=
2711
  subtype_NAME
2712
| subtype_Name ' Access
2713
 
2714
MECHANISM ::=
2715
  MECHANISM_NAME
2716
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2717
 
2718
MECHANISM_ASSOCIATION ::=
2719
  [formal_parameter_NAME =>] MECHANISM_NAME
2720
 
2721
MECHANISM_NAME ::=
2722
  Value
2723
| Reference
2724
| Descriptor [([Class =>] CLASS_NAME)]
2725
| Short_Descriptor [([Class =>] CLASS_NAME)]
2726
 
2727
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2728
@end smallexample
2729
 
2730
@noindent
2731
This pragma is identical to @code{Import_Procedure} except that the
2732
first parameter of @var{LOCAL_NAME}, which must be present, must be of
2733
mode @code{OUT}, and externally the subprogram is treated as a function
2734
with this parameter as the result of the function.  The purpose of this
2735
capability is to allow the use of @code{OUT} and @code{IN OUT}
2736
parameters in interfacing to external functions (which are not permitted
2737
in Ada functions).  You may optionally use the @code{Mechanism}
2738
parameters to specify passing mechanisms for the parameters.
2739
If you specify a single mechanism name, it applies to all parameters.
2740
Otherwise you may specify a mechanism on a parameter by parameter
2741
basis using either positional or named notation.  If the mechanism is not
2742
specified, the default mechanism is used.
2743
 
2744
Note that it is important to use this pragma in conjunction with a separate
2745
pragma Import that specifies the desired convention, since otherwise the
2746
default convention is Ada, which is almost certainly not what is required.
2747
 
2748
@node Pragma Initialize_Scalars
2749
@unnumberedsec Pragma Initialize_Scalars
2750
@findex Initialize_Scalars
2751
@cindex debugging with Initialize_Scalars
2752
@noindent
2753
Syntax:
2754
 
2755
@smallexample @c ada
2756
pragma Initialize_Scalars;
2757
@end smallexample
2758
 
2759
@noindent
2760
This pragma is similar to @code{Normalize_Scalars} conceptually but has
2761
two important differences.  First, there is no requirement for the pragma
2762
to be used uniformly in all units of a partition, in particular, it is fine
2763
to use this just for some or all of the application units of a partition,
2764
without needing to recompile the run-time library.
2765
 
2766
In the case where some units are compiled with the pragma, and some without,
2767
then a declaration of a variable where the type is defined in package
2768
Standard or is locally declared will always be subject to initialization,
2769
as will any declaration of a scalar variable.  For composite variables,
2770
whether the variable is initialized may also depend on whether the package
2771
in which the type of the variable is declared is compiled with the pragma.
2772
 
2773
The other important difference is that you can control the value used
2774
for initializing scalar objects.  At bind time, you can select several
2775
options for initialization. You can
2776
initialize with invalid values (similar to Normalize_Scalars, though for
2777
Initialize_Scalars it is not always possible to determine the invalid
2778
values in complex cases like signed component fields with non-standard
2779
sizes). You can also initialize with high or
2780
low values, or with a specified bit pattern.  See the users guide for binder
2781
options for specifying these cases.
2782
 
2783
This means that you can compile a program, and then without having to
2784
recompile the program, you can run it with different values being used
2785
for initializing otherwise uninitialized values, to test if your program
2786
behavior depends on the choice.  Of course the behavior should not change,
2787
and if it does, then most likely you have an erroneous reference to an
2788
uninitialized value.
2789
 
2790
It is even possible to change the value at execution time eliminating even
2791
the need to rebind with a different switch using an environment variable.
2792
See the GNAT users guide for details.
2793
 
2794
Note that pragma @code{Initialize_Scalars} is particularly useful in
2795
conjunction with the enhanced validity checking that is now provided
2796
in GNAT, which checks for invalid values under more conditions.
2797
Using this feature (see description of the @option{-gnatV} flag in the
2798
users guide) in conjunction with pragma @code{Initialize_Scalars}
2799
provides a powerful new tool to assist in the detection of problems
2800
caused by uninitialized variables.
2801
 
2802
Note: the use of @code{Initialize_Scalars} has a fairly extensive
2803
effect on the generated code. This may cause your code to be
2804
substantially larger. It may also cause an increase in the amount
2805
of stack required, so it is probably a good idea to turn on stack
2806
checking (see description of stack checking in the GNAT users guide)
2807
when using this pragma.
2808
 
2809
@node Pragma Inline_Always
2810
@unnumberedsec Pragma Inline_Always
2811
@findex Inline_Always
2812
@noindent
2813
Syntax:
2814
 
2815
@smallexample @c ada
2816
pragma Inline_Always (NAME [, NAME]);
2817
@end smallexample
2818
 
2819
@noindent
2820
Similar to pragma @code{Inline} except that inlining is not subject to
2821
the use of option @option{-gnatn} and the inlining happens regardless of
2822
whether this option is used.
2823
 
2824
@node Pragma Inline_Generic
2825
@unnumberedsec Pragma Inline_Generic
2826
@findex Inline_Generic
2827
@noindent
2828
Syntax:
2829
 
2830
@smallexample @c ada
2831
pragma Inline_Generic (generic_package_NAME);
2832
@end smallexample
2833
 
2834
@noindent
2835
This is implemented for compatibility with DEC Ada 83 and is recognized,
2836
but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2837
by default when using GNAT@.
2838
 
2839
@node Pragma Interface
2840
@unnumberedsec Pragma Interface
2841
@findex Interface
2842
@noindent
2843
Syntax:
2844
 
2845
@smallexample @c ada
2846
pragma Interface (
2847
     [Convention    =>] convention_identifier,
2848
     [Entity        =>] local_NAME
2849
  [, [External_Name =>] static_string_expression]
2850
  [, [Link_Name     =>] static_string_expression]);
2851
@end smallexample
2852
 
2853
@noindent
2854
This pragma is identical in syntax and semantics to
2855
the standard Ada pragma @code{Import}.  It is provided for compatibility
2856
with Ada 83.  The definition is upwards compatible both with pragma
2857
@code{Interface} as defined in the Ada 83 Reference Manual, and also
2858
with some extended implementations of this pragma in certain Ada 83
2859
implementations.
2860
 
2861
@node Pragma Interface_Name
2862
@unnumberedsec Pragma Interface_Name
2863
@findex Interface_Name
2864
@noindent
2865
Syntax:
2866
 
2867
@smallexample @c ada
2868
pragma Interface_Name (
2869
     [Entity        =>] LOCAL_NAME
2870
  [, [External_Name =>] static_string_EXPRESSION]
2871
  [, [Link_Name     =>] static_string_EXPRESSION]);
2872
@end smallexample
2873
 
2874
@noindent
2875
This pragma provides an alternative way of specifying the interface name
2876
for an interfaced subprogram, and is provided for compatibility with Ada
2877
83 compilers that use the pragma for this purpose.  You must provide at
2878
least one of @var{External_Name} or @var{Link_Name}.
2879
 
2880
@node Pragma Interrupt_Handler
2881
@unnumberedsec Pragma Interrupt_Handler
2882
@findex Interrupt_Handler
2883
@noindent
2884
Syntax:
2885
 
2886
@smallexample @c ada
2887
pragma Interrupt_Handler (procedure_LOCAL_NAME);
2888
@end smallexample
2889
 
2890
@noindent
2891
This program unit pragma is supported for parameterless protected procedures
2892
as described in Annex C of the Ada Reference Manual. On the AAMP target
2893
the pragma can also be specified for nonprotected parameterless procedures
2894
that are declared at the library level (which includes procedures
2895
declared at the top level of a library package). In the case of AAMP,
2896
when this pragma is applied to a nonprotected procedure, the instruction
2897
@code{IERET} is generated for returns from the procedure, enabling
2898
maskable interrupts, in place of the normal return instruction.
2899
 
2900
@node Pragma Interrupt_State
2901
@unnumberedsec Pragma Interrupt_State
2902
@findex Interrupt_State
2903
@noindent
2904
Syntax:
2905
 
2906
@smallexample @c ada
2907
pragma Interrupt_State
2908
 ([Name  =>] value,
2909
  [State =>] SYSTEM | RUNTIME | USER);
2910
@end smallexample
2911
 
2912
@noindent
2913
Normally certain interrupts are reserved to the implementation.  Any attempt
2914
to attach an interrupt causes Program_Error to be raised, as described in
2915
RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2916
many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2917
reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2918
interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2919
@code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2920
Ada exceptions, or used to implement run-time functions such as the
2921
@code{abort} statement and stack overflow checking.
2922
 
2923
Pragma @code{Interrupt_State} provides a general mechanism for overriding
2924
such uses of interrupts.  It subsumes the functionality of pragma
2925
@code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2926
available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2927
it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2928
and may be used to mark interrupts required by the board support package
2929
as reserved.
2930
 
2931
Interrupts can be in one of three states:
2932
@itemize @bullet
2933
@item System
2934
 
2935
The interrupt is reserved (no Ada handler can be installed), and the
2936
Ada run-time may not install a handler. As a result you are guaranteed
2937
standard system default action if this interrupt is raised.
2938
 
2939
@item Runtime
2940
 
2941
The interrupt is reserved (no Ada handler can be installed). The run time
2942
is allowed to install a handler for internal control purposes, but is
2943
not required to do so.
2944
 
2945
@item User
2946
 
2947
The interrupt is unreserved.  The user may install a handler to provide
2948
some other action.
2949
@end itemize
2950
 
2951
@noindent
2952
These states are the allowed values of the @code{State} parameter of the
2953
pragma.  The @code{Name} parameter is a value of the type
2954
@code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2955
@code{Ada.Interrupts.Names}.
2956
 
2957
This is a configuration pragma, and the binder will check that there
2958
are no inconsistencies between different units in a partition in how a
2959
given interrupt is specified. It may appear anywhere a pragma is legal.
2960
 
2961
The effect is to move the interrupt to the specified state.
2962
 
2963
By declaring interrupts to be SYSTEM, you guarantee the standard system
2964
action, such as a core dump.
2965
 
2966
By declaring interrupts to be USER, you guarantee that you can install
2967
a handler.
2968
 
2969
Note that certain signals on many operating systems cannot be caught and
2970
handled by applications.  In such cases, the pragma is ignored.  See the
2971
operating system documentation, or the value of the array @code{Reserved}
2972
declared in the spec of package @code{System.OS_Interface}.
2973
 
2974
Overriding the default state of signals used by the Ada runtime may interfere
2975
with an application's runtime behavior in the cases of the synchronous signals,
2976
and in the case of the signal used to implement the @code{abort} statement.
2977
 
2978
@node Pragma Keep_Names
2979
@unnumberedsec Pragma Keep_Names
2980
@findex Keep_Names
2981
@noindent
2982
Syntax:
2983
 
2984
@smallexample @c ada
2985
pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2986
@end smallexample
2987
 
2988
@noindent
2989
The @var{LOCAL_NAME} argument
2990
must refer to an enumeration first subtype
2991
in the current declarative part. The effect is to retain the enumeration
2992
literal names for use by @code{Image} and @code{Value} even if a global
2993
@code{Discard_Names} pragma applies. This is useful when you want to
2994
generally suppress enumeration literal names and for example you therefore
2995
use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2996
want to retain the names for specific enumeration types.
2997
 
2998
@node Pragma License
2999
@unnumberedsec Pragma License
3000
@findex License
3001
@cindex License checking
3002
@noindent
3003
Syntax:
3004
 
3005
@smallexample @c ada
3006
pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3007
@end smallexample
3008
 
3009
@noindent
3010
This pragma is provided to allow automated checking for appropriate license
3011
conditions with respect to the standard and modified GPL@.  A pragma
3012
@code{License}, which is a configuration pragma that typically appears at
3013
the start of a source file or in a separate @file{gnat.adc} file, specifies
3014
the licensing conditions of a unit as follows:
3015
 
3016
@itemize @bullet
3017
@item Unrestricted
3018
This is used for a unit that can be freely used with no license restrictions.
3019
Examples of such units are public domain units, and units from the Ada
3020
Reference Manual.
3021
 
3022
@item GPL
3023
This is used for a unit that is licensed under the unmodified GPL, and which
3024
therefore cannot be @code{with}'ed by a restricted unit.
3025
 
3026
@item Modified_GPL
3027
This is used for a unit licensed under the GNAT modified GPL that includes
3028
a special exception paragraph that specifically permits the inclusion of
3029
the unit in programs without requiring the entire program to be released
3030
under the GPL@.
3031
 
3032
@item Restricted
3033
This is used for a unit that is restricted in that it is not permitted to
3034
depend on units that are licensed under the GPL@.  Typical examples are
3035
proprietary code that is to be released under more restrictive license
3036
conditions.  Note that restricted units are permitted to @code{with} units
3037
which are licensed under the modified GPL (this is the whole point of the
3038
modified GPL).
3039
 
3040
@end itemize
3041
 
3042
@noindent
3043
Normally a unit with no @code{License} pragma is considered to have an
3044
unknown license, and no checking is done.  However, standard GNAT headers
3045
are recognized, and license information is derived from them as follows.
3046
 
3047
@itemize @bullet
3048
 
3049
A GNAT license header starts with a line containing 78 hyphens.  The following
3050
comment text is searched for the appearance of any of the following strings.
3051
 
3052
If the string ``GNU General Public License'' is found, then the unit is assumed
3053
to have GPL license, unless the string ``As a special exception'' follows, in
3054
which case the license is assumed to be modified GPL@.
3055
 
3056
If one of the strings
3057
``This specification is adapted from the Ada Semantic Interface'' or
3058
``This specification is derived from the Ada Reference Manual'' is found
3059
then the unit is assumed to be unrestricted.
3060
@end itemize
3061
 
3062
@noindent
3063
These default actions means that a program with a restricted license pragma
3064
will automatically get warnings if a GPL unit is inappropriately
3065
@code{with}'ed.  For example, the program:
3066
 
3067
@smallexample @c ada
3068
with Sem_Ch3;
3069
with GNAT.Sockets;
3070
procedure Secret_Stuff is
3071
  @dots{}
3072
end Secret_Stuff
3073
@end smallexample
3074
 
3075
@noindent
3076
if compiled with pragma @code{License} (@code{Restricted}) in a
3077
@file{gnat.adc} file will generate the warning:
3078
 
3079
@smallexample
3080
1.  with Sem_Ch3;
3081
        |
3082
   >>> license of withed unit "Sem_Ch3" is incompatible
3083
 
3084
2.  with GNAT.Sockets;
3085
3.  procedure Secret_Stuff is
3086
@end smallexample
3087
 
3088
@noindent
3089
Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3090
compiler and is licensed under the
3091
GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3092
run time, and is therefore licensed under the modified GPL@.
3093
 
3094
@node Pragma Link_With
3095
@unnumberedsec Pragma Link_With
3096
@findex Link_With
3097
@noindent
3098
Syntax:
3099
 
3100
@smallexample @c ada
3101
pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3102
@end smallexample
3103
 
3104
@noindent
3105
This pragma is provided for compatibility with certain Ada 83 compilers.
3106
It has exactly the same effect as pragma @code{Linker_Options} except
3107
that spaces occurring within one of the string expressions are treated
3108
as separators. For example, in the following case:
3109
 
3110
@smallexample @c ada
3111
pragma Link_With ("-labc -ldef");
3112
@end smallexample
3113
 
3114
@noindent
3115
results in passing the strings @code{-labc} and @code{-ldef} as two
3116
separate arguments to the linker. In addition pragma Link_With allows
3117
multiple arguments, with the same effect as successive pragmas.
3118
 
3119
@node Pragma Linker_Alias
3120
@unnumberedsec Pragma Linker_Alias
3121
@findex Linker_Alias
3122
@noindent
3123
Syntax:
3124
 
3125
@smallexample @c ada
3126
pragma Linker_Alias (
3127
  [Entity =>] LOCAL_NAME,
3128
  [Target =>] static_string_EXPRESSION);
3129
@end smallexample
3130
 
3131
@noindent
3132
@var{LOCAL_NAME} must refer to an object that is declared at the library
3133
level. This pragma establishes the given entity as a linker alias for the
3134
given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3135
and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3136
@var{static_string_EXPRESSION} in the object file, that is to say no space
3137
is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3138
to the same address as @var{static_string_EXPRESSION} by the linker.
3139
 
3140
The actual linker name for the target must be used (e.g.@: the fully
3141
encoded name with qualification in Ada, or the mangled name in C++),
3142
or it must be declared using the C convention with @code{pragma Import}
3143
or @code{pragma Export}.
3144
 
3145
Not all target machines support this pragma. On some of them it is accepted
3146
only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3147
 
3148
@smallexample @c ada
3149
--  Example of the use of pragma Linker_Alias
3150
 
3151
package p is
3152
  i : Integer := 1;
3153
  pragma Export (C, i);
3154
 
3155
  new_name_for_i : Integer;
3156
  pragma Linker_Alias (new_name_for_i, "i");
3157
end p;
3158
@end smallexample
3159
 
3160
@node Pragma Linker_Constructor
3161
@unnumberedsec Pragma Linker_Constructor
3162
@findex Linker_Constructor
3163
@noindent
3164
Syntax:
3165
 
3166
@smallexample @c ada
3167
pragma Linker_Constructor (procedure_LOCAL_NAME);
3168
@end smallexample
3169
 
3170
@noindent
3171
@var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3172
is declared at the library level. A procedure to which this pragma is
3173
applied will be treated as an initialization routine by the linker.
3174
It is equivalent to @code{__attribute__((constructor))} in GNU C and
3175
causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3176
of the executable is called (or immediately after the shared library is
3177
loaded if the procedure is linked in a shared library), in particular
3178
before the Ada run-time environment is set up.
3179
 
3180
Because of these specific contexts, the set of operations such a procedure
3181
can perform is very limited and the type of objects it can manipulate is
3182
essentially restricted to the elementary types. In particular, it must only
3183
contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3184
 
3185
This pragma is used by GNAT to implement auto-initialization of shared Stand
3186
Alone Libraries, which provides a related capability without the restrictions
3187
listed above. Where possible, the use of Stand Alone Libraries is preferable
3188
to the use of this pragma.
3189
 
3190
@node Pragma Linker_Destructor
3191
@unnumberedsec Pragma Linker_Destructor
3192
@findex Linker_Destructor
3193
@noindent
3194
Syntax:
3195
 
3196
@smallexample @c ada
3197
pragma Linker_Destructor (procedure_LOCAL_NAME);
3198
@end smallexample
3199
 
3200
@noindent
3201
@var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3202
is declared at the library level. A procedure to which this pragma is
3203
applied will be treated as a finalization routine by the linker.
3204
It is equivalent to @code{__attribute__((destructor))} in GNU C and
3205
causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3206
of the executable has exited (or immediately before the shared library
3207
is unloaded if the procedure is linked in a shared library), in particular
3208
after the Ada run-time environment is shut down.
3209
 
3210
See @code{pragma Linker_Constructor} for the set of restrictions that apply
3211
because of these specific contexts.
3212
 
3213
@node Pragma Linker_Section
3214
@unnumberedsec Pragma Linker_Section
3215
@findex Linker_Section
3216
@noindent
3217
Syntax:
3218
 
3219
@smallexample @c ada
3220
pragma Linker_Section (
3221
  [Entity  =>] LOCAL_NAME,
3222
  [Section =>] static_string_EXPRESSION);
3223
@end smallexample
3224
 
3225
@noindent
3226
@var{LOCAL_NAME} must refer to an object that is declared at the library
3227
level. This pragma specifies the name of the linker section for the given
3228
entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3229
causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3230
section of the executable (assuming the linker doesn't rename the section).
3231
 
3232
The compiler normally places library-level objects in standard sections
3233
depending on their type: procedures and functions generally go in the
3234
@code{.text} section, initialized variables in the @code{.data} section
3235
and uninitialized variables in the @code{.bss} section.
3236
 
3237
Other, special sections may exist on given target machines to map special
3238
hardware, for example I/O ports or flash memory. This pragma is a means to
3239
defer the final layout of the executable to the linker, thus fully working
3240
at the symbolic level with the compiler.
3241
 
3242
Some file formats do not support arbitrary sections so not all target
3243
machines support this pragma. The use of this pragma may cause a program
3244
execution to be erroneous if it is used to place an entity into an
3245
inappropriate section (e.g.@: a modified variable into the @code{.text}
3246
section). See also @code{pragma Persistent_BSS}.
3247
 
3248
@smallexample @c ada
3249
--  Example of the use of pragma Linker_Section
3250
 
3251
package IO_Card is
3252
  Port_A : Integer;
3253
  pragma Volatile (Port_A);
3254
  pragma Linker_Section (Port_A, ".bss.port_a");
3255
 
3256
  Port_B : Integer;
3257
  pragma Volatile (Port_B);
3258
  pragma Linker_Section (Port_B, ".bss.port_b");
3259
end IO_Card;
3260
@end smallexample
3261
 
3262
@node Pragma Long_Float
3263
@unnumberedsec Pragma Long_Float
3264
@cindex OpenVMS
3265
@findex Long_Float
3266
@noindent
3267
Syntax:
3268
 
3269
@smallexample @c ada
3270
pragma Long_Float (FLOAT_FORMAT);
3271
 
3272
FLOAT_FORMAT ::= D_Float | G_Float
3273
@end smallexample
3274
 
3275
@noindent
3276
This pragma is implemented only in the OpenVMS implementation of GNAT@.
3277
It allows control over the internal representation chosen for the predefined
3278
type @code{Long_Float} and for floating point type representations with
3279
@code{digits} specified in the range 7 through 15.
3280
For further details on this pragma, see the
3281
@cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3282
this pragma, the standard runtime libraries must be recompiled.
3283
@xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3284
@value{EDITION} User's Guide OpenVMS}, for a description of the
3285
@code{GNAT LIBRARY} command.
3286
 
3287
@node Pragma Machine_Attribute
3288
@unnumberedsec Pragma Machine_Attribute
3289
@findex Machine_Attribute
3290
@noindent
3291
Syntax:
3292
 
3293
@smallexample @c ada
3294
pragma Machine_Attribute (
3295
     [Entity         =>] LOCAL_NAME,
3296
     [Attribute_Name =>] static_string_EXPRESSION
3297
  [, [Info           =>] static_EXPRESSION] );
3298
@end smallexample
3299
 
3300
@noindent
3301
Machine-dependent attributes can be specified for types and/or
3302
declarations.  This pragma is semantically equivalent to
3303
@code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3304
specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3305
in GNU C, where @code{@var{attribute_name}} is recognized by the
3306
compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3307
specific macro.  A string literal for the optional parameter @var{info}
3308
is transformed into an identifier, which may make this pragma unusable
3309
for some attributes.  @xref{Target Attributes,, Defining target-specific
3310
uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3311
Internals}, further information.
3312
 
3313
@node Pragma Main
3314
@unnumberedsec Pragma Main
3315
@cindex OpenVMS
3316
@findex Main
3317
@noindent
3318
Syntax:
3319
 
3320
@smallexample @c ada
3321
pragma Main
3322
 (MAIN_OPTION [, MAIN_OPTION]);
3323
 
3324
MAIN_OPTION ::=
3325
  [Stack_Size              =>] static_integer_EXPRESSION
3326
| [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3327
| [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3328
@end smallexample
3329
 
3330
@noindent
3331
This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3332
no effect in GNAT, other than being syntax checked.
3333
 
3334
@node Pragma Main_Storage
3335
@unnumberedsec Pragma Main_Storage
3336
@cindex OpenVMS
3337
@findex Main_Storage
3338
@noindent
3339
Syntax:
3340
 
3341
@smallexample @c ada
3342
pragma Main_Storage
3343
  (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3344
 
3345
MAIN_STORAGE_OPTION ::=
3346
  [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3347
| [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3348
@end smallexample
3349
 
3350
@noindent
3351
This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3352
no effect in GNAT, other than being syntax checked.  Note that the pragma
3353
also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3354
 
3355
@node Pragma No_Body
3356
@unnumberedsec Pragma No_Body
3357
@findex No_Body
3358
@noindent
3359
Syntax:
3360
 
3361
@smallexample @c ada
3362
pragma No_Body;
3363
@end smallexample
3364
 
3365
@noindent
3366
There are a number of cases in which a package spec does not require a body,
3367
and in fact a body is not permitted. GNAT will not permit the spec to be
3368
compiled if there is a body around. The pragma No_Body allows you to provide
3369
a body file, even in a case where no body is allowed. The body file must
3370
contain only comments and a single No_Body pragma. This is recognized by
3371
the compiler as indicating that no body is logically present.
3372
 
3373
This is particularly useful during maintenance when a package is modified in
3374
such a way that a body needed before is no longer needed. The provision of a
3375
dummy body with a No_Body pragma ensures that there is no interference from
3376
earlier versions of the package body.
3377
 
3378
@node Pragma No_Return
3379
@unnumberedsec Pragma No_Return
3380
@findex No_Return
3381
@noindent
3382
Syntax:
3383
 
3384
@smallexample @c ada
3385
pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3386
@end smallexample
3387
 
3388
@noindent
3389
Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3390
declarations in the current declarative part.  A procedure to which this
3391
pragma is applied may not contain any explicit @code{return} statements.
3392
In addition, if the procedure contains any implicit returns from falling
3393
off the end of a statement sequence, then execution of that implicit
3394
return will cause Program_Error to be raised.
3395
 
3396
One use of this pragma is to identify procedures whose only purpose is to raise
3397
an exception. Another use of this pragma is to suppress incorrect warnings
3398
about missing returns in functions, where the last statement of a function
3399
statement sequence is a call to such a procedure.
3400
 
3401
Note that in Ada 2005 mode, this pragma is part of the language, and is
3402
identical in effect to the pragma as implemented in Ada 95 mode.
3403
 
3404
@node Pragma No_Strict_Aliasing
3405
@unnumberedsec Pragma No_Strict_Aliasing
3406
@findex No_Strict_Aliasing
3407
@noindent
3408
Syntax:
3409
 
3410
@smallexample @c ada
3411
pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3412
@end smallexample
3413
 
3414
@noindent
3415
@var{type_LOCAL_NAME} must refer to an access type
3416
declaration in the current declarative part.  The effect is to inhibit
3417
strict aliasing optimization for the given type.  The form with no
3418
arguments is a configuration pragma which applies to all access types
3419
declared in units to which the pragma applies. For a detailed
3420
description of the strict aliasing optimization, and the situations
3421
in which it must be suppressed, see @ref{Optimization and Strict
3422
Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3423
 
3424
@node Pragma Normalize_Scalars
3425
@unnumberedsec Pragma Normalize_Scalars
3426
@findex Normalize_Scalars
3427
@noindent
3428
Syntax:
3429
 
3430
@smallexample @c ada
3431
pragma Normalize_Scalars;
3432
@end smallexample
3433
 
3434
@noindent
3435
This is a language defined pragma which is fully implemented in GNAT@.  The
3436
effect is to cause all scalar objects that are not otherwise initialized
3437
to be initialized.  The initial values are implementation dependent and
3438
are as follows:
3439
 
3440
@table @code
3441
@item Standard.Character
3442
@noindent
3443
Objects whose root type is Standard.Character are initialized to
3444
Character'Last unless the subtype range excludes NUL (in which case
3445
NUL is used). This choice will always generate an invalid value if
3446
one exists.
3447
 
3448
@item Standard.Wide_Character
3449
@noindent
3450
Objects whose root type is Standard.Wide_Character are initialized to
3451
Wide_Character'Last unless the subtype range excludes NUL (in which case
3452
NUL is used). This choice will always generate an invalid value if
3453
one exists.
3454
 
3455
@item Standard.Wide_Wide_Character
3456
@noindent
3457
Objects whose root type is Standard.Wide_Wide_Character are initialized to
3458
the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3459
which case NUL is used). This choice will always generate an invalid value if
3460
one exists.
3461
 
3462
@item Integer types
3463
@noindent
3464
Objects of an integer type are treated differently depending on whether
3465
negative values are present in the subtype. If no negative values are
3466
present, then all one bits is used as the initial value except in the
3467
special case where zero is excluded from the subtype, in which case
3468
all zero bits are used. This choice will always generate an invalid
3469
value if one exists.
3470
 
3471
For subtypes with negative values present, the largest negative number
3472
is used, except in the unusual case where this largest negative number
3473
is in the subtype, and the largest positive number is not, in which case
3474
the largest positive value is used. This choice will always generate
3475
an invalid value if one exists.
3476
 
3477
@item Floating-Point Types
3478
Objects of all floating-point types are initialized to all 1-bits. For
3479
standard IEEE format, this corresponds to a NaN (not a number) which is
3480
indeed an invalid value.
3481
 
3482
@item Fixed-Point Types
3483
Objects of all fixed-point types are treated as described above for integers,
3484
with the rules applying to the underlying integer value used to represent
3485
the fixed-point value.
3486
 
3487
@item Modular types
3488
Objects of a modular type are initialized to all one bits, except in
3489
the special case where zero is excluded from the subtype, in which
3490
case all zero bits are used. This choice will always generate an
3491
invalid value if one exists.
3492
 
3493
@item Enumeration types
3494
Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3495
the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3496
whose Pos value is zero, in which case a code of zero is used. This choice
3497
will always generate an invalid value if one exists.
3498
 
3499
@end table
3500
 
3501
@node Pragma Obsolescent
3502
@unnumberedsec Pragma Obsolescent
3503
@findex Obsolescent
3504
@noindent
3505
Syntax:
3506
 
3507
@smallexample @c ada
3508
pragma Obsolescent;
3509
 
3510
pragma Obsolescent (
3511
  [Message =>] static_string_EXPRESSION
3512
[,[Version =>] Ada_05]]);
3513
 
3514
pragma Obsolescent (
3515
  [Entity  =>] NAME
3516
[,[Message =>] static_string_EXPRESSION
3517
[,[Version =>] Ada_05]] );
3518
@end smallexample
3519
 
3520
@noindent
3521
This pragma can occur immediately following a declaration of an entity,
3522
including the case of a record component. If no Entity argument is present,
3523
then this declaration is the one to which the pragma applies. If an Entity
3524
parameter is present, it must either match the name of the entity in this
3525
declaration, or alternatively, the pragma can immediately follow an enumeration
3526
type declaration, where the Entity argument names one of the enumeration
3527
literals.
3528
 
3529
This pragma is used to indicate that the named entity
3530
is considered obsolescent and should not be used. Typically this is
3531
used when an API must be modified by eventually removing or modifying
3532
existing subprograms or other entities. The pragma can be used at an
3533
intermediate stage when the entity is still present, but will be
3534
removed later.
3535
 
3536
The effect of this pragma is to output a warning message on a reference to
3537
an entity thus marked that the subprogram is obsolescent if the appropriate
3538
warning option in the compiler is activated. If the Message parameter is
3539
present, then a second warning message is given containing this text. In
3540
addition, a reference to the eneity is considered to be a violation of pragma
3541
Restrictions (No_Obsolescent_Features).
3542
 
3543
This pragma can also be used as a program unit pragma for a package,
3544
in which case the entity name is the name of the package, and the
3545
pragma indicates that the entire package is considered
3546
obsolescent. In this case a client @code{with}'ing such a package
3547
violates the restriction, and the @code{with} statement is
3548
flagged with warnings if the warning option is set.
3549
 
3550
If the Version parameter is present (which must be exactly
3551
the identifier Ada_05, no other argument is allowed), then the
3552
indication of obsolescence applies only when compiling in Ada 2005
3553
mode. This is primarily intended for dealing with the situations
3554
in the predefined library where subprograms or packages
3555
have become defined as obsolescent in Ada 2005
3556
(e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3557
 
3558
The following examples show typical uses of this pragma:
3559
 
3560
@smallexample @c ada
3561
package p is
3562
   pragma Obsolescent (p, Message => "use pp instead of p");
3563
end p;
3564
 
3565
package q is
3566
   procedure q2;
3567
   pragma Obsolescent ("use q2new instead");
3568
 
3569
   type R is new integer;
3570
   pragma Obsolescent
3571
     (Entity  => R,
3572
      Message => "use RR in Ada 2005",
3573
      Version => Ada_05);
3574
 
3575
   type M is record
3576
      F1 : Integer;
3577
      F2 : Integer;
3578
      pragma Obsolescent;
3579
      F3 : Integer;
3580
   end record;
3581
 
3582
   type E is (a, bc, 'd', quack);
3583
   pragma Obsolescent (Entity => bc)
3584
   pragma Obsolescent (Entity => 'd')
3585
 
3586
   function "+"
3587
     (a, b : character) return character;
3588
   pragma Obsolescent (Entity => "+");
3589
end;
3590
@end smallexample
3591
 
3592
@noindent
3593
Note that, as for all pragmas, if you use a pragma argument identifier,
3594
then all subsequent parameters must also use a pragma argument identifier.
3595
So if you specify "Entity =>" for the Entity argument, and a Message
3596
argument is present, it must be preceded by "Message =>".
3597
 
3598
@node Pragma Optimize_Alignment
3599
@unnumberedsec Pragma Optimize_Alignment
3600
@findex Optimize_Alignment
3601
@cindex Alignment, default settings
3602
@noindent
3603
Syntax:
3604
 
3605
@smallexample @c ada
3606
pragma Optimize_Alignment (TIME | SPACE | OFF);
3607
@end smallexample
3608
 
3609
@noindent
3610
This is a configuration pragma which affects the choice of default alignments
3611
for types where no alignment is explicitly specified. There is a time/space
3612
trade-off in the selection of these values. Large alignments result in more
3613
efficient code, at the expense of larger data space, since sizes have to be
3614
increased to match these alignments. Smaller alignments save space, but the
3615
access code is slower. The normal choice of default alignments (which is what
3616
you get if you do not use this pragma, or if you use an argument of OFF),
3617
tries to balance these two requirements.
3618
 
3619
Specifying SPACE causes smaller default alignments to be chosen in two cases.
3620
First any packed record is given an alignment of 1. Second, if a size is given
3621
for the type, then the alignment is chosen to avoid increasing this size. For
3622
example, consider:
3623
 
3624
@smallexample @c ada
3625
   type R is record
3626
      X : Integer;
3627
      Y : Character;
3628
   end record;
3629
 
3630
   for R'Size use 5*8;
3631
@end smallexample
3632
 
3633
@noindent
3634
In the default mode, this type gets an alignment of 4, so that access to the
3635
Integer field X are efficient. But this means that objects of the type end up
3636
with a size of 8 bytes. This is a valid choice, since sizes of objects are
3637
allowed to be bigger than the size of the type, but it can waste space if for
3638
example fields of type R appear in an enclosing record. If the above type is
3639
compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3640
 
3641
Specifying TIME causes larger default alignments to be chosen in the case of
3642
small types with sizes that are not a power of 2. For example, consider:
3643
 
3644
@smallexample @c ada
3645
   type R is record
3646
      A : Character;
3647
      B : Character;
3648
      C : Boolean;
3649
   end record;
3650
 
3651
   pragma Pack (R);
3652
   for R'Size use 17;
3653
@end smallexample
3654
 
3655
@noindent
3656
The default alignment for this record is normally 1, but if this type is
3657
compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3658
to 4, which wastes space for objects of the type, since they are now 4 bytes
3659
long, but results in more efficient access when the whole record is referenced.
3660
 
3661
As noted above, this is a configuration pragma, and there is a requirement
3662
that all units in a partition be compiled with a consistent setting of the
3663
optimization setting. This would normally be achieved by use of a configuration
3664
pragma file containing the appropriate setting. The exception to this rule is
3665
that units with an explicit configuration pragma in the same file as the source
3666
unit are excluded from the consistency check, as are all predefined units. The
3667
latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3668
pragma appears at the start of the file.
3669
 
3670
@node Pragma Passive
3671
@unnumberedsec Pragma Passive
3672
@findex Passive
3673
@noindent
3674
Syntax:
3675
 
3676
@smallexample @c ada
3677
pragma Passive [(Semaphore | No)];
3678
@end smallexample
3679
 
3680
@noindent
3681
Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3682
compatibility with DEC Ada 83 implementations, where it is used within a
3683
task definition to request that a task be made passive.  If the argument
3684
@code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3685
treats the pragma as an assertion that the containing task is passive
3686
and that optimization of context switch with this task is permitted and
3687
desired.  If the argument @code{No} is present, the task must not be
3688
optimized.  GNAT does not attempt to optimize any tasks in this manner
3689
(since protected objects are available in place of passive tasks).
3690
 
3691
@node Pragma Persistent_BSS
3692
@unnumberedsec Pragma Persistent_BSS
3693
@findex Persistent_BSS
3694
@noindent
3695
Syntax:
3696
 
3697
@smallexample @c ada
3698
pragma Persistent_BSS [(LOCAL_NAME)]
3699
@end smallexample
3700
 
3701
@noindent
3702
This pragma allows selected objects to be placed in the @code{.persistent_bss}
3703
section. On some targets the linker and loader provide for special
3704
treatment of this section, allowing a program to be reloaded without
3705
affecting the contents of this data (hence the name persistent).
3706
 
3707
There are two forms of usage. If an argument is given, it must be the
3708
local name of a library level object, with no explicit initialization
3709
and whose type is potentially persistent. If no argument is given, then
3710
the pragma is a configuration pragma, and applies to all library level
3711
objects with no explicit initialization of potentially persistent types.
3712
 
3713
A potentially persistent type is a scalar type, or a non-tagged,
3714
non-discriminated record, all of whose components have no explicit
3715
initialization and are themselves of a potentially persistent type,
3716
or an array, all of whose constraints are static, and whose component
3717
type is potentially persistent.
3718
 
3719
If this pragma is used on a target where this feature is not supported,
3720
then the pragma will be ignored. See also @code{pragma Linker_Section}.
3721
 
3722
@node Pragma Polling
3723
@unnumberedsec Pragma Polling
3724
@findex Polling
3725
@noindent
3726
Syntax:
3727
 
3728
@smallexample @c ada
3729
pragma Polling (ON | OFF);
3730
@end smallexample
3731
 
3732
@noindent
3733
This pragma controls the generation of polling code.  This is normally off.
3734
If @code{pragma Polling (ON)} is used then periodic calls are generated to
3735
the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3736
runtime library, and can be found in file @file{a-excpol.adb}.
3737
 
3738
Pragma @code{Polling} can appear as a configuration pragma (for example it
3739
can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3740
can be used in the statement or declaration sequence to control polling
3741
more locally.
3742
 
3743
A call to the polling routine is generated at the start of every loop and
3744
at the start of every subprogram call.  This guarantees that the @code{Poll}
3745
routine is called frequently, and places an upper bound (determined by
3746
the complexity of the code) on the period between two @code{Poll} calls.
3747
 
3748
The primary purpose of the polling interface is to enable asynchronous
3749
aborts on targets that cannot otherwise support it (for example Windows
3750
NT), but it may be used for any other purpose requiring periodic polling.
3751
The standard version is null, and can be replaced by a user program.  This
3752
will require re-compilation of the @code{Ada.Exceptions} package that can
3753
be found in files @file{a-except.ads} and @file{a-except.adb}.
3754
 
3755
A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3756
distribution) is used to enable the asynchronous abort capability on
3757
targets that do not normally support the capability.  The version of
3758
@code{Poll} in this file makes a call to the appropriate runtime routine
3759
to test for an abort condition.
3760
 
3761
Note that polling can also be enabled by use of the @option{-gnatP} switch.
3762
@xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3763
details.
3764
 
3765
@node Pragma Postcondition
3766
@unnumberedsec Pragma Postcondition
3767
@cindex Postconditions
3768
@cindex Checks, postconditions
3769
@findex Postconditions
3770
@noindent
3771
Syntax:
3772
 
3773
@smallexample @c ada
3774
pragma Postcondition (
3775
   [Check   =>] Boolean_Expression
3776
 [,[Message =>] String_Expression]);
3777
@end smallexample
3778
 
3779
@noindent
3780
The @code{Postcondition} pragma allows specification of automatic
3781
postcondition checks for subprograms. These checks are similar to
3782
assertions, but are automatically inserted just prior to the return
3783
statements of the subprogram with which they are associated (including
3784
implicit returns at the end of procedure bodies and associated
3785
exception handlers).
3786
 
3787
In addition, the boolean expression which is the condition which
3788
must be true may contain references to function'Result in the case
3789
of a function to refer to the returned value.
3790
 
3791
@code{Postcondition} pragmas may appear either immediate following the
3792
(separate) declaration of a subprogram, or at the start of the
3793
declarations of a subprogram body. Only other pragmas may intervene
3794
(that is appear between the subprogram declaration and its
3795
postconditions, or appear before the postcondition in the
3796
declaration sequence in a subprogram body). In the case of a
3797
postcondition appearing after a subprogram declaration, the
3798
formal arguments of the subprogram are visible, and can be
3799
referenced in the postcondition expressions.
3800
 
3801
The postconditions are collected and automatically tested just
3802
before any return (implicit or explicit) in the subprogram body.
3803
A postcondition is only recognized if postconditions are active
3804
at the time the pragma is encountered. The compiler switch @option{gnata}
3805
turns on all postconditions by default, and pragma @code{Check_Policy}
3806
with an identifier of @code{Postcondition} can also be used to
3807
control whether postconditions are active.
3808
 
3809
The general approach is that postconditions are placed in the spec
3810
if they represent functional aspects which make sense to the client.
3811
For example we might have:
3812
 
3813
@smallexample @c ada
3814
   function Direction return Integer;
3815
   pragma Postcondition
3816
    (Direction'Result = +1
3817
       or else
3818
     Direction'Result = -1);
3819
@end smallexample
3820
 
3821
@noindent
3822
which serves to document that the result must be +1 or -1, and
3823
will test that this is the case at run time if postcondition
3824
checking is active.
3825
 
3826
Postconditions within the subprogram body can be used to
3827
check that some internal aspect of the implementation,
3828
not visible to the client, is operating as expected.
3829
For instance if a square root routine keeps an internal
3830
counter of the number of times it is called, then we
3831
might have the following postcondition:
3832
 
3833
@smallexample @c ada
3834
   Sqrt_Calls : Natural := 0;
3835
 
3836
   function Sqrt (Arg : Float) return Float is
3837
     pragma Postcondition
3838
       (Sqrt_Calls = Sqrt_Calls'Old + 1);
3839
     ...
3840
   end Sqrt
3841
@end smallexample
3842
 
3843
@noindent
3844
As this example, shows, the use of the @code{Old} attribute
3845
is often useful in postconditions to refer to the state on
3846
entry to the subprogram.
3847
 
3848
Note that postconditions are only checked on normal returns
3849
from the subprogram. If an abnormal return results from
3850
raising an exception, then the postconditions are not checked.
3851
 
3852
If a postcondition fails, then the exception
3853
@code{System.Assertions.Assert_Failure} is raised. If
3854
a message argument was supplied, then the given string
3855
will be used as the exception message. If no message
3856
argument was supplied, then the default message has
3857
the form "Postcondition failed at file:line". The
3858
exception is raised in the context of the subprogram
3859
body, so it is possible to catch postcondition failures
3860
within the subprogram body itself.
3861
 
3862
Within a package spec, normal visibility rules
3863
in Ada would prevent forward references within a
3864
postcondition pragma to functions defined later in
3865
the same package. This would introduce undesirable
3866
ordering constraints. To avoid this problem, all
3867
postcondition pragmas are analyzed at the end of
3868
the package spec, allowing forward references.
3869
 
3870
The following example shows that this even allows
3871
mutually recursive postconditions as in:
3872
 
3873
@smallexample @c ada
3874
package Parity_Functions is
3875
   function Odd  (X : Natural) return Boolean;
3876
   pragma Postcondition
3877
     (Odd'Result =
3878
        (x = 1
3879
          or else
3880
        (x /= 0 and then Even (X - 1))));
3881
 
3882
   function Even (X : Natural) return Boolean;
3883
   pragma Postcondition
3884
     (Even'Result =
3885
        (x = 0
3886
          or else
3887
        (x /= 1 and then Odd (X - 1))));
3888
 
3889
end Parity_Functions;
3890
@end smallexample
3891
 
3892
@noindent
3893
There are no restrictions on the complexity or form of
3894
conditions used within @code{Postcondition} pragmas.
3895
The following example shows that it is even possible
3896
to verify performance behavior.
3897
 
3898
@smallexample @c ada
3899
package Sort is
3900
 
3901
   Performance : constant Float;
3902
   --  Performance constant set by implementation
3903
   --  to match target architecture behavior.
3904
 
3905
   procedure Treesort (Arg : String);
3906
   --  Sorts characters of argument using N*logN sort
3907
   pragma Postcondition
3908
     (Float (Clock - Clock'Old) <=
3909
        Float (Arg'Length) *
3910
        log (Float (Arg'Length)) *
3911
        Performance);
3912
end Sort;
3913
@end smallexample
3914
 
3915
@noindent
3916
Note: postcondition pragmas associated with subprograms that are
3917
marked as Inline_Always, or those marked as Inline with front-end
3918
inlining (-gnatN option set) are accepted and legality-checked
3919
by the compiler, but are ignored at run-time even if postcondition
3920
checking is enabled.
3921
 
3922
@node Pragma Precondition
3923
@unnumberedsec Pragma Precondition
3924
@cindex Preconditions
3925
@cindex Checks, preconditions
3926
@findex Preconditions
3927
@noindent
3928
Syntax:
3929
 
3930
@smallexample @c ada
3931
pragma Precondition (
3932
   [Check   =>] Boolean_Expression
3933
 [,[Message =>] String_Expression]);
3934
@end smallexample
3935
 
3936
@noindent
3937
The @code{Precondition} pragma is similar to @code{Postcondition}
3938
except that the corresponding checks take place immediately upon
3939
entry to the subprogram, and if a precondition fails, the exception
3940
is raised in the context of the caller, and the attribute 'Result
3941
cannot be used within the precondition expression.
3942
 
3943
Otherwise, the placement and visibility rules are identical to those
3944
described for postconditions. The following is an example of use
3945
within a package spec:
3946
 
3947
@smallexample @c ada
3948
package Math_Functions is
3949
   ...
3950
   function Sqrt (Arg : Float) return Float;
3951
   pragma Precondition (Arg >= 0.0)
3952
   ...
3953
end Math_Functions;
3954
@end smallexample
3955
 
3956
@noindent
3957
@code{Precondition} pragmas may appear either immediate following the
3958
(separate) declaration of a subprogram, or at the start of the
3959
declarations of a subprogram body. Only other pragmas may intervene
3960
(that is appear between the subprogram declaration and its
3961
postconditions, or appear before the postcondition in the
3962
declaration sequence in a subprogram body).
3963
 
3964
Note: postcondition pragmas associated with subprograms that are
3965
marked as Inline_Always, or those marked as Inline with front-end
3966
inlining (-gnatN option set) are accepted and legality-checked
3967
by the compiler, but are ignored at run-time even if postcondition
3968
checking is enabled.
3969
 
3970
 
3971
 
3972
@node Pragma Profile (Ravenscar)
3973
@unnumberedsec Pragma Profile (Ravenscar)
3974
@findex Ravenscar
3975
@noindent
3976
Syntax:
3977
 
3978
@smallexample @c ada
3979
pragma Profile (Ravenscar);
3980
@end smallexample
3981
 
3982
@noindent
3983
A configuration pragma that establishes the following set of configuration
3984
pragmas:
3985
 
3986
@table @code
3987
@item Task_Dispatching_Policy (FIFO_Within_Priorities)
3988
[RM D.2.2] Tasks are dispatched following a preemptive
3989
priority-ordered scheduling policy.
3990
 
3991
@item Locking_Policy (Ceiling_Locking)
3992
[RM D.3] While tasks and interrupts execute a protected action, they inherit
3993
the ceiling priority of the corresponding protected object.
3994
@c
3995
@c @item Detect_Blocking
3996
@c This pragma forces the detection of potentially blocking operations within a
3997
@c protected operation, and to raise Program_Error if that happens.
3998
@end table
3999
@noindent
4000
 
4001
plus the following set of restrictions:
4002
 
4003
@table @code
4004
@item Max_Entry_Queue_Length = 1
4005
Defines the maximum number of calls that are queued on a (protected) entry.
4006
Note that this restrictions is checked at run time. Violation of this
4007
restriction results in the raising of Program_Error exception at the point of
4008
the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4009
always 1 and hence no task can be queued on a protected entry.
4010
 
4011
@item Max_Protected_Entries = 1
4012
[RM D.7] Specifies the maximum number of entries per protected type. The
4013
bounds of every entry family of a protected unit shall be static, or shall be
4014
defined by a discriminant of a subtype whose corresponding bound is static.
4015
For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4016
 
4017
@item Max_Task_Entries = 0
4018
[RM D.7] Specifies the maximum number of entries
4019
per task.  The bounds of every entry family
4020
of a task unit shall be static, or shall be
4021
defined by a discriminant of a subtype whose
4022
corresponding bound is static.  A value of zero
4023
indicates that no rendezvous are possible.  For
4024
the Profile (Ravenscar), the value of Max_Task_Entries is always
4025
 
4026
 
4027
@item No_Abort_Statements
4028
[RM D.7] There are no abort_statements, and there are
4029
no calls to Task_Identification.Abort_Task.
4030
 
4031
@item No_Asynchronous_Control
4032
There are no semantic dependences on the package
4033
Asynchronous_Task_Control.
4034
 
4035
@item No_Calendar
4036
There are no semantic dependencies on the package Ada.Calendar.
4037
 
4038
@item No_Dynamic_Attachment
4039
There is no call to any of the operations defined in package Ada.Interrupts
4040
(Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4041
Detach_Handler, and Reference).
4042
 
4043
@item No_Dynamic_Priorities
4044
[RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4045
 
4046
@item No_Implicit_Heap_Allocations
4047
[RM D.7] No constructs are allowed to cause implicit heap allocation.
4048
 
4049
@item No_Local_Protected_Objects
4050
Protected objects and access types that designate
4051
such objects shall be declared only at library level.
4052
 
4053
@item No_Local_Timing_Events
4054
[RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4055
declared at the library level.
4056
 
4057
@item No_Protected_Type_Allocators
4058
There are no allocators for protected types or
4059
types containing protected subcomponents.
4060
 
4061
@item No_Relative_Delay
4062
There are no delay_relative statements.
4063
 
4064
@item No_Requeue_Statements
4065
Requeue statements are not allowed.
4066
 
4067
@item No_Select_Statements
4068
There are no select_statements.
4069
 
4070
@item No_Specific_Termination_Handlers
4071
[RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4072
or to Ada.Task_Termination.Specific_Handler.
4073
 
4074
@item No_Task_Allocators
4075
[RM D.7] There are no allocators for task types
4076
or types containing task subcomponents.
4077
 
4078
@item No_Task_Attributes_Package
4079
There are no semantic dependencies on the Ada.Task_Attributes package.
4080
 
4081
@item No_Task_Hierarchy
4082
[RM D.7] All (non-environment) tasks depend
4083
directly on the environment task of the partition.
4084
 
4085
@item No_Task_Termination
4086
Tasks which terminate are erroneous.
4087
 
4088
@item No_Unchecked_Conversion
4089
There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4090
 
4091
@item No_Unchecked_Deallocation
4092
There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4093
 
4094
@item Simple_Barriers
4095
Entry barrier condition expressions shall be either static
4096
boolean expressions or boolean objects which are declared in
4097
the protected type which contains the entry.
4098
@end table
4099
 
4100
@noindent
4101
This set of configuration pragmas and restrictions correspond to the
4102
definition of the ``Ravenscar Profile'' for limited tasking, devised and
4103
published by the @cite{International Real-Time Ada Workshop}, 1997,
4104
and whose most recent description is available at
4105
@url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4106
 
4107
The original definition of the profile was revised at subsequent IRTAW
4108
meetings. It has been included in the ISO
4109
@cite{Guide for the Use of the Ada Programming Language in High
4110
Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4111
the next revision of the standard. The formal definition given by
4112
the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4113
AI-305) available at
4114
@url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4115
@url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4116
respectively.
4117
 
4118
The above set is a superset of the restrictions provided by pragma
4119
@code{Profile (Restricted)}, it includes six additional restrictions
4120
(@code{Simple_Barriers}, @code{No_Select_Statements},
4121
@code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4122
@code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4123
that pragma @code{Profile (Ravenscar)}, like the pragma
4124
@code{Profile (Restricted)},
4125
automatically causes the use of a simplified,
4126
more efficient version of the tasking run-time system.
4127
 
4128
@node Pragma Profile (Restricted)
4129
@unnumberedsec Pragma Profile (Restricted)
4130
@findex Restricted Run Time
4131
@noindent
4132
Syntax:
4133
 
4134
@smallexample @c ada
4135
pragma Profile (Restricted);
4136
@end smallexample
4137
 
4138
@noindent
4139
A configuration pragma that establishes the following set of restrictions:
4140
 
4141
@itemize @bullet
4142
@item No_Abort_Statements
4143
@item No_Entry_Queue
4144
@item No_Task_Hierarchy
4145
@item No_Task_Allocators
4146
@item No_Dynamic_Priorities
4147
@item No_Terminate_Alternatives
4148
@item No_Dynamic_Attachment
4149
@item No_Protected_Type_Allocators
4150
@item No_Local_Protected_Objects
4151
@item No_Requeue_Statements
4152
@item No_Task_Attributes_Package
4153
@item Max_Asynchronous_Select_Nesting =  0
4154
@item Max_Task_Entries =  0
4155
@item Max_Protected_Entries = 1
4156
@item Max_Select_Alternatives = 0
4157
@end itemize
4158
 
4159
@noindent
4160
This set of restrictions causes the automatic selection of a simplified
4161
version of the run time that provides improved performance for the
4162
limited set of tasking functionality permitted by this set of restrictions.
4163
 
4164
@node Pragma Psect_Object
4165
@unnumberedsec Pragma Psect_Object
4166
@findex Psect_Object
4167
@noindent
4168
Syntax:
4169
 
4170
@smallexample @c ada
4171
pragma Psect_Object (
4172
     [Internal =>] LOCAL_NAME,
4173
  [, [External =>] EXTERNAL_SYMBOL]
4174
  [, [Size     =>] EXTERNAL_SYMBOL]);
4175
 
4176
EXTERNAL_SYMBOL ::=
4177
  IDENTIFIER
4178
| static_string_EXPRESSION
4179
@end smallexample
4180
 
4181
@noindent
4182
This pragma is identical in effect to pragma @code{Common_Object}.
4183
 
4184
@node Pragma Pure_Function
4185
@unnumberedsec Pragma Pure_Function
4186
@findex Pure_Function
4187
@noindent
4188
Syntax:
4189
 
4190
@smallexample @c ada
4191
pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4192
@end smallexample
4193
 
4194
@noindent
4195
This pragma appears in the same declarative part as a function
4196
declaration (or a set of function declarations if more than one
4197
overloaded declaration exists, in which case the pragma applies
4198
to all entities).  It specifies that the function @code{Entity} is
4199
to be considered pure for the purposes of code generation.  This means
4200
that the compiler can assume that there are no side effects, and
4201
in particular that two calls with identical arguments produce the
4202
same result.  It also means that the function can be used in an
4203
address clause.
4204
 
4205
Note that, quite deliberately, there are no static checks to try
4206
to ensure that this promise is met, so @code{Pure_Function} can be used
4207
with functions that are conceptually pure, even if they do modify
4208
global variables.  For example, a square root function that is
4209
instrumented to count the number of times it is called is still
4210
conceptually pure, and can still be optimized, even though it
4211
modifies a global variable (the count).  Memo functions are another
4212
example (where a table of previous calls is kept and consulted to
4213
avoid re-computation).
4214
 
4215
@findex Pure
4216
Note: Most functions in a @code{Pure} package are automatically pure, and
4217
there is no need to use pragma @code{Pure_Function} for such functions.  One
4218
exception is any function that has at least one formal of type
4219
@code{System.Address} or a type derived from it.  Such functions are not
4220
considered pure by default, since the compiler assumes that the
4221
@code{Address} parameter may be functioning as a pointer and that the
4222
referenced data may change even if the address value does not.
4223
Similarly, imported functions are not considered to be pure by default,
4224
since there is no way of checking that they are in fact pure.  The use
4225
of pragma @code{Pure_Function} for such a function will override these default
4226
assumption, and cause the compiler to treat a designated subprogram as pure
4227
in these cases.
4228
 
4229
Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4230
applies to the underlying renamed function.  This can be used to
4231
disambiguate cases of overloading where some but not all functions
4232
in a set of overloaded functions are to be designated as pure.
4233
 
4234
If pragma @code{Pure_Function} is applied to a library level function, the
4235
function is also considered pure from an optimization point of view, but the
4236
unit is not a Pure unit in the categorization sense. So for example, a function
4237
thus marked is free to @code{with} non-pure units.
4238
 
4239
@node Pragma Restriction_Warnings
4240
@unnumberedsec Pragma Restriction_Warnings
4241
@findex Restriction_Warnings
4242
@noindent
4243
Syntax:
4244
 
4245
@smallexample @c ada
4246
pragma Restriction_Warnings
4247
  (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4248
@end smallexample
4249
 
4250
@noindent
4251
This pragma allows a series of restriction identifiers to be
4252
specified (the list of allowed identifiers is the same as for
4253
pragma @code{Restrictions}). For each of these identifiers
4254
the compiler checks for violations of the restriction, but
4255
generates a warning message rather than an error message
4256
if the restriction is violated.
4257
 
4258
@node Pragma Shared
4259
@unnumberedsec Pragma Shared
4260
@findex Shared
4261
 
4262
@noindent
4263
This pragma is provided for compatibility with Ada 83. The syntax and
4264
semantics are identical to pragma Atomic.
4265
 
4266
@node Pragma Short_Circuit_And_Or
4267
@unnumberedsec Pragma Short_Circuit_And_Or
4268
@findex Short_Circuit_And_Or
4269
 
4270
@noindent
4271
This configuration pragma causes any occurrence of the AND operator applied to
4272
operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4273
is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4274
may be useful in the context of certification protocols requiring the use of
4275
short-circuited logical operators. If this configuration pragma occurs locally
4276
within the file being compiled, it applies only to the file being compiled.
4277
There is no requirement that all units in a partition use this option.
4278
 
4279
semantics are identical to pragma Atomic.
4280
@node Pragma Source_File_Name
4281
@unnumberedsec Pragma Source_File_Name
4282
@findex Source_File_Name
4283
@noindent
4284
Syntax:
4285
 
4286
@smallexample @c ada
4287
pragma Source_File_Name (
4288
  [Unit_Name   =>] unit_NAME,
4289
  Spec_File_Name =>  STRING_LITERAL,
4290
  [Index => INTEGER_LITERAL]);
4291
 
4292
pragma Source_File_Name (
4293
  [Unit_Name   =>] unit_NAME,
4294
  Body_File_Name =>  STRING_LITERAL,
4295
  [Index => INTEGER_LITERAL]);
4296
@end smallexample
4297
 
4298
@noindent
4299
Use this to override the normal naming convention.  It is a configuration
4300
pragma, and so has the usual applicability of configuration pragmas
4301
(i.e.@: it applies to either an entire partition, or to all units in a
4302
compilation, or to a single unit, depending on how it is used.
4303
@var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4304
the second argument is required, and indicates whether this is the file
4305
name for the spec or for the body.
4306
 
4307
The optional Index argument should be used when a file contains multiple
4308
units, and when you do not want to use @code{gnatchop} to separate then
4309
into multiple files (which is the recommended procedure to limit the
4310
number of recompilations that are needed when some sources change).
4311
For instance, if the source file @file{source.ada} contains
4312
 
4313
@smallexample @c ada
4314
package B is
4315
...
4316
end B;
4317
 
4318
with B;
4319
procedure A is
4320
begin
4321
   ..
4322
end A;
4323
@end smallexample
4324
 
4325
you could use the following configuration pragmas:
4326
 
4327
@smallexample @c ada
4328
pragma Source_File_Name
4329
  (B, Spec_File_Name => "source.ada", Index => 1);
4330
pragma Source_File_Name
4331
  (A, Body_File_Name => "source.ada", Index => 2);
4332
@end smallexample
4333
 
4334
Note that the @code{gnatname} utility can also be used to generate those
4335
configuration pragmas.
4336
 
4337
Another form of the @code{Source_File_Name} pragma allows
4338
the specification of patterns defining alternative file naming schemes
4339
to apply to all files.
4340
 
4341
@smallexample @c ada
4342
pragma Source_File_Name
4343
  (  [Spec_File_Name  =>] STRING_LITERAL
4344
   [,[Casing          =>] CASING_SPEC]
4345
   [,[Dot_Replacement =>] STRING_LITERAL]);
4346
 
4347
pragma Source_File_Name
4348
  (  [Body_File_Name  =>] STRING_LITERAL
4349
   [,[Casing          =>] CASING_SPEC]
4350
   [,[Dot_Replacement =>] STRING_LITERAL]);
4351
 
4352
pragma Source_File_Name
4353
  (  [Subunit_File_Name =>] STRING_LITERAL
4354
   [,[Casing            =>] CASING_SPEC]
4355
   [,[Dot_Replacement   =>] STRING_LITERAL]);
4356
 
4357
CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4358
@end smallexample
4359
 
4360
@noindent
4361
The first argument is a pattern that contains a single asterisk indicating
4362
the point at which the unit name is to be inserted in the pattern string
4363
to form the file name.  The second argument is optional.  If present it
4364
specifies the casing of the unit name in the resulting file name string.
4365
The default is lower case.  Finally the third argument allows for systematic
4366
replacement of any dots in the unit name by the specified string literal.
4367
 
4368
A pragma Source_File_Name cannot appear after a
4369
@ref{Pragma Source_File_Name_Project}.
4370
 
4371
For more details on the use of the @code{Source_File_Name} pragma,
4372
@xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4373
and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4374
User's Guide}.
4375
 
4376
@node Pragma Source_File_Name_Project
4377
@unnumberedsec Pragma Source_File_Name_Project
4378
@findex Source_File_Name_Project
4379
@noindent
4380
 
4381
This pragma has the same syntax and semantics as pragma Source_File_Name.
4382
It is only allowed as a stand alone configuration pragma.
4383
It cannot appear after a @ref{Pragma Source_File_Name}, and
4384
most importantly, once pragma Source_File_Name_Project appears,
4385
no further Source_File_Name pragmas are allowed.
4386
 
4387
The intention is that Source_File_Name_Project pragmas are always
4388
generated by the Project Manager in a manner consistent with the naming
4389
specified in a project file, and when naming is controlled in this manner,
4390
it is not permissible to attempt to modify this naming scheme using
4391
Source_File_Name pragmas (which would not be known to the project manager).
4392
 
4393
@node Pragma Source_Reference
4394
@unnumberedsec Pragma Source_Reference
4395
@findex Source_Reference
4396
@noindent
4397
Syntax:
4398
 
4399
@smallexample @c ada
4400
pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4401
@end smallexample
4402
 
4403
@noindent
4404
This pragma must appear as the first line of a source file.
4405
@var{integer_literal} is the logical line number of the line following
4406
the pragma line (for use in error messages and debugging
4407
information).  @var{string_literal} is a static string constant that
4408
specifies the file name to be used in error messages and debugging
4409
information.  This is most notably used for the output of @code{gnatchop}
4410
with the @option{-r} switch, to make sure that the original unchopped
4411
source file is the one referred to.
4412
 
4413
The second argument must be a string literal, it cannot be a static
4414
string expression other than a string literal.  This is because its value
4415
is needed for error messages issued by all phases of the compiler.
4416
 
4417
@node Pragma Stream_Convert
4418
@unnumberedsec Pragma Stream_Convert
4419
@findex Stream_Convert
4420
@noindent
4421
Syntax:
4422
 
4423
@smallexample @c ada
4424
pragma Stream_Convert (
4425
  [Entity =>] type_LOCAL_NAME,
4426
  [Read   =>] function_NAME,
4427
  [Write  =>] function_NAME);
4428
@end smallexample
4429
 
4430
@noindent
4431
This pragma provides an efficient way of providing stream functions for
4432
types defined in packages.  Not only is it simpler to use than declaring
4433
the necessary functions with attribute representation clauses, but more
4434
significantly, it allows the declaration to made in such a way that the
4435
stream packages are not loaded unless they are needed.  The use of
4436
the Stream_Convert pragma adds no overhead at all, unless the stream
4437
attributes are actually used on the designated type.
4438
 
4439
The first argument specifies the type for which stream functions are
4440
provided.  The second parameter provides a function used to read values
4441
of this type.  It must name a function whose argument type may be any
4442
subtype, and whose returned type must be the type given as the first
4443
argument to the pragma.
4444
 
4445
The meaning of the @var{Read}
4446
parameter is that if a stream attribute directly
4447
or indirectly specifies reading of the type given as the first parameter,
4448
then a value of the type given as the argument to the Read function is
4449
read from the stream, and then the Read function is used to convert this
4450
to the required target type.
4451
 
4452
Similarly the @var{Write} parameter specifies how to treat write attributes
4453
that directly or indirectly apply to the type given as the first parameter.
4454
It must have an input parameter of the type specified by the first parameter,
4455
and the return type must be the same as the input type of the Read function.
4456
The effect is to first call the Write function to convert to the given stream
4457
type, and then write the result type to the stream.
4458
 
4459
The Read and Write functions must not be overloaded subprograms.  If necessary
4460
renamings can be supplied to meet this requirement.
4461
The usage of this attribute is best illustrated by a simple example, taken
4462
from the GNAT implementation of package Ada.Strings.Unbounded:
4463
 
4464
@smallexample @c ada
4465
function To_Unbounded (S : String)
4466
           return Unbounded_String
4467
  renames To_Unbounded_String;
4468
 
4469
pragma Stream_Convert
4470
  (Unbounded_String, To_Unbounded, To_String);
4471
@end smallexample
4472
 
4473
@noindent
4474
The specifications of the referenced functions, as given in the Ada
4475
Reference Manual are:
4476
 
4477
@smallexample @c ada
4478
function To_Unbounded_String (Source : String)
4479
  return Unbounded_String;
4480
 
4481
function To_String (Source : Unbounded_String)
4482
  return String;
4483
@end smallexample
4484
 
4485
@noindent
4486
The effect is that if the value of an unbounded string is written to a stream,
4487
then the representation of the item in the stream is in the same format that
4488
would be used for @code{Standard.String'Output}, and this same representation
4489
is expected when a value of this type is read from the stream. Note that the
4490
value written always includes the bounds, even for Unbounded_String'Write,
4491
since Unbounded_String is not an array type.
4492
 
4493
@node Pragma Style_Checks
4494
@unnumberedsec Pragma Style_Checks
4495
@findex Style_Checks
4496
@noindent
4497
Syntax:
4498
 
4499
@smallexample @c ada
4500
pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4501
                     On | Off [, LOCAL_NAME]);
4502
@end smallexample
4503
 
4504
@noindent
4505
This pragma is used in conjunction with compiler switches to control the
4506
built in style checking provided by GNAT@.  The compiler switches, if set,
4507
provide an initial setting for the switches, and this pragma may be used
4508
to modify these settings, or the settings may be provided entirely by
4509
the use of the pragma.  This pragma can be used anywhere that a pragma
4510
is legal, including use as a configuration pragma (including use in
4511
the @file{gnat.adc} file).
4512
 
4513
The form with a string literal specifies which style options are to be
4514
activated.  These are additive, so they apply in addition to any previously
4515
set style check options.  The codes for the options are the same as those
4516
used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4517
For example the following two methods can be used to enable
4518
layout checking:
4519
 
4520
@itemize @bullet
4521
@item
4522
@smallexample @c ada
4523
pragma Style_Checks ("l");
4524
@end smallexample
4525
 
4526
@item
4527
@smallexample
4528
gcc -c -gnatyl @dots{}
4529
@end smallexample
4530
@end itemize
4531
 
4532
@noindent
4533
The form ALL_CHECKS activates all standard checks (its use is equivalent
4534
to the use of the @code{gnaty} switch with no options.  @xref{Top,
4535
@value{EDITION} User's Guide, About This Guide, gnat_ugn,
4536
@value{EDITION} User's Guide}, for details.
4537
 
4538
The forms with @code{Off} and @code{On}
4539
can be used to temporarily disable style checks
4540
as shown in the following example:
4541
 
4542
@smallexample @c ada
4543
@iftex
4544
@leftskip=0cm
4545
@end iftex
4546
pragma Style_Checks ("k"); -- requires keywords in lower case
4547
pragma Style_Checks (Off); -- turn off style checks
4548
NULL;                      -- this will not generate an error message
4549
pragma Style_Checks (On);  -- turn style checks back on
4550
NULL;                      -- this will generate an error message
4551
@end smallexample
4552
 
4553
@noindent
4554
Finally the two argument form is allowed only if the first argument is
4555
@code{On} or @code{Off}.  The effect is to turn of semantic style checks
4556
for the specified entity, as shown in the following example:
4557
 
4558
@smallexample @c ada
4559
@iftex
4560
@leftskip=0cm
4561
@end iftex
4562
pragma Style_Checks ("r"); -- require consistency of identifier casing
4563
Arg : Integer;
4564
Rf1 : Integer := ARG;      -- incorrect, wrong case
4565
pragma Style_Checks (Off, Arg);
4566
Rf2 : Integer := ARG;      -- OK, no error
4567
@end smallexample
4568
 
4569
@node Pragma Subtitle
4570
@unnumberedsec Pragma Subtitle
4571
@findex Subtitle
4572
@noindent
4573
Syntax:
4574
 
4575
@smallexample @c ada
4576
pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4577
@end smallexample
4578
 
4579
@noindent
4580
This pragma is recognized for compatibility with other Ada compilers
4581
but is ignored by GNAT@.
4582
 
4583
@node Pragma Suppress
4584
@unnumberedsec Pragma Suppress
4585
@findex Suppress
4586
@noindent
4587
Syntax:
4588
 
4589
@smallexample @c ada
4590
pragma Suppress (Identifier [, [On =>] Name]);
4591
@end smallexample
4592
 
4593
@noindent
4594
This is a standard pragma, and supports all the check names required in
4595
the RM. It is included here because GNAT recognizes one additional check
4596
name: @code{Alignment_Check} which can be used to suppress alignment checks
4597
on addresses used in address clauses. Such checks can also be suppressed
4598
by suppressing range checks, but the specific use of @code{Alignment_Check}
4599
allows suppression of alignment checks without suppressing other range checks.
4600
 
4601
Note that pragma Suppress gives the compiler permission to omit
4602
checks, but does not require the compiler to omit checks. The compiler
4603
will generate checks if they are essentially free, even when they are
4604
suppressed. In particular, if the compiler can prove that a certain
4605
check will necessarily fail, it will generate code to do an
4606
unconditional ``raise'', even if checks are suppressed. The compiler
4607
warns in this case.
4608
 
4609
Of course, run-time checks are omitted whenever the compiler can prove
4610
that they will not fail, whether or not checks are suppressed.
4611
 
4612
@node Pragma Suppress_All
4613
@unnumberedsec Pragma Suppress_All
4614
@findex Suppress_All
4615
@noindent
4616
Syntax:
4617
 
4618
@smallexample @c ada
4619
pragma Suppress_All;
4620
@end smallexample
4621
 
4622
@noindent
4623
This pragma can only appear immediately following a compilation
4624
unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4625
which it follows.  This pragma is implemented for compatibility with DEC
4626
Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4627
configuration pragma is the preferred usage in GNAT@.
4628
 
4629
@node Pragma Suppress_Exception_Locations
4630
@unnumberedsec Pragma Suppress_Exception_Locations
4631
@findex Suppress_Exception_Locations
4632
@noindent
4633
Syntax:
4634
 
4635
@smallexample @c ada
4636
pragma Suppress_Exception_Locations;
4637
@end smallexample
4638
 
4639
@noindent
4640
In normal mode, a raise statement for an exception by default generates
4641
an exception message giving the file name and line number for the location
4642
of the raise. This is useful for debugging and logging purposes, but this
4643
entails extra space for the strings for the messages. The configuration
4644
pragma @code{Suppress_Exception_Locations} can be used to suppress the
4645
generation of these strings, with the result that space is saved, but the
4646
exception message for such raises is null. This configuration pragma may
4647
appear in a global configuration pragma file, or in a specific unit as
4648
usual. It is not required that this pragma be used consistently within
4649
a partition, so it is fine to have some units within a partition compiled
4650
with this pragma and others compiled in normal mode without it.
4651
 
4652
@node Pragma Suppress_Initialization
4653
@unnumberedsec Pragma Suppress_Initialization
4654
@findex Suppress_Initialization
4655
@cindex Suppressing initialization
4656
@cindex Initialization, suppression of
4657
@noindent
4658
Syntax:
4659
 
4660
@smallexample @c ada
4661
pragma Suppress_Initialization ([Entity =>] type_Name);
4662
@end smallexample
4663
 
4664
@noindent
4665
This pragma suppresses any implicit or explicit initialization
4666
associated with the given type name for all variables of this type.
4667
 
4668
@node Pragma Task_Info
4669
@unnumberedsec Pragma Task_Info
4670
@findex Task_Info
4671
@noindent
4672
Syntax
4673
 
4674
@smallexample @c ada
4675
pragma Task_Info (EXPRESSION);
4676
@end smallexample
4677
 
4678
@noindent
4679
This pragma appears within a task definition (like pragma
4680
@code{Priority}) and applies to the task in which it appears.  The
4681
argument must be of type @code{System.Task_Info.Task_Info_Type}.
4682
The @code{Task_Info} pragma provides system dependent control over
4683
aspects of tasking implementation, for example, the ability to map
4684
tasks to specific processors.  For details on the facilities available
4685
for the version of GNAT that you are using, see the documentation
4686
in the spec of package System.Task_Info in the runtime
4687
library.
4688
 
4689
@node Pragma Task_Name
4690
@unnumberedsec Pragma Task_Name
4691
@findex Task_Name
4692
@noindent
4693
Syntax
4694
 
4695
@smallexample @c ada
4696
pragma Task_Name (string_EXPRESSION);
4697
@end smallexample
4698
 
4699
@noindent
4700
This pragma appears within a task definition (like pragma
4701
@code{Priority}) and applies to the task in which it appears.  The
4702
argument must be of type String, and provides a name to be used for
4703
the task instance when the task is created.  Note that this expression
4704
is not required to be static, and in particular, it can contain
4705
references to task discriminants.  This facility can be used to
4706
provide different names for different tasks as they are created,
4707
as illustrated in the example below.
4708
 
4709
The task name is recorded internally in the run-time structures
4710
and is accessible to tools like the debugger.  In addition the
4711
routine @code{Ada.Task_Identification.Image} will return this
4712
string, with a unique task address appended.
4713
 
4714
@smallexample @c ada
4715
--  Example of the use of pragma Task_Name
4716
 
4717
with Ada.Task_Identification;
4718
use Ada.Task_Identification;
4719
with Text_IO; use Text_IO;
4720
procedure t3 is
4721
 
4722
   type Astring is access String;
4723
 
4724
   task type Task_Typ (Name : access String) is
4725
      pragma Task_Name (Name.all);
4726
   end Task_Typ;
4727
 
4728
   task body Task_Typ is
4729
      Nam : constant String := Image (Current_Task);
4730
   begin
4731
      Put_Line ("-->" & Nam (1 .. 14) & "<--");
4732
   end Task_Typ;
4733
 
4734
   type Ptr_Task is access Task_Typ;
4735
   Task_Var : Ptr_Task;
4736
 
4737
begin
4738
   Task_Var :=
4739
     new Task_Typ (new String'("This is task 1"));
4740
   Task_Var :=
4741
     new Task_Typ (new String'("This is task 2"));
4742
end;
4743
@end smallexample
4744
 
4745
@node Pragma Task_Storage
4746
@unnumberedsec Pragma Task_Storage
4747
@findex Task_Storage
4748
Syntax:
4749
 
4750
@smallexample @c ada
4751
pragma Task_Storage (
4752
  [Task_Type =>] LOCAL_NAME,
4753
  [Top_Guard =>] static_integer_EXPRESSION);
4754
@end smallexample
4755
 
4756
@noindent
4757
This pragma specifies the length of the guard area for tasks.  The guard
4758
area is an additional storage area allocated to a task.  A value of zero
4759
means that either no guard area is created or a minimal guard area is
4760
created, depending on the target.  This pragma can appear anywhere a
4761
@code{Storage_Size} attribute definition clause is allowed for a task
4762
type.
4763
 
4764
@node Pragma Thread_Local_Storage
4765
@unnumberedsec Pragma Thread_Local_Storage
4766
@findex Thread_Local_Storage
4767
@cindex Task specific storage
4768
@cindex TLS (Thread Local Storage)
4769
Syntax:
4770
 
4771
@smallexample @c ada
4772
pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4773
@end smallexample
4774
 
4775
@noindent
4776
This pragma specifies that the specified entity, which must be
4777
a variable declared in a library level package, is to be marked as
4778
"Thread Local Storage" (@code{TLS}). On systems supporting this (which
4779
include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4780
(and hence each Ada task) to see a distinct copy of the variable.
4781
 
4782
The variable may not have default initialization, and if there is
4783
an explicit initialization, it must be either @code{null} for an
4784
access variable, or a static expression for a scalar variable.
4785
This provides a low level mechanism similar to that provided by
4786
the @code{Ada.Task_Attributes} package, but much more efficient
4787
and is also useful in writing interface code that will interact
4788
with foreign threads.
4789
 
4790
If this pragma is used on a system where @code{TLS} is not supported,
4791
then an error message will be generated and the program will be rejected.
4792
 
4793
@node Pragma Time_Slice
4794
@unnumberedsec Pragma Time_Slice
4795
@findex Time_Slice
4796
@noindent
4797
Syntax:
4798
 
4799
@smallexample @c ada
4800
pragma Time_Slice (static_duration_EXPRESSION);
4801
@end smallexample
4802
 
4803
@noindent
4804
For implementations of GNAT on operating systems where it is possible
4805
to supply a time slice value, this pragma may be used for this purpose.
4806
It is ignored if it is used in a system that does not allow this control,
4807
or if it appears in other than the main program unit.
4808
@cindex OpenVMS
4809
Note that the effect of this pragma is identical to the effect of the
4810
DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4811
 
4812
@node Pragma Title
4813
@unnumberedsec Pragma Title
4814
@findex Title
4815
@noindent
4816
Syntax:
4817
 
4818
@smallexample @c ada
4819
pragma Title (TITLING_OPTION [, TITLING OPTION]);
4820
 
4821
TITLING_OPTION ::=
4822
  [Title    =>] STRING_LITERAL,
4823
| [Subtitle =>] STRING_LITERAL
4824
@end smallexample
4825
 
4826
@noindent
4827
Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4828
pragma used in DEC Ada 83 implementations to provide a title and/or
4829
subtitle for the program listing.  The program listing generated by GNAT
4830
does not have titles or subtitles.
4831
 
4832
Unlike other pragmas, the full flexibility of named notation is allowed
4833
for this pragma, i.e.@: the parameters may be given in any order if named
4834
notation is used, and named and positional notation can be mixed
4835
following the normal rules for procedure calls in Ada.
4836
 
4837
@node Pragma Unchecked_Union
4838
@unnumberedsec Pragma Unchecked_Union
4839
@cindex Unions in C
4840
@findex Unchecked_Union
4841
@noindent
4842
Syntax:
4843
 
4844
@smallexample @c ada
4845
pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4846
@end smallexample
4847
 
4848
@noindent
4849
This pragma is used to specify a representation of a record type that is
4850
equivalent to a C union. It was introduced as a GNAT implementation defined
4851
pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4852
pragma, making it language defined, and GNAT fully implements this extended
4853
version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4854
details, consult the Ada 2005 Reference Manual, section B.3.3.
4855
 
4856
@node Pragma Unimplemented_Unit
4857
@unnumberedsec Pragma Unimplemented_Unit
4858
@findex Unimplemented_Unit
4859
@noindent
4860
Syntax:
4861
 
4862
@smallexample @c ada
4863
pragma Unimplemented_Unit;
4864
@end smallexample
4865
 
4866
@noindent
4867
If this pragma occurs in a unit that is processed by the compiler, GNAT
4868
aborts with the message @samp{@var{xxx} not implemented}, where
4869
@var{xxx} is the name of the current compilation unit.  This pragma is
4870
intended to allow the compiler to handle unimplemented library units in
4871
a clean manner.
4872
 
4873
The abort only happens if code is being generated.  Thus you can use
4874
specs of unimplemented packages in syntax or semantic checking mode.
4875
 
4876
@node Pragma Universal_Aliasing
4877
@unnumberedsec Pragma Universal_Aliasing
4878
@findex Universal_Aliasing
4879
@noindent
4880
Syntax:
4881
 
4882
@smallexample @c ada
4883
pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4884
@end smallexample
4885
 
4886
@noindent
4887
@var{type_LOCAL_NAME} must refer to a type declaration in the current
4888
declarative part.  The effect is to inhibit strict type-based aliasing
4889
optimization for the given type.  In other words, the effect is as though
4890
access types designating this type were subject to pragma No_Strict_Aliasing.
4891
For a detailed description of the strict aliasing optimization, and the
4892
situations in which it must be suppressed, @xref{Optimization and Strict
4893
Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4894
 
4895
@node Pragma Universal_Data
4896
@unnumberedsec Pragma Universal_Data
4897
@findex Universal_Data
4898
@noindent
4899
Syntax:
4900
 
4901
@smallexample @c ada
4902
pragma Universal_Data [(library_unit_Name)];
4903
@end smallexample
4904
 
4905
@noindent
4906
This pragma is supported only for the AAMP target and is ignored for
4907
other targets. The pragma specifies that all library-level objects
4908
(Counter 0 data) associated with the library unit are to be accessed
4909
and updated using universal addressing (24-bit addresses for AAMP5)
4910
rather than the default of 16-bit Data Environment (DENV) addressing.
4911
Use of this pragma will generally result in less efficient code for
4912
references to global data associated with the library unit, but
4913
allows such data to be located anywhere in memory. This pragma is
4914
a library unit pragma, but can also be used as a configuration pragma
4915
(including use in the @file{gnat.adc} file). The functionality
4916
of this pragma is also available by applying the -univ switch on the
4917
compilations of units where universal addressing of the data is desired.
4918
 
4919
@node Pragma Unmodified
4920
@unnumberedsec Pragma Unmodified
4921
@findex Unmodified
4922
@cindex Warnings, unmodified
4923
@noindent
4924
Syntax:
4925
 
4926
@smallexample @c ada
4927
pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4928
@end smallexample
4929
 
4930
@noindent
4931
This pragma signals that the assignable entities (variables,
4932
@code{out} parameters, @code{in out} parameters) whose names are listed are
4933
deliberately not assigned in the current source unit. This
4934
suppresses warnings about the
4935
entities being referenced but not assigned, and in addition a warning will be
4936
generated if one of these entities is in fact assigned in the
4937
same unit as the pragma (or in the corresponding body, or one
4938
of its subunits).
4939
 
4940
This is particularly useful for clearly signaling that a particular
4941
parameter is not modified, even though the spec suggests that it might
4942
be.
4943
 
4944
@node Pragma Unreferenced
4945
@unnumberedsec Pragma Unreferenced
4946
@findex Unreferenced
4947
@cindex Warnings, unreferenced
4948
@noindent
4949
Syntax:
4950
 
4951
@smallexample @c ada
4952
pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4953
pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4954
@end smallexample
4955
 
4956
@noindent
4957
This pragma signals that the entities whose names are listed are
4958
deliberately not referenced in the current source unit. This
4959
suppresses warnings about the
4960
entities being unreferenced, and in addition a warning will be
4961
generated if one of these entities is in fact referenced in the
4962
same unit as the pragma (or in the corresponding body, or one
4963
of its subunits).
4964
 
4965
This is particularly useful for clearly signaling that a particular
4966
parameter is not referenced in some particular subprogram implementation
4967
and that this is deliberate. It can also be useful in the case of
4968
objects declared only for their initialization or finalization side
4969
effects.
4970
 
4971
If @code{LOCAL_NAME} identifies more than one matching homonym in the
4972
current scope, then the entity most recently declared is the one to which
4973
the pragma applies. Note that in the case of accept formals, the pragma
4974
Unreferenced may appear immediately after the keyword @code{do} which
4975
allows the indication of whether or not accept formals are referenced
4976
or not to be given individually for each accept statement.
4977
 
4978
The left hand side of an assignment does not count as a reference for the
4979
purpose of this pragma. Thus it is fine to assign to an entity for which
4980
pragma Unreferenced is given.
4981
 
4982
Note that if a warning is desired for all calls to a given subprogram,
4983
regardless of whether they occur in the same unit as the subprogram
4984
declaration, then this pragma should not be used (calls from another
4985
unit would not be flagged); pragma Obsolescent can be used instead
4986
for this purpose, see @xref{Pragma Obsolescent}.
4987
 
4988
The second form of pragma @code{Unreferenced} is used within a context
4989
clause. In this case the arguments must be unit names of units previously
4990
mentioned in @code{with} clauses (similar to the usage of pragma
4991
@code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4992
units and unreferenced entities within these units.
4993
 
4994
@node Pragma Unreferenced_Objects
4995
@unnumberedsec Pragma Unreferenced_Objects
4996
@findex Unreferenced_Objects
4997
@cindex Warnings, unreferenced
4998
@noindent
4999
Syntax:
5000
 
5001
@smallexample @c ada
5002
pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5003
@end smallexample
5004
 
5005
@noindent
5006
This pragma signals that for the types or subtypes whose names are
5007
listed, objects which are declared with one of these types or subtypes may
5008
not be referenced, and if no references appear, no warnings are given.
5009
 
5010
This is particularly useful for objects which are declared solely for their
5011
initialization and finalization effect. Such variables are sometimes referred
5012
to as RAII variables (Resource Acquisition Is Initialization). Using this
5013
pragma on the relevant type (most typically a limited controlled type), the
5014
compiler will automatically suppress unwanted warnings about these variables
5015
not being referenced.
5016
 
5017
@node Pragma Unreserve_All_Interrupts
5018
@unnumberedsec Pragma Unreserve_All_Interrupts
5019
@findex Unreserve_All_Interrupts
5020
@noindent
5021
Syntax:
5022
 
5023
@smallexample @c ada
5024
pragma Unreserve_All_Interrupts;
5025
@end smallexample
5026
 
5027
@noindent
5028
Normally certain interrupts are reserved to the implementation.  Any attempt
5029
to attach an interrupt causes Program_Error to be raised, as described in
5030
RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5031
many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5032
reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5033
interrupt execution.
5034
 
5035
If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5036
a program, then all such interrupts are unreserved.  This allows the
5037
program to handle these interrupts, but disables their standard
5038
functions.  For example, if this pragma is used, then pressing
5039
@kbd{Ctrl-C} will not automatically interrupt execution.  However,
5040
a program can then handle the @code{SIGINT} interrupt as it chooses.
5041
 
5042
For a full list of the interrupts handled in a specific implementation,
5043
see the source code for the spec of @code{Ada.Interrupts.Names} in
5044
file @file{a-intnam.ads}.  This is a target dependent file that contains the
5045
list of interrupts recognized for a given target.  The documentation in
5046
this file also specifies what interrupts are affected by the use of
5047
the @code{Unreserve_All_Interrupts} pragma.
5048
 
5049
For a more general facility for controlling what interrupts can be
5050
handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5051
of the @code{Unreserve_All_Interrupts} pragma.
5052
 
5053
@node Pragma Unsuppress
5054
@unnumberedsec Pragma Unsuppress
5055
@findex Unsuppress
5056
@noindent
5057
Syntax:
5058
 
5059
@smallexample @c ada
5060
pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5061
@end smallexample
5062
 
5063
@noindent
5064
This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5065
there is no corresponding pragma @code{Suppress} in effect, it has no
5066
effect.  The range of the effect is the same as for pragma
5067
@code{Suppress}.  The meaning of the arguments is identical to that used
5068
in pragma @code{Suppress}.
5069
 
5070
One important application is to ensure that checks are on in cases where
5071
code depends on the checks for its correct functioning, so that the code
5072
will compile correctly even if the compiler switches are set to suppress
5073
checks.
5074
 
5075
@node Pragma Use_VADS_Size
5076
@unnumberedsec Pragma Use_VADS_Size
5077
@cindex @code{Size}, VADS compatibility
5078
@findex Use_VADS_Size
5079
@noindent
5080
Syntax:
5081
 
5082
@smallexample @c ada
5083
pragma Use_VADS_Size;
5084
@end smallexample
5085
 
5086
@noindent
5087
This is a configuration pragma.  In a unit to which it applies, any use
5088
of the 'Size attribute is automatically interpreted as a use of the
5089
'VADS_Size attribute.  Note that this may result in incorrect semantic
5090
processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5091
the handling of existing code which depends on the interpretation of Size
5092
as implemented in the VADS compiler.  See description of the VADS_Size
5093
attribute for further details.
5094
 
5095
@node Pragma Validity_Checks
5096
@unnumberedsec Pragma Validity_Checks
5097
@findex Validity_Checks
5098
@noindent
5099
Syntax:
5100
 
5101
@smallexample @c ada
5102
pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5103
@end smallexample
5104
 
5105
@noindent
5106
This pragma is used in conjunction with compiler switches to control the
5107
built-in validity checking provided by GNAT@.  The compiler switches, if set
5108
provide an initial setting for the switches, and this pragma may be used
5109
to modify these settings, or the settings may be provided entirely by
5110
the use of the pragma.  This pragma can be used anywhere that a pragma
5111
is legal, including use as a configuration pragma (including use in
5112
the @file{gnat.adc} file).
5113
 
5114
The form with a string literal specifies which validity options are to be
5115
activated.  The validity checks are first set to include only the default
5116
reference manual settings, and then a string of letters in the string
5117
specifies the exact set of options required.  The form of this string
5118
is exactly as described for the @option{-gnatVx} compiler switch (see the
5119
GNAT users guide for details).  For example the following two methods
5120
can be used to enable validity checking for mode @code{in} and
5121
@code{in out} subprogram parameters:
5122
 
5123
@itemize @bullet
5124
@item
5125
@smallexample @c ada
5126
pragma Validity_Checks ("im");
5127
@end smallexample
5128
 
5129
@item
5130
@smallexample
5131
gcc -c -gnatVim @dots{}
5132
@end smallexample
5133
@end itemize
5134
 
5135
@noindent
5136
The form ALL_CHECKS activates all standard checks (its use is equivalent
5137
to the use of the @code{gnatva} switch.
5138
 
5139
The forms with @code{Off} and @code{On}
5140
can be used to temporarily disable validity checks
5141
as shown in the following example:
5142
 
5143
@smallexample @c ada
5144
@iftex
5145
@leftskip=0cm
5146
@end iftex
5147
pragma Validity_Checks ("c"); -- validity checks for copies
5148
pragma Validity_Checks (Off); -- turn off validity checks
5149
A := B;                       -- B will not be validity checked
5150
pragma Validity_Checks (On);  -- turn validity checks back on
5151
A := C;                       -- C will be validity checked
5152
@end smallexample
5153
 
5154
@node Pragma Volatile
5155
@unnumberedsec Pragma Volatile
5156
@findex Volatile
5157
@noindent
5158
Syntax:
5159
 
5160
@smallexample @c ada
5161
pragma Volatile (LOCAL_NAME);
5162
@end smallexample
5163
 
5164
@noindent
5165
This pragma is defined by the Ada Reference Manual, and the GNAT
5166
implementation is fully conformant with this definition.  The reason it
5167
is mentioned in this section is that a pragma of the same name was supplied
5168
in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5169
implementation of pragma Volatile is upwards compatible with the
5170
implementation in DEC Ada 83.
5171
 
5172
@node Pragma Warnings
5173
@unnumberedsec Pragma Warnings
5174
@findex Warnings
5175
@noindent
5176
Syntax:
5177
 
5178
@smallexample @c ada
5179
pragma Warnings (On | Off);
5180
pragma Warnings (On | Off, LOCAL_NAME);
5181
pragma Warnings (static_string_EXPRESSION);
5182
pragma Warnings (On | Off, static_string_EXPRESSION);
5183
@end smallexample
5184
 
5185
@noindent
5186
Normally warnings are enabled, with the output being controlled by
5187
the command line switch.  Warnings (@code{Off}) turns off generation of
5188
warnings until a Warnings (@code{On}) is encountered or the end of the
5189
current unit.  If generation of warnings is turned off using this
5190
pragma, then no warning messages are output, regardless of the
5191
setting of the command line switches.
5192
 
5193
The form with a single argument may be used as a configuration pragma.
5194
 
5195
If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5196
the specified entity.  This suppression is effective from the point where
5197
it occurs till the end of the extended scope of the variable (similar to
5198
the scope of @code{Suppress}).
5199
 
5200
The form with a single static_string_EXPRESSION argument provides more precise
5201
control over which warnings are active. The string is a list of letters
5202
specifying which warnings are to be activated and which deactivated. The
5203
code for these letters is the same as the string used in the command
5204
line switch controlling warnings. For a brief summary, use the gnatmake
5205
command with no arguments, which will generate usage information containing
5206
the list of warnings switches supported. For
5207
full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5208
User's Guide}.
5209
 
5210
@noindent
5211
The specified warnings will be in effect until the end of the program
5212
or another pragma Warnings is encountered. The effect of the pragma is
5213
cumulative. Initially the set of warnings is the standard default set
5214
as possibly modified by compiler switches. Then each pragma Warning
5215
modifies this set of warnings as specified. This form of the pragma may
5216
also be used as a configuration pragma.
5217
 
5218
The fourth form, with an On|Off parameter and a string, is used to
5219
control individual messages, based on their text. The string argument
5220
is a pattern that is used to match against the text of individual
5221
warning messages (not including the initial "warning: " tag).
5222
 
5223
The pattern may contain asterisks, which match zero or more characters in
5224
the message. For example, you can use
5225
@code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5226
message @code{warning: 960 bits of "a" unused}. No other regular
5227
expression notations are permitted. All characters other than asterisk in
5228
these three specific cases are treated as literal characters in the match.
5229
 
5230
There are two ways to use this pragma. The OFF form can be used as a
5231
configuration pragma. The effect is to suppress all warnings (if any)
5232
that match the pattern string throughout the compilation.
5233
 
5234
The second usage is to suppress a warning locally, and in this case, two
5235
pragmas must appear in sequence:
5236
 
5237
@smallexample @c ada
5238
pragma Warnings (Off, Pattern);
5239
@dots{} code where given warning is to be suppressed
5240
pragma Warnings (On, Pattern);
5241
@end smallexample
5242
 
5243
@noindent
5244
In this usage, the pattern string must match in the Off and On pragmas,
5245
and at least one matching warning must be suppressed.
5246
 
5247
Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5248
used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5249
be useful in checking whether obsolete pragmas in existing programs are hiding
5250
real problems.
5251
 
5252
@node Pragma Weak_External
5253
@unnumberedsec Pragma Weak_External
5254
@findex Weak_External
5255
@noindent
5256
Syntax:
5257
 
5258
@smallexample @c ada
5259
pragma Weak_External ([Entity =>] LOCAL_NAME);
5260
@end smallexample
5261
 
5262
@noindent
5263
@var{LOCAL_NAME} must refer to an object that is declared at the library
5264
level. This pragma specifies that the given entity should be marked as a
5265
weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5266
in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5267
of a regular symbol, that is to say a symbol that does not have to be
5268
resolved by the linker if used in conjunction with a pragma Import.
5269
 
5270
When a weak symbol is not resolved by the linker, its address is set to
5271
zero. This is useful in writing interfaces to external modules that may
5272
or may not be linked in the final executable, for example depending on
5273
configuration settings.
5274
 
5275
If a program references at run time an entity to which this pragma has been
5276
applied, and the corresponding symbol was not resolved at link time, then
5277
the execution of the program is erroneous. It is not erroneous to take the
5278
Address of such an entity, for example to guard potential references,
5279
as shown in the example below.
5280
 
5281
Some file formats do not support weak symbols so not all target machines
5282
support this pragma.
5283
 
5284
@smallexample @c ada
5285
--  Example of the use of pragma Weak_External
5286
 
5287
package External_Module is
5288
  key : Integer;
5289
  pragma Import (C, key);
5290
  pragma Weak_External (key);
5291
  function Present return boolean;
5292
end External_Module;
5293
 
5294
with System; use System;
5295
package body External_Module is
5296
  function Present return boolean is
5297
  begin
5298
    return key'Address /= System.Null_Address;
5299
  end Present;
5300
end External_Module;
5301
@end smallexample
5302
 
5303
@node Pragma Wide_Character_Encoding
5304
@unnumberedsec Pragma Wide_Character_Encoding
5305
@findex Wide_Character_Encoding
5306
@noindent
5307
Syntax:
5308
 
5309
@smallexample @c ada
5310
pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5311
@end smallexample
5312
 
5313
@noindent
5314
This pragma specifies the wide character encoding to be used in program
5315
source text appearing subsequently. It is a configuration pragma, but may
5316
also be used at any point that a pragma is allowed, and it is permissible
5317
to have more than one such pragma in a file, allowing multiple encodings
5318
to appear within the same file.
5319
 
5320
The argument can be an identifier or a character literal. In the identifier
5321
case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5322
@code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5323
case it is correspondingly one of the characters @samp{h}, @samp{u},
5324
@samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5325
 
5326
Note that when the pragma is used within a file, it affects only the
5327
encoding within that file, and does not affect withed units, specs,
5328
or subunits.
5329
 
5330
@node Implementation Defined Attributes
5331
@chapter Implementation Defined Attributes
5332
Ada defines (throughout the Ada reference manual,
5333
summarized in Annex K),
5334
a set of attributes that provide useful additional functionality in all
5335
areas of the language.  These language defined attributes are implemented
5336
in GNAT and work as described in the Ada Reference Manual.
5337
 
5338
In addition, Ada allows implementations to define additional
5339
attributes whose meaning is defined by the implementation.  GNAT provides
5340
a number of these implementation-dependent attributes which can be used
5341
to extend and enhance the functionality of the compiler.  This section of
5342
the GNAT reference manual describes these additional attributes.
5343
 
5344
Note that any program using these attributes may not be portable to
5345
other compilers (although GNAT implements this set of attributes on all
5346
platforms).  Therefore if portability to other compilers is an important
5347
consideration, you should minimize the use of these attributes.
5348
 
5349
@menu
5350
* Abort_Signal::
5351
* Address_Size::
5352
* Asm_Input::
5353
* Asm_Output::
5354
* AST_Entry::
5355
* Bit::
5356
* Bit_Position::
5357
* Compiler_Version::
5358
* Code_Address::
5359
* Default_Bit_Order::
5360
* Elaborated::
5361
* Elab_Body::
5362
* Elab_Spec::
5363
* Emax::
5364
* Enabled::
5365
* Enum_Rep::
5366
* Enum_Val::
5367
* Epsilon::
5368
* Fixed_Value::
5369
* Has_Access_Values::
5370
* Has_Discriminants::
5371
* Img::
5372
* Integer_Value::
5373
* Invalid_Value::
5374
* Large::
5375
* Machine_Size::
5376
* Mantissa::
5377
* Max_Interrupt_Priority::
5378
* Max_Priority::
5379
* Maximum_Alignment::
5380
* Mechanism_Code::
5381
* Null_Parameter::
5382
* Object_Size::
5383
* Old::
5384
* Passed_By_Reference::
5385
* Pool_Address::
5386
* Range_Length::
5387
* Result::
5388
* Safe_Emax::
5389
* Safe_Large::
5390
* Small::
5391
* Storage_Unit::
5392
* Stub_Type::
5393
* Target_Name::
5394
* Tick::
5395
* To_Address::
5396
* Type_Class::
5397
* UET_Address::
5398
* Unconstrained_Array::
5399
* Universal_Literal_String::
5400
* Unrestricted_Access::
5401
* VADS_Size::
5402
* Value_Size::
5403
* Wchar_T_Size::
5404
* Word_Size::
5405
@end menu
5406
 
5407
@node Abort_Signal
5408
@unnumberedsec Abort_Signal
5409
@findex Abort_Signal
5410
@noindent
5411
@code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5412
prefix) provides the entity for the special exception used to signal
5413
task abort or asynchronous transfer of control.  Normally this attribute
5414
should only be used in the tasking runtime (it is highly peculiar, and
5415
completely outside the normal semantics of Ada, for a user program to
5416
intercept the abort exception).
5417
 
5418
@node Address_Size
5419
@unnumberedsec Address_Size
5420
@cindex Size of @code{Address}
5421
@findex Address_Size
5422
@noindent
5423
@code{Standard'Address_Size} (@code{Standard} is the only allowed
5424
prefix) is a static constant giving the number of bits in an
5425
@code{Address}. It is the same value as System.Address'Size,
5426
but has the advantage of being static, while a direct
5427
reference to System.Address'Size is non-static because Address
5428
is a private type.
5429
 
5430
@node Asm_Input
5431
@unnumberedsec Asm_Input
5432
@findex Asm_Input
5433
@noindent
5434
The @code{Asm_Input} attribute denotes a function that takes two
5435
parameters.  The first is a string, the second is an expression of the
5436
type designated by the prefix.  The first (string) argument is required
5437
to be a static expression, and is the constraint for the parameter,
5438
(e.g.@: what kind of register is required).  The second argument is the
5439
value to be used as the input argument.  The possible values for the
5440
constant are the same as those used in the RTL, and are dependent on
5441
the configuration file used to built the GCC back end.
5442
@ref{Machine Code Insertions}
5443
 
5444
@node Asm_Output
5445
@unnumberedsec Asm_Output
5446
@findex Asm_Output
5447
@noindent
5448
The @code{Asm_Output} attribute denotes a function that takes two
5449
parameters.  The first is a string, the second is the name of a variable
5450
of the type designated by the attribute prefix.  The first (string)
5451
argument is required to be a static expression and designates the
5452
constraint for the parameter (e.g.@: what kind of register is
5453
required).  The second argument is the variable to be updated with the
5454
result.  The possible values for constraint are the same as those used in
5455
the RTL, and are dependent on the configuration file used to build the
5456
GCC back end.  If there are no output operands, then this argument may
5457
either be omitted, or explicitly given as @code{No_Output_Operands}.
5458
@ref{Machine Code Insertions}
5459
 
5460
@node AST_Entry
5461
@unnumberedsec AST_Entry
5462
@cindex OpenVMS
5463
@findex AST_Entry
5464
@noindent
5465
This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5466
the name of an entry, it yields a value of the predefined type AST_Handler
5467
(declared in the predefined package System, as extended by the use of
5468
pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5469
be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5470
Language Reference Manual}, section 9.12a.
5471
 
5472
@node Bit
5473
@unnumberedsec Bit
5474
@findex Bit
5475
@code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5476
offset within the storage unit (byte) that contains the first bit of
5477
storage allocated for the object.  The value of this attribute is of the
5478
type @code{Universal_Integer}, and is always a non-negative number not
5479
exceeding the value of @code{System.Storage_Unit}.
5480
 
5481
For an object that is a variable or a constant allocated in a register,
5482
the value is zero.  (The use of this attribute does not force the
5483
allocation of a variable to memory).
5484
 
5485
For an object that is a formal parameter, this attribute applies
5486
to either the matching actual parameter or to a copy of the
5487
matching actual parameter.
5488
 
5489
For an access object the value is zero.  Note that
5490
@code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5491
designated object.  Similarly for a record component
5492
@code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5493
@code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5494
are subject to index checks.
5495
 
5496
This attribute is designed to be compatible with the DEC Ada 83 definition
5497
and implementation of the @code{Bit} attribute.
5498
 
5499
@node Bit_Position
5500
@unnumberedsec Bit_Position
5501
@findex Bit_Position
5502
@noindent
5503
@code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5504
of the fields of the record type, yields the bit
5505
offset within the record contains the first bit of
5506
storage allocated for the object.  The value of this attribute is of the
5507
type @code{Universal_Integer}.  The value depends only on the field
5508
@var{C} and is independent of the alignment of
5509
the containing record @var{R}.
5510
 
5511
@node Compiler_Version
5512
@unnumberedsec Compiler_Version
5513
@findex Compiler_Version
5514
@noindent
5515
@code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5516
prefix) yields a static string identifying the version of the compiler
5517
being used to compile the unit containing the attribute reference. A
5518
typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5519
 
5520
@node Code_Address
5521
@unnumberedsec Code_Address
5522
@findex Code_Address
5523
@cindex Subprogram address
5524
@cindex Address of subprogram code
5525
@noindent
5526
The @code{'Address}
5527
attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5528
intended effect seems to be to provide
5529
an address value which can be used to call the subprogram by means of
5530
an address clause as in the following example:
5531
 
5532
@smallexample @c ada
5533
procedure K is @dots{}
5534
 
5535
procedure L;
5536
for L'Address use K'Address;
5537
pragma Import (Ada, L);
5538
@end smallexample
5539
 
5540
@noindent
5541
A call to @code{L} is then expected to result in a call to @code{K}@.
5542
In Ada 83, where there were no access-to-subprogram values, this was
5543
a common work-around for getting the effect of an indirect call.
5544
GNAT implements the above use of @code{Address} and the technique
5545
illustrated by the example code works correctly.
5546
 
5547
However, for some purposes, it is useful to have the address of the start
5548
of the generated code for the subprogram.  On some architectures, this is
5549
not necessarily the same as the @code{Address} value described above.
5550
For example, the @code{Address} value may reference a subprogram
5551
descriptor rather than the subprogram itself.
5552
 
5553
The @code{'Code_Address} attribute, which can only be applied to
5554
subprogram entities, always returns the address of the start of the
5555
generated code of the specified subprogram, which may or may not be
5556
the same value as is returned by the corresponding @code{'Address}
5557
attribute.
5558
 
5559
@node Default_Bit_Order
5560
@unnumberedsec Default_Bit_Order
5561
@cindex Big endian
5562
@cindex Little endian
5563
@findex Default_Bit_Order
5564
@noindent
5565
@code{Standard'Default_Bit_Order} (@code{Standard} is the only
5566
permissible prefix), provides the value @code{System.Default_Bit_Order}
5567
as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5568
@code{Low_Order_First}).  This is used to construct the definition of
5569
@code{Default_Bit_Order} in package @code{System}.
5570
 
5571
@node Elaborated
5572
@unnumberedsec Elaborated
5573
@findex Elaborated
5574
@noindent
5575
The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5576
value is a Boolean which indicates whether or not the given unit has been
5577
elaborated.  This attribute is primarily intended for internal use by the
5578
generated code for dynamic elaboration checking, but it can also be used
5579
in user programs.  The value will always be True once elaboration of all
5580
units has been completed.  An exception is for units which need no
5581
elaboration, the value is always False for such units.
5582
 
5583
@node Elab_Body
5584
@unnumberedsec Elab_Body
5585
@findex Elab_Body
5586
@noindent
5587
This attribute can only be applied to a program unit name.  It returns
5588
the entity for the corresponding elaboration procedure for elaborating
5589
the body of the referenced unit.  This is used in the main generated
5590
elaboration procedure by the binder and is not normally used in any
5591
other context.  However, there may be specialized situations in which it
5592
is useful to be able to call this elaboration procedure from Ada code,
5593
e.g.@: if it is necessary to do selective re-elaboration to fix some
5594
error.
5595
 
5596
@node Elab_Spec
5597
@unnumberedsec Elab_Spec
5598
@findex Elab_Spec
5599
@noindent
5600
This attribute can only be applied to a program unit name.  It returns
5601
the entity for the corresponding elaboration procedure for elaborating
5602
the spec of the referenced unit.  This is used in the main
5603
generated elaboration procedure by the binder and is not normally used
5604
in any other context.  However, there may be specialized situations in
5605
which it is useful to be able to call this elaboration procedure from
5606
Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5607
some error.
5608
 
5609
@node Emax
5610
@unnumberedsec Emax
5611
@cindex Ada 83 attributes
5612
@findex Emax
5613
@noindent
5614
The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5615
the Ada 83 reference manual for an exact description of the semantics of
5616
this attribute.
5617
 
5618
@node Enabled
5619
@unnumberedsec Enabled
5620
@findex Enabled
5621
@noindent
5622
The @code{Enabled} attribute allows an application program to check at compile
5623
time to see if the designated check is currently enabled. The prefix is a
5624
simple identifier, referencing any predefined check name (other than
5625
@code{All_Checks}) or a check name introduced by pragma Check_Name. If
5626
no argument is given for the attribute, the check is for the general state
5627
of the check, if an argument is given, then it is an entity name, and the
5628
check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5629
given naming the entity (if not, then the argument is ignored).
5630
 
5631
Note that instantiations inherit the check status at the point of the
5632
instantiation, so a useful idiom is to have a library package that
5633
introduces a check name with @code{pragma Check_Name}, and then contains
5634
generic packages or subprograms which use the @code{Enabled} attribute
5635
to see if the check is enabled. A user of this package can then issue
5636
a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5637
the package or subprogram, controlling whether the check will be present.
5638
 
5639
@node Enum_Rep
5640
@unnumberedsec Enum_Rep
5641
@cindex Representation of enums
5642
@findex Enum_Rep
5643
@noindent
5644
For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5645
function with the following spec:
5646
 
5647
@smallexample @c ada
5648
function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5649
  return @i{Universal_Integer};
5650
@end smallexample
5651
 
5652
@noindent
5653
It is also allowable to apply @code{Enum_Rep} directly to an object of an
5654
enumeration type or to a non-overloaded enumeration
5655
literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5656
@code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5657
enumeration literal or object.
5658
 
5659
The function returns the representation value for the given enumeration
5660
value.  This will be equal to value of the @code{Pos} attribute in the
5661
absence of an enumeration representation clause.  This is a static
5662
attribute (i.e.@: the result is static if the argument is static).
5663
 
5664
@code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5665
in which case it simply returns the integer value.  The reason for this
5666
is to allow it to be used for @code{(<>)} discrete formal arguments in
5667
a generic unit that can be instantiated with either enumeration types
5668
or integer types.  Note that if @code{Enum_Rep} is used on a modular
5669
type whose upper bound exceeds the upper bound of the largest signed
5670
integer type, and the argument is a variable, so that the universal
5671
integer calculation is done at run time, then the call to @code{Enum_Rep}
5672
may raise @code{Constraint_Error}.
5673
 
5674
@node Enum_Val
5675
@unnumberedsec Enum_Val
5676
@cindex Representation of enums
5677
@findex Enum_Val
5678
@noindent
5679
For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5680
function with the following spec:
5681
 
5682
@smallexample @c ada
5683
function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5684
  return @var{S}'Base};
5685
@end smallexample
5686
 
5687
@noindent
5688
The function returns the enumeration value whose representation matches the
5689
argument, or raises Constraint_Error if no enumeration literal of the type
5690
has the matching value.
5691
This will be equal to value of the @code{Val} attribute in the
5692
absence of an enumeration representation clause.  This is a static
5693
attribute (i.e.@: the result is static if the argument is static).
5694
 
5695
@node Epsilon
5696
@unnumberedsec Epsilon
5697
@cindex Ada 83 attributes
5698
@findex Epsilon
5699
@noindent
5700
The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5701
the Ada 83 reference manual for an exact description of the semantics of
5702
this attribute.
5703
 
5704
@node Fixed_Value
5705
@unnumberedsec Fixed_Value
5706
@findex Fixed_Value
5707
@noindent
5708
For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5709
function with the following specification:
5710
 
5711
@smallexample @c ada
5712
function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5713
  return @var{S};
5714
@end smallexample
5715
 
5716
@noindent
5717
The value returned is the fixed-point value @var{V} such that
5718
 
5719
@smallexample @c ada
5720
@var{V} = Arg * @var{S}'Small
5721
@end smallexample
5722
 
5723
@noindent
5724
The effect is thus similar to first converting the argument to the
5725
integer type used to represent @var{S}, and then doing an unchecked
5726
conversion to the fixed-point type.  The difference is
5727
that there are full range checks, to ensure that the result is in range.
5728
This attribute is primarily intended for use in implementation of the
5729
input-output functions for fixed-point values.
5730
 
5731
@node Has_Access_Values
5732
@unnumberedsec Has_Access_Values
5733
@cindex Access values, testing for
5734
@findex Has_Access_Values
5735
@noindent
5736
The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5737
is a Boolean value which is True if the is an access type, or is a composite
5738
type with a component (at any nesting depth) that is an access type, and is
5739
False otherwise.
5740
The intended use of this attribute is in conjunction with generic
5741
definitions.  If the attribute is applied to a generic private type, it
5742
indicates whether or not the corresponding actual type has access values.
5743
 
5744
@node Has_Discriminants
5745
@unnumberedsec Has_Discriminants
5746
@cindex Discriminants, testing for
5747
@findex Has_Discriminants
5748
@noindent
5749
The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5750
is a Boolean value which is True if the type has discriminants, and False
5751
otherwise.  The intended use of this attribute is in conjunction with generic
5752
definitions.  If the attribute is applied to a generic private type, it
5753
indicates whether or not the corresponding actual type has discriminants.
5754
 
5755
@node Img
5756
@unnumberedsec Img
5757
@findex Img
5758
@noindent
5759
The @code{Img} attribute differs from @code{Image} in that it may be
5760
applied to objects as well as types, in which case it gives the
5761
@code{Image} for the subtype of the object.  This is convenient for
5762
debugging:
5763
 
5764
@smallexample @c ada
5765
Put_Line ("X = " & X'Img);
5766
@end smallexample
5767
 
5768
@noindent
5769
has the same meaning as the more verbose:
5770
 
5771
@smallexample @c ada
5772
Put_Line ("X = " & @var{T}'Image (X));
5773
@end smallexample
5774
 
5775
@noindent
5776
where @var{T} is the (sub)type of the object @code{X}.
5777
 
5778
@node Integer_Value
5779
@unnumberedsec Integer_Value
5780
@findex Integer_Value
5781
@noindent
5782
For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5783
function with the following spec:
5784
 
5785
@smallexample @c ada
5786
function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5787
  return @var{S};
5788
@end smallexample
5789
 
5790
@noindent
5791
The value returned is the integer value @var{V}, such that
5792
 
5793
@smallexample @c ada
5794
Arg = @var{V} * @var{T}'Small
5795
@end smallexample
5796
 
5797
@noindent
5798
where @var{T} is the type of @code{Arg}.
5799
The effect is thus similar to first doing an unchecked conversion from
5800
the fixed-point type to its corresponding implementation type, and then
5801
converting the result to the target integer type.  The difference is
5802
that there are full range checks, to ensure that the result is in range.
5803
This attribute is primarily intended for use in implementation of the
5804
standard input-output functions for fixed-point values.
5805
 
5806
@node Invalid_Value
5807
@unnumberedsec Invalid_Value
5808
@findex Invalid_Value
5809
@noindent
5810
For every scalar type S, S'Invalid_Value returns an undefined value of the
5811
type. If possible this value is an invalid representation for the type. The
5812
value returned is identical to the value used to initialize an otherwise
5813
uninitialized value of the type if pragma Initialize_Scalars is used,
5814
including the ability to modify the value with the binder -Sxx flag and
5815
relevant environment variables at run time.
5816
 
5817
@node Large
5818
@unnumberedsec Large
5819
@cindex Ada 83 attributes
5820
@findex Large
5821
@noindent
5822
The @code{Large} attribute is provided for compatibility with Ada 83.  See
5823
the Ada 83 reference manual for an exact description of the semantics of
5824
this attribute.
5825
 
5826
@node Machine_Size
5827
@unnumberedsec Machine_Size
5828
@findex Machine_Size
5829
@noindent
5830
This attribute is identical to the @code{Object_Size} attribute.  It is
5831
provided for compatibility with the DEC Ada 83 attribute of this name.
5832
 
5833
@node Mantissa
5834
@unnumberedsec Mantissa
5835
@cindex Ada 83 attributes
5836
@findex Mantissa
5837
@noindent
5838
The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5839
the Ada 83 reference manual for an exact description of the semantics of
5840
this attribute.
5841
 
5842
@node Max_Interrupt_Priority
5843
@unnumberedsec Max_Interrupt_Priority
5844
@cindex Interrupt priority, maximum
5845
@findex Max_Interrupt_Priority
5846
@noindent
5847
@code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5848
permissible prefix), provides the same value as
5849
@code{System.Max_Interrupt_Priority}.
5850
 
5851
@node Max_Priority
5852
@unnumberedsec Max_Priority
5853
@cindex Priority, maximum
5854
@findex Max_Priority
5855
@noindent
5856
@code{Standard'Max_Priority} (@code{Standard} is the only permissible
5857
prefix) provides the same value as @code{System.Max_Priority}.
5858
 
5859
@node Maximum_Alignment
5860
@unnumberedsec Maximum_Alignment
5861
@cindex Alignment, maximum
5862
@findex Maximum_Alignment
5863
@noindent
5864
@code{Standard'Maximum_Alignment} (@code{Standard} is the only
5865
permissible prefix) provides the maximum useful alignment value for the
5866
target.  This is a static value that can be used to specify the alignment
5867
for an object, guaranteeing that it is properly aligned in all
5868
cases.
5869
 
5870
@node Mechanism_Code
5871
@unnumberedsec Mechanism_Code
5872
@cindex Return values, passing mechanism
5873
@cindex Parameters, passing mechanism
5874
@findex Mechanism_Code
5875
@noindent
5876
@code{@var{function}'Mechanism_Code} yields an integer code for the
5877
mechanism used for the result of function, and
5878
@code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5879
used for formal parameter number @var{n} (a static integer value with 1
5880
meaning the first parameter) of @var{subprogram}.  The code returned is:
5881
 
5882
@table @asis
5883
@item 1
5884
by copy (value)
5885
@item 2
5886
by reference
5887
@item 3
5888
by descriptor (default descriptor class)
5889
@item 4
5890
by descriptor (UBS: unaligned bit string)
5891
@item 5
5892
by descriptor (UBSB: aligned bit string with arbitrary bounds)
5893
@item 6
5894
by descriptor (UBA: unaligned bit array)
5895
@item 7
5896
by descriptor (S: string, also scalar access type parameter)
5897
@item 8
5898
by descriptor (SB: string with arbitrary bounds)
5899
@item 9
5900
by descriptor (A: contiguous array)
5901
@item 10
5902
by descriptor (NCA: non-contiguous array)
5903
@end table
5904
 
5905
@noindent
5906
Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5907
@cindex OpenVMS
5908
 
5909
@node Null_Parameter
5910
@unnumberedsec Null_Parameter
5911
@cindex Zero address, passing
5912
@findex Null_Parameter
5913
@noindent
5914
A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5915
type or subtype @var{T} allocated at machine address zero.  The attribute
5916
is allowed only as the default expression of a formal parameter, or as
5917
an actual expression of a subprogram call.  In either case, the
5918
subprogram must be imported.
5919
 
5920
The identity of the object is represented by the address zero in the
5921
argument list, independent of the passing mechanism (explicit or
5922
default).
5923
 
5924
This capability is needed to specify that a zero address should be
5925
passed for a record or other composite object passed by reference.
5926
There is no way of indicating this without the @code{Null_Parameter}
5927
attribute.
5928
 
5929
@node Object_Size
5930
@unnumberedsec Object_Size
5931
@cindex Size, used for objects
5932
@findex Object_Size
5933
@noindent
5934
The size of an object is not necessarily the same as the size of the type
5935
of an object.  This is because by default object sizes are increased to be
5936
a multiple of the alignment of the object.  For example,
5937
@code{Natural'Size} is
5938
31, but by default objects of type @code{Natural} will have a size of 32 bits.
5939
Similarly, a record containing an integer and a character:
5940
 
5941
@smallexample @c ada
5942
type Rec is record
5943
   I : Integer;
5944
   C : Character;
5945
end record;
5946
@end smallexample
5947
 
5948
@noindent
5949
will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5950
alignment will be 4, because of the
5951
integer field, and so the default size of record objects for this type
5952
will be 64 (8 bytes).
5953
 
5954
@node Old
5955
@unnumberedsec Old
5956
@cindex Capturing Old values
5957
@cindex Postconditions
5958
@noindent
5959
The attribute Prefix'Old can be used within a
5960
subprogram to refer to the value of the prefix on entry. So for
5961
example if you have an argument of a record type X called Arg1,
5962
you can refer to Arg1.Field'Old which yields the value of
5963
Arg1.Field on entry. The implementation simply involves generating
5964
an object declaration which captures the value on entry. Any
5965
prefix is allowed except one of a limited type (since limited
5966
types cannot be copied to capture their values) or a local variable
5967
(since it does not exist at subprogram entry time).
5968
 
5969
The following example shows the use of 'Old to implement
5970
a test of a postcondition:
5971
 
5972
@smallexample @c ada
5973
with Old_Pkg;
5974
procedure Old is
5975
begin
5976
   Old_Pkg.Incr;
5977
end Old;
5978
 
5979
package Old_Pkg is
5980
   procedure Incr;
5981
end Old_Pkg;
5982
 
5983
package body Old_Pkg is
5984
   Count : Natural := 0;
5985
 
5986
   procedure Incr is
5987
   begin
5988
      ... code manipulating the value of Count
5989
 
5990
      pragma Assert (Count = Count'Old + 1);
5991
   end Incr;
5992
end Old_Pkg;
5993
@end smallexample
5994
 
5995
@noindent
5996
Note that it is allowed to apply 'Old to a constant entity, but this will
5997
result in a warning, since the old and new values will always be the same.
5998
 
5999
@node Passed_By_Reference
6000
@unnumberedsec Passed_By_Reference
6001
@cindex Parameters, when passed by reference
6002
@findex Passed_By_Reference
6003
@noindent
6004
@code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6005
a value of type @code{Boolean} value that is @code{True} if the type is
6006
normally passed by reference and @code{False} if the type is normally
6007
passed by copy in calls.  For scalar types, the result is always @code{False}
6008
and is static.  For non-scalar types, the result is non-static.
6009
 
6010
@node Pool_Address
6011
@unnumberedsec Pool_Address
6012
@cindex Parameters, when passed by reference
6013
@findex Pool_Address
6014
@noindent
6015
@code{@var{X}'Pool_Address} for any object @var{X} returns the address
6016
of X within its storage pool. This is the same as
6017
@code{@var{X}'Address}, except that for an unconstrained array whose
6018
bounds are allocated just before the first component,
6019
@code{@var{X}'Pool_Address} returns the address of those bounds,
6020
whereas @code{@var{X}'Address} returns the address of the first
6021
component.
6022
 
6023
Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6024
the object is allocated'', which could be a user-defined storage pool,
6025
the global heap, on the stack, or in a static memory area. For an
6026
object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6027
what is passed to @code{Allocate} and returned from @code{Deallocate}.
6028
 
6029
@node Range_Length
6030
@unnumberedsec Range_Length
6031
@findex Range_Length
6032
@noindent
6033
@code{@var{type}'Range_Length} for any discrete type @var{type} yields
6034
the number of values represented by the subtype (zero for a null
6035
range).  The result is static for static subtypes.  @code{Range_Length}
6036
applied to the index subtype of a one dimensional array always gives the
6037
same result as @code{Range} applied to the array itself.
6038
 
6039
@node Result
6040
@unnumberedsec Result
6041
@findex Result
6042
@noindent
6043
@code{@var{function}'Result} can only be used with in a Postcondition pragma
6044
for a function. The prefix must be the name of the corresponding function. This
6045
is used to refer to the result of the function in the postcondition expression.
6046
For a further discussion of the use of this attribute and examples of its use,
6047
see the description of pragma Postcondition.
6048
 
6049
@node Safe_Emax
6050
@unnumberedsec Safe_Emax
6051
@cindex Ada 83 attributes
6052
@findex Safe_Emax
6053
@noindent
6054
The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6055
the Ada 83 reference manual for an exact description of the semantics of
6056
this attribute.
6057
 
6058
@node Safe_Large
6059
@unnumberedsec Safe_Large
6060
@cindex Ada 83 attributes
6061
@findex Safe_Large
6062
@noindent
6063
The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6064
the Ada 83 reference manual for an exact description of the semantics of
6065
this attribute.
6066
 
6067
@node Small
6068
@unnumberedsec Small
6069
@cindex Ada 83 attributes
6070
@findex Small
6071
@noindent
6072
The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6073
fixed-point types.
6074
GNAT also allows this attribute to be applied to floating-point types
6075
for compatibility with Ada 83.  See
6076
the Ada 83 reference manual for an exact description of the semantics of
6077
this attribute when applied to floating-point types.
6078
 
6079
@node Storage_Unit
6080
@unnumberedsec Storage_Unit
6081
@findex Storage_Unit
6082
@noindent
6083
@code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6084
prefix) provides the same value as @code{System.Storage_Unit}.
6085
 
6086
@node Stub_Type
6087
@unnumberedsec Stub_Type
6088
@findex Stub_Type
6089
@noindent
6090
The GNAT implementation of remote access-to-classwide types is
6091
organized as described in AARM section E.4 (20.t): a value of an RACW type
6092
(designating a remote object) is represented as a normal access
6093
value, pointing to a "stub" object which in turn contains the
6094
necessary information to contact the designated remote object. A
6095
call on any dispatching operation of such a stub object does the
6096
remote call, if necessary, using the information in the stub object
6097
to locate the target partition, etc.
6098
 
6099
For a prefix @code{T} that denotes a remote access-to-classwide type,
6100
@code{T'Stub_Type} denotes the type of the corresponding stub objects.
6101
 
6102
By construction, the layout of @code{T'Stub_Type} is identical to that of
6103
type @code{RACW_Stub_Type} declared in the internal implementation-defined
6104
unit @code{System.Partition_Interface}. Use of this attribute will create
6105
an implicit dependency on this unit.
6106
 
6107
@node Target_Name
6108
@unnumberedsec Target_Name
6109
@findex Target_Name
6110
@noindent
6111
@code{Standard'Target_Name} (@code{Standard} is the only permissible
6112
prefix) provides a static string value that identifies the target
6113
for the current compilation. For GCC implementations, this is the
6114
standard gcc target name without the terminating slash (for
6115
example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6116
 
6117
@node Tick
6118
@unnumberedsec Tick
6119
@findex Tick
6120
@noindent
6121
@code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6122
provides the same value as @code{System.Tick},
6123
 
6124
@node To_Address
6125
@unnumberedsec To_Address
6126
@findex To_Address
6127
@noindent
6128
The @code{System'To_Address}
6129
(@code{System} is the only permissible prefix)
6130
denotes a function identical to
6131
@code{System.Storage_Elements.To_Address} except that
6132
it is a static attribute.  This means that if its argument is
6133
a static expression, then the result of the attribute is a
6134
static expression.  The result is that such an expression can be
6135
used in contexts (e.g.@: preelaborable packages) which require a
6136
static expression and where the function call could not be used
6137
(since the function call is always non-static, even if its
6138
argument is static).
6139
 
6140
@node Type_Class
6141
@unnumberedsec Type_Class
6142
@findex Type_Class
6143
@noindent
6144
@code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6145
the value of the type class for the full type of @var{type}.  If
6146
@var{type} is a generic formal type, the value is the value for the
6147
corresponding actual subtype.  The value of this attribute is of type
6148
@code{System.Aux_DEC.Type_Class}, which has the following definition:
6149
 
6150
@smallexample @c ada
6151
  type Type_Class is
6152
    (Type_Class_Enumeration,
6153
     Type_Class_Integer,
6154
     Type_Class_Fixed_Point,
6155
     Type_Class_Floating_Point,
6156
     Type_Class_Array,
6157
     Type_Class_Record,
6158
     Type_Class_Access,
6159
     Type_Class_Task,
6160
     Type_Class_Address);
6161
@end smallexample
6162
 
6163
@noindent
6164
Protected types yield the value @code{Type_Class_Task}, which thus
6165
applies to all concurrent types.  This attribute is designed to
6166
be compatible with the DEC Ada 83 attribute of the same name.
6167
 
6168
@node UET_Address
6169
@unnumberedsec UET_Address
6170
@findex UET_Address
6171
@noindent
6172
The @code{UET_Address} attribute can only be used for a prefix which
6173
denotes a library package.  It yields the address of the unit exception
6174
table when zero cost exception handling is used.  This attribute is
6175
intended only for use within the GNAT implementation.  See the unit
6176
@code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6177
for details on how this attribute is used in the implementation.
6178
 
6179
@node Unconstrained_Array
6180
@unnumberedsec Unconstrained_Array
6181
@findex Unconstrained_Array
6182
@noindent
6183
The @code{Unconstrained_Array} attribute can be used with a prefix that
6184
denotes any type or subtype. It is a static attribute that yields
6185
@code{True} if the prefix designates an unconstrained array,
6186
and @code{False} otherwise. In a generic instance, the result is
6187
still static, and yields the result of applying this test to the
6188
generic actual.
6189
 
6190
@node Universal_Literal_String
6191
@unnumberedsec Universal_Literal_String
6192
@cindex Named numbers, representation of
6193
@findex Universal_Literal_String
6194
@noindent
6195
The prefix of @code{Universal_Literal_String} must be a named
6196
number.  The static result is the string consisting of the characters of
6197
the number as defined in the original source.  This allows the user
6198
program to access the actual text of named numbers without intermediate
6199
conversions and without the need to enclose the strings in quotes (which
6200
would preclude their use as numbers).  This is used internally for the
6201
construction of values of the floating-point attributes from the file
6202
@file{ttypef.ads}, but may also be used by user programs.
6203
 
6204
For example, the following program prints the first 50 digits of pi:
6205
 
6206
@smallexample @c ada
6207
with Text_IO; use Text_IO;
6208
with Ada.Numerics;
6209
procedure Pi is
6210
begin
6211
   Put (Ada.Numerics.Pi'Universal_Literal_String);
6212
end;
6213
@end smallexample
6214
 
6215
@node Unrestricted_Access
6216
@unnumberedsec Unrestricted_Access
6217
@cindex @code{Access}, unrestricted
6218
@findex Unrestricted_Access
6219
@noindent
6220
The @code{Unrestricted_Access} attribute is similar to @code{Access}
6221
except that all accessibility and aliased view checks are omitted.  This
6222
is a user-beware attribute.  It is similar to
6223
@code{Address}, for which it is a desirable replacement where the value
6224
desired is an access type.  In other words, its effect is identical to
6225
first applying the @code{Address} attribute and then doing an unchecked
6226
conversion to a desired access type.  In GNAT, but not necessarily in
6227
other implementations, the use of static chains for inner level
6228
subprograms means that @code{Unrestricted_Access} applied to a
6229
subprogram yields a value that can be called as long as the subprogram
6230
is in scope (normal Ada accessibility rules restrict this usage).
6231
 
6232
It is possible to use @code{Unrestricted_Access} for any type, but care
6233
must be exercised if it is used to create pointers to unconstrained
6234
objects. In this case, the resulting pointer has the same scope as the
6235
context of the attribute, and may not be returned to some enclosing
6236
scope. For instance, a function cannot use @code{Unrestricted_Access}
6237
to create a unconstrained pointer and then return that value to the
6238
caller.
6239
 
6240
@node VADS_Size
6241
@unnumberedsec VADS_Size
6242
@cindex @code{Size}, VADS compatibility
6243
@findex VADS_Size
6244
@noindent
6245
The @code{'VADS_Size} attribute is intended to make it easier to port
6246
legacy code which relies on the semantics of @code{'Size} as implemented
6247
by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6248
same semantic interpretation.  In particular, @code{'VADS_Size} applied
6249
to a predefined or other primitive type with no Size clause yields the
6250
Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6251
typical machines).  In addition @code{'VADS_Size} applied to an object
6252
gives the result that would be obtained by applying the attribute to
6253
the corresponding type.
6254
 
6255
@node Value_Size
6256
@unnumberedsec Value_Size
6257
@cindex @code{Size}, setting for not-first subtype
6258
@findex Value_Size
6259
@code{@var{type}'Value_Size} is the number of bits required to represent
6260
a value of the given subtype.  It is the same as @code{@var{type}'Size},
6261
but, unlike @code{Size}, may be set for non-first subtypes.
6262
 
6263
@node Wchar_T_Size
6264
@unnumberedsec Wchar_T_Size
6265
@findex Wchar_T_Size
6266
@code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6267
prefix) provides the size in bits of the C @code{wchar_t} type
6268
primarily for constructing the definition of this type in
6269
package @code{Interfaces.C}.
6270
 
6271
@node Word_Size
6272
@unnumberedsec Word_Size
6273
@findex Word_Size
6274
@code{Standard'Word_Size} (@code{Standard} is the only permissible
6275
prefix) provides the value @code{System.Word_Size}.
6276
 
6277
@c ------------------------
6278
@node Implementation Advice
6279
@chapter Implementation Advice
6280
@noindent
6281
The main text of the Ada Reference Manual describes the required
6282
behavior of all Ada compilers, and the GNAT compiler conforms to
6283
these requirements.
6284
 
6285
In addition, there are sections throughout the Ada Reference Manual headed
6286
by the phrase ``Implementation advice''.  These sections are not normative,
6287
i.e., they do not specify requirements that all compilers must
6288
follow.  Rather they provide advice on generally desirable behavior.  You
6289
may wonder why they are not requirements.  The most typical answer is
6290
that they describe behavior that seems generally desirable, but cannot
6291
be provided on all systems, or which may be undesirable on some systems.
6292
 
6293
As far as practical, GNAT follows the implementation advice sections in
6294
the Ada Reference Manual.  This chapter contains a table giving the
6295
reference manual section number, paragraph number and several keywords
6296
for each advice.  Each entry consists of the text of the advice followed
6297
by the GNAT interpretation of this advice.  Most often, this simply says
6298
``followed'', which means that GNAT follows the advice.  However, in a
6299
number of cases, GNAT deliberately deviates from this advice, in which
6300
case the text describes what GNAT does and why.
6301
 
6302
@cindex Error detection
6303
@unnumberedsec 1.1.3(20): Error Detection
6304
@sp 1
6305
@cartouche
6306
If an implementation detects the use of an unsupported Specialized Needs
6307
Annex feature at run time, it should raise @code{Program_Error} if
6308
feasible.
6309
@end cartouche
6310
Not relevant.  All specialized needs annex features are either supported,
6311
or diagnosed at compile time.
6312
 
6313
@cindex Child Units
6314
@unnumberedsec 1.1.3(31): Child Units
6315
@sp 1
6316
@cartouche
6317
If an implementation wishes to provide implementation-defined
6318
extensions to the functionality of a language-defined library unit, it
6319
should normally do so by adding children to the library unit.
6320
@end cartouche
6321
Followed.
6322
 
6323
@cindex Bounded errors
6324
@unnumberedsec 1.1.5(12): Bounded Errors
6325
@sp 1
6326
@cartouche
6327
If an implementation detects a bounded error or erroneous
6328
execution, it should raise @code{Program_Error}.
6329
@end cartouche
6330
Followed in all cases in which the implementation detects a bounded
6331
error or erroneous execution.  Not all such situations are detected at
6332
runtime.
6333
 
6334
@cindex Pragmas
6335
@unnumberedsec 2.8(16): Pragmas
6336
@sp 1
6337
@cartouche
6338
Normally, implementation-defined pragmas should have no semantic effect
6339
for error-free programs; that is, if the implementation-defined pragmas
6340
are removed from a working program, the program should still be legal,
6341
and should still have the same semantics.
6342
@end cartouche
6343
The following implementation defined pragmas are exceptions to this
6344
rule:
6345
 
6346
@table @code
6347
@item Abort_Defer
6348
Affects semantics
6349
@item Ada_83
6350
Affects legality
6351
@item Assert
6352
Affects semantics
6353
@item CPP_Class
6354
Affects semantics
6355
@item CPP_Constructor
6356
Affects semantics
6357
@item Debug
6358
Affects semantics
6359
@item Interface_Name
6360
Affects semantics
6361
@item Machine_Attribute
6362
Affects semantics
6363
@item Unimplemented_Unit
6364
Affects legality
6365
@item Unchecked_Union
6366
Affects semantics
6367
@end table
6368
 
6369
@noindent
6370
In each of the above cases, it is essential to the purpose of the pragma
6371
that this advice not be followed.  For details see the separate section
6372
on implementation defined pragmas.
6373
 
6374
@unnumberedsec 2.8(17-19): Pragmas
6375
@sp 1
6376
@cartouche
6377
Normally, an implementation should not define pragmas that can
6378
make an illegal program legal, except as follows:
6379
@end cartouche
6380
@sp 1
6381
@cartouche
6382
A pragma used to complete a declaration, such as a pragma @code{Import};
6383
@end cartouche
6384
@sp 1
6385
@cartouche
6386
A pragma used to configure the environment by adding, removing, or
6387
replacing @code{library_items}.
6388
@end cartouche
6389
See response to paragraph 16 of this same section.
6390
 
6391
@cindex Character Sets
6392
@cindex Alternative Character Sets
6393
@unnumberedsec 3.5.2(5): Alternative Character Sets
6394
@sp 1
6395
@cartouche
6396
If an implementation supports a mode with alternative interpretations
6397
for @code{Character} and @code{Wide_Character}, the set of graphic
6398
characters of @code{Character} should nevertheless remain a proper
6399
subset of the set of graphic characters of @code{Wide_Character}.  Any
6400
character set ``localizations'' should be reflected in the results of
6401
the subprograms defined in the language-defined package
6402
@code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6403
an alternative interpretation of @code{Character}, the implementation should
6404
also support a corresponding change in what is a legal
6405
@code{identifier_letter}.
6406
@end cartouche
6407
Not all wide character modes follow this advice, in particular the JIS
6408
and IEC modes reflect standard usage in Japan, and in these encoding,
6409
the upper half of the Latin-1 set is not part of the wide-character
6410
subset, since the most significant bit is used for wide character
6411
encoding.  However, this only applies to the external forms.  Internally
6412
there is no such restriction.
6413
 
6414
@cindex Integer types
6415
@unnumberedsec 3.5.4(28): Integer Types
6416
 
6417
@sp 1
6418
@cartouche
6419
An implementation should support @code{Long_Integer} in addition to
6420
@code{Integer} if the target machine supports 32-bit (or longer)
6421
arithmetic.  No other named integer subtypes are recommended for package
6422
@code{Standard}.  Instead, appropriate named integer subtypes should be
6423
provided in the library package @code{Interfaces} (see B.2).
6424
@end cartouche
6425
@code{Long_Integer} is supported.  Other standard integer types are supported
6426
so this advice is not fully followed.  These types
6427
are supported for convenient interface to C, and so that all hardware
6428
types of the machine are easily available.
6429
@unnumberedsec 3.5.4(29): Integer Types
6430
 
6431
@sp 1
6432
@cartouche
6433
An implementation for a two's complement machine should support
6434
modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6435
implementation should support a non-binary modules up to @code{Integer'Last}.
6436
@end cartouche
6437
Followed.
6438
 
6439
@cindex Enumeration values
6440
@unnumberedsec 3.5.5(8): Enumeration Values
6441
@sp 1
6442
@cartouche
6443
For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6444
subtype, if the value of the operand does not correspond to the internal
6445
code for any enumeration literal of its type (perhaps due to an
6446
un-initialized variable), then the implementation should raise
6447
@code{Program_Error}.  This is particularly important for enumeration
6448
types with noncontiguous internal codes specified by an
6449
enumeration_representation_clause.
6450
@end cartouche
6451
Followed.
6452
 
6453
@cindex Float types
6454
@unnumberedsec 3.5.7(17): Float Types
6455
@sp 1
6456
@cartouche
6457
An implementation should support @code{Long_Float} in addition to
6458
@code{Float} if the target machine supports 11 or more digits of
6459
precision.  No other named floating point subtypes are recommended for
6460
package @code{Standard}.  Instead, appropriate named floating point subtypes
6461
should be provided in the library package @code{Interfaces} (see B.2).
6462
@end cartouche
6463
@code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6464
former provides improved compatibility with other implementations
6465
supporting this type.  The latter corresponds to the highest precision
6466
floating-point type supported by the hardware.  On most machines, this
6467
will be the same as @code{Long_Float}, but on some machines, it will
6468
correspond to the IEEE extended form.  The notable case is all ia32
6469
(x86) implementations, where @code{Long_Long_Float} corresponds to
6470
the 80-bit extended precision format supported in hardware on this
6471
processor.  Note that the 128-bit format on SPARC is not supported,
6472
since this is a software rather than a hardware format.
6473
 
6474
@cindex Multidimensional arrays
6475
@cindex Arrays, multidimensional
6476
@unnumberedsec 3.6.2(11): Multidimensional Arrays
6477
@sp 1
6478
@cartouche
6479
An implementation should normally represent multidimensional arrays in
6480
row-major order, consistent with the notation used for multidimensional
6481
array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6482
(@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6483
column-major order should be used instead (see B.5, ``Interfacing with
6484
Fortran'').
6485
@end cartouche
6486
Followed.
6487
 
6488
@findex Duration'Small
6489
@unnumberedsec 9.6(30-31): Duration'Small
6490
@sp 1
6491
@cartouche
6492
Whenever possible in an implementation, the value of @code{Duration'Small}
6493
should be no greater than 100 microseconds.
6494
@end cartouche
6495
Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6496
 
6497
@sp 1
6498
@cartouche
6499
The time base for @code{delay_relative_statements} should be monotonic;
6500
it need not be the same time base as used for @code{Calendar.Clock}.
6501
@end cartouche
6502
Followed.
6503
 
6504
@unnumberedsec 10.2.1(12): Consistent Representation
6505
@sp 1
6506
@cartouche
6507
In an implementation, a type declared in a pre-elaborated package should
6508
have the same representation in every elaboration of a given version of
6509
the package, whether the elaborations occur in distinct executions of
6510
the same program, or in executions of distinct programs or partitions
6511
that include the given version.
6512
@end cartouche
6513
Followed, except in the case of tagged types.  Tagged types involve
6514
implicit pointers to a local copy of a dispatch table, and these pointers
6515
have representations which thus depend on a particular elaboration of the
6516
package.  It is not easy to see how it would be possible to follow this
6517
advice without severely impacting efficiency of execution.
6518
 
6519
@cindex Exception information
6520
@unnumberedsec 11.4.1(19): Exception Information
6521
@sp 1
6522
@cartouche
6523
@code{Exception_Message} by default and @code{Exception_Information}
6524
should produce information useful for
6525
debugging.  @code{Exception_Message} should be short, about one
6526
line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6527
should not include the
6528
@code{Exception_Name}.  @code{Exception_Information} should include both
6529
the @code{Exception_Name} and the @code{Exception_Message}.
6530
@end cartouche
6531
Followed.  For each exception that doesn't have a specified
6532
@code{Exception_Message}, the compiler generates one containing the location
6533
of the raise statement.  This location has the form ``file:line'', where
6534
file is the short file name (without path information) and line is the line
6535
number in the file.  Note that in the case of the Zero Cost Exception
6536
mechanism, these messages become redundant with the Exception_Information that
6537
contains a full backtrace of the calling sequence, so they are disabled.
6538
To disable explicitly the generation of the source location message, use the
6539
Pragma @code{Discard_Names}.
6540
 
6541
@cindex Suppression of checks
6542
@cindex Checks, suppression of
6543
@unnumberedsec 11.5(28): Suppression of Checks
6544
@sp 1
6545
@cartouche
6546
The implementation should minimize the code executed for checks that
6547
have been suppressed.
6548
@end cartouche
6549
Followed.
6550
 
6551
@cindex Representation clauses
6552
@unnumberedsec 13.1 (21-24): Representation Clauses
6553
@sp 1
6554
@cartouche
6555
The recommended level of support for all representation items is
6556
qualified as follows:
6557
@end cartouche
6558
@sp 1
6559
@cartouche
6560
An implementation need not support representation items containing
6561
non-static expressions, except that an implementation should support a
6562
representation item for a given entity if each non-static expression in
6563
the representation item is a name that statically denotes a constant
6564
declared before the entity.
6565
@end cartouche
6566
Followed.  In fact, GNAT goes beyond the recommended level of support
6567
by allowing nonstatic expressions in some representation clauses even
6568
without the need to declare constants initialized with the values of
6569
such expressions.
6570
For example:
6571
 
6572
@smallexample @c ada
6573
  X : Integer;
6574
  Y : Float;
6575
  for Y'Address use X'Address;>>
6576
@end smallexample
6577
 
6578
 
6579
@sp 1
6580
@cartouche
6581
An implementation need not support a specification for the @code{Size}
6582
for a given composite subtype, nor the size or storage place for an
6583
object (including a component) of a given composite subtype, unless the
6584
constraints on the subtype and its composite subcomponents (if any) are
6585
all static constraints.
6586
@end cartouche
6587
Followed.  Size Clauses are not permitted on non-static components, as
6588
described above.
6589
 
6590
@sp 1
6591
@cartouche
6592
An aliased component, or a component whose type is by-reference, should
6593
always be allocated at an addressable location.
6594
@end cartouche
6595
Followed.
6596
 
6597
@cindex Packed types
6598
@unnumberedsec 13.2(6-8): Packed Types
6599
@sp 1
6600
@cartouche
6601
If a type is packed, then the implementation should try to minimize
6602
storage allocated to objects of the type, possibly at the expense of
6603
speed of accessing components, subject to reasonable complexity in
6604
addressing calculations.
6605
@end cartouche
6606
@sp 1
6607
@cartouche
6608
The recommended level of support pragma @code{Pack} is:
6609
 
6610
For a packed record type, the components should be packed as tightly as
6611
possible subject to the Sizes of the component subtypes, and subject to
6612
any @code{record_representation_clause} that applies to the type; the
6613
implementation may, but need not, reorder components or cross aligned
6614
word boundaries to improve the packing.  A component whose @code{Size} is
6615
greater than the word size may be allocated an integral number of words.
6616
@end cartouche
6617
Followed.  Tight packing of arrays is supported for all component sizes
6618
up to 64-bits. If the array component size is 1 (that is to say, if
6619
the component is a boolean type or an enumeration type with two values)
6620
then values of the type are implicitly initialized to zero. This
6621
happens both for objects of the packed type, and for objects that have a
6622
subcomponent of the packed type.
6623
 
6624
@sp 1
6625
@cartouche
6626
An implementation should support Address clauses for imported
6627
subprograms.
6628
@end cartouche
6629
Followed.
6630
@cindex @code{Address} clauses
6631
@unnumberedsec 13.3(14-19): Address Clauses
6632
 
6633
@sp 1
6634
@cartouche
6635
For an array @var{X}, @code{@var{X}'Address} should point at the first
6636
component of the array, and not at the array bounds.
6637
@end cartouche
6638
Followed.
6639
 
6640
@sp 1
6641
@cartouche
6642
The recommended level of support for the @code{Address} attribute is:
6643
 
6644
@code{@var{X}'Address} should produce a useful result if @var{X} is an
6645
object that is aliased or of a by-reference type, or is an entity whose
6646
@code{Address} has been specified.
6647
@end cartouche
6648
Followed.  A valid address will be produced even if none of those
6649
conditions have been met.  If necessary, the object is forced into
6650
memory to ensure the address is valid.
6651
 
6652
@sp 1
6653
@cartouche
6654
An implementation should support @code{Address} clauses for imported
6655
subprograms.
6656
@end cartouche
6657
Followed.
6658
 
6659
@sp 1
6660
@cartouche
6661
Objects (including subcomponents) that are aliased or of a by-reference
6662
type should be allocated on storage element boundaries.
6663
@end cartouche
6664
Followed.
6665
 
6666
@sp 1
6667
@cartouche
6668
If the @code{Address} of an object is specified, or it is imported or exported,
6669
then the implementation should not perform optimizations based on
6670
assumptions of no aliases.
6671
@end cartouche
6672
Followed.
6673
 
6674
@cindex @code{Alignment} clauses
6675
@unnumberedsec 13.3(29-35): Alignment Clauses
6676
@sp 1
6677
@cartouche
6678
The recommended level of support for the @code{Alignment} attribute for
6679
subtypes is:
6680
 
6681
An implementation should support specified Alignments that are factors
6682
and multiples of the number of storage elements per word, subject to the
6683
following:
6684
@end cartouche
6685
Followed.
6686
 
6687
@sp 1
6688
@cartouche
6689
An implementation need not support specified @code{Alignment}s for
6690
combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6691
loaded and stored by available machine instructions.
6692
@end cartouche
6693
Followed.
6694
 
6695
@sp 1
6696
@cartouche
6697
An implementation need not support specified @code{Alignment}s that are
6698
greater than the maximum @code{Alignment} the implementation ever returns by
6699
default.
6700
@end cartouche
6701
Followed.
6702
 
6703
@sp 1
6704
@cartouche
6705
The recommended level of support for the @code{Alignment} attribute for
6706
objects is:
6707
 
6708
Same as above, for subtypes, but in addition:
6709
@end cartouche
6710
Followed.
6711
 
6712
@sp 1
6713
@cartouche
6714
For stand-alone library-level objects of statically constrained
6715
subtypes, the implementation should support all @code{Alignment}s
6716
supported by the target linker.  For example, page alignment is likely to
6717
be supported for such objects, but not for subtypes.
6718
@end cartouche
6719
Followed.
6720
 
6721
@cindex @code{Size} clauses
6722
@unnumberedsec 13.3(42-43): Size Clauses
6723
@sp 1
6724
@cartouche
6725
The recommended level of support for the @code{Size} attribute of
6726
objects is:
6727
 
6728
A @code{Size} clause should be supported for an object if the specified
6729
@code{Size} is at least as large as its subtype's @code{Size}, and
6730
corresponds to a size in storage elements that is a multiple of the
6731
object's @code{Alignment} (if the @code{Alignment} is nonzero).
6732
@end cartouche
6733
Followed.
6734
 
6735
@unnumberedsec 13.3(50-56): Size Clauses
6736
@sp 1
6737
@cartouche
6738
If the @code{Size} of a subtype is specified, and allows for efficient
6739
independent addressability (see 9.10) on the target architecture, then
6740
the @code{Size} of the following objects of the subtype should equal the
6741
@code{Size} of the subtype:
6742
 
6743
Aliased objects (including components).
6744
@end cartouche
6745
Followed.
6746
 
6747
@sp 1
6748
@cartouche
6749
@code{Size} clause on a composite subtype should not affect the
6750
internal layout of components.
6751
@end cartouche
6752
Followed. But note that this can be overridden by use of the implementation
6753
pragma Implicit_Packing in the case of packed arrays.
6754
 
6755
@sp 1
6756
@cartouche
6757
The recommended level of support for the @code{Size} attribute of subtypes is:
6758
@end cartouche
6759
@sp 1
6760
@cartouche
6761
The @code{Size} (if not specified) of a static discrete or fixed point
6762
subtype should be the number of bits needed to represent each value
6763
belonging to the subtype using an unbiased representation, leaving space
6764
for a sign bit only if the subtype contains negative values.  If such a
6765
subtype is a first subtype, then an implementation should support a
6766
specified @code{Size} for it that reflects this representation.
6767
@end cartouche
6768
Followed.
6769
 
6770
@sp 1
6771
@cartouche
6772
For a subtype implemented with levels of indirection, the @code{Size}
6773
should include the size of the pointers, but not the size of what they
6774
point at.
6775
@end cartouche
6776
Followed.
6777
 
6778
@cindex @code{Component_Size} clauses
6779
@unnumberedsec 13.3(71-73): Component Size Clauses
6780
@sp 1
6781
@cartouche
6782
The recommended level of support for the @code{Component_Size}
6783
attribute is:
6784
@end cartouche
6785
@sp 1
6786
@cartouche
6787
An implementation need not support specified @code{Component_Sizes} that are
6788
less than the @code{Size} of the component subtype.
6789
@end cartouche
6790
Followed.
6791
 
6792
@sp 1
6793
@cartouche
6794
An implementation should support specified @code{Component_Size}s that
6795
are factors and multiples of the word size.  For such
6796
@code{Component_Size}s, the array should contain no gaps between
6797
components.  For other @code{Component_Size}s (if supported), the array
6798
should contain no gaps between components when packing is also
6799
specified; the implementation should forbid this combination in cases
6800
where it cannot support a no-gaps representation.
6801
@end cartouche
6802
Followed.
6803
 
6804
@cindex Enumeration representation clauses
6805
@cindex Representation clauses, enumeration
6806
@unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6807
@sp 1
6808
@cartouche
6809
The recommended level of support for enumeration representation clauses
6810
is:
6811
 
6812
An implementation need not support enumeration representation clauses
6813
for boolean types, but should at minimum support the internal codes in
6814
the range @code{System.Min_Int.System.Max_Int}.
6815
@end cartouche
6816
Followed.
6817
 
6818
@cindex Record representation clauses
6819
@cindex Representation clauses, records
6820
@unnumberedsec 13.5.1(17-22): Record Representation Clauses
6821
@sp 1
6822
@cartouche
6823
The recommended level of support for
6824
@*@code{record_representation_clauses} is:
6825
 
6826
An implementation should support storage places that can be extracted
6827
with a load, mask, shift sequence of machine code, and set with a load,
6828
shift, mask, store sequence, given the available machine instructions
6829
and run-time model.
6830
@end cartouche
6831
Followed.
6832
 
6833
@sp 1
6834
@cartouche
6835
A storage place should be supported if its size is equal to the
6836
@code{Size} of the component subtype, and it starts and ends on a
6837
boundary that obeys the @code{Alignment} of the component subtype.
6838
@end cartouche
6839
Followed.
6840
 
6841
@sp 1
6842
@cartouche
6843
If the default bit ordering applies to the declaration of a given type,
6844
then for a component whose subtype's @code{Size} is less than the word
6845
size, any storage place that does not cross an aligned word boundary
6846
should be supported.
6847
@end cartouche
6848
Followed.
6849
 
6850
@sp 1
6851
@cartouche
6852
An implementation may reserve a storage place for the tag field of a
6853
tagged type, and disallow other components from overlapping that place.
6854
@end cartouche
6855
Followed.  The storage place for the tag field is the beginning of the tagged
6856
record, and its size is Address'Size.  GNAT will reject an explicit component
6857
clause for the tag field.
6858
 
6859
@sp 1
6860
@cartouche
6861
An implementation need not support a @code{component_clause} for a
6862
component of an extension part if the storage place is not after the
6863
storage places of all components of the parent type, whether or not
6864
those storage places had been specified.
6865
@end cartouche
6866
Followed.  The above advice on record representation clauses is followed,
6867
and all mentioned features are implemented.
6868
 
6869
@cindex Storage place attributes
6870
@unnumberedsec 13.5.2(5): Storage Place Attributes
6871
@sp 1
6872
@cartouche
6873
If a component is represented using some form of pointer (such as an
6874
offset) to the actual data of the component, and this data is contiguous
6875
with the rest of the object, then the storage place attributes should
6876
reflect the place of the actual data, not the pointer.  If a component is
6877
allocated discontinuously from the rest of the object, then a warning
6878
should be generated upon reference to one of its storage place
6879
attributes.
6880
@end cartouche
6881
Followed.  There are no such components in GNAT@.
6882
 
6883
@cindex Bit ordering
6884
@unnumberedsec 13.5.3(7-8): Bit Ordering
6885
@sp 1
6886
@cartouche
6887
The recommended level of support for the non-default bit ordering is:
6888
@end cartouche
6889
@sp 1
6890
@cartouche
6891
If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6892
should support the non-default bit ordering in addition to the default
6893
bit ordering.
6894
@end cartouche
6895
Followed.  Word size does not equal storage size in this implementation.
6896
Thus non-default bit ordering is not supported.
6897
 
6898
@cindex @code{Address}, as private type
6899
@unnumberedsec 13.7(37): Address as Private
6900
@sp 1
6901
@cartouche
6902
@code{Address} should be of a private type.
6903
@end cartouche
6904
Followed.
6905
 
6906
@cindex Operations, on @code{Address}
6907
@cindex @code{Address}, operations of
6908
@unnumberedsec 13.7.1(16): Address Operations
6909
@sp 1
6910
@cartouche
6911
Operations in @code{System} and its children should reflect the target
6912
environment semantics as closely as is reasonable.  For example, on most
6913
machines, it makes sense for address arithmetic to ``wrap around''.
6914
Operations that do not make sense should raise @code{Program_Error}.
6915
@end cartouche
6916
Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6917
operation raises @code{Program_Error}, since all operations make sense.
6918
 
6919
@cindex Unchecked conversion
6920
@unnumberedsec 13.9(14-17): Unchecked Conversion
6921
@sp 1
6922
@cartouche
6923
The @code{Size} of an array object should not include its bounds; hence,
6924
the bounds should not be part of the converted data.
6925
@end cartouche
6926
Followed.
6927
 
6928
@sp 1
6929
@cartouche
6930
The implementation should not generate unnecessary run-time checks to
6931
ensure that the representation of @var{S} is a representation of the
6932
target type.  It should take advantage of the permission to return by
6933
reference when possible.  Restrictions on unchecked conversions should be
6934
avoided unless required by the target environment.
6935
@end cartouche
6936
Followed.  There are no restrictions on unchecked conversion.  A warning is
6937
generated if the source and target types do not have the same size since
6938
the semantics in this case may be target dependent.
6939
 
6940
@sp 1
6941
@cartouche
6942
The recommended level of support for unchecked conversions is:
6943
@end cartouche
6944
@sp 1
6945
@cartouche
6946
Unchecked conversions should be supported and should be reversible in
6947
the cases where this clause defines the result.  To enable meaningful use
6948
of unchecked conversion, a contiguous representation should be used for
6949
elementary subtypes, for statically constrained array subtypes whose
6950
component subtype is one of the subtypes described in this paragraph,
6951
and for record subtypes without discriminants whose component subtypes
6952
are described in this paragraph.
6953
@end cartouche
6954
Followed.
6955
 
6956
@cindex Heap usage, implicit
6957
@unnumberedsec 13.11(23-25): Implicit Heap Usage
6958
@sp 1
6959
@cartouche
6960
An implementation should document any cases in which it dynamically
6961
allocates heap storage for a purpose other than the evaluation of an
6962
allocator.
6963
@end cartouche
6964
Followed, the only other points at which heap storage is dynamically
6965
allocated are as follows:
6966
 
6967
@itemize @bullet
6968
@item
6969
At initial elaboration time, to allocate dynamically sized global
6970
objects.
6971
 
6972
@item
6973
To allocate space for a task when a task is created.
6974
 
6975
@item
6976
To extend the secondary stack dynamically when needed.  The secondary
6977
stack is used for returning variable length results.
6978
@end itemize
6979
 
6980
@sp 1
6981
@cartouche
6982
A default (implementation-provided) storage pool for an
6983
access-to-constant type should not have overhead to support deallocation of
6984
individual objects.
6985
@end cartouche
6986
Followed.
6987
 
6988
@sp 1
6989
@cartouche
6990
A storage pool for an anonymous access type should be created at the
6991
point of an allocator for the type, and be reclaimed when the designated
6992
object becomes inaccessible.
6993
@end cartouche
6994
Followed.
6995
 
6996
@cindex Unchecked deallocation
6997
@unnumberedsec 13.11.2(17): Unchecked De-allocation
6998
@sp 1
6999
@cartouche
7000
For a standard storage pool, @code{Free} should actually reclaim the
7001
storage.
7002
@end cartouche
7003
Followed.
7004
 
7005
@cindex Stream oriented attributes
7006
@unnumberedsec 13.13.2(17): Stream Oriented Attributes
7007
@sp 1
7008
@cartouche
7009
If a stream element is the same size as a storage element, then the
7010
normal in-memory representation should be used by @code{Read} and
7011
@code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7012
should use the smallest number of stream elements needed to represent
7013
all values in the base range of the scalar type.
7014
@end cartouche
7015
 
7016
Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7017
which specifies using the size of the first subtype.
7018
However, such an implementation is based on direct binary
7019
representations and is therefore target- and endianness-dependent.
7020
To address this issue, GNAT also supplies an alternate implementation
7021
of the stream attributes @code{Read} and @code{Write},
7022
which uses the target-independent XDR standard representation
7023
for scalar types.
7024
@cindex XDR representation
7025
@cindex @code{Read} attribute
7026
@cindex @code{Write} attribute
7027
@cindex Stream oriented attributes
7028
The XDR implementation is provided as an alternative body of the
7029
@code{System.Stream_Attributes} package, in the file
7030
@file{s-strxdr.adb} in the GNAT library.
7031
There is no @file{s-strxdr.ads} file.
7032
In order to install the XDR implementation, do the following:
7033
@enumerate
7034
@item Replace the default implementation of the
7035
@code{System.Stream_Attributes} package with the XDR implementation.
7036
For example on a Unix platform issue the commands:
7037
@smallexample
7038
$ mv s-stratt.adb s-strold.adb
7039
$ mv s-strxdr.adb s-stratt.adb
7040
@end smallexample
7041
 
7042
@item
7043
Rebuild the GNAT run-time library as documented in
7044
@ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7045
@end enumerate
7046
 
7047
@unnumberedsec A.1(52): Names of Predefined Numeric Types
7048
@sp 1
7049
@cartouche
7050
If an implementation provides additional named predefined integer types,
7051
then the names should end with @samp{Integer} as in
7052
@samp{Long_Integer}.  If an implementation provides additional named
7053
predefined floating point types, then the names should end with
7054
@samp{Float} as in @samp{Long_Float}.
7055
@end cartouche
7056
Followed.
7057
 
7058
@findex Ada.Characters.Handling
7059
@unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7060
@sp 1
7061
@cartouche
7062
If an implementation provides a localized definition of @code{Character}
7063
or @code{Wide_Character}, then the effects of the subprograms in
7064
@code{Characters.Handling} should reflect the localizations.  See also
7065
3.5.2.
7066
@end cartouche
7067
Followed.  GNAT provides no such localized definitions.
7068
 
7069
@cindex Bounded-length strings
7070
@unnumberedsec A.4.4(106): Bounded-Length String Handling
7071
@sp 1
7072
@cartouche
7073
Bounded string objects should not be implemented by implicit pointers
7074
and dynamic allocation.
7075
@end cartouche
7076
Followed.  No implicit pointers or dynamic allocation are used.
7077
 
7078
@cindex Random number generation
7079
@unnumberedsec A.5.2(46-47): Random Number Generation
7080
@sp 1
7081
@cartouche
7082
Any storage associated with an object of type @code{Generator} should be
7083
reclaimed on exit from the scope of the object.
7084
@end cartouche
7085
Followed.
7086
 
7087
@sp 1
7088
@cartouche
7089
If the generator period is sufficiently long in relation to the number
7090
of distinct initiator values, then each possible value of
7091
@code{Initiator} passed to @code{Reset} should initiate a sequence of
7092
random numbers that does not, in a practical sense, overlap the sequence
7093
initiated by any other value.  If this is not possible, then the mapping
7094
between initiator values and generator states should be a rapidly
7095
varying function of the initiator value.
7096
@end cartouche
7097
Followed.  The generator period is sufficiently long for the first
7098
condition here to hold true.
7099
 
7100
@findex Get_Immediate
7101
@unnumberedsec A.10.7(23): @code{Get_Immediate}
7102
@sp 1
7103
@cartouche
7104
The @code{Get_Immediate} procedures should be implemented with
7105
unbuffered input.  For a device such as a keyboard, input should be
7106
@dfn{available} if a key has already been typed, whereas for a disk
7107
file, input should always be available except at end of file.  For a file
7108
associated with a keyboard-like device, any line-editing features of the
7109
underlying operating system should be disabled during the execution of
7110
@code{Get_Immediate}.
7111
@end cartouche
7112
Followed on all targets except VxWorks. For VxWorks, there is no way to
7113
provide this functionality that does not result in the input buffer being
7114
flushed before the @code{Get_Immediate} call. A special unit
7115
@code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7116
this functionality.
7117
 
7118
@findex Export
7119
@unnumberedsec B.1(39-41): Pragma @code{Export}
7120
@sp 1
7121
@cartouche
7122
If an implementation supports pragma @code{Export} to a given language,
7123
then it should also allow the main subprogram to be written in that
7124
language.  It should support some mechanism for invoking the elaboration
7125
of the Ada library units included in the system, and for invoking the
7126
finalization of the environment task.  On typical systems, the
7127
recommended mechanism is to provide two subprograms whose link names are
7128
@code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7129
elaboration code for library units.  @code{adafinal} should contain the
7130
finalization code.  These subprograms should have no effect the second
7131
and subsequent time they are called.
7132
@end cartouche
7133
Followed.
7134
 
7135
@sp 1
7136
@cartouche
7137
Automatic elaboration of pre-elaborated packages should be
7138
provided when pragma @code{Export} is supported.
7139
@end cartouche
7140
Followed when the main program is in Ada.  If the main program is in a
7141
foreign language, then
7142
@code{adainit} must be called to elaborate pre-elaborated
7143
packages.
7144
 
7145
@sp 1
7146
@cartouche
7147
For each supported convention @var{L} other than @code{Intrinsic}, an
7148
implementation should support @code{Import} and @code{Export} pragmas
7149
for objects of @var{L}-compatible types and for subprograms, and pragma
7150
@code{Convention} for @var{L}-eligible types and for subprograms,
7151
presuming the other language has corresponding features.  Pragma
7152
@code{Convention} need not be supported for scalar types.
7153
@end cartouche
7154
Followed.
7155
 
7156
@cindex Package @code{Interfaces}
7157
@findex Interfaces
7158
@unnumberedsec B.2(12-13): Package @code{Interfaces}
7159
@sp 1
7160
@cartouche
7161
For each implementation-defined convention identifier, there should be a
7162
child package of package Interfaces with the corresponding name.  This
7163
package should contain any declarations that would be useful for
7164
interfacing to the language (implementation) represented by the
7165
convention.  Any declarations useful for interfacing to any language on
7166
the given hardware architecture should be provided directly in
7167
@code{Interfaces}.
7168
@end cartouche
7169
Followed. An additional package not defined
7170
in the Ada Reference Manual is @code{Interfaces.CPP}, used
7171
for interfacing to C++.
7172
 
7173
@sp 1
7174
@cartouche
7175
An implementation supporting an interface to C, COBOL, or Fortran should
7176
provide the corresponding package or packages described in the following
7177
clauses.
7178
@end cartouche
7179
Followed.  GNAT provides all the packages described in this section.
7180
 
7181
@cindex C, interfacing with
7182
@unnumberedsec B.3(63-71): Interfacing with C
7183
@sp 1
7184
@cartouche
7185
An implementation should support the following interface correspondences
7186
between Ada and C@.
7187
@end cartouche
7188
Followed.
7189
 
7190
@sp 1
7191
@cartouche
7192
An Ada procedure corresponds to a void-returning C function.
7193
@end cartouche
7194
Followed.
7195
 
7196
@sp 1
7197
@cartouche
7198
An Ada function corresponds to a non-void C function.
7199
@end cartouche
7200
Followed.
7201
 
7202
@sp 1
7203
@cartouche
7204
An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7205
function.
7206
@end cartouche
7207
Followed.
7208
 
7209
@sp 1
7210
@cartouche
7211
An Ada @code{in} parameter of an access-to-object type with designated
7212
type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7213
where @var{t} is the C type corresponding to the Ada type @var{T}.
7214
@end cartouche
7215
Followed.
7216
 
7217
@sp 1
7218
@cartouche
7219
An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7220
parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7221
argument to a C function, where @var{t} is the C type corresponding to
7222
the Ada type @var{T}.  In the case of an elementary @code{out} or
7223
@code{in out} parameter, a pointer to a temporary copy is used to
7224
preserve by-copy semantics.
7225
@end cartouche
7226
Followed.
7227
 
7228
@sp 1
7229
@cartouche
7230
An Ada parameter of a record type @var{T}, of any mode, is passed as a
7231
@code{@var{t}*} argument to a C function, where @var{t} is the C
7232
structure corresponding to the Ada type @var{T}.
7233
@end cartouche
7234
Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7235
pragma, or Convention, or by explicitly specifying the mechanism for a given
7236
call using an extended import or export pragma.
7237
 
7238
@sp 1
7239
@cartouche
7240
An Ada parameter of an array type with component type @var{T}, of any
7241
mode, is passed as a @code{@var{t}*} argument to a C function, where
7242
@var{t} is the C type corresponding to the Ada type @var{T}.
7243
@end cartouche
7244
Followed.
7245
 
7246
@sp 1
7247
@cartouche
7248
An Ada parameter of an access-to-subprogram type is passed as a pointer
7249
to a C function whose prototype corresponds to the designated
7250
subprogram's specification.
7251
@end cartouche
7252
Followed.
7253
 
7254
@cindex COBOL, interfacing with
7255
@unnumberedsec B.4(95-98): Interfacing with COBOL
7256
@sp 1
7257
@cartouche
7258
An Ada implementation should support the following interface
7259
correspondences between Ada and COBOL@.
7260
@end cartouche
7261
Followed.
7262
 
7263
@sp 1
7264
@cartouche
7265
An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7266
the COBOL type corresponding to @var{T}.
7267
@end cartouche
7268
Followed.
7269
 
7270
@sp 1
7271
@cartouche
7272
An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7273
the corresponding COBOL type.
7274
@end cartouche
7275
Followed.
7276
 
7277
@sp 1
7278
@cartouche
7279
Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7280
COBOL type corresponding to the Ada parameter type; for scalars, a local
7281
copy is used if necessary to ensure by-copy semantics.
7282
@end cartouche
7283
Followed.
7284
 
7285
@cindex Fortran, interfacing with
7286
@unnumberedsec B.5(22-26): Interfacing with Fortran
7287
@sp 1
7288
@cartouche
7289
An Ada implementation should support the following interface
7290
correspondences between Ada and Fortran:
7291
@end cartouche
7292
Followed.
7293
 
7294
@sp 1
7295
@cartouche
7296
An Ada procedure corresponds to a Fortran subroutine.
7297
@end cartouche
7298
Followed.
7299
 
7300
@sp 1
7301
@cartouche
7302
An Ada function corresponds to a Fortran function.
7303
@end cartouche
7304
Followed.
7305
 
7306
@sp 1
7307
@cartouche
7308
An Ada parameter of an elementary, array, or record type @var{T} is
7309
passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7310
the Fortran type corresponding to the Ada type @var{T}, and where the
7311
INTENT attribute of the corresponding dummy argument matches the Ada
7312
formal parameter mode; the Fortran implementation's parameter passing
7313
conventions are used.  For elementary types, a local copy is used if
7314
necessary to ensure by-copy semantics.
7315
@end cartouche
7316
Followed.
7317
 
7318
@sp 1
7319
@cartouche
7320
An Ada parameter of an access-to-subprogram type is passed as a
7321
reference to a Fortran procedure whose interface corresponds to the
7322
designated subprogram's specification.
7323
@end cartouche
7324
Followed.
7325
 
7326
@cindex Machine operations
7327
@unnumberedsec C.1(3-5): Access to Machine Operations
7328
@sp 1
7329
@cartouche
7330
The machine code or intrinsic support should allow access to all
7331
operations normally available to assembly language programmers for the
7332
target environment, including privileged instructions, if any.
7333
@end cartouche
7334
Followed.
7335
 
7336
@sp 1
7337
@cartouche
7338
The interfacing pragmas (see Annex B) should support interface to
7339
assembler; the default assembler should be associated with the
7340
convention identifier @code{Assembler}.
7341
@end cartouche
7342
Followed.
7343
 
7344
@sp 1
7345
@cartouche
7346
If an entity is exported to assembly language, then the implementation
7347
should allocate it at an addressable location, and should ensure that it
7348
is retained by the linking process, even if not otherwise referenced
7349
from the Ada code.  The implementation should assume that any call to a
7350
machine code or assembler subprogram is allowed to read or update every
7351
object that is specified as exported.
7352
@end cartouche
7353
Followed.
7354
 
7355
@unnumberedsec C.1(10-16): Access to Machine Operations
7356
@sp 1
7357
@cartouche
7358
The implementation should ensure that little or no overhead is
7359
associated with calling intrinsic and machine-code subprograms.
7360
@end cartouche
7361
Followed for both intrinsics and machine-code subprograms.
7362
 
7363
@sp 1
7364
@cartouche
7365
It is recommended that intrinsic subprograms be provided for convenient
7366
access to any machine operations that provide special capabilities or
7367
efficiency and that are not otherwise available through the language
7368
constructs.
7369
@end cartouche
7370
Followed.  A full set of machine operation intrinsic subprograms is provided.
7371
 
7372
@sp 1
7373
@cartouche
7374
Atomic read-modify-write operations---e.g.@:, test and set, compare and
7375
swap, decrement and test, enqueue/dequeue.
7376
@end cartouche
7377
Followed on any target supporting such operations.
7378
 
7379
@sp 1
7380
@cartouche
7381
Standard numeric functions---e.g.@:, sin, log.
7382
@end cartouche
7383
Followed on any target supporting such operations.
7384
 
7385
@sp 1
7386
@cartouche
7387
String manipulation operations---e.g.@:, translate and test.
7388
@end cartouche
7389
Followed on any target supporting such operations.
7390
 
7391
@sp 1
7392
@cartouche
7393
Vector operations---e.g.@:, compare vector against thresholds.
7394
@end cartouche
7395
Followed on any target supporting such operations.
7396
 
7397
@sp 1
7398
@cartouche
7399
Direct operations on I/O ports.
7400
@end cartouche
7401
Followed on any target supporting such operations.
7402
 
7403
@cindex Interrupt support
7404
@unnumberedsec C.3(28): Interrupt Support
7405
@sp 1
7406
@cartouche
7407
If the @code{Ceiling_Locking} policy is not in effect, the
7408
implementation should provide means for the application to specify which
7409
interrupts are to be blocked during protected actions, if the underlying
7410
system allows for a finer-grain control of interrupt blocking.
7411
@end cartouche
7412
Followed.  The underlying system does not allow for finer-grain control
7413
of interrupt blocking.
7414
 
7415
@cindex Protected procedure handlers
7416
@unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7417
@sp 1
7418
@cartouche
7419
Whenever possible, the implementation should allow interrupt handlers to
7420
be called directly by the hardware.
7421
@end cartouche
7422
@c SGI info:
7423
@ignore
7424
This is never possible under IRIX, so this is followed by default.
7425
@end ignore
7426
Followed on any target where the underlying operating system permits
7427
such direct calls.
7428
 
7429
@sp 1
7430
@cartouche
7431
Whenever practical, violations of any
7432
implementation-defined restrictions should be detected before run time.
7433
@end cartouche
7434
Followed.  Compile time warnings are given when possible.
7435
 
7436
@cindex Package @code{Interrupts}
7437
@findex Interrupts
7438
@unnumberedsec C.3.2(25): Package @code{Interrupts}
7439
 
7440
@sp 1
7441
@cartouche
7442
If implementation-defined forms of interrupt handler procedures are
7443
supported, such as protected procedures with parameters, then for each
7444
such form of a handler, a type analogous to @code{Parameterless_Handler}
7445
should be specified in a child package of @code{Interrupts}, with the
7446
same operations as in the predefined package Interrupts.
7447
@end cartouche
7448
Followed.
7449
 
7450
@cindex Pre-elaboration requirements
7451
@unnumberedsec C.4(14): Pre-elaboration Requirements
7452
@sp 1
7453
@cartouche
7454
It is recommended that pre-elaborated packages be implemented in such a
7455
way that there should be little or no code executed at run time for the
7456
elaboration of entities not already covered by the Implementation
7457
Requirements.
7458
@end cartouche
7459
Followed.  Executable code is generated in some cases, e.g.@: loops
7460
to initialize large arrays.
7461
 
7462
@unnumberedsec C.5(8): Pragma @code{Discard_Names}
7463
 
7464
@sp 1
7465
@cartouche
7466
If the pragma applies to an entity, then the implementation should
7467
reduce the amount of storage used for storing names associated with that
7468
entity.
7469
@end cartouche
7470
Followed.
7471
 
7472
@cindex Package @code{Task_Attributes}
7473
@findex Task_Attributes
7474
@unnumberedsec C.7.2(30): The Package Task_Attributes
7475
@sp 1
7476
@cartouche
7477
Some implementations are targeted to domains in which memory use at run
7478
time must be completely deterministic.  For such implementations, it is
7479
recommended that the storage for task attributes will be pre-allocated
7480
statically and not from the heap.  This can be accomplished by either
7481
placing restrictions on the number and the size of the task's
7482
attributes, or by using the pre-allocated storage for the first @var{N}
7483
attribute objects, and the heap for the others.  In the latter case,
7484
@var{N} should be documented.
7485
@end cartouche
7486
Not followed.  This implementation is not targeted to such a domain.
7487
 
7488
@cindex Locking Policies
7489
@unnumberedsec D.3(17): Locking Policies
7490
 
7491
@sp 1
7492
@cartouche
7493
The implementation should use names that end with @samp{_Locking} for
7494
locking policies defined by the implementation.
7495
@end cartouche
7496
Followed.  A single implementation-defined locking policy is defined,
7497
whose name (@code{Inheritance_Locking}) follows this suggestion.
7498
 
7499
@cindex Entry queuing policies
7500
@unnumberedsec D.4(16): Entry Queuing Policies
7501
@sp 1
7502
@cartouche
7503
Names that end with @samp{_Queuing} should be used
7504
for all implementation-defined queuing policies.
7505
@end cartouche
7506
Followed.  No such implementation-defined queuing policies exist.
7507
 
7508
@cindex Preemptive abort
7509
@unnumberedsec D.6(9-10): Preemptive Abort
7510
@sp 1
7511
@cartouche
7512
Even though the @code{abort_statement} is included in the list of
7513
potentially blocking operations (see 9.5.1), it is recommended that this
7514
statement be implemented in a way that never requires the task executing
7515
the @code{abort_statement} to block.
7516
@end cartouche
7517
Followed.
7518
 
7519
@sp 1
7520
@cartouche
7521
On a multi-processor, the delay associated with aborting a task on
7522
another processor should be bounded; the implementation should use
7523
periodic polling, if necessary, to achieve this.
7524
@end cartouche
7525
Followed.
7526
 
7527
@cindex Tasking restrictions
7528
@unnumberedsec D.7(21): Tasking Restrictions
7529
@sp 1
7530
@cartouche
7531
When feasible, the implementation should take advantage of the specified
7532
restrictions to produce a more efficient implementation.
7533
@end cartouche
7534
GNAT currently takes advantage of these restrictions by providing an optimized
7535
run time when the Ravenscar profile and the GNAT restricted run time set
7536
of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7537
pragma @code{Profile (Restricted)} for more details.
7538
 
7539
@cindex Time, monotonic
7540
@unnumberedsec D.8(47-49): Monotonic Time
7541
@sp 1
7542
@cartouche
7543
When appropriate, implementations should provide configuration
7544
mechanisms to change the value of @code{Tick}.
7545
@end cartouche
7546
Such configuration mechanisms are not appropriate to this implementation
7547
and are thus not supported.
7548
 
7549
@sp 1
7550
@cartouche
7551
It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7552
be implemented as transformations of the same time base.
7553
@end cartouche
7554
Followed.
7555
 
7556
@sp 1
7557
@cartouche
7558
It is recommended that the @dfn{best} time base which exists in
7559
the underlying system be available to the application through
7560
@code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7561
@end cartouche
7562
Followed.
7563
 
7564
@cindex Partition communication subsystem
7565
@cindex PCS
7566
@unnumberedsec E.5(28-29): Partition Communication Subsystem
7567
@sp 1
7568
@cartouche
7569
Whenever possible, the PCS on the called partition should allow for
7570
multiple tasks to call the RPC-receiver with different messages and
7571
should allow them to block until the corresponding subprogram body
7572
returns.
7573
@end cartouche
7574
Followed by GLADE, a separately supplied PCS that can be used with
7575
GNAT.
7576
 
7577
@sp 1
7578
@cartouche
7579
The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7580
should raise @code{Storage_Error} if it runs out of space trying to
7581
write the @code{Item} into the stream.
7582
@end cartouche
7583
Followed by GLADE, a separately supplied PCS that can be used with
7584
GNAT@.
7585
 
7586
@cindex COBOL support
7587
@unnumberedsec F(7): COBOL Support
7588
@sp 1
7589
@cartouche
7590
If COBOL (respectively, C) is widely supported in the target
7591
environment, implementations supporting the Information Systems Annex
7592
should provide the child package @code{Interfaces.COBOL} (respectively,
7593
@code{Interfaces.C}) specified in Annex B and should support a
7594
@code{convention_identifier} of COBOL (respectively, C) in the interfacing
7595
pragmas (see Annex B), thus allowing Ada programs to interface with
7596
programs written in that language.
7597
@end cartouche
7598
Followed.
7599
 
7600
@cindex Decimal radix support
7601
@unnumberedsec F.1(2): Decimal Radix Support
7602
@sp 1
7603
@cartouche
7604
Packed decimal should be used as the internal representation for objects
7605
of subtype @var{S} when @var{S}'Machine_Radix = 10.
7606
@end cartouche
7607
Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7608
representations.
7609
 
7610
@cindex Numerics
7611
@unnumberedsec G: Numerics
7612
@sp 2
7613
@cartouche
7614
If Fortran (respectively, C) is widely supported in the target
7615
environment, implementations supporting the Numerics Annex
7616
should provide the child package @code{Interfaces.Fortran} (respectively,
7617
@code{Interfaces.C}) specified in Annex B and should support a
7618
@code{convention_identifier} of Fortran (respectively, C) in the interfacing
7619
pragmas (see Annex B), thus allowing Ada programs to interface with
7620
programs written in that language.
7621
@end cartouche
7622
Followed.
7623
 
7624
@cindex Complex types
7625
@unnumberedsec G.1.1(56-58): Complex Types
7626
@sp 2
7627
@cartouche
7628
Because the usual mathematical meaning of multiplication of a complex
7629
operand and a real operand is that of the scaling of both components of
7630
the former by the latter, an implementation should not perform this
7631
operation by first promoting the real operand to complex type and then
7632
performing a full complex multiplication.  In systems that, in the
7633
future, support an Ada binding to IEC 559:1989, the latter technique
7634
will not generate the required result when one of the components of the
7635
complex operand is infinite.  (Explicit multiplication of the infinite
7636
component by the zero component obtained during promotion yields a NaN
7637
that propagates into the final result.) Analogous advice applies in the
7638
case of multiplication of a complex operand and a pure-imaginary
7639
operand, and in the case of division of a complex operand by a real or
7640
pure-imaginary operand.
7641
@end cartouche
7642
Not followed.
7643
 
7644
@sp 1
7645
@cartouche
7646
Similarly, because the usual mathematical meaning of addition of a
7647
complex operand and a real operand is that the imaginary operand remains
7648
unchanged, an implementation should not perform this operation by first
7649
promoting the real operand to complex type and then performing a full
7650
complex addition.  In implementations in which the @code{Signed_Zeros}
7651
attribute of the component type is @code{True} (and which therefore
7652
conform to IEC 559:1989 in regard to the handling of the sign of zero in
7653
predefined arithmetic operations), the latter technique will not
7654
generate the required result when the imaginary component of the complex
7655
operand is a negatively signed zero.  (Explicit addition of the negative
7656
zero to the zero obtained during promotion yields a positive zero.)
7657
Analogous advice applies in the case of addition of a complex operand
7658
and a pure-imaginary operand, and in the case of subtraction of a
7659
complex operand and a real or pure-imaginary operand.
7660
@end cartouche
7661
Not followed.
7662
 
7663
@sp 1
7664
@cartouche
7665
Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7666
attempt to provide a rational treatment of the signs of zero results and
7667
result components.  As one example, the result of the @code{Argument}
7668
function should have the sign of the imaginary component of the
7669
parameter @code{X} when the point represented by that parameter lies on
7670
the positive real axis; as another, the sign of the imaginary component
7671
of the @code{Compose_From_Polar} function should be the same as
7672
(respectively, the opposite of) that of the @code{Argument} parameter when that
7673
parameter has a value of zero and the @code{Modulus} parameter has a
7674
nonnegative (respectively, negative) value.
7675
@end cartouche
7676
Followed.
7677
 
7678
@cindex Complex elementary functions
7679
@unnumberedsec G.1.2(49): Complex Elementary Functions
7680
@sp 1
7681
@cartouche
7682
Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7683
@code{True} should attempt to provide a rational treatment of the signs
7684
of zero results and result components.  For example, many of the complex
7685
elementary functions have components that are odd functions of one of
7686
the parameter components; in these cases, the result component should
7687
have the sign of the parameter component at the origin.  Other complex
7688
elementary functions have zero components whose sign is opposite that of
7689
a parameter component at the origin, or is always positive or always
7690
negative.
7691
@end cartouche
7692
Followed.
7693
 
7694
@cindex Accuracy requirements
7695
@unnumberedsec G.2.4(19): Accuracy Requirements
7696
@sp 1
7697
@cartouche
7698
The versions of the forward trigonometric functions without a
7699
@code{Cycle} parameter should not be implemented by calling the
7700
corresponding version with a @code{Cycle} parameter of
7701
@code{2.0*Numerics.Pi}, since this will not provide the required
7702
accuracy in some portions of the domain.  For the same reason, the
7703
version of @code{Log} without a @code{Base} parameter should not be
7704
implemented by calling the corresponding version with a @code{Base}
7705
parameter of @code{Numerics.e}.
7706
@end cartouche
7707
Followed.
7708
 
7709
@cindex Complex arithmetic accuracy
7710
@cindex Accuracy, complex arithmetic
7711
@unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7712
 
7713
@sp 1
7714
@cartouche
7715
The version of the @code{Compose_From_Polar} function without a
7716
@code{Cycle} parameter should not be implemented by calling the
7717
corresponding version with a @code{Cycle} parameter of
7718
@code{2.0*Numerics.Pi}, since this will not provide the required
7719
accuracy in some portions of the domain.
7720
@end cartouche
7721
Followed.
7722
 
7723
@c -----------------------------------------
7724
@node Implementation Defined Characteristics
7725
@chapter Implementation Defined Characteristics
7726
 
7727
@noindent
7728
In addition to the implementation dependent pragmas and attributes, and
7729
the implementation advice, there are a number of other Ada features
7730
that are potentially implementation dependent.  These are mentioned
7731
throughout the Ada Reference Manual, and are summarized in Annex M@.
7732
 
7733
A requirement for conforming Ada compilers is that they provide
7734
documentation describing how the implementation deals with each of these
7735
issues.  In this chapter, you will find each point in Annex M listed
7736
followed by a description in italic font of how GNAT
7737
@c SGI info:
7738
@ignore
7739
in the ProDev Ada
7740
implementation on IRIX 5.3 operating system or greater
7741
@end ignore
7742
handles the implementation dependence.
7743
 
7744
You can use this chapter as a guide to minimizing implementation
7745
dependent features in your programs if portability to other compilers
7746
and other operating systems is an important consideration.  The numbers
7747
in each section below correspond to the paragraph number in the Ada
7748
Reference Manual.
7749
 
7750
@sp 1
7751
@cartouche
7752
@noindent
7753
@strong{2}.  Whether or not each recommendation given in Implementation
7754
Advice is followed.  See 1.1.2(37).
7755
@end cartouche
7756
@noindent
7757
@xref{Implementation Advice}.
7758
 
7759
@sp 1
7760
@cartouche
7761
@noindent
7762
@strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7763
@end cartouche
7764
@noindent
7765
The complexity of programs that can be processed is limited only by the
7766
total amount of available virtual memory, and disk space for the
7767
generated object files.
7768
 
7769
@sp 1
7770
@cartouche
7771
@noindent
7772
@strong{4}.  Variations from the standard that are impractical to avoid
7773
given the implementation's execution environment.  See 1.1.3(6).
7774
@end cartouche
7775
@noindent
7776
There are no variations from the standard.
7777
 
7778
@sp 1
7779
@cartouche
7780
@noindent
7781
@strong{5}.  Which @code{code_statement}s cause external
7782
interactions.  See 1.1.3(10).
7783
@end cartouche
7784
@noindent
7785
Any @code{code_statement} can potentially cause external interactions.
7786
 
7787
@sp 1
7788
@cartouche
7789
@noindent
7790
@strong{6}.  The coded representation for the text of an Ada
7791
program.  See 2.1(4).
7792
@end cartouche
7793
@noindent
7794
See separate section on source representation.
7795
 
7796
@sp 1
7797
@cartouche
7798
@noindent
7799
@strong{7}.  The control functions allowed in comments.  See 2.1(14).
7800
@end cartouche
7801
@noindent
7802
See separate section on source representation.
7803
 
7804
@sp 1
7805
@cartouche
7806
@noindent
7807
@strong{8}.  The representation for an end of line.  See 2.2(2).
7808
@end cartouche
7809
@noindent
7810
See separate section on source representation.
7811
 
7812
@sp 1
7813
@cartouche
7814
@noindent
7815
@strong{9}.  Maximum supported line length and lexical element
7816
length.  See 2.2(15).
7817
@end cartouche
7818
@noindent
7819
The maximum line length is 255 characters and the maximum length of a
7820
lexical element is also 255 characters.
7821
 
7822
@sp 1
7823
@cartouche
7824
@noindent
7825
@strong{10}.  Implementation defined pragmas.  See 2.8(14).
7826
@end cartouche
7827
@noindent
7828
 
7829
@xref{Implementation Defined Pragmas}.
7830
 
7831
@sp 1
7832
@cartouche
7833
@noindent
7834
@strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7835
@end cartouche
7836
@noindent
7837
Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7838
parameter, checks that the optimization flag is set, and aborts if it is
7839
not.
7840
 
7841
@sp 1
7842
@cartouche
7843
@noindent
7844
@strong{12}.  The sequence of characters of the value returned by
7845
@code{@var{S}'Image} when some of the graphic characters of
7846
@code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7847
3.5(37).
7848
@end cartouche
7849
@noindent
7850
The sequence of characters is as defined by the wide character encoding
7851
method used for the source.  See section on source representation for
7852
further details.
7853
 
7854
@sp 1
7855
@cartouche
7856
@noindent
7857
@strong{13}.  The predefined integer types declared in
7858
@code{Standard}.  See 3.5.4(25).
7859
@end cartouche
7860
@noindent
7861
@table @code
7862
@item Short_Short_Integer
7863
8 bit signed
7864
@item Short_Integer
7865
(Short) 16 bit signed
7866
@item Integer
7867
32 bit signed
7868
@item Long_Integer
7869
64 bit signed (Alpha OpenVMS only)
7870
32 bit signed (all other targets)
7871
@item Long_Long_Integer
7872
64 bit signed
7873
@end table
7874
 
7875
@sp 1
7876
@cartouche
7877
@noindent
7878
@strong{14}.  Any nonstandard integer types and the operators defined
7879
for them.  See 3.5.4(26).
7880
@end cartouche
7881
@noindent
7882
There are no nonstandard integer types.
7883
 
7884
@sp 1
7885
@cartouche
7886
@noindent
7887
@strong{15}.  Any nonstandard real types and the operators defined for
7888
them.  See 3.5.6(8).
7889
@end cartouche
7890
@noindent
7891
There are no nonstandard real types.
7892
 
7893
@sp 1
7894
@cartouche
7895
@noindent
7896
@strong{16}.  What combinations of requested decimal precision and range
7897
are supported for floating point types.  See 3.5.7(7).
7898
@end cartouche
7899
@noindent
7900
The precision and range is as defined by the IEEE standard.
7901
 
7902
@sp 1
7903
@cartouche
7904
@noindent
7905
@strong{17}.  The predefined floating point types declared in
7906
@code{Standard}.  See 3.5.7(16).
7907
@end cartouche
7908
@noindent
7909
@table @code
7910
@item Short_Float
7911
32 bit IEEE short
7912
@item Float
7913
(Short) 32 bit IEEE short
7914
@item Long_Float
7915
64 bit IEEE long
7916
@item Long_Long_Float
7917
64 bit IEEE long (80 bit IEEE long on x86 processors)
7918
@end table
7919
 
7920
@sp 1
7921
@cartouche
7922
@noindent
7923
@strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7924
@end cartouche
7925
@noindent
7926
@code{Fine_Delta} is 2**(@minus{}63)
7927
 
7928
@sp 1
7929
@cartouche
7930
@noindent
7931
@strong{19}.  What combinations of small, range, and digits are
7932
supported for fixed point types.  See 3.5.9(10).
7933
@end cartouche
7934
@noindent
7935
Any combinations are permitted that do not result in a small less than
7936
@code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7937
If the mantissa is larger than 53 bits on machines where Long_Long_Float
7938
is 64 bits (true of all architectures except ia32), then the output from
7939
Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7940
is because floating-point conversions are used to convert fixed point.
7941
 
7942
@sp 1
7943
@cartouche
7944
@noindent
7945
@strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7946
within an unnamed @code{block_statement}.  See 3.9(10).
7947
@end cartouche
7948
@noindent
7949
Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7950
decimal integer are allocated.
7951
 
7952
@sp 1
7953
@cartouche
7954
@noindent
7955
@strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7956
@end cartouche
7957
@noindent
7958
@xref{Implementation Defined Attributes}.
7959
 
7960
@sp 1
7961
@cartouche
7962
@noindent
7963
@strong{22}.  Any implementation-defined time types.  See 9.6(6).
7964
@end cartouche
7965
@noindent
7966
There are no implementation-defined time types.
7967
 
7968
@sp 1
7969
@cartouche
7970
@noindent
7971
@strong{23}.  The time base associated with relative delays.
7972
@end cartouche
7973
@noindent
7974
See 9.6(20).  The time base used is that provided by the C library
7975
function @code{gettimeofday}.
7976
 
7977
@sp 1
7978
@cartouche
7979
@noindent
7980
@strong{24}.  The time base of the type @code{Calendar.Time}.  See
7981
9.6(23).
7982
@end cartouche
7983
@noindent
7984
The time base used is that provided by the C library function
7985
@code{gettimeofday}.
7986
 
7987
@sp 1
7988
@cartouche
7989
@noindent
7990
@strong{25}.  The time zone used for package @code{Calendar}
7991
operations.  See 9.6(24).
7992
@end cartouche
7993
@noindent
7994
The time zone used by package @code{Calendar} is the current system time zone
7995
setting for local time, as accessed by the C library function
7996
@code{localtime}.
7997
 
7998
@sp 1
7999
@cartouche
8000
@noindent
8001
@strong{26}.  Any limit on @code{delay_until_statements} of
8002
@code{select_statements}.  See 9.6(29).
8003
@end cartouche
8004
@noindent
8005
There are no such limits.
8006
 
8007
@sp 1
8008
@cartouche
8009
@noindent
8010
@strong{27}.  Whether or not two non-overlapping parts of a composite
8011
object are independently addressable, in the case where packing, record
8012
layout, or @code{Component_Size} is specified for the object.  See
8013
9.10(1).
8014
@end cartouche
8015
@noindent
8016
Separate components are independently addressable if they do not share
8017
overlapping storage units.
8018
 
8019
@sp 1
8020
@cartouche
8021
@noindent
8022
@strong{28}.  The representation for a compilation.  See 10.1(2).
8023
@end cartouche
8024
@noindent
8025
A compilation is represented by a sequence of files presented to the
8026
compiler in a single invocation of the @command{gcc} command.
8027
 
8028
@sp 1
8029
@cartouche
8030
@noindent
8031
@strong{29}.  Any restrictions on compilations that contain multiple
8032
compilation_units.  See 10.1(4).
8033
@end cartouche
8034
@noindent
8035
No single file can contain more than one compilation unit, but any
8036
sequence of files can be presented to the compiler as a single
8037
compilation.
8038
 
8039
@sp 1
8040
@cartouche
8041
@noindent
8042
@strong{30}.  The mechanisms for creating an environment and for adding
8043
and replacing compilation units.  See 10.1.4(3).
8044
@end cartouche
8045
@noindent
8046
See separate section on compilation model.
8047
 
8048
@sp 1
8049
@cartouche
8050
@noindent
8051
@strong{31}.  The manner of explicitly assigning library units to a
8052
partition.  See 10.2(2).
8053
@end cartouche
8054
@noindent
8055
If a unit contains an Ada main program, then the Ada units for the partition
8056
are determined by recursive application of the rules in the Ada Reference
8057
Manual section 10.2(2-6).  In other words, the Ada units will be those that
8058
are needed by the main program, and then this definition of need is applied
8059
recursively to those units, and the partition contains the transitive
8060
closure determined by this relationship.  In short, all the necessary units
8061
are included, with no need to explicitly specify the list.  If additional
8062
units are required, e.g.@: by foreign language units, then all units must be
8063
mentioned in the context clause of one of the needed Ada units.
8064
 
8065
If the partition contains no main program, or if the main program is in
8066
a language other than Ada, then GNAT
8067
provides the binder options @option{-z} and @option{-n} respectively, and in
8068
this case a list of units can be explicitly supplied to the binder for
8069
inclusion in the partition (all units needed by these units will also
8070
be included automatically).  For full details on the use of these
8071
options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8072
@value{EDITION} User's Guide}.
8073
 
8074
@sp 1
8075
@cartouche
8076
@noindent
8077
@strong{32}.  The implementation-defined means, if any, of specifying
8078
which compilation units are needed by a given compilation unit.  See
8079
10.2(2).
8080
@end cartouche
8081
@noindent
8082
The units needed by a given compilation unit are as defined in
8083
the Ada Reference Manual section 10.2(2-6).  There are no
8084
implementation-defined pragmas or other implementation-defined
8085
means for specifying needed units.
8086
 
8087
@sp 1
8088
@cartouche
8089
@noindent
8090
@strong{33}.  The manner of designating the main subprogram of a
8091
partition.  See 10.2(7).
8092
@end cartouche
8093
@noindent
8094
The main program is designated by providing the name of the
8095
corresponding @file{ALI} file as the input parameter to the binder.
8096
 
8097
@sp 1
8098
@cartouche
8099
@noindent
8100
@strong{34}.  The order of elaboration of @code{library_items}.  See
8101
10.2(18).
8102
@end cartouche
8103
@noindent
8104
The first constraint on ordering is that it meets the requirements of
8105
Chapter 10 of the Ada Reference Manual.  This still leaves some
8106
implementation dependent choices, which are resolved by first
8107
elaborating bodies as early as possible (i.e., in preference to specs
8108
where there is a choice), and second by evaluating the immediate with
8109
clauses of a unit to determine the probably best choice, and
8110
third by elaborating in alphabetical order of unit names
8111
where a choice still remains.
8112
 
8113
@sp 1
8114
@cartouche
8115
@noindent
8116
@strong{35}.  Parameter passing and function return for the main
8117
subprogram.  See 10.2(21).
8118
@end cartouche
8119
@noindent
8120
The main program has no parameters.  It may be a procedure, or a function
8121
returning an integer type.  In the latter case, the returned integer
8122
value is the return code of the program (overriding any value that
8123
may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8124
 
8125
@sp 1
8126
@cartouche
8127
@noindent
8128
@strong{36}.  The mechanisms for building and running partitions.  See
8129
10.2(24).
8130
@end cartouche
8131
@noindent
8132
GNAT itself supports programs with only a single partition.  The GNATDIST
8133
tool provided with the GLADE package (which also includes an implementation
8134
of the PCS) provides a completely flexible method for building and running
8135
programs consisting of multiple partitions.  See the separate GLADE manual
8136
for details.
8137
 
8138
@sp 1
8139
@cartouche
8140
@noindent
8141
@strong{37}.  The details of program execution, including program
8142
termination.  See 10.2(25).
8143
@end cartouche
8144
@noindent
8145
See separate section on compilation model.
8146
 
8147
@sp 1
8148
@cartouche
8149
@noindent
8150
@strong{38}.  The semantics of any non-active partitions supported by the
8151
implementation.  See 10.2(28).
8152
@end cartouche
8153
@noindent
8154
Passive partitions are supported on targets where shared memory is
8155
provided by the operating system.  See the GLADE reference manual for
8156
further details.
8157
 
8158
@sp 1
8159
@cartouche
8160
@noindent
8161
@strong{39}.  The information returned by @code{Exception_Message}.  See
8162
11.4.1(10).
8163
@end cartouche
8164
@noindent
8165
Exception message returns the null string unless a specific message has
8166
been passed by the program.
8167
 
8168
@sp 1
8169
@cartouche
8170
@noindent
8171
@strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8172
declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8173
@end cartouche
8174
@noindent
8175
Blocks have implementation defined names of the form @code{B@var{nnn}}
8176
where @var{nnn} is an integer.
8177
 
8178
@sp 1
8179
@cartouche
8180
@noindent
8181
@strong{41}.  The information returned by
8182
@code{Exception_Information}.  See 11.4.1(13).
8183
@end cartouche
8184
@noindent
8185
@code{Exception_Information} returns a string in the following format:
8186
 
8187
@smallexample
8188
@emph{Exception_Name:} nnnnn
8189
@emph{Message:} mmmmm
8190
@emph{PID:} ppp
8191
@emph{Call stack traceback locations:}
8192
0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8193
@end smallexample
8194
 
8195
@noindent
8196
where
8197
 
8198
@itemize @bullet
8199
@item
8200
@code{nnnn} is the fully qualified name of the exception in all upper
8201
case letters. This line is always present.
8202
 
8203
@item
8204
@code{mmmm} is the message (this line present only if message is non-null)
8205
 
8206
@item
8207
@code{ppp} is the Process Id value as a decimal integer (this line is
8208
present only if the Process Id is nonzero). Currently we are
8209
not making use of this field.
8210
 
8211
@item
8212
The Call stack traceback locations line and the following values
8213
are present only if at least one traceback location was recorded.
8214
The values are given in C style format, with lower case letters
8215
for a-f, and only as many digits present as are necessary.
8216
@end itemize
8217
 
8218
@noindent
8219
The line terminator sequence at the end of each line, including
8220
the last line is a single @code{LF} character (@code{16#0A#}).
8221
 
8222
@sp 1
8223
@cartouche
8224
@noindent
8225
@strong{42}.  Implementation-defined check names.  See 11.5(27).
8226
@end cartouche
8227
@noindent
8228
The implementation defined check name Alignment_Check controls checking of
8229
address clause values for proper alignment (that is, the address supplied
8230
must be consistent with the alignment of the type).
8231
 
8232
In addition, a user program can add implementation-defined check names
8233
by means of the pragma Check_Name.
8234
 
8235
@sp 1
8236
@cartouche
8237
@noindent
8238
@strong{43}.  The interpretation of each aspect of representation.  See
8239
13.1(20).
8240
@end cartouche
8241
@noindent
8242
See separate section on data representations.
8243
 
8244
@sp 1
8245
@cartouche
8246
@noindent
8247
@strong{44}.  Any restrictions placed upon representation items.  See
8248
13.1(20).
8249
@end cartouche
8250
@noindent
8251
See separate section on data representations.
8252
 
8253
@sp 1
8254
@cartouche
8255
@noindent
8256
@strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8257
13.3(48).
8258
@end cartouche
8259
@noindent
8260
Size for an indefinite subtype is the maximum possible size, except that
8261
for the case of a subprogram parameter, the size of the parameter object
8262
is the actual size.
8263
 
8264
@sp 1
8265
@cartouche
8266
@noindent
8267
@strong{46}.  The default external representation for a type tag.  See
8268
13.3(75).
8269
@end cartouche
8270
@noindent
8271
The default external representation for a type tag is the fully expanded
8272
name of the type in upper case letters.
8273
 
8274
@sp 1
8275
@cartouche
8276
@noindent
8277
@strong{47}.  What determines whether a compilation unit is the same in
8278
two different partitions.  See 13.3(76).
8279
@end cartouche
8280
@noindent
8281
A compilation unit is the same in two different partitions if and only
8282
if it derives from the same source file.
8283
 
8284
@sp 1
8285
@cartouche
8286
@noindent
8287
@strong{48}.  Implementation-defined components.  See 13.5.1(15).
8288
@end cartouche
8289
@noindent
8290
The only implementation defined component is the tag for a tagged type,
8291
which contains a pointer to the dispatching table.
8292
 
8293
@sp 1
8294
@cartouche
8295
@noindent
8296
@strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8297
ordering.  See 13.5.3(5).
8298
@end cartouche
8299
@noindent
8300
@code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8301
implementation, so no non-default bit ordering is supported.  The default
8302
bit ordering corresponds to the natural endianness of the target architecture.
8303
 
8304
@sp 1
8305
@cartouche
8306
@noindent
8307
@strong{50}.  The contents of the visible part of package @code{System}
8308
and its language-defined children.  See 13.7(2).
8309
@end cartouche
8310
@noindent
8311
See the definition of these packages in files @file{system.ads} and
8312
@file{s-stoele.ads}.
8313
 
8314
@sp 1
8315
@cartouche
8316
@noindent
8317
@strong{51}.  The contents of the visible part of package
8318
@code{System.Machine_Code}, and the meaning of
8319
@code{code_statements}.  See 13.8(7).
8320
@end cartouche
8321
@noindent
8322
See the definition and documentation in file @file{s-maccod.ads}.
8323
 
8324
@sp 1
8325
@cartouche
8326
@noindent
8327
@strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8328
@end cartouche
8329
@noindent
8330
Unchecked conversion between types of the same size
8331
results in an uninterpreted transmission of the bits from one type
8332
to the other.  If the types are of unequal sizes, then in the case of
8333
discrete types, a shorter source is first zero or sign extended as
8334
necessary, and a shorter target is simply truncated on the left.
8335
For all non-discrete types, the source is first copied if necessary
8336
to ensure that the alignment requirements of the target are met, then
8337
a pointer is constructed to the source value, and the result is obtained
8338
by dereferencing this pointer after converting it to be a pointer to the
8339
target type. Unchecked conversions where the target subtype is an
8340
unconstrained array are not permitted. If the target alignment is
8341
greater than the source alignment, then a copy of the result is
8342
made with appropriate alignment
8343
 
8344
@sp 1
8345
@cartouche
8346
@noindent
8347
@strong{53}.  The manner of choosing a storage pool for an access type
8348
when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8349
@end cartouche
8350
@noindent
8351
There are 3 different standard pools used by the compiler when
8352
@code{Storage_Pool} is not specified depending whether the type is local
8353
to a subprogram or defined at the library level and whether
8354
@code{Storage_Size}is specified or not.  See documentation in the runtime
8355
library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8356
@code{System.Pool_Local} in files @file{s-poosiz.ads},
8357
@file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8358
default pools used.
8359
 
8360
@sp 1
8361
@cartouche
8362
@noindent
8363
@strong{54}.  Whether or not the implementation provides user-accessible
8364
names for the standard pool type(s).  See 13.11(17).
8365
@end cartouche
8366
@noindent
8367
 
8368
See documentation in the sources of the run time mentioned in paragraph
8369
@strong{53} .  All these pools are accessible by means of @code{with}'ing
8370
these units.
8371
 
8372
@sp 1
8373
@cartouche
8374
@noindent
8375
@strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8376
@end cartouche
8377
@noindent
8378
@code{Storage_Size} is measured in storage units, and refers to the
8379
total space available for an access type collection, or to the primary
8380
stack space for a task.
8381
 
8382
@sp 1
8383
@cartouche
8384
@noindent
8385
@strong{56}.  Implementation-defined aspects of storage pools.  See
8386
13.11(22).
8387
@end cartouche
8388
@noindent
8389
See documentation in the sources of the run time mentioned in paragraph
8390
@strong{53} for details on GNAT-defined aspects of storage pools.
8391
 
8392
@sp 1
8393
@cartouche
8394
@noindent
8395
@strong{57}.  The set of restrictions allowed in a pragma
8396
@code{Restrictions}.  See 13.12(7).
8397
@end cartouche
8398
@noindent
8399
All RM defined Restriction identifiers are implemented.  The following
8400
additional restriction identifiers are provided.  There are two separate
8401
lists of implementation dependent restriction identifiers.  The first
8402
set requires consistency throughout a partition (in other words, if the
8403
restriction identifier is used for any compilation unit in the partition,
8404
then all compilation units in the partition must obey the restriction.
8405
 
8406
@table @code
8407
 
8408
@item Simple_Barriers
8409
@findex Simple_Barriers
8410
This restriction ensures at compile time that barriers in entry declarations
8411
for protected types are restricted to either static boolean expressions or
8412
references to simple boolean variables defined in the private part of the
8413
protected type.  No other form of entry barriers is permitted.  This is one
8414
of the restrictions of the Ravenscar profile for limited tasking (see also
8415
pragma @code{Profile (Ravenscar)}).
8416
 
8417
@item Max_Entry_Queue_Length => Expr
8418
@findex Max_Entry_Queue_Length
8419
This restriction is a declaration that any protected entry compiled in
8420
the scope of the restriction has at most the specified number of
8421
tasks waiting on the entry
8422
at any one time, and so no queue is required.  This restriction is not
8423
checked at compile time.  A program execution is erroneous if an attempt
8424
is made to queue more than the specified number of tasks on such an entry.
8425
 
8426
@item No_Calendar
8427
@findex No_Calendar
8428
This restriction ensures at compile time that there is no implicit or
8429
explicit dependence on the package @code{Ada.Calendar}.
8430
 
8431
@item No_Default_Initialization
8432
@findex No_Default_Initialization
8433
 
8434
This restriction prohibits any instance of default initialization of variables.
8435
The binder implements a consistency rule which prevents any unit compiled
8436
without the restriction from with'ing a unit with the restriction (this allows
8437
the generation of initialization procedures to be skipped, since you can be
8438
sure that no call is ever generated to an initialization procedure in a unit
8439
with the restriction active). If used in conjunction with Initialize_Scalars or
8440
Normalize_Scalars, the effect is to prohibit all cases of variables declared
8441
without a specific initializer (including the case of OUT scalar parameters).
8442
 
8443
@item No_Direct_Boolean_Operators
8444
@findex No_Direct_Boolean_Operators
8445
This restriction ensures that no logical (and/or/xor) are used on
8446
operands of type Boolean (or any type derived
8447
from Boolean). This is intended for use in safety critical programs
8448
where the certification protocol requires the use of short-circuit
8449
(and then, or else) forms for all composite boolean operations.
8450
 
8451
@item No_Dispatching_Calls
8452
@findex No_Dispatching_Calls
8453
This restriction ensures at compile time that the code generated by the
8454
compiler involves no dispatching calls. The use of this restriction allows the
8455
safe use of record extensions, classwide membership tests and other classwide
8456
features not involving implicit dispatching. This restriction ensures that
8457
the code contains no indirect calls through a dispatching mechanism. Note that
8458
this includes internally-generated calls created by the compiler, for example
8459
in the implementation of class-wide objects assignments. The
8460
membership test is allowed in the presence of this restriction, because its
8461
implementation requires no dispatching.
8462
This restriction is comparable to the official Ada restriction
8463
@code{No_Dispatch} except that it is a bit less restrictive in that it allows
8464
all classwide constructs that do not imply dispatching.
8465
The following example indicates constructs that violate this restriction.
8466
 
8467
@smallexample
8468
package Pkg is
8469
  type T is tagged record
8470
    Data : Natural;
8471
  end record;
8472
  procedure P (X : T);
8473
 
8474
  type DT is new T with record
8475
    More_Data : Natural;
8476
  end record;
8477
  procedure Q (X : DT);
8478
end Pkg;
8479
 
8480
with Pkg; use Pkg;
8481
procedure Example is
8482
  procedure Test (O : T'Class) is
8483
    N : Natural  := O'Size;--  Error: Dispatching call
8484
    C : T'Class := O;      --  Error: implicit Dispatching Call
8485
  begin
8486
    if O in DT'Class then  --  OK   : Membership test
8487
       Q (DT (O));         --  OK   : Type conversion plus direct call
8488
    else
8489
       P (O);              --  Error: Dispatching call
8490
    end if;
8491
  end Test;
8492
 
8493
  Obj : DT;
8494
begin
8495
  P (Obj);                 --  OK   : Direct call
8496
  P (T (Obj));             --  OK   : Type conversion plus direct call
8497
  P (T'Class (Obj));       --  Error: Dispatching call
8498
 
8499
  Test (Obj);              --  OK   : Type conversion
8500
 
8501
  if Obj in T'Class then   --  OK   : Membership test
8502
     null;
8503
  end if;
8504
end Example;
8505
@end smallexample
8506
 
8507
@item No_Dynamic_Attachment
8508
@findex No_Dynamic_Attachment
8509
This restriction ensures that there is no call to any of the operations
8510
defined in package Ada.Interrupts.
8511
 
8512
@item No_Enumeration_Maps
8513
@findex No_Enumeration_Maps
8514
This restriction ensures at compile time that no operations requiring
8515
enumeration maps are used (that is Image and Value attributes applied
8516
to enumeration types).
8517
 
8518
@item No_Entry_Calls_In_Elaboration_Code
8519
@findex No_Entry_Calls_In_Elaboration_Code
8520
This restriction ensures at compile time that no task or protected entry
8521
calls are made during elaboration code.  As a result of the use of this
8522
restriction, the compiler can assume that no code past an accept statement
8523
in a task can be executed at elaboration time.
8524
 
8525
@item No_Exception_Handlers
8526
@findex No_Exception_Handlers
8527
This restriction ensures at compile time that there are no explicit
8528
exception handlers. It also indicates that no exception propagation will
8529
be provided. In this mode, exceptions may be raised but will result in
8530
an immediate call to the last chance handler, a routine that the user
8531
must define with the following profile:
8532
 
8533
@smallexample @c ada
8534
procedure Last_Chance_Handler
8535
  (Source_Location : System.Address; Line : Integer);
8536
pragma Export (C, Last_Chance_Handler,
8537
               "__gnat_last_chance_handler");
8538
@end smallexample
8539
 
8540
The parameter is a C null-terminated string representing a message to be
8541
associated with the exception (typically the source location of the raise
8542
statement generated by the compiler). The Line parameter when nonzero
8543
represents the line number in the source program where the raise occurs.
8544
 
8545
@item No_Exception_Propagation
8546
@findex No_Exception_Propagation
8547
This restriction guarantees that exceptions are never propagated to an outer
8548
subprogram scope). The only case in which an exception may be raised is when
8549
the handler is statically in the same subprogram, so that the effect of a raise
8550
is essentially like a goto statement. Any other raise statement (implicit or
8551
explicit) will be considered unhandled. Exception handlers are allowed, but may
8552
not contain an exception occurrence identifier (exception choice). In addition
8553
use of the package GNAT.Current_Exception is not permitted, and reraise
8554
statements (raise with no operand) are not permitted.
8555
 
8556
@item No_Exception_Registration
8557
@findex No_Exception_Registration
8558
This restriction ensures at compile time that no stream operations for
8559
types Exception_Id or Exception_Occurrence are used. This also makes it
8560
impossible to pass exceptions to or from a partition with this restriction
8561
in a distributed environment. If this exception is active, then the generated
8562
code is simplified by omitting the otherwise-required global registration
8563
of exceptions when they are declared.
8564
 
8565
@item No_Implicit_Conditionals
8566
@findex No_Implicit_Conditionals
8567
This restriction ensures that the generated code does not contain any
8568
implicit conditionals, either by modifying the generated code where possible,
8569
or by rejecting any construct that would otherwise generate an implicit
8570
conditional. Note that this check does not include run time constraint
8571
checks, which on some targets may generate implicit conditionals as
8572
well. To control the latter, constraint checks can be suppressed in the
8573
normal manner. Constructs generating implicit conditionals include comparisons
8574
of composite objects and the Max/Min attributes.
8575
 
8576
@item No_Implicit_Dynamic_Code
8577
@findex No_Implicit_Dynamic_Code
8578
@cindex trampoline
8579
This restriction prevents the compiler from building ``trampolines''.
8580
This is a structure that is built on the stack and contains dynamic
8581
code to be executed at run time. On some targets, a trampoline is
8582
built for the following features: @code{Access},
8583
@code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8584
nested task bodies; primitive operations of nested tagged types.
8585
Trampolines do not work on machines that prevent execution of stack
8586
data. For example, on windows systems, enabling DEP (data execution
8587
protection) will cause trampolines to raise an exception.
8588
Trampolines are also quite slow at run time.
8589
 
8590
On many targets, trampolines have been largely eliminated. Look at the
8591
version of system.ads for your target --- if it has
8592
Always_Compatible_Rep equal to False, then trampolines are largely
8593
eliminated. In particular, a trampoline is built for the following
8594
features: @code{Address} of a nested subprogram;
8595
@code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8596
but only if pragma Favor_Top_Level applies, or the access type has a
8597
foreign-language convention; primitive operations of nested tagged
8598
types.
8599
 
8600
@item No_Implicit_Loops
8601
@findex No_Implicit_Loops
8602
This restriction ensures that the generated code does not contain any
8603
implicit @code{for} loops, either by modifying
8604
the generated code where possible,
8605
or by rejecting any construct that would otherwise generate an implicit
8606
@code{for} loop. If this restriction is active, it is possible to build
8607
large array aggregates with all static components without generating an
8608
intermediate temporary, and without generating a loop to initialize individual
8609
components. Otherwise, a loop is created for arrays larger than about 5000
8610
scalar components.
8611
 
8612
@item No_Initialize_Scalars
8613
@findex No_Initialize_Scalars
8614
This restriction ensures that no unit in the partition is compiled with
8615
pragma Initialize_Scalars. This allows the generation of more efficient
8616
code, and in particular eliminates dummy null initialization routines that
8617
are otherwise generated for some record and array types.
8618
 
8619
@item No_Local_Protected_Objects
8620
@findex No_Local_Protected_Objects
8621
This restriction ensures at compile time that protected objects are
8622
only declared at the library level.
8623
 
8624
@item No_Protected_Type_Allocators
8625
@findex No_Protected_Type_Allocators
8626
This restriction ensures at compile time that there are no allocator
8627
expressions that attempt to allocate protected objects.
8628
 
8629
@item No_Secondary_Stack
8630
@findex No_Secondary_Stack
8631
This restriction ensures at compile time that the generated code does not
8632
contain any reference to the secondary stack.  The secondary stack is used
8633
to implement functions returning unconstrained objects (arrays or records)
8634
on some targets.
8635
 
8636
@item No_Select_Statements
8637
@findex No_Select_Statements
8638
This restriction ensures at compile time no select statements of any kind
8639
are permitted, that is the keyword @code{select} may not appear.
8640
This is one of the restrictions of the Ravenscar
8641
profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8642
 
8643
@item No_Standard_Storage_Pools
8644
@findex No_Standard_Storage_Pools
8645
This restriction ensures at compile time that no access types
8646
use the standard default storage pool.  Any access type declared must
8647
have an explicit Storage_Pool attribute defined specifying a
8648
user-defined storage pool.
8649
 
8650
@item No_Streams
8651
@findex No_Streams
8652
This restriction ensures at compile/bind time that there are no
8653
stream objects created and no use of stream attributes.
8654
This restriction does not forbid dependences on the package
8655
@code{Ada.Streams}. So it is permissible to with
8656
@code{Ada.Streams} (or another package that does so itself)
8657
as long as no actual stream objects are created and no
8658
stream attributes are used.
8659
 
8660
Note that the use of restriction allows optimization of tagged types,
8661
since they do not need to worry about dispatching stream operations.
8662
To take maximum advantage of this space-saving optimization, any
8663
unit declaring a tagged type should be compiled with the restriction,
8664
though this is not required.
8665
 
8666
@item No_Task_Attributes_Package
8667
@findex No_Task_Attributes_Package
8668
This restriction ensures at compile time that there are no implicit or
8669
explicit dependencies on the package @code{Ada.Task_Attributes}.
8670
 
8671
@item No_Task_Termination
8672
@findex No_Task_Termination
8673
This restriction ensures at compile time that no terminate alternatives
8674
appear in any task body.
8675
 
8676
@item No_Tasking
8677
@findex No_Tasking
8678
This restriction prevents the declaration of tasks or task types throughout
8679
the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8680
except that violations are caught at compile time and cause an error message
8681
to be output either by the compiler or binder.
8682
 
8683
@item Static_Priorities
8684
@findex Static_Priorities
8685
This restriction ensures at compile time that all priority expressions
8686
are static, and that there are no dependencies on the package
8687
@code{Ada.Dynamic_Priorities}.
8688
 
8689
@item Static_Storage_Size
8690
@findex Static_Storage_Size
8691
This restriction ensures at compile time that any expression appearing
8692
in a Storage_Size pragma or attribute definition clause is static.
8693
 
8694
@end table
8695
 
8696
@noindent
8697
The second set of implementation dependent restriction identifiers
8698
does not require partition-wide consistency.
8699
The restriction may be enforced for a single
8700
compilation unit without any effect on any of the
8701
other compilation units in the partition.
8702
 
8703
@table @code
8704
 
8705
@item No_Elaboration_Code
8706
@findex No_Elaboration_Code
8707
This restriction ensures at compile time that no elaboration code is
8708
generated.  Note that this is not the same condition as is enforced
8709
by pragma @code{Preelaborate}.  There are cases in which pragma
8710
@code{Preelaborate} still permits code to be generated (e.g.@: code
8711
to initialize a large array to all zeroes), and there are cases of units
8712
which do not meet the requirements for pragma @code{Preelaborate},
8713
but for which no elaboration code is generated.  Generally, it is
8714
the case that preelaborable units will meet the restrictions, with
8715
the exception of large aggregates initialized with an others_clause,
8716
and exception declarations (which generate calls to a run-time
8717
registry procedure).  This restriction is enforced on
8718
a unit by unit basis, it need not be obeyed consistently
8719
throughout a partition.
8720
 
8721
In the case of aggregates with others, if the aggregate has a dynamic
8722
size, there is no way to eliminate the elaboration code (such dynamic
8723
bounds would be incompatible with @code{Preelaborate} in any case). If
8724
the bounds are static, then use of this restriction actually modifies
8725
the code choice of the compiler to avoid generating a loop, and instead
8726
generate the aggregate statically if possible, no matter how many times
8727
the data for the others clause must be repeatedly generated.
8728
 
8729
It is not possible to precisely document
8730
the constructs which are compatible with this restriction, since,
8731
unlike most other restrictions, this is not a restriction on the
8732
source code, but a restriction on the generated object code. For
8733
example, if the source contains a declaration:
8734
 
8735
@smallexample
8736
   Val : constant Integer := X;
8737
@end smallexample
8738
 
8739
@noindent
8740
where X is not a static constant, it may be possible, depending
8741
on complex optimization circuitry, for the compiler to figure
8742
out the value of X at compile time, in which case this initialization
8743
can be done by the loader, and requires no initialization code. It
8744
is not possible to document the precise conditions under which the
8745
optimizer can figure this out.
8746
 
8747
Note that this the implementation of this restriction requires full
8748
code generation. If it is used in conjunction with "semantics only"
8749
checking, then some cases of violations may be missed.
8750
 
8751
@item No_Entry_Queue
8752
@findex No_Entry_Queue
8753
This restriction is a declaration that any protected entry compiled in
8754
the scope of the restriction has at most one task waiting on the entry
8755
at any one time, and so no queue is required.  This restriction is not
8756
checked at compile time.  A program execution is erroneous if an attempt
8757
is made to queue a second task on such an entry.
8758
 
8759
@item No_Implementation_Attributes
8760
@findex No_Implementation_Attributes
8761
This restriction checks at compile time that no GNAT-defined attributes
8762
are present.  With this restriction, the only attributes that can be used
8763
are those defined in the Ada Reference Manual.
8764
 
8765
@item No_Implementation_Pragmas
8766
@findex No_Implementation_Pragmas
8767
This restriction checks at compile time that no GNAT-defined pragmas
8768
are present.  With this restriction, the only pragmas that can be used
8769
are those defined in the Ada Reference Manual.
8770
 
8771
@item No_Implementation_Restrictions
8772
@findex No_Implementation_Restrictions
8773
This restriction checks at compile time that no GNAT-defined restriction
8774
identifiers (other than @code{No_Implementation_Restrictions} itself)
8775
are present.  With this restriction, the only other restriction identifiers
8776
that can be used are those defined in the Ada Reference Manual.
8777
 
8778
@item No_Wide_Characters
8779
@findex No_Wide_Characters
8780
This restriction ensures at compile time that no uses of the types
8781
@code{Wide_Character} or @code{Wide_String} or corresponding wide
8782
wide types
8783
appear, and that no wide or wide wide string or character literals
8784
appear in the program (that is literals representing characters not in
8785
type @code{Character}.
8786
 
8787
@end table
8788
 
8789
@sp 1
8790
@cartouche
8791
@noindent
8792
@strong{58}.  The consequences of violating limitations on
8793
@code{Restrictions} pragmas.  See 13.12(9).
8794
@end cartouche
8795
@noindent
8796
Restrictions that can be checked at compile time result in illegalities
8797
if violated.  Currently there are no other consequences of violating
8798
restrictions.
8799
 
8800
@sp 1
8801
@cartouche
8802
@noindent
8803
@strong{59}.  The representation used by the @code{Read} and
8804
@code{Write} attributes of elementary types in terms of stream
8805
elements.  See 13.13.2(9).
8806
@end cartouche
8807
@noindent
8808
The representation is the in-memory representation of the base type of
8809
the type, using the number of bits corresponding to the
8810
@code{@var{type}'Size} value, and the natural ordering of the machine.
8811
 
8812
@sp 1
8813
@cartouche
8814
@noindent
8815
@strong{60}.  The names and characteristics of the numeric subtypes
8816
declared in the visible part of package @code{Standard}.  See A.1(3).
8817
@end cartouche
8818
@noindent
8819
See items describing the integer and floating-point types supported.
8820
 
8821
@sp 1
8822
@cartouche
8823
@noindent
8824
@strong{61}.  The accuracy actually achieved by the elementary
8825
functions.  See A.5.1(1).
8826
@end cartouche
8827
@noindent
8828
The elementary functions correspond to the functions available in the C
8829
library.  Only fast math mode is implemented.
8830
 
8831
@sp 1
8832
@cartouche
8833
@noindent
8834
@strong{62}.  The sign of a zero result from some of the operators or
8835
functions in @code{Numerics.Generic_Elementary_Functions}, when
8836
@code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8837
@end cartouche
8838
@noindent
8839
The sign of zeroes follows the requirements of the IEEE 754 standard on
8840
floating-point.
8841
 
8842
@sp 1
8843
@cartouche
8844
@noindent
8845
@strong{63}.  The value of
8846
@code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8847
@end cartouche
8848
@noindent
8849
Maximum image width is 649, see library file @file{a-numran.ads}.
8850
 
8851
@sp 1
8852
@cartouche
8853
@noindent
8854
@strong{64}.  The value of
8855
@code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8856
@end cartouche
8857
@noindent
8858
Maximum image width is 80, see library file @file{a-nudira.ads}.
8859
 
8860
@sp 1
8861
@cartouche
8862
@noindent
8863
@strong{65}.  The algorithms for random number generation.  See
8864
A.5.2(32).
8865
@end cartouche
8866
@noindent
8867
The algorithm is documented in the source files @file{a-numran.ads} and
8868
@file{a-numran.adb}.
8869
 
8870
@sp 1
8871
@cartouche
8872
@noindent
8873
@strong{66}.  The string representation of a random number generator's
8874
state.  See A.5.2(38).
8875
@end cartouche
8876
@noindent
8877
See the documentation contained in the file @file{a-numran.adb}.
8878
 
8879
@sp 1
8880
@cartouche
8881
@noindent
8882
@strong{67}.  The minimum time interval between calls to the
8883
time-dependent Reset procedure that are guaranteed to initiate different
8884
random number sequences.  See A.5.2(45).
8885
@end cartouche
8886
@noindent
8887
The minimum period between reset calls to guarantee distinct series of
8888
random numbers is one microsecond.
8889
 
8890
@sp 1
8891
@cartouche
8892
@noindent
8893
@strong{68}.  The values of the @code{Model_Mantissa},
8894
@code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8895
@code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8896
Annex is not supported.  See A.5.3(72).
8897
@end cartouche
8898
@noindent
8899
See the source file @file{ttypef.ads} for the values of all numeric
8900
attributes.
8901
 
8902
@sp 1
8903
@cartouche
8904
@noindent
8905
@strong{69}.  Any implementation-defined characteristics of the
8906
input-output packages.  See A.7(14).
8907
@end cartouche
8908
@noindent
8909
There are no special implementation defined characteristics for these
8910
packages.
8911
 
8912
@sp 1
8913
@cartouche
8914
@noindent
8915
@strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8916
A.9(10).
8917
@end cartouche
8918
@noindent
8919
All type representations are contiguous, and the @code{Buffer_Size} is
8920
the value of @code{@var{type}'Size} rounded up to the next storage unit
8921
boundary.
8922
 
8923
@sp 1
8924
@cartouche
8925
@noindent
8926
@strong{71}.  External files for standard input, standard output, and
8927
standard error See A.10(5).
8928
@end cartouche
8929
@noindent
8930
These files are mapped onto the files provided by the C streams
8931
libraries.  See source file @file{i-cstrea.ads} for further details.
8932
 
8933
@sp 1
8934
@cartouche
8935
@noindent
8936
@strong{72}.  The accuracy of the value produced by @code{Put}.  See
8937
A.10.9(36).
8938
@end cartouche
8939
@noindent
8940
If more digits are requested in the output than are represented by the
8941
precision of the value, zeroes are output in the corresponding least
8942
significant digit positions.
8943
 
8944
@sp 1
8945
@cartouche
8946
@noindent
8947
@strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8948
@code{Command_Name}.  See A.15(1).
8949
@end cartouche
8950
@noindent
8951
These are mapped onto the @code{argv} and @code{argc} parameters of the
8952
main program in the natural manner.
8953
 
8954
@sp 1
8955
@cartouche
8956
@noindent
8957
@strong{74}.  Implementation-defined convention names.  See B.1(11).
8958
@end cartouche
8959
@noindent
8960
The following convention names are supported
8961
 
8962
@table @code
8963
@item  Ada
8964
Ada
8965
@item Assembler
8966
Assembly language
8967
@item Asm
8968
Synonym for Assembler
8969
@item Assembly
8970
Synonym for Assembler
8971
@item C
8972
C
8973
@item C_Pass_By_Copy
8974
Allowed only for record types, like C, but also notes that record
8975
is to be passed by copy rather than reference.
8976
@item COBOL
8977
COBOL
8978
@item C_Plus_Plus (or CPP)
8979
C++
8980
@item Default
8981
Treated the same as C
8982
@item External
8983
Treated the same as C
8984
@item Fortran
8985
Fortran
8986
@item Intrinsic
8987
For support of pragma @code{Import} with convention Intrinsic, see
8988
separate section on Intrinsic Subprograms.
8989
@item Stdcall
8990
Stdcall (used for Windows implementations only).  This convention correspond
8991
to the WINAPI (previously called Pascal convention) C/C++ convention under
8992
Windows.  A function with this convention cleans the stack before exit.
8993
@item DLL
8994
Synonym for Stdcall
8995
@item Win32
8996
Synonym for Stdcall
8997
@item Stubbed
8998
Stubbed is a special convention used to indicate that the body of the
8999
subprogram will be entirely ignored.  Any call to the subprogram
9000
is converted into a raise of the @code{Program_Error} exception.  If a
9001
pragma @code{Import} specifies convention @code{stubbed} then no body need
9002
be present at all.  This convention is useful during development for the
9003
inclusion of subprograms whose body has not yet been written.
9004
 
9005
@end table
9006
@noindent
9007
In addition, all otherwise unrecognized convention names are also
9008
treated as being synonymous with convention C@.  In all implementations
9009
except for VMS, use of such other names results in a warning.  In VMS
9010
implementations, these names are accepted silently.
9011
 
9012
@sp 1
9013
@cartouche
9014
@noindent
9015
@strong{75}.  The meaning of link names.  See B.1(36).
9016
@end cartouche
9017
@noindent
9018
Link names are the actual names used by the linker.
9019
 
9020
@sp 1
9021
@cartouche
9022
@noindent
9023
@strong{76}.  The manner of choosing link names when neither the link
9024
name nor the address of an imported or exported entity is specified.  See
9025
B.1(36).
9026
@end cartouche
9027
@noindent
9028
The default linker name is that which would be assigned by the relevant
9029
external language, interpreting the Ada name as being in all lower case
9030
letters.
9031
 
9032
@sp 1
9033
@cartouche
9034
@noindent
9035
@strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9036
@end cartouche
9037
@noindent
9038
The string passed to @code{Linker_Options} is presented uninterpreted as
9039
an argument to the link command, unless it contains ASCII.NUL characters.
9040
NUL characters if they appear act as argument separators, so for example
9041
 
9042
@smallexample @c ada
9043
pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9044
@end smallexample
9045
 
9046
@noindent
9047
causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9048
linker. The order of linker options is preserved for a given unit. The final
9049
list of options passed to the linker is in reverse order of the elaboration
9050
order. For example, linker options for a body always appear before the options
9051
from the corresponding package spec.
9052
 
9053
@sp 1
9054
@cartouche
9055
@noindent
9056
@strong{78}.  The contents of the visible part of package
9057
@code{Interfaces} and its language-defined descendants.  See B.2(1).
9058
@end cartouche
9059
@noindent
9060
See files with prefix @file{i-} in the distributed library.
9061
 
9062
@sp 1
9063
@cartouche
9064
@noindent
9065
@strong{79}.  Implementation-defined children of package
9066
@code{Interfaces}.  The contents of the visible part of package
9067
@code{Interfaces}.  See B.2(11).
9068
@end cartouche
9069
@noindent
9070
See files with prefix @file{i-} in the distributed library.
9071
 
9072
@sp 1
9073
@cartouche
9074
@noindent
9075
@strong{80}.  The types @code{Floating}, @code{Long_Floating},
9076
@code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9077
@code{COBOL_Character}; and the initialization of the variables
9078
@code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9079
@code{Interfaces.COBOL}.  See B.4(50).
9080
@end cartouche
9081
@noindent
9082
@table @code
9083
@item Floating
9084
Float
9085
@item Long_Floating
9086
(Floating) Long_Float
9087
@item Binary
9088
Integer
9089
@item Long_Binary
9090
Long_Long_Integer
9091
@item Decimal_Element
9092
Character
9093
@item COBOL_Character
9094
Character
9095
@end table
9096
 
9097
@noindent
9098
For initialization, see the file @file{i-cobol.ads} in the distributed library.
9099
 
9100
@sp 1
9101
@cartouche
9102
@noindent
9103
@strong{81}.  Support for access to machine instructions.  See C.1(1).
9104
@end cartouche
9105
@noindent
9106
See documentation in file @file{s-maccod.ads} in the distributed library.
9107
 
9108
@sp 1
9109
@cartouche
9110
@noindent
9111
@strong{82}.  Implementation-defined aspects of access to machine
9112
operations.  See C.1(9).
9113
@end cartouche
9114
@noindent
9115
See documentation in file @file{s-maccod.ads} in the distributed library.
9116
 
9117
@sp 1
9118
@cartouche
9119
@noindent
9120
@strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9121
@end cartouche
9122
@noindent
9123
Interrupts are mapped to signals or conditions as appropriate.  See
9124
definition of unit
9125
@code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9126
on the interrupts supported on a particular target.
9127
 
9128
@sp 1
9129
@cartouche
9130
@noindent
9131
@strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9132
C.4(13).
9133
@end cartouche
9134
@noindent
9135
GNAT does not permit a partition to be restarted without reloading,
9136
except under control of the debugger.
9137
 
9138
@sp 1
9139
@cartouche
9140
@noindent
9141
@strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9142
@end cartouche
9143
@noindent
9144
Pragma @code{Discard_Names} causes names of enumeration literals to
9145
be suppressed.  In the presence of this pragma, the Image attribute
9146
provides the image of the Pos of the literal, and Value accepts
9147
Pos values.
9148
 
9149
@sp 1
9150
@cartouche
9151
@noindent
9152
@strong{86}.  The result of the @code{Task_Identification.Image}
9153
attribute.  See C.7.1(7).
9154
@end cartouche
9155
@noindent
9156
The result of this attribute is a string that identifies
9157
the object or component that denotes a given task. If a variable @code{Var}
9158
has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9159
where the suffix
9160
is the hexadecimal representation of the virtual address of the corresponding
9161
task control block. If the variable is an array of tasks, the image of each
9162
task will have the form of an indexed component indicating the position of a
9163
given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9164
component of a record, the image of the task will have the form of a selected
9165
component. These rules are fully recursive, so that the image of a task that
9166
is a subcomponent of a composite object corresponds to the expression that
9167
designates this task.
9168
@noindent
9169
If a task is created by an allocator, its image depends on the context. If the
9170
allocator is part of an object declaration, the rules described above are used
9171
to construct its image, and this image is not affected by subsequent
9172
assignments. If the allocator appears within an expression, the image
9173
includes only the name of the task type.
9174
@noindent
9175
If the configuration pragma Discard_Names is present, or if the restriction
9176
No_Implicit_Heap_Allocation is in effect,  the image reduces to
9177
the numeric suffix, that is to say the hexadecimal representation of the
9178
virtual address of the control block of the task.
9179
@sp 1
9180
@cartouche
9181
@noindent
9182
@strong{87}.  The value of @code{Current_Task} when in a protected entry
9183
or interrupt handler.  See C.7.1(17).
9184
@end cartouche
9185
@noindent
9186
Protected entries or interrupt handlers can be executed by any
9187
convenient thread, so the value of @code{Current_Task} is undefined.
9188
 
9189
@sp 1
9190
@cartouche
9191
@noindent
9192
@strong{88}.  The effect of calling @code{Current_Task} from an entry
9193
body or interrupt handler.  See C.7.1(19).
9194
@end cartouche
9195
@noindent
9196
The effect of calling @code{Current_Task} from an entry body or
9197
interrupt handler is to return the identification of the task currently
9198
executing the code.
9199
 
9200
@sp 1
9201
@cartouche
9202
@noindent
9203
@strong{89}.  Implementation-defined aspects of
9204
@code{Task_Attributes}.  See C.7.2(19).
9205
@end cartouche
9206
@noindent
9207
There are no implementation-defined aspects of @code{Task_Attributes}.
9208
 
9209
@sp 1
9210
@cartouche
9211
@noindent
9212
@strong{90}.  Values of all @code{Metrics}.  See D(2).
9213
@end cartouche
9214
@noindent
9215
The metrics information for GNAT depends on the performance of the
9216
underlying operating system.  The sources of the run-time for tasking
9217
implementation, together with the output from @option{-gnatG} can be
9218
used to determine the exact sequence of operating systems calls made
9219
to implement various tasking constructs.  Together with appropriate
9220
information on the performance of the underlying operating system,
9221
on the exact target in use, this information can be used to determine
9222
the required metrics.
9223
 
9224
@sp 1
9225
@cartouche
9226
@noindent
9227
@strong{91}.  The declarations of @code{Any_Priority} and
9228
@code{Priority}.  See D.1(11).
9229
@end cartouche
9230
@noindent
9231
See declarations in file @file{system.ads}.
9232
 
9233
@sp 1
9234
@cartouche
9235
@noindent
9236
@strong{92}.  Implementation-defined execution resources.  See D.1(15).
9237
@end cartouche
9238
@noindent
9239
There are no implementation-defined execution resources.
9240
 
9241
@sp 1
9242
@cartouche
9243
@noindent
9244
@strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9245
access to a protected object keeps its processor busy.  See D.2.1(3).
9246
@end cartouche
9247
@noindent
9248
On a multi-processor, a task that is waiting for access to a protected
9249
object does not keep its processor busy.
9250
 
9251
@sp 1
9252
@cartouche
9253
@noindent
9254
@strong{94}.  The affect of implementation defined execution resources
9255
on task dispatching.  See D.2.1(9).
9256
@end cartouche
9257
@noindent
9258
@c SGI info
9259
@ignore
9260
Tasks map to IRIX threads, and the dispatching policy is as defined by
9261
the IRIX implementation of threads.
9262
@end ignore
9263
Tasks map to threads in the threads package used by GNAT@.  Where possible
9264
and appropriate, these threads correspond to native threads of the
9265
underlying operating system.
9266
 
9267
@sp 1
9268
@cartouche
9269
@noindent
9270
@strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9271
in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9272
@end cartouche
9273
@noindent
9274
There are no implementation-defined policy-identifiers allowed in this
9275
pragma.
9276
 
9277
@sp 1
9278
@cartouche
9279
@noindent
9280
@strong{96}.  Implementation-defined aspects of priority inversion.  See
9281
D.2.2(16).
9282
@end cartouche
9283
@noindent
9284
Execution of a task cannot be preempted by the implementation processing
9285
of delay expirations for lower priority tasks.
9286
 
9287
@sp 1
9288
@cartouche
9289
@noindent
9290
@strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9291
@end cartouche
9292
@noindent
9293
@c SGI info:
9294
@ignore
9295
Tasks map to IRIX threads, and the dispatching policy is as defined by
9296
the IRIX implementation of threads.
9297
@end ignore
9298
The policy is the same as that of the underlying threads implementation.
9299
 
9300
@sp 1
9301
@cartouche
9302
@noindent
9303
@strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9304
in a pragma @code{Locking_Policy}.  See D.3(4).
9305
@end cartouche
9306
@noindent
9307
The only implementation defined policy permitted in GNAT is
9308
@code{Inheritance_Locking}.  On targets that support this policy, locking
9309
is implemented by inheritance, i.e.@: the task owning the lock operates
9310
at a priority equal to the highest priority of any task currently
9311
requesting the lock.
9312
 
9313
@sp 1
9314
@cartouche
9315
@noindent
9316
@strong{99}.  Default ceiling priorities.  See D.3(10).
9317
@end cartouche
9318
@noindent
9319
The ceiling priority of protected objects of the type
9320
@code{System.Interrupt_Priority'Last} as described in the Ada
9321
Reference Manual D.3(10),
9322
 
9323
@sp 1
9324
@cartouche
9325
@noindent
9326
@strong{100}.  The ceiling of any protected object used internally by
9327
the implementation.  See D.3(16).
9328
@end cartouche
9329
@noindent
9330
The ceiling priority of internal protected objects is
9331
@code{System.Priority'Last}.
9332
 
9333
@sp 1
9334
@cartouche
9335
@noindent
9336
@strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9337
@end cartouche
9338
@noindent
9339
There are no implementation-defined queuing policies.
9340
 
9341
@sp 1
9342
@cartouche
9343
@noindent
9344
@strong{102}.  On a multiprocessor, any conditions that cause the
9345
completion of an aborted construct to be delayed later than what is
9346
specified for a single processor.  See D.6(3).
9347
@end cartouche
9348
@noindent
9349
The semantics for abort on a multi-processor is the same as on a single
9350
processor, there are no further delays.
9351
 
9352
@sp 1
9353
@cartouche
9354
@noindent
9355
@strong{103}.  Any operations that implicitly require heap storage
9356
allocation.  See D.7(8).
9357
@end cartouche
9358
@noindent
9359
The only operation that implicitly requires heap storage allocation is
9360
task creation.
9361
 
9362
@sp 1
9363
@cartouche
9364
@noindent
9365
@strong{104}.  Implementation-defined aspects of pragma
9366
@code{Restrictions}.  See D.7(20).
9367
@end cartouche
9368
@noindent
9369
There are no such implementation-defined aspects.
9370
 
9371
@sp 1
9372
@cartouche
9373
@noindent
9374
@strong{105}.  Implementation-defined aspects of package
9375
@code{Real_Time}.  See D.8(17).
9376
@end cartouche
9377
@noindent
9378
There are no implementation defined aspects of package @code{Real_Time}.
9379
 
9380
@sp 1
9381
@cartouche
9382
@noindent
9383
@strong{106}.  Implementation-defined aspects of
9384
@code{delay_statements}.  See D.9(8).
9385
@end cartouche
9386
@noindent
9387
Any difference greater than one microsecond will cause the task to be
9388
delayed (see D.9(7)).
9389
 
9390
@sp 1
9391
@cartouche
9392
@noindent
9393
@strong{107}.  The upper bound on the duration of interrupt blocking
9394
caused by the implementation.  See D.12(5).
9395
@end cartouche
9396
@noindent
9397
The upper bound is determined by the underlying operating system.  In
9398
no cases is it more than 10 milliseconds.
9399
 
9400
@sp 1
9401
@cartouche
9402
@noindent
9403
@strong{108}.  The means for creating and executing distributed
9404
programs.  See E(5).
9405
@end cartouche
9406
@noindent
9407
The GLADE package provides a utility GNATDIST for creating and executing
9408
distributed programs.  See the GLADE reference manual for further details.
9409
 
9410
@sp 1
9411
@cartouche
9412
@noindent
9413
@strong{109}.  Any events that can result in a partition becoming
9414
inaccessible.  See E.1(7).
9415
@end cartouche
9416
@noindent
9417
See the GLADE reference manual for full details on such events.
9418
 
9419
@sp 1
9420
@cartouche
9421
@noindent
9422
@strong{110}.  The scheduling policies, treatment of priorities, and
9423
management of shared resources between partitions in certain cases.  See
9424
E.1(11).
9425
@end cartouche
9426
@noindent
9427
See the GLADE reference manual for full details on these aspects of
9428
multi-partition execution.
9429
 
9430
@sp 1
9431
@cartouche
9432
@noindent
9433
@strong{111}.  Events that cause the version of a compilation unit to
9434
change.  See E.3(5).
9435
@end cartouche
9436
@noindent
9437
Editing the source file of a compilation unit, or the source files of
9438
any units on which it is dependent in a significant way cause the version
9439
to change.  No other actions cause the version number to change.  All changes
9440
are significant except those which affect only layout, capitalization or
9441
comments.
9442
 
9443
@sp 1
9444
@cartouche
9445
@noindent
9446
@strong{112}.  Whether the execution of the remote subprogram is
9447
immediately aborted as a result of cancellation.  See E.4(13).
9448
@end cartouche
9449
@noindent
9450
See the GLADE reference manual for details on the effect of abort in
9451
a distributed application.
9452
 
9453
@sp 1
9454
@cartouche
9455
@noindent
9456
@strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9457
@end cartouche
9458
@noindent
9459
See the GLADE reference manual for a full description of all implementation
9460
defined aspects of the PCS@.
9461
 
9462
@sp 1
9463
@cartouche
9464
@noindent
9465
@strong{114}.  Implementation-defined interfaces in the PCS@.  See
9466
E.5(26).
9467
@end cartouche
9468
@noindent
9469
See the GLADE reference manual for a full description of all
9470
implementation defined interfaces.
9471
 
9472
@sp 1
9473
@cartouche
9474
@noindent
9475
@strong{115}.  The values of named numbers in the package
9476
@code{Decimal}.  See F.2(7).
9477
@end cartouche
9478
@noindent
9479
@table @code
9480
@item Max_Scale
9481
+18
9482
@item Min_Scale
9483
-18
9484
@item Min_Delta
9485
1.0E-18
9486
@item Max_Delta
9487
1.0E+18
9488
@item Max_Decimal_Digits
9489
18
9490
@end table
9491
 
9492
@sp 1
9493
@cartouche
9494
@noindent
9495
@strong{116}.  The value of @code{Max_Picture_Length} in the package
9496
@code{Text_IO.Editing}.  See F.3.3(16).
9497
@end cartouche
9498
@noindent
9499
64
9500
 
9501
@sp 1
9502
@cartouche
9503
@noindent
9504
@strong{117}.  The value of @code{Max_Picture_Length} in the package
9505
@code{Wide_Text_IO.Editing}.  See F.3.4(5).
9506
@end cartouche
9507
@noindent
9508
64
9509
 
9510
@sp 1
9511
@cartouche
9512
@noindent
9513
@strong{118}.  The accuracy actually achieved by the complex elementary
9514
functions and by other complex arithmetic operations.  See G.1(1).
9515
@end cartouche
9516
@noindent
9517
Standard library functions are used for the complex arithmetic
9518
operations.  Only fast math mode is currently supported.
9519
 
9520
@sp 1
9521
@cartouche
9522
@noindent
9523
@strong{119}.  The sign of a zero result (or a component thereof) from
9524
any operator or function in @code{Numerics.Generic_Complex_Types}, when
9525
@code{Real'Signed_Zeros} is True.  See G.1.1(53).
9526
@end cartouche
9527
@noindent
9528
The signs of zero values are as recommended by the relevant
9529
implementation advice.
9530
 
9531
@sp 1
9532
@cartouche
9533
@noindent
9534
@strong{120}.  The sign of a zero result (or a component thereof) from
9535
any operator or function in
9536
@code{Numerics.Generic_Complex_Elementary_Functions}, when
9537
@code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9538
@end cartouche
9539
@noindent
9540
The signs of zero values are as recommended by the relevant
9541
implementation advice.
9542
 
9543
@sp 1
9544
@cartouche
9545
@noindent
9546
@strong{121}.  Whether the strict mode or the relaxed mode is the
9547
default.  See G.2(2).
9548
@end cartouche
9549
@noindent
9550
The strict mode is the default.  There is no separate relaxed mode.  GNAT
9551
provides a highly efficient implementation of strict mode.
9552
 
9553
@sp 1
9554
@cartouche
9555
@noindent
9556
@strong{122}.  The result interval in certain cases of fixed-to-float
9557
conversion.  See G.2.1(10).
9558
@end cartouche
9559
@noindent
9560
For cases where the result interval is implementation dependent, the
9561
accuracy is that provided by performing all operations in 64-bit IEEE
9562
floating-point format.
9563
 
9564
@sp 1
9565
@cartouche
9566
@noindent
9567
@strong{123}.  The result of a floating point arithmetic operation in
9568
overflow situations, when the @code{Machine_Overflows} attribute of the
9569
result type is @code{False}.  See G.2.1(13).
9570
@end cartouche
9571
@noindent
9572
Infinite and NaN values are produced as dictated by the IEEE
9573
floating-point standard.
9574
 
9575
Note that on machines that are not fully compliant with the IEEE
9576
floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9577
must be used for achieving IEEE confirming behavior (although at the cost
9578
of a significant performance penalty), so infinite and NaN values are
9579
properly generated.
9580
 
9581
@sp 1
9582
@cartouche
9583
@noindent
9584
@strong{124}.  The result interval for division (or exponentiation by a
9585
negative exponent), when the floating point hardware implements division
9586
as multiplication by a reciprocal.  See G.2.1(16).
9587
@end cartouche
9588
@noindent
9589
Not relevant, division is IEEE exact.
9590
 
9591
@sp 1
9592
@cartouche
9593
@noindent
9594
@strong{125}.  The definition of close result set, which determines the
9595
accuracy of certain fixed point multiplications and divisions.  See
9596
G.2.3(5).
9597
@end cartouche
9598
@noindent
9599
Operations in the close result set are performed using IEEE long format
9600
floating-point arithmetic.  The input operands are converted to
9601
floating-point, the operation is done in floating-point, and the result
9602
is converted to the target type.
9603
 
9604
@sp 1
9605
@cartouche
9606
@noindent
9607
@strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9608
point multiplication or division for which the result shall be in the
9609
perfect result set.  See G.2.3(22).
9610
@end cartouche
9611
@noindent
9612
The result is only defined to be in the perfect result set if the result
9613
can be computed by a single scaling operation involving a scale factor
9614
representable in 64-bits.
9615
 
9616
@sp 1
9617
@cartouche
9618
@noindent
9619
@strong{127}.  The result of a fixed point arithmetic operation in
9620
overflow situations, when the @code{Machine_Overflows} attribute of the
9621
result type is @code{False}.  See G.2.3(27).
9622
@end cartouche
9623
@noindent
9624
Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9625
types.
9626
 
9627
@sp 1
9628
@cartouche
9629
@noindent
9630
@strong{128}.  The result of an elementary function reference in
9631
overflow situations, when the @code{Machine_Overflows} attribute of the
9632
result type is @code{False}.  See G.2.4(4).
9633
@end cartouche
9634
@noindent
9635
IEEE infinite and Nan values are produced as appropriate.
9636
 
9637
@sp 1
9638
@cartouche
9639
@noindent
9640
@strong{129}.  The value of the angle threshold, within which certain
9641
elementary functions, complex arithmetic operations, and complex
9642
elementary functions yield results conforming to a maximum relative
9643
error bound.  See G.2.4(10).
9644
@end cartouche
9645
@noindent
9646
Information on this subject is not yet available.
9647
 
9648
@sp 1
9649
@cartouche
9650
@noindent
9651
@strong{130}.  The accuracy of certain elementary functions for
9652
parameters beyond the angle threshold.  See G.2.4(10).
9653
@end cartouche
9654
@noindent
9655
Information on this subject is not yet available.
9656
 
9657
@sp 1
9658
@cartouche
9659
@noindent
9660
@strong{131}.  The result of a complex arithmetic operation or complex
9661
elementary function reference in overflow situations, when the
9662
@code{Machine_Overflows} attribute of the corresponding real type is
9663
@code{False}.  See G.2.6(5).
9664
@end cartouche
9665
@noindent
9666
IEEE infinite and Nan values are produced as appropriate.
9667
 
9668
@sp 1
9669
@cartouche
9670
@noindent
9671
@strong{132}.  The accuracy of certain complex arithmetic operations and
9672
certain complex elementary functions for parameters (or components
9673
thereof) beyond the angle threshold.  See G.2.6(8).
9674
@end cartouche
9675
@noindent
9676
Information on those subjects is not yet available.
9677
 
9678
@sp 1
9679
@cartouche
9680
@noindent
9681
@strong{133}.  Information regarding bounded errors and erroneous
9682
execution.  See H.2(1).
9683
@end cartouche
9684
@noindent
9685
Information on this subject is not yet available.
9686
 
9687
@sp 1
9688
@cartouche
9689
@noindent
9690
@strong{134}.  Implementation-defined aspects of pragma
9691
@code{Inspection_Point}.  See H.3.2(8).
9692
@end cartouche
9693
@noindent
9694
Pragma @code{Inspection_Point} ensures that the variable is live and can
9695
be examined by the debugger at the inspection point.
9696
 
9697
@sp 1
9698
@cartouche
9699
@noindent
9700
@strong{135}.  Implementation-defined aspects of pragma
9701
@code{Restrictions}.  See H.4(25).
9702
@end cartouche
9703
@noindent
9704
There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9705
use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9706
generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9707
 
9708
@sp 1
9709
@cartouche
9710
@noindent
9711
@strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9712
H.4(27).
9713
@end cartouche
9714
@noindent
9715
There are no restrictions on pragma @code{Restrictions}.
9716
 
9717
@node Intrinsic Subprograms
9718
@chapter Intrinsic Subprograms
9719
@cindex Intrinsic Subprograms
9720
 
9721
@menu
9722
* Intrinsic Operators::
9723
* Enclosing_Entity::
9724
* Exception_Information::
9725
* Exception_Message::
9726
* Exception_Name::
9727
* File::
9728
* Line::
9729
* Rotate_Left::
9730
* Rotate_Right::
9731
* Shift_Left::
9732
* Shift_Right::
9733
* Shift_Right_Arithmetic::
9734
* Source_Location::
9735
@end menu
9736
 
9737
@noindent
9738
GNAT allows a user application program to write the declaration:
9739
 
9740
@smallexample @c ada
9741
   pragma Import (Intrinsic, name);
9742
@end smallexample
9743
 
9744
@noindent
9745
providing that the name corresponds to one of the implemented intrinsic
9746
subprograms in GNAT, and that the parameter profile of the referenced
9747
subprogram meets the requirements.  This chapter describes the set of
9748
implemented intrinsic subprograms, and the requirements on parameter profiles.
9749
Note that no body is supplied; as with other uses of pragma Import, the
9750
body is supplied elsewhere (in this case by the compiler itself).  Note
9751
that any use of this feature is potentially non-portable, since the
9752
Ada standard does not require Ada compilers to implement this feature.
9753
 
9754
@node Intrinsic Operators
9755
@section Intrinsic Operators
9756
@cindex Intrinsic operator
9757
 
9758
@noindent
9759
All the predefined numeric operators in package Standard
9760
in @code{pragma Import (Intrinsic,..)}
9761
declarations.  In the binary operator case, the operands must have the same
9762
size.  The operand or operands must also be appropriate for
9763
the operator.  For example, for addition, the operands must
9764
both be floating-point or both be fixed-point, and the
9765
right operand for @code{"**"} must have a root type of
9766
@code{Standard.Integer'Base}.
9767
You can use an intrinsic operator declaration as in the following example:
9768
 
9769
@smallexample @c ada
9770
   type Int1 is new Integer;
9771
   type Int2 is new Integer;
9772
 
9773
   function "+" (X1 : Int1; X2 : Int2) return Int1;
9774
   function "+" (X1 : Int1; X2 : Int2) return Int2;
9775
   pragma Import (Intrinsic, "+");
9776
@end smallexample
9777
 
9778
@noindent
9779
This declaration would permit ``mixed mode'' arithmetic on items
9780
of the differing types @code{Int1} and @code{Int2}.
9781
It is also possible to specify such operators for private types, if the
9782
full views are appropriate arithmetic types.
9783
 
9784
@node Enclosing_Entity
9785
@section Enclosing_Entity
9786
@cindex Enclosing_Entity
9787
@noindent
9788
This intrinsic subprogram is used in the implementation of the
9789
library routine @code{GNAT.Source_Info}.  The only useful use of the
9790
intrinsic import in this case is the one in this unit, so an
9791
application program should simply call the function
9792
@code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9793
the current subprogram, package, task, entry, or protected subprogram.
9794
 
9795
@node Exception_Information
9796
@section Exception_Information
9797
@cindex Exception_Information'
9798
@noindent
9799
This intrinsic subprogram is used in the implementation of the
9800
library routine @code{GNAT.Current_Exception}.  The only useful
9801
use of the intrinsic import in this case is the one in this unit,
9802
so an application program should simply call the function
9803
@code{GNAT.Current_Exception.Exception_Information} to obtain
9804
the exception information associated with the current exception.
9805
 
9806
@node Exception_Message
9807
@section Exception_Message
9808
@cindex Exception_Message
9809
@noindent
9810
This intrinsic subprogram is used in the implementation of the
9811
library routine @code{GNAT.Current_Exception}.  The only useful
9812
use of the intrinsic import in this case is the one in this unit,
9813
so an application program should simply call the function
9814
@code{GNAT.Current_Exception.Exception_Message} to obtain
9815
the message associated with the current exception.
9816
 
9817
@node Exception_Name
9818
@section Exception_Name
9819
@cindex Exception_Name
9820
@noindent
9821
This intrinsic subprogram is used in the implementation of the
9822
library routine @code{GNAT.Current_Exception}.  The only useful
9823
use of the intrinsic import in this case is the one in this unit,
9824
so an application program should simply call the function
9825
@code{GNAT.Current_Exception.Exception_Name} to obtain
9826
the name of the current exception.
9827
 
9828
@node File
9829
@section File
9830
@cindex File
9831
@noindent
9832
This intrinsic subprogram is used in the implementation of the
9833
library routine @code{GNAT.Source_Info}.  The only useful use of the
9834
intrinsic import in this case is the one in this unit, so an
9835
application program should simply call the function
9836
@code{GNAT.Source_Info.File} to obtain the name of the current
9837
file.
9838
 
9839
@node Line
9840
@section Line
9841
@cindex Line
9842
@noindent
9843
This intrinsic subprogram is used in the implementation of the
9844
library routine @code{GNAT.Source_Info}.  The only useful use of the
9845
intrinsic import in this case is the one in this unit, so an
9846
application program should simply call the function
9847
@code{GNAT.Source_Info.Line} to obtain the number of the current
9848
source line.
9849
 
9850
@node Rotate_Left
9851
@section Rotate_Left
9852
@cindex Rotate_Left
9853
@noindent
9854
In standard Ada, the @code{Rotate_Left} function is available only
9855
for the predefined modular types in package @code{Interfaces}.  However, in
9856
GNAT it is possible to define a Rotate_Left function for a user
9857
defined modular type or any signed integer type as in this example:
9858
 
9859
@smallexample @c ada
9860
   function Shift_Left
9861
     (Value  : My_Modular_Type;
9862
      Amount : Natural)
9863
      return   My_Modular_Type;
9864
@end smallexample
9865
 
9866
@noindent
9867
The requirements are that the profile be exactly as in the example
9868
above.  The only modifications allowed are in the formal parameter
9869
names, and in the type of @code{Value} and the return type, which
9870
must be the same, and must be either a signed integer type, or
9871
a modular integer type with a binary modulus, and the size must
9872
be 8.  16, 32 or 64 bits.
9873
 
9874
@node Rotate_Right
9875
@section Rotate_Right
9876
@cindex Rotate_Right
9877
@noindent
9878
A @code{Rotate_Right} function can be defined for any user defined
9879
binary modular integer type, or signed integer type, as described
9880
above for @code{Rotate_Left}.
9881
 
9882
@node Shift_Left
9883
@section Shift_Left
9884
@cindex Shift_Left
9885
@noindent
9886
A @code{Shift_Left} function can be defined for any user defined
9887
binary modular integer type, or signed integer type, as described
9888
above for @code{Rotate_Left}.
9889
 
9890
@node Shift_Right
9891
@section Shift_Right
9892
@cindex Shift_Right
9893
@noindent
9894
A @code{Shift_Right} function can be defined for any user defined
9895
binary modular integer type, or signed integer type, as described
9896
above for @code{Rotate_Left}.
9897
 
9898
@node Shift_Right_Arithmetic
9899
@section Shift_Right_Arithmetic
9900
@cindex Shift_Right_Arithmetic
9901
@noindent
9902
A @code{Shift_Right_Arithmetic} function can be defined for any user
9903
defined binary modular integer type, or signed integer type, as described
9904
above for @code{Rotate_Left}.
9905
 
9906
@node Source_Location
9907
@section Source_Location
9908
@cindex Source_Location
9909
@noindent
9910
This intrinsic subprogram is used in the implementation of the
9911
library routine @code{GNAT.Source_Info}.  The only useful use of the
9912
intrinsic import in this case is the one in this unit, so an
9913
application program should simply call the function
9914
@code{GNAT.Source_Info.Source_Location} to obtain the current
9915
source file location.
9916
 
9917
@node Representation Clauses and Pragmas
9918
@chapter Representation Clauses and Pragmas
9919
@cindex Representation Clauses
9920
 
9921
@menu
9922
* Alignment Clauses::
9923
* Size Clauses::
9924
* Storage_Size Clauses::
9925
* Size of Variant Record Objects::
9926
* Biased Representation ::
9927
* Value_Size and Object_Size Clauses::
9928
* Component_Size Clauses::
9929
* Bit_Order Clauses::
9930
* Effect of Bit_Order on Byte Ordering::
9931
* Pragma Pack for Arrays::
9932
* Pragma Pack for Records::
9933
* Record Representation Clauses::
9934
* Enumeration Clauses::
9935
* Address Clauses::
9936
* Effect of Convention on Representation::
9937
* Determining the Representations chosen by GNAT::
9938
@end menu
9939
 
9940
@noindent
9941
@cindex Representation Clause
9942
@cindex Representation Pragma
9943
@cindex Pragma, representation
9944
This section describes the representation clauses accepted by GNAT, and
9945
their effect on the representation of corresponding data objects.
9946
 
9947
GNAT fully implements Annex C (Systems Programming).  This means that all
9948
the implementation advice sections in chapter 13 are fully implemented.
9949
However, these sections only require a minimal level of support for
9950
representation clauses.  GNAT provides much more extensive capabilities,
9951
and this section describes the additional capabilities provided.
9952
 
9953
@node Alignment Clauses
9954
@section Alignment Clauses
9955
@cindex Alignment Clause
9956
 
9957
@noindent
9958
GNAT requires that all alignment clauses specify a power of 2, and all
9959
default alignments are always a power of 2.  The default alignment
9960
values are as follows:
9961
 
9962
@itemize @bullet
9963
@item @emph{Primitive Types}.
9964
For primitive types, the alignment is the minimum of the actual size of
9965
objects of the type divided by @code{Storage_Unit},
9966
and the maximum alignment supported by the target.
9967
(This maximum alignment is given by the GNAT-specific attribute
9968
@code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9969
@cindex @code{Maximum_Alignment} attribute
9970
For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9971
default alignment will be 8 on any target that supports alignments
9972
this large, but on some targets, the maximum alignment may be smaller
9973
than 8, in which case objects of type @code{Long_Float} will be maximally
9974
aligned.
9975
 
9976
@item @emph{Arrays}.
9977
For arrays, the alignment is equal to the alignment of the component type
9978
for the normal case where no packing or component size is given.  If the
9979
array is packed, and the packing is effective (see separate section on
9980
packed arrays), then the alignment will be one for long packed arrays,
9981
or arrays whose length is not known at compile time.  For short packed
9982
arrays, which are handled internally as modular types, the alignment
9983
will be as described for primitive types, e.g.@: a packed array of length
9984
31 bits will have an object size of four bytes, and an alignment of 4.
9985
 
9986
@item @emph{Records}.
9987
For the normal non-packed case, the alignment of a record is equal to
9988
the maximum alignment of any of its components.  For tagged records, this
9989
includes the implicit access type used for the tag.  If a pragma @code{Pack}
9990
is used and all components are packable (see separate section on pragma
9991
@code{Pack}), then the resulting alignment is 1, unless the layout of the
9992
record makes it profitable to increase it.
9993
 
9994
A special case is when:
9995
@itemize @bullet
9996
@item
9997
the size of the record is given explicitly, or a
9998
full record representation clause is given, and
9999
@item
10000
the size of the record is 2, 4, or 8 bytes.
10001
@end itemize
10002
@noindent
10003
In this case, an alignment is chosen to match the
10004
size of the record. For example, if we have:
10005
 
10006
@smallexample @c ada
10007
   type Small is record
10008
      A, B : Character;
10009
   end record;
10010
   for Small'Size use 16;
10011
@end smallexample
10012
 
10013
@noindent
10014
then the default alignment of the record type @code{Small} is 2, not 1. This
10015
leads to more efficient code when the record is treated as a unit, and also
10016
allows the type to specified as @code{Atomic} on architectures requiring
10017
strict alignment.
10018
 
10019
@end itemize
10020
 
10021
@noindent
10022
An alignment clause may specify a larger alignment than the default value
10023
up to some maximum value dependent on the target (obtainable by using the
10024
attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10025
a smaller alignment than the default value for enumeration, integer and
10026
fixed point types, as well as for record types, for example
10027
 
10028
@smallexample @c ada
10029
  type V is record
10030
     A : Integer;
10031
  end record;
10032
 
10033
  for V'alignment use 1;
10034
@end smallexample
10035
 
10036
@noindent
10037
@cindex Alignment, default
10038
The default alignment for the type @code{V} is 4, as a result of the
10039
Integer field in the record, but it is permissible, as shown, to
10040
override the default alignment of the record with a smaller value.
10041
 
10042
@node Size Clauses
10043
@section Size Clauses
10044
@cindex Size Clause
10045
 
10046
@noindent
10047
The default size for a type @code{T} is obtainable through the
10048
language-defined attribute @code{T'Size} and also through the
10049
equivalent GNAT-defined attribute @code{T'Value_Size}.
10050
For objects of type @code{T}, GNAT will generally increase the type size
10051
so that the object size (obtainable through the GNAT-defined attribute
10052
@code{T'Object_Size})
10053
is a multiple of @code{T'Alignment * Storage_Unit}.
10054
For example
10055
 
10056
@smallexample @c ada
10057
   type Smallint is range 1 .. 6;
10058
 
10059
   type Rec is record
10060
      Y1 : integer;
10061
      Y2 : boolean;
10062
   end record;
10063
@end smallexample
10064
 
10065
@noindent
10066
In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10067
as specified by the RM rules,
10068
but objects of this type will have a size of 8
10069
(@code{Smallint'Object_Size} = 8),
10070
since objects by default occupy an integral number
10071
of storage units.  On some targets, notably older
10072
versions of the Digital Alpha, the size of stand
10073
alone objects of this type may be 32, reflecting
10074
the inability of the hardware to do byte load/stores.
10075
 
10076
Similarly, the size of type @code{Rec} is 40 bits
10077
(@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10078
the alignment is 4, so objects of this type will have
10079
their size increased to 64 bits so that it is a multiple
10080
of the alignment (in bits).  This decision is
10081
in accordance with the specific Implementation Advice in RM 13.3(43):
10082
 
10083
@quotation
10084
A @code{Size} clause should be supported for an object if the specified
10085
@code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10086
to a size in storage elements that is a multiple of the object's
10087
@code{Alignment} (if the @code{Alignment} is nonzero).
10088
@end quotation
10089
 
10090
@noindent
10091
An explicit size clause may be used to override the default size by
10092
increasing it.  For example, if we have:
10093
 
10094
@smallexample @c ada
10095
   type My_Boolean is new Boolean;
10096
   for My_Boolean'Size use 32;
10097
@end smallexample
10098
 
10099
@noindent
10100
then values of this type will always be 32 bits long.  In the case of
10101
discrete types, the size can be increased up to 64 bits, with the effect
10102
that the entire specified field is used to hold the value, sign- or
10103
zero-extended as appropriate.  If more than 64 bits is specified, then
10104
padding space is allocated after the value, and a warning is issued that
10105
there are unused bits.
10106
 
10107
Similarly the size of records and arrays may be increased, and the effect
10108
is to add padding bits after the value.  This also causes a warning message
10109
to be generated.
10110
 
10111
The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10112
Size in bits, this corresponds to an object of size 256 megabytes (minus
10113
one).  This limitation is true on all targets.  The reason for this
10114
limitation is that it improves the quality of the code in many cases
10115
if it is known that a Size value can be accommodated in an object of
10116
type Integer.
10117
 
10118
@node Storage_Size Clauses
10119
@section Storage_Size Clauses
10120
@cindex Storage_Size Clause
10121
 
10122
@noindent
10123
For tasks, the @code{Storage_Size} clause specifies the amount of space
10124
to be allocated for the task stack.  This cannot be extended, and if the
10125
stack is exhausted, then @code{Storage_Error} will be raised (if stack
10126
checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10127
or a @code{Storage_Size} pragma in the task definition to set the
10128
appropriate required size.  A useful technique is to include in every
10129
task definition a pragma of the form:
10130
 
10131
@smallexample @c ada
10132
   pragma Storage_Size (Default_Stack_Size);
10133
@end smallexample
10134
 
10135
@noindent
10136
Then @code{Default_Stack_Size} can be defined in a global package, and
10137
modified as required. Any tasks requiring stack sizes different from the
10138
default can have an appropriate alternative reference in the pragma.
10139
 
10140
You can also use the @option{-d} binder switch to modify the default stack
10141
size.
10142
 
10143
For access types, the @code{Storage_Size} clause specifies the maximum
10144
space available for allocation of objects of the type.  If this space is
10145
exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10146
In the case where the access type is declared local to a subprogram, the
10147
use of a @code{Storage_Size} clause triggers automatic use of a special
10148
predefined storage pool (@code{System.Pool_Size}) that ensures that all
10149
space for the pool is automatically reclaimed on exit from the scope in
10150
which the type is declared.
10151
 
10152
A special case recognized by the compiler is the specification of a
10153
@code{Storage_Size} of zero for an access type.  This means that no
10154
items can be allocated from the pool, and this is recognized at compile
10155
time, and all the overhead normally associated with maintaining a fixed
10156
size storage pool is eliminated.  Consider the following example:
10157
 
10158
@smallexample @c ada
10159
   procedure p is
10160
      type R is array (Natural) of Character;
10161
      type P is access all R;
10162
      for P'Storage_Size use 0;
10163
      --  Above access type intended only for interfacing purposes
10164
 
10165
      y : P;
10166
 
10167
      procedure g (m : P);
10168
      pragma Import (C, g);
10169
 
10170
      --  @dots{}
10171
 
10172
   begin
10173
      --  @dots{}
10174
      y := new R;
10175
   end;
10176
@end smallexample
10177
 
10178
@noindent
10179
As indicated in this example, these dummy storage pools are often useful in
10180
connection with interfacing where no object will ever be allocated.  If you
10181
compile the above example, you get the warning:
10182
 
10183
@smallexample
10184
   p.adb:16:09: warning: allocation from empty storage pool
10185
   p.adb:16:09: warning: Storage_Error will be raised at run time
10186
@end smallexample
10187
 
10188
@noindent
10189
Of course in practice, there will not be any explicit allocators in the
10190
case of such an access declaration.
10191
 
10192
@node Size of Variant Record Objects
10193
@section Size of Variant Record Objects
10194
@cindex Size, variant record objects
10195
@cindex Variant record objects, size
10196
 
10197
@noindent
10198
In the case of variant record objects, there is a question whether Size gives
10199
information about a particular variant, or the maximum size required
10200
for any variant.  Consider the following program
10201
 
10202
@smallexample @c ada
10203
with Text_IO; use Text_IO;
10204
procedure q is
10205
   type R1 (A : Boolean := False) is record
10206
     case A is
10207
       when True  => X : Character;
10208
       when False => null;
10209
     end case;
10210
   end record;
10211
 
10212
   V1 : R1 (False);
10213
   V2 : R1;
10214
 
10215
begin
10216
   Put_Line (Integer'Image (V1'Size));
10217
   Put_Line (Integer'Image (V2'Size));
10218
end q;
10219
@end smallexample
10220
 
10221
@noindent
10222
Here we are dealing with a variant record, where the True variant
10223
requires 16 bits, and the False variant requires 8 bits.
10224
In the above example, both V1 and V2 contain the False variant,
10225
which is only 8 bits long.  However, the result of running the
10226
program is:
10227
 
10228
@smallexample
10229
8
10230
16
10231
@end smallexample
10232
 
10233
@noindent
10234
The reason for the difference here is that the discriminant value of
10235
V1 is fixed, and will always be False.  It is not possible to assign
10236
a True variant value to V1, therefore 8 bits is sufficient.  On the
10237
other hand, in the case of V2, the initial discriminant value is
10238
False (from the default), but it is possible to assign a True
10239
variant value to V2, therefore 16 bits must be allocated for V2
10240
in the general case, even fewer bits may be needed at any particular
10241
point during the program execution.
10242
 
10243
As can be seen from the output of this program, the @code{'Size}
10244
attribute applied to such an object in GNAT gives the actual allocated
10245
size of the variable, which is the largest size of any of the variants.
10246
The Ada Reference Manual is not completely clear on what choice should
10247
be made here, but the GNAT behavior seems most consistent with the
10248
language in the RM@.
10249
 
10250
In some cases, it may be desirable to obtain the size of the current
10251
variant, rather than the size of the largest variant.  This can be
10252
achieved in GNAT by making use of the fact that in the case of a
10253
subprogram parameter, GNAT does indeed return the size of the current
10254
variant (because a subprogram has no way of knowing how much space
10255
is actually allocated for the actual).
10256
 
10257
Consider the following modified version of the above program:
10258
 
10259
@smallexample @c ada
10260
with Text_IO; use Text_IO;
10261
procedure q is
10262
   type R1 (A : Boolean := False) is record
10263
     case A is
10264
       when True  => X : Character;
10265
       when False => null;
10266
     end case;
10267
   end record;
10268
 
10269
   V2 : R1;
10270
 
10271
   function Size (V : R1) return Integer is
10272
   begin
10273
      return V'Size;
10274
   end Size;
10275
 
10276
begin
10277
   Put_Line (Integer'Image (V2'Size));
10278
   Put_Line (Integer'IMage (Size (V2)));
10279
   V2 := (True, 'x');
10280
   Put_Line (Integer'Image (V2'Size));
10281
   Put_Line (Integer'IMage (Size (V2)));
10282
end q;
10283
@end smallexample
10284
 
10285
@noindent
10286
The output from this program is
10287
 
10288
@smallexample
10289
16
10290
8
10291
16
10292
16
10293
@end smallexample
10294
 
10295
@noindent
10296
Here we see that while the @code{'Size} attribute always returns
10297
the maximum size, regardless of the current variant value, the
10298
@code{Size} function does indeed return the size of the current
10299
variant value.
10300
 
10301
@node Biased Representation
10302
@section Biased Representation
10303
@cindex Size for biased representation
10304
@cindex Biased representation
10305
 
10306
@noindent
10307
In the case of scalars with a range starting at other than zero, it is
10308
possible in some cases to specify a size smaller than the default minimum
10309
value, and in such cases, GNAT uses an unsigned biased representation,
10310
in which zero is used to represent the lower bound, and successive values
10311
represent successive values of the type.
10312
 
10313
For example, suppose we have the declaration:
10314
 
10315
@smallexample @c ada
10316
   type Small is range -7 .. -4;
10317
   for Small'Size use 2;
10318
@end smallexample
10319
 
10320
@noindent
10321
Although the default size of type @code{Small} is 4, the @code{Size}
10322
clause is accepted by GNAT and results in the following representation
10323
scheme:
10324
 
10325
@smallexample
10326
  -7 is represented as 2#00#
10327
  -6 is represented as 2#01#
10328
  -5 is represented as 2#10#
10329
  -4 is represented as 2#11#
10330
@end smallexample
10331
 
10332
@noindent
10333
Biased representation is only used if the specified @code{Size} clause
10334
cannot be accepted in any other manner.  These reduced sizes that force
10335
biased representation can be used for all discrete types except for
10336
enumeration types for which a representation clause is given.
10337
 
10338
@node Value_Size and Object_Size Clauses
10339
@section Value_Size and Object_Size Clauses
10340
@findex Value_Size
10341
@findex Object_Size
10342
@cindex Size, of objects
10343
 
10344
@noindent
10345
In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10346
number of bits required to hold values of type @code{T}.
10347
Although this interpretation was allowed in Ada 83, it was not required,
10348
and this requirement in practice can cause some significant difficulties.
10349
For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10350
However, in Ada 95 and Ada 2005,
10351
@code{Natural'Size} is
10352
typically 31.  This means that code may change in behavior when moving
10353
from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10354
 
10355
@smallexample @c ada
10356
   type Rec is record;
10357
      A : Natural;
10358
      B : Natural;
10359
   end record;
10360
 
10361
   for Rec use record
10362
      at 0  range 0 .. Natural'Size - 1;
10363
      at 0  range Natural'Size .. 2 * Natural'Size - 1;
10364
   end record;
10365
@end smallexample
10366
 
10367
@noindent
10368
In the above code, since the typical size of @code{Natural} objects
10369
is 32 bits and @code{Natural'Size} is 31, the above code can cause
10370
unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10371
there are cases where the fact that the object size can exceed the
10372
size of the type causes surprises.
10373
 
10374
To help get around this problem GNAT provides two implementation
10375
defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10376
applied to a type, these attributes yield the size of the type
10377
(corresponding to the RM defined size attribute), and the size of
10378
objects of the type respectively.
10379
 
10380
The @code{Object_Size} is used for determining the default size of
10381
objects and components.  This size value can be referred to using the
10382
@code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10383
the basis of the determination of the size.  The backend is free to
10384
pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10385
character might be stored in 32 bits on a machine with no efficient
10386
byte access instructions such as the Alpha.
10387
 
10388
The default rules for the value of @code{Object_Size} for
10389
discrete types are as follows:
10390
 
10391
@itemize @bullet
10392
@item
10393
The @code{Object_Size} for base subtypes reflect the natural hardware
10394
size in bits (run the compiler with @option{-gnatS} to find those values
10395
for numeric types). Enumeration types and fixed-point base subtypes have
10396
8, 16, 32 or 64 bits for this size, depending on the range of values
10397
to be stored.
10398
 
10399
@item
10400
The @code{Object_Size} of a subtype is the same as the
10401
@code{Object_Size} of
10402
the type from which it is obtained.
10403
 
10404
@item
10405
The @code{Object_Size} of a derived base type is copied from the parent
10406
base type, and the @code{Object_Size} of a derived first subtype is copied
10407
from the parent first subtype.
10408
@end itemize
10409
 
10410
@noindent
10411
The @code{Value_Size} attribute
10412
is the (minimum) number of bits required to store a value
10413
of the type.
10414
This value is used to determine how tightly to pack
10415
records or arrays with components of this type, and also affects
10416
the semantics of unchecked conversion (unchecked conversions where
10417
the @code{Value_Size} values differ generate a warning, and are potentially
10418
target dependent).
10419
 
10420
The default rules for the value of @code{Value_Size} are as follows:
10421
 
10422
@itemize @bullet
10423
@item
10424
The @code{Value_Size} for a base subtype is the minimum number of bits
10425
required to store all values of the type (including the sign bit
10426
only if negative values are possible).
10427
 
10428
@item
10429
If a subtype statically matches the first subtype of a given type, then it has
10430
by default the same @code{Value_Size} as the first subtype.  This is a
10431
consequence of RM 13.1(14) (``if two subtypes statically match,
10432
then their subtype-specific aspects are the same''.)
10433
 
10434
@item
10435
All other subtypes have a @code{Value_Size} corresponding to the minimum
10436
number of bits required to store all values of the subtype.  For
10437
dynamic bounds, it is assumed that the value can range down or up
10438
to the corresponding bound of the ancestor
10439
@end itemize
10440
 
10441
@noindent
10442
The RM defined attribute @code{Size} corresponds to the
10443
@code{Value_Size} attribute.
10444
 
10445
The @code{Size} attribute may be defined for a first-named subtype.  This sets
10446
the @code{Value_Size} of
10447
the first-named subtype to the given value, and the
10448
@code{Object_Size} of this first-named subtype to the given value padded up
10449
to an appropriate boundary.  It is a consequence of the default rules
10450
above that this @code{Object_Size} will apply to all further subtypes.  On the
10451
other hand, @code{Value_Size} is affected only for the first subtype, any
10452
dynamic subtypes obtained from it directly, and any statically matching
10453
subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10454
 
10455
@code{Value_Size} and
10456
@code{Object_Size} may be explicitly set for any subtype using
10457
an attribute definition clause.  Note that the use of these attributes
10458
can cause the RM 13.1(14) rule to be violated.  If two access types
10459
reference aliased objects whose subtypes have differing @code{Object_Size}
10460
values as a result of explicit attribute definition clauses, then it
10461
is erroneous to convert from one access subtype to the other.
10462
 
10463
At the implementation level, Esize stores the Object_Size and the
10464
RM_Size field stores the @code{Value_Size} (and hence the value of the
10465
@code{Size} attribute,
10466
which, as noted above, is equivalent to @code{Value_Size}).
10467
 
10468
To get a feel for the difference, consider the following examples (note
10469
that in each case the base is @code{Short_Short_Integer} with a size of 8):
10470
 
10471
@smallexample
10472
                                       Object_Size     Value_Size
10473
 
10474
type x1 is range 0 .. 5;                    8               3
10475
 
10476
type x2 is range 0 .. 5;
10477
for x2'size use 12;                        16              12
10478
 
10479
subtype x3 is x2 range 0 .. 3;             16               2
10480
 
10481
subtype x4 is x2'base range 0 .. 10;        8               4
10482
 
10483
subtype x5 is x2 range 0 .. dynamic;       16               3*
10484
 
10485
subtype x6 is x2'base range 0 .. dynamic;   8               3*
10486
 
10487
@end smallexample
10488
 
10489
@noindent
10490
Note: the entries marked ``3*'' are not actually specified by the Ada
10491
Reference Manual, but it seems in the spirit of the RM rules to allocate
10492
the minimum number of bits (here 3, given the range for @code{x2})
10493
known to be large enough to hold the given range of values.
10494
 
10495
So far, so good, but GNAT has to obey the RM rules, so the question is
10496
under what conditions must the RM @code{Size} be used.
10497
The following is a list
10498
of the occasions on which the RM @code{Size} must be used:
10499
 
10500
@itemize @bullet
10501
@item
10502
Component size for packed arrays or records
10503
 
10504
@item
10505
Value of the attribute @code{Size} for a type
10506
 
10507
@item
10508
Warning about sizes not matching for unchecked conversion
10509
@end itemize
10510
 
10511
@noindent
10512
For record types, the @code{Object_Size} is always a multiple of the
10513
alignment of the type (this is true for all types). In some cases the
10514
@code{Value_Size} can be smaller. Consider:
10515
 
10516
@smallexample
10517
   type R is record
10518
     X : Integer;
10519
     Y : Character;
10520
   end record;
10521
@end smallexample
10522
 
10523
@noindent
10524
On a typical 32-bit architecture, the X component will be four bytes, and
10525
require four-byte alignment, and the Y component will be one byte. In this
10526
case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10527
required to store a value of this type, and for example, it is permissible
10528
to have a component of type R in an outer array whose component size is
10529
specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10530
since it must be rounded up so that this value is a multiple of the
10531
alignment (4 bytes = 32 bits).
10532
 
10533
@noindent
10534
For all other types, the @code{Object_Size}
10535
and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10536
Only @code{Size} may be specified for such types.
10537
 
10538
@node Component_Size Clauses
10539
@section Component_Size Clauses
10540
@cindex Component_Size Clause
10541
 
10542
@noindent
10543
Normally, the value specified in a component size clause must be consistent
10544
with the subtype of the array component with regard to size and alignment.
10545
In other words, the value specified must be at least equal to the size
10546
of this subtype, and must be a multiple of the alignment value.
10547
 
10548
In addition, component size clauses are allowed which cause the array
10549
to be packed, by specifying a smaller value.  A first case is for
10550
component size values in the range 1 through 63.  The value specified
10551
must not be smaller than the Size of the subtype.  GNAT will accurately
10552
honor all packing requests in this range.  For example, if we have:
10553
 
10554
@smallexample @c ada
10555
type r is array (1 .. 8) of Natural;
10556
for r'Component_Size use 31;
10557
@end smallexample
10558
 
10559
@noindent
10560
then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10561
Of course access to the components of such an array is considerably
10562
less efficient than if the natural component size of 32 is used.
10563
A second case is when the subtype of the component is a record type
10564
padded because of its default alignment.  For example, if we have:
10565
 
10566
@smallexample @c ada
10567
type r is record
10568
  i : Integer;
10569
  j : Integer;
10570
  b : Boolean;
10571
end record;
10572
 
10573
type a is array (1 .. 8) of r;
10574
for a'Component_Size use 72;
10575
@end smallexample
10576
 
10577
@noindent
10578
then the resulting array has a length of 72 bytes, instead of 96 bytes
10579
if the alignment of the record (4) was obeyed.
10580
 
10581
Note that there is no point in giving both a component size clause
10582
and a pragma Pack for the same array type. if such duplicate
10583
clauses are given, the pragma Pack will be ignored.
10584
 
10585
@node Bit_Order Clauses
10586
@section Bit_Order Clauses
10587
@cindex Bit_Order Clause
10588
@cindex bit ordering
10589
@cindex ordering, of bits
10590
 
10591
@noindent
10592
For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10593
attribute.  The specification may either correspond to the default bit
10594
order for the target, in which case the specification has no effect and
10595
places no additional restrictions, or it may be for the non-standard
10596
setting (that is the opposite of the default).
10597
 
10598
In the case where the non-standard value is specified, the effect is
10599
to renumber bits within each byte, but the ordering of bytes is not
10600
affected.  There are certain
10601
restrictions placed on component clauses as follows:
10602
 
10603
@itemize @bullet
10604
 
10605
@item Components fitting within a single storage unit.
10606
@noindent
10607
These are unrestricted, and the effect is merely to renumber bits.  For
10608
example if we are on a little-endian machine with @code{Low_Order_First}
10609
being the default, then the following two declarations have exactly
10610
the same effect:
10611
 
10612
@smallexample @c ada
10613
   type R1 is record
10614
      A : Boolean;
10615
      B : Integer range 1 .. 120;
10616
   end record;
10617
 
10618
   for R1 use record
10619
      A at 0 range 0 .. 0;
10620
      B at 0 range 1 .. 7;
10621
   end record;
10622
 
10623
   type R2 is record
10624
      A : Boolean;
10625
      B : Integer range 1 .. 120;
10626
   end record;
10627
 
10628
   for R2'Bit_Order use High_Order_First;
10629
 
10630
   for R2 use record
10631
      A at 0 range 7 .. 7;
10632
      B at 0 range 0 .. 6;
10633
   end record;
10634
@end smallexample
10635
 
10636
@noindent
10637
The useful application here is to write the second declaration with the
10638
@code{Bit_Order} attribute definition clause, and know that it will be treated
10639
the same, regardless of whether the target is little-endian or big-endian.
10640
 
10641
@item Components occupying an integral number of bytes.
10642
@noindent
10643
These are components that exactly fit in two or more bytes.  Such component
10644
declarations are allowed, but have no effect, since it is important to realize
10645
that the @code{Bit_Order} specification does not affect the ordering of bytes.
10646
In particular, the following attempt at getting an endian-independent integer
10647
does not work:
10648
 
10649
@smallexample @c ada
10650
   type R2 is record
10651
      A : Integer;
10652
   end record;
10653
 
10654
   for R2'Bit_Order use High_Order_First;
10655
 
10656
   for R2 use record
10657
      A at 0 range 0 .. 31;
10658
   end record;
10659
@end smallexample
10660
 
10661
@noindent
10662
This declaration will result in a little-endian integer on a
10663
little-endian machine, and a big-endian integer on a big-endian machine.
10664
If byte flipping is required for interoperability between big- and
10665
little-endian machines, this must be explicitly programmed.  This capability
10666
is not provided by @code{Bit_Order}.
10667
 
10668
@item Components that are positioned across byte boundaries
10669
@noindent
10670
but do not occupy an integral number of bytes.  Given that bytes are not
10671
reordered, such fields would occupy a non-contiguous sequence of bits
10672
in memory, requiring non-trivial code to reassemble.  They are for this
10673
reason not permitted, and any component clause specifying such a layout
10674
will be flagged as illegal by GNAT@.
10675
 
10676
@end itemize
10677
 
10678
@noindent
10679
Since the misconception that Bit_Order automatically deals with all
10680
endian-related incompatibilities is a common one, the specification of
10681
a component field that is an integral number of bytes will always
10682
generate a warning.  This warning may be suppressed using @code{pragma
10683
Warnings (Off)} if desired.  The following section contains additional
10684
details regarding the issue of byte ordering.
10685
 
10686
@node Effect of Bit_Order on Byte Ordering
10687
@section Effect of Bit_Order on Byte Ordering
10688
@cindex byte ordering
10689
@cindex ordering, of bytes
10690
 
10691
@noindent
10692
In this section we will review the effect of the @code{Bit_Order} attribute
10693
definition clause on byte ordering.  Briefly, it has no effect at all, but
10694
a detailed example will be helpful.  Before giving this
10695
example, let us review the precise
10696
definition of the effect of defining @code{Bit_Order}.  The effect of a
10697
non-standard bit order is described in section 15.5.3 of the Ada
10698
Reference Manual:
10699
 
10700
@quotation
10701
2   A bit ordering is a method of interpreting the meaning of
10702
the storage place attributes.
10703
@end quotation
10704
 
10705
@noindent
10706
To understand the precise definition of storage place attributes in
10707
this context, we visit section 13.5.1 of the manual:
10708
 
10709
@quotation
10710
13   A record_representation_clause (without the mod_clause)
10711
specifies the layout.  The storage place attributes (see 13.5.2)
10712
are taken from the values of the position, first_bit, and last_bit
10713
expressions after normalizing those values so that first_bit is
10714
less than Storage_Unit.
10715
@end quotation
10716
 
10717
@noindent
10718
The critical point here is that storage places are taken from
10719
the values after normalization, not before.  So the @code{Bit_Order}
10720
interpretation applies to normalized values.  The interpretation
10721
is described in the later part of the 15.5.3 paragraph:
10722
 
10723
@quotation
10724
2   A bit ordering is a method of interpreting the meaning of
10725
the storage place attributes.  High_Order_First (known in the
10726
vernacular as ``big endian'') means that the first bit of a
10727
storage element (bit 0) is the most significant bit (interpreting
10728
the sequence of bits that represent a component as an unsigned
10729
integer value).  Low_Order_First (known in the vernacular as
10730
``little endian'') means the opposite: the first bit is the
10731
least significant.
10732
@end quotation
10733
 
10734
@noindent
10735
Note that the numbering is with respect to the bits of a storage
10736
unit.  In other words, the specification affects only the numbering
10737
of bits within a single storage unit.
10738
 
10739
We can make the effect clearer by giving an example.
10740
 
10741
Suppose that we have an external device which presents two bytes, the first
10742
byte presented, which is the first (low addressed byte) of the two byte
10743
record is called Master, and the second byte is called Slave.
10744
 
10745
The left most (most significant bit is called Control for each byte, and
10746
the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10747
(least significant) bit.
10748
 
10749
On a big-endian machine, we can write the following representation clause
10750
 
10751
@smallexample @c ada
10752
   type Data is record
10753
      Master_Control : Bit;
10754
      Master_V1      : Bit;
10755
      Master_V2      : Bit;
10756
      Master_V3      : Bit;
10757
      Master_V4      : Bit;
10758
      Master_V5      : Bit;
10759
      Master_V6      : Bit;
10760
      Master_V7      : Bit;
10761
      Slave_Control  : Bit;
10762
      Slave_V1       : Bit;
10763
      Slave_V2       : Bit;
10764
      Slave_V3       : Bit;
10765
      Slave_V4       : Bit;
10766
      Slave_V5       : Bit;
10767
      Slave_V6       : Bit;
10768
      Slave_V7       : Bit;
10769
   end record;
10770
 
10771
   for Data use record
10772
      Master_Control at 0 range 0 .. 0;
10773
      Master_V1      at 0 range 1 .. 1;
10774
      Master_V2      at 0 range 2 .. 2;
10775
      Master_V3      at 0 range 3 .. 3;
10776
      Master_V4      at 0 range 4 .. 4;
10777
      Master_V5      at 0 range 5 .. 5;
10778
      Master_V6      at 0 range 6 .. 6;
10779
      Master_V7      at 0 range 7 .. 7;
10780
      Slave_Control  at 1 range 0 .. 0;
10781
      Slave_V1       at 1 range 1 .. 1;
10782
      Slave_V2       at 1 range 2 .. 2;
10783
      Slave_V3       at 1 range 3 .. 3;
10784
      Slave_V4       at 1 range 4 .. 4;
10785
      Slave_V5       at 1 range 5 .. 5;
10786
      Slave_V6       at 1 range 6 .. 6;
10787
      Slave_V7       at 1 range 7 .. 7;
10788
   end record;
10789
@end smallexample
10790
 
10791
@noindent
10792
Now if we move this to a little endian machine, then the bit ordering within
10793
the byte is backwards, so we have to rewrite the record rep clause as:
10794
 
10795
@smallexample @c ada
10796
   for Data use record
10797
      Master_Control at 0 range 7 .. 7;
10798
      Master_V1      at 0 range 6 .. 6;
10799
      Master_V2      at 0 range 5 .. 5;
10800
      Master_V3      at 0 range 4 .. 4;
10801
      Master_V4      at 0 range 3 .. 3;
10802
      Master_V5      at 0 range 2 .. 2;
10803
      Master_V6      at 0 range 1 .. 1;
10804
      Master_V7      at 0 range 0 .. 0;
10805
      Slave_Control  at 1 range 7 .. 7;
10806
      Slave_V1       at 1 range 6 .. 6;
10807
      Slave_V2       at 1 range 5 .. 5;
10808
      Slave_V3       at 1 range 4 .. 4;
10809
      Slave_V4       at 1 range 3 .. 3;
10810
      Slave_V5       at 1 range 2 .. 2;
10811
      Slave_V6       at 1 range 1 .. 1;
10812
      Slave_V7       at 1 range 0 .. 0;
10813
   end record;
10814
@end smallexample
10815
 
10816
@noindent
10817
It is a nuisance to have to rewrite the clause, especially if
10818
the code has to be maintained on both machines.  However,
10819
this is a case that we can handle with the
10820
@code{Bit_Order} attribute if it is implemented.
10821
Note that the implementation is not required on byte addressed
10822
machines, but it is indeed implemented in GNAT.
10823
This means that we can simply use the
10824
first record clause, together with the declaration
10825
 
10826
@smallexample @c ada
10827
   for Data'Bit_Order use High_Order_First;
10828
@end smallexample
10829
 
10830
@noindent
10831
and the effect is what is desired, namely the layout is exactly the same,
10832
independent of whether the code is compiled on a big-endian or little-endian
10833
machine.
10834
 
10835
The important point to understand is that byte ordering is not affected.
10836
A @code{Bit_Order} attribute definition never affects which byte a field
10837
ends up in, only where it ends up in that byte.
10838
To make this clear, let us rewrite the record rep clause of the previous
10839
example as:
10840
 
10841
@smallexample @c ada
10842
   for Data'Bit_Order use High_Order_First;
10843
   for Data use record
10844
      Master_Control at 0 range  0 .. 0;
10845
      Master_V1      at 0 range  1 .. 1;
10846
      Master_V2      at 0 range  2 .. 2;
10847
      Master_V3      at 0 range  3 .. 3;
10848
      Master_V4      at 0 range  4 .. 4;
10849
      Master_V5      at 0 range  5 .. 5;
10850
      Master_V6      at 0 range  6 .. 6;
10851
      Master_V7      at 0 range  7 .. 7;
10852
      Slave_Control  at 0 range  8 .. 8;
10853
      Slave_V1       at 0 range  9 .. 9;
10854
      Slave_V2       at 0 range 10 .. 10;
10855
      Slave_V3       at 0 range 11 .. 11;
10856
      Slave_V4       at 0 range 12 .. 12;
10857
      Slave_V5       at 0 range 13 .. 13;
10858
      Slave_V6       at 0 range 14 .. 14;
10859
      Slave_V7       at 0 range 15 .. 15;
10860
   end record;
10861
@end smallexample
10862
 
10863
@noindent
10864
This is exactly equivalent to saying (a repeat of the first example):
10865
 
10866
@smallexample @c ada
10867
   for Data'Bit_Order use High_Order_First;
10868
   for Data use record
10869
      Master_Control at 0 range 0 .. 0;
10870
      Master_V1      at 0 range 1 .. 1;
10871
      Master_V2      at 0 range 2 .. 2;
10872
      Master_V3      at 0 range 3 .. 3;
10873
      Master_V4      at 0 range 4 .. 4;
10874
      Master_V5      at 0 range 5 .. 5;
10875
      Master_V6      at 0 range 6 .. 6;
10876
      Master_V7      at 0 range 7 .. 7;
10877
      Slave_Control  at 1 range 0 .. 0;
10878
      Slave_V1       at 1 range 1 .. 1;
10879
      Slave_V2       at 1 range 2 .. 2;
10880
      Slave_V3       at 1 range 3 .. 3;
10881
      Slave_V4       at 1 range 4 .. 4;
10882
      Slave_V5       at 1 range 5 .. 5;
10883
      Slave_V6       at 1 range 6 .. 6;
10884
      Slave_V7       at 1 range 7 .. 7;
10885
   end record;
10886
@end smallexample
10887
 
10888
@noindent
10889
Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10890
field.  The storage place attributes are obtained by normalizing the
10891
values given so that the @code{First_Bit} value is less than 8.  After
10892
normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10893
we specified in the other case.
10894
 
10895
Now one might expect that the @code{Bit_Order} attribute might affect
10896
bit numbering within the entire record component (two bytes in this
10897
case, thus affecting which byte fields end up in), but that is not
10898
the way this feature is defined, it only affects numbering of bits,
10899
not which byte they end up in.
10900
 
10901
Consequently it never makes sense to specify a starting bit number
10902
greater than 7 (for a byte addressable field) if an attribute
10903
definition for @code{Bit_Order} has been given, and indeed it
10904
may be actively confusing to specify such a value, so the compiler
10905
generates a warning for such usage.
10906
 
10907
If you do need to control byte ordering then appropriate conditional
10908
values must be used.  If in our example, the slave byte came first on
10909
some machines we might write:
10910
 
10911
@smallexample @c ada
10912
   Master_Byte_First constant Boolean := @dots{};
10913
 
10914
   Master_Byte : constant Natural :=
10915
                   1 - Boolean'Pos (Master_Byte_First);
10916
   Slave_Byte  : constant Natural :=
10917
                   Boolean'Pos (Master_Byte_First);
10918
 
10919
   for Data'Bit_Order use High_Order_First;
10920
   for Data use record
10921
      Master_Control at Master_Byte range 0 .. 0;
10922
      Master_V1      at Master_Byte range 1 .. 1;
10923
      Master_V2      at Master_Byte range 2 .. 2;
10924
      Master_V3      at Master_Byte range 3 .. 3;
10925
      Master_V4      at Master_Byte range 4 .. 4;
10926
      Master_V5      at Master_Byte range 5 .. 5;
10927
      Master_V6      at Master_Byte range 6 .. 6;
10928
      Master_V7      at Master_Byte range 7 .. 7;
10929
      Slave_Control  at Slave_Byte  range 0 .. 0;
10930
      Slave_V1       at Slave_Byte  range 1 .. 1;
10931
      Slave_V2       at Slave_Byte  range 2 .. 2;
10932
      Slave_V3       at Slave_Byte  range 3 .. 3;
10933
      Slave_V4       at Slave_Byte  range 4 .. 4;
10934
      Slave_V5       at Slave_Byte  range 5 .. 5;
10935
      Slave_V6       at Slave_Byte  range 6 .. 6;
10936
      Slave_V7       at Slave_Byte  range 7 .. 7;
10937
   end record;
10938
@end smallexample
10939
 
10940
@noindent
10941
Now to switch between machines, all that is necessary is
10942
to set the boolean constant @code{Master_Byte_First} in
10943
an appropriate manner.
10944
 
10945
@node Pragma Pack for Arrays
10946
@section Pragma Pack for Arrays
10947
@cindex Pragma Pack (for arrays)
10948
 
10949
@noindent
10950
Pragma @code{Pack} applied to an array has no effect unless the component type
10951
is packable.  For a component type to be packable, it must be one of the
10952
following cases:
10953
 
10954
@itemize @bullet
10955
@item
10956
Any scalar type
10957
@item
10958
Any type whose size is specified with a size clause
10959
@item
10960
Any packed array type with a static size
10961
@item
10962
Any record type padded because of its default alignment
10963
@end itemize
10964
 
10965
@noindent
10966
For all these cases, if the component subtype size is in the range
10967
1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10968
component size were specified giving the component subtype size.
10969
For example if we have:
10970
 
10971
@smallexample @c ada
10972
   type r is range 0 .. 17;
10973
 
10974
   type ar is array (1 .. 8) of r;
10975
   pragma Pack (ar);
10976
@end smallexample
10977
 
10978
@noindent
10979
Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10980
and the size of the array @code{ar} will be exactly 40 bits.
10981
 
10982
Note that in some cases this rather fierce approach to packing can produce
10983
unexpected effects.  For example, in Ada 95 and Ada 2005,
10984
subtype @code{Natural} typically has a size of 31, meaning that if you
10985
pack an array of @code{Natural}, you get 31-bit
10986
close packing, which saves a few bits, but results in far less efficient
10987
access.  Since many other Ada compilers will ignore such a packing request,
10988
GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10989
might not be what is intended.  You can easily remove this warning by
10990
using an explicit @code{Component_Size} setting instead, which never generates
10991
a warning, since the intention of the programmer is clear in this case.
10992
 
10993
GNAT treats packed arrays in one of two ways.  If the size of the array is
10994
known at compile time and is less than 64 bits, then internally the array
10995
is represented as a single modular type, of exactly the appropriate number
10996
of bits.  If the length is greater than 63 bits, or is not known at compile
10997
time, then the packed array is represented as an array of bytes, and the
10998
length is always a multiple of 8 bits.
10999
 
11000
Note that to represent a packed array as a modular type, the alignment must
11001
be suitable for the modular type involved. For example, on typical machines
11002
a 32-bit packed array will be represented by a 32-bit modular integer with
11003
an alignment of four bytes. If you explicitly override the default alignment
11004
with an alignment clause that is too small, the modular representation
11005
cannot be used. For example, consider the following set of declarations:
11006
 
11007
@smallexample @c ada
11008
   type R is range 1 .. 3;
11009
   type S is array (1 .. 31) of R;
11010
   for S'Component_Size use 2;
11011
   for S'Size use 62;
11012
   for S'Alignment use 1;
11013
@end smallexample
11014
 
11015
@noindent
11016
If the alignment clause were not present, then a 62-bit modular
11017
representation would be chosen (typically with an alignment of 4 or 8
11018
bytes depending on the target). But the default alignment is overridden
11019
with the explicit alignment clause. This means that the modular
11020
representation cannot be used, and instead the array of bytes
11021
representation must be used, meaning that the length must be a multiple
11022
of 8. Thus the above set of declarations will result in a diagnostic
11023
rejecting the size clause and noting that the minimum size allowed is 64.
11024
 
11025
@cindex Pragma Pack (for type Natural)
11026
@cindex Pragma Pack warning
11027
 
11028
One special case that is worth noting occurs when the base type of the
11029
component size is 8/16/32 and the subtype is one bit less. Notably this
11030
occurs with subtype @code{Natural}. Consider:
11031
 
11032
@smallexample @c ada
11033
   type Arr is array (1 .. 32) of Natural;
11034
   pragma Pack (Arr);
11035
@end smallexample
11036
 
11037
@noindent
11038
In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11039
since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11040
Ada 83 compilers did not attempt 31 bit packing.
11041
 
11042
In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11043
GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11044
substantial unintended performance penalty when porting legacy Ada 83 code.
11045
To help prevent this, GNAT generates a warning in such cases. If you really
11046
want 31 bit packing in a case like this, you can set the component size
11047
explicitly:
11048
 
11049
@smallexample @c ada
11050
   type Arr is array (1 .. 32) of Natural;
11051
   for Arr'Component_Size use 31;
11052
@end smallexample
11053
 
11054
@noindent
11055
Here 31-bit packing is achieved as required, and no warning is generated,
11056
since in this case the programmer intention is clear.
11057
 
11058
@node Pragma Pack for Records
11059
@section Pragma Pack for Records
11060
@cindex Pragma Pack (for records)
11061
 
11062
@noindent
11063
Pragma @code{Pack} applied to a record will pack the components to reduce
11064
wasted space from alignment gaps and by reducing the amount of space
11065
taken by components.  We distinguish between @emph{packable} components and
11066
@emph{non-packable} components.
11067
Components of the following types are considered packable:
11068
@itemize @bullet
11069
@item
11070
All primitive types are packable.
11071
 
11072
@item
11073
Small packed arrays, whose size does not exceed 64 bits, and where the
11074
size is statically known at compile time, are represented internally
11075
as modular integers, and so they are also packable.
11076
 
11077
@end itemize
11078
 
11079
@noindent
11080
All packable components occupy the exact number of bits corresponding to
11081
their @code{Size} value, and are packed with no padding bits, i.e.@: they
11082
can start on an arbitrary bit boundary.
11083
 
11084
All other types are non-packable, they occupy an integral number of
11085
storage units, and
11086
are placed at a boundary corresponding to their alignment requirements.
11087
 
11088
For example, consider the record
11089
 
11090
@smallexample @c ada
11091
   type Rb1 is array (1 .. 13) of Boolean;
11092
   pragma Pack (rb1);
11093
 
11094
   type Rb2 is array (1 .. 65) of Boolean;
11095
   pragma Pack (rb2);
11096
 
11097
   type x2 is record
11098
      l1 : Boolean;
11099
      l2 : Duration;
11100
      l3 : Float;
11101
      l4 : Boolean;
11102
      l5 : Rb1;
11103
      l6 : Rb2;
11104
   end record;
11105
   pragma Pack (x2);
11106
@end smallexample
11107
 
11108
@noindent
11109
The representation for the record x2 is as follows:
11110
 
11111
@smallexample @c ada
11112
for x2'Size use 224;
11113
for x2 use record
11114
   l1 at  0 range  0 .. 0;
11115
   l2 at  0 range  1 .. 64;
11116
   l3 at 12 range  0 .. 31;
11117
   l4 at 16 range  0 .. 0;
11118
   l5 at 16 range  1 .. 13;
11119
   l6 at 18 range  0 .. 71;
11120
end record;
11121
@end smallexample
11122
 
11123
@noindent
11124
Studying this example, we see that the packable fields @code{l1}
11125
and @code{l2} are
11126
of length equal to their sizes, and placed at specific bit boundaries (and
11127
not byte boundaries) to
11128
eliminate padding.  But @code{l3} is of a non-packable float type, so
11129
it is on the next appropriate alignment boundary.
11130
 
11131
The next two fields are fully packable, so @code{l4} and @code{l5} are
11132
minimally packed with no gaps.  However, type @code{Rb2} is a packed
11133
array that is longer than 64 bits, so it is itself non-packable.  Thus
11134
the @code{l6} field is aligned to the next byte boundary, and takes an
11135
integral number of bytes, i.e.@: 72 bits.
11136
 
11137
@node Record Representation Clauses
11138
@section Record Representation Clauses
11139
@cindex Record Representation Clause
11140
 
11141
@noindent
11142
Record representation clauses may be given for all record types, including
11143
types obtained by record extension.  Component clauses are allowed for any
11144
static component.  The restrictions on component clauses depend on the type
11145
of the component.
11146
 
11147
@cindex Component Clause
11148
For all components of an elementary type, the only restriction on component
11149
clauses is that the size must be at least the 'Size value of the type
11150
(actually the Value_Size).  There are no restrictions due to alignment,
11151
and such components may freely cross storage boundaries.
11152
 
11153
Packed arrays with a size up to and including 64 bits are represented
11154
internally using a modular type with the appropriate number of bits, and
11155
thus the same lack of restriction applies.  For example, if you declare:
11156
 
11157
@smallexample @c ada
11158
   type R is array (1 .. 49) of Boolean;
11159
   pragma Pack (R);
11160
   for R'Size use 49;
11161
@end smallexample
11162
 
11163
@noindent
11164
then a component clause for a component of type R may start on any
11165
specified bit boundary, and may specify a value of 49 bits or greater.
11166
 
11167
For packed bit arrays that are longer than 64 bits, there are two
11168
cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11169
including the important case of single bits or boolean values, then
11170
there are no limitations on placement of such components, and they
11171
may start and end at arbitrary bit boundaries.
11172
 
11173
If the component size is not a power of 2 (e.g.@: 3 or 5), then
11174
an array of this type longer than 64 bits must always be placed on
11175
on a storage unit (byte) boundary and occupy an integral number
11176
of storage units (bytes). Any component clause that does not
11177
meet this requirement will be rejected.
11178
 
11179
Any aliased component, or component of an aliased type, must
11180
have its normal alignment and size. A component clause that
11181
does not meet this requirement will be rejected.
11182
 
11183
The tag field of a tagged type always occupies an address sized field at
11184
the start of the record.  No component clause may attempt to overlay this
11185
tag. When a tagged type appears as a component, the tag field must have
11186
proper alignment
11187
 
11188
In the case of a record extension T1, of a type T, no component clause applied
11189
to the type T1 can specify a storage location that would overlap the first
11190
T'Size bytes of the record.
11191
 
11192
For all other component types, including non-bit-packed arrays,
11193
the component can be placed at an arbitrary bit boundary,
11194
so for example, the following is permitted:
11195
 
11196
@smallexample @c ada
11197
   type R is array (1 .. 10) of Boolean;
11198
   for R'Size use 80;
11199
 
11200
   type Q is record
11201
      G, H : Boolean;
11202
      L, M : R;
11203
   end record;
11204
 
11205
   for Q use record
11206
      G at 0 range  0 ..   0;
11207
      H at 0 range  1 ..   1;
11208
      L at 0 range  2 ..  81;
11209
      R at 0 range 82 .. 161;
11210
   end record;
11211
@end smallexample
11212
 
11213
@noindent
11214
Note: the above rules apply to recent releases of GNAT 5.
11215
In GNAT 3, there are more severe restrictions on larger components.
11216
For non-primitive types, including packed arrays with a size greater than
11217
64 bits, component clauses must respect the alignment requirement of the
11218
type, in particular, always starting on a byte boundary, and the length
11219
must be a multiple of the storage unit.
11220
 
11221
@node Enumeration Clauses
11222
@section Enumeration Clauses
11223
 
11224
The only restriction on enumeration clauses is that the range of values
11225
must be representable.  For the signed case, if one or more of the
11226
representation values are negative, all values must be in the range:
11227
 
11228
@smallexample @c ada
11229
   System.Min_Int .. System.Max_Int
11230
@end smallexample
11231
 
11232
@noindent
11233
For the unsigned case, where all values are nonnegative, the values must
11234
be in the range:
11235
 
11236
@smallexample @c ada
11237
 
11238
@end smallexample
11239
 
11240
@noindent
11241
A @emph{confirming} representation clause is one in which the values range
11242
from 0 in sequence, i.e.@: a clause that confirms the default representation
11243
for an enumeration type.
11244
Such a confirming representation
11245
is permitted by these rules, and is specially recognized by the compiler so
11246
that no extra overhead results from the use of such a clause.
11247
 
11248
If an array has an index type which is an enumeration type to which an
11249
enumeration clause has been applied, then the array is stored in a compact
11250
manner.  Consider the declarations:
11251
 
11252
@smallexample @c ada
11253
   type r is (A, B, C);
11254
   for r use (A => 1, B => 5, C => 10);
11255
   type t is array (r) of Character;
11256
@end smallexample
11257
 
11258
@noindent
11259
The array type t corresponds to a vector with exactly three elements and
11260
has a default size equal to @code{3*Character'Size}.  This ensures efficient
11261
use of space, but means that accesses to elements of the array will incur
11262
the overhead of converting representation values to the corresponding
11263
positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11264
 
11265
@node Address Clauses
11266
@section Address Clauses
11267
@cindex Address Clause
11268
 
11269
The reference manual allows a general restriction on representation clauses,
11270
as found in RM 13.1(22):
11271
 
11272
@quotation
11273
An implementation need not support representation
11274
items containing nonstatic expressions, except that
11275
an implementation should support a representation item
11276
for a given entity if each nonstatic expression in the
11277
representation item is a name that statically denotes
11278
a constant declared before the entity.
11279
@end quotation
11280
 
11281
@noindent
11282
In practice this is applicable only to address clauses, since this is the
11283
only case in which a non-static expression is permitted by the syntax.  As
11284
the AARM notes in sections 13.1 (22.a-22.h):
11285
 
11286
@display
11287
  22.a   Reason: This is to avoid the following sort of thing:
11288
 
11289
  22.b        X : Integer := F(@dots{});
11290
              Y : Address := G(@dots{});
11291
              for X'Address use Y;
11292
 
11293
  22.c   In the above, we have to evaluate the
11294
         initialization expression for X before we
11295
         know where to put the result.  This seems
11296
         like an unreasonable implementation burden.
11297
 
11298
  22.d   The above code should instead be written
11299
         like this:
11300
 
11301
  22.e        Y : constant Address := G(@dots{});
11302
              X : Integer := F(@dots{});
11303
              for X'Address use Y;
11304
 
11305
  22.f   This allows the expression ``Y'' to be safely
11306
         evaluated before X is created.
11307
 
11308
  22.g   The constant could be a formal parameter of mode in.
11309
 
11310
  22.h   An implementation can support other nonstatic
11311
         expressions if it wants to.  Expressions of type
11312
         Address are hardly ever static, but their value
11313
         might be known at compile time anyway in many
11314
         cases.
11315
@end display
11316
 
11317
@noindent
11318
GNAT does indeed permit many additional cases of non-static expressions.  In
11319
particular, if the type involved is elementary there are no restrictions
11320
(since in this case, holding a temporary copy of the initialization value,
11321
if one is present, is inexpensive).  In addition, if there is no implicit or
11322
explicit initialization, then there are no restrictions.  GNAT will reject
11323
only the case where all three of these conditions hold:
11324
 
11325
@itemize @bullet
11326
 
11327
@item
11328
The type of the item is non-elementary (e.g.@: a record or array).
11329
 
11330
@item
11331
There is explicit or implicit initialization required for the object.
11332
Note that access values are always implicitly initialized, and also
11333
in GNAT, certain bit-packed arrays (those having a dynamic length or
11334
a length greater than 64) will also be implicitly initialized to zero.
11335
 
11336
@item
11337
The address value is non-static.  Here GNAT is more permissive than the
11338
RM, and allows the address value to be the address of a previously declared
11339
stand-alone variable, as long as it does not itself have an address clause.
11340
 
11341
@smallexample @c ada
11342
           Anchor  : Some_Initialized_Type;
11343
           Overlay : Some_Initialized_Type;
11344
           for Overlay'Address use Anchor'Address;
11345
@end smallexample
11346
 
11347
@noindent
11348
However, the prefix of the address clause cannot be an array component, or
11349
a component of a discriminated record.
11350
 
11351
@end itemize
11352
 
11353
@noindent
11354
As noted above in section 22.h, address values are typically non-static.  In
11355
particular the To_Address function, even if applied to a literal value, is
11356
a non-static function call.  To avoid this minor annoyance, GNAT provides
11357
the implementation defined attribute 'To_Address.  The following two
11358
expressions have identical values:
11359
 
11360
@findex Attribute
11361
@findex To_Address
11362
@smallexample @c ada
11363
   To_Address (16#1234_0000#)
11364
   System'To_Address (16#1234_0000#);
11365
@end smallexample
11366
 
11367
@noindent
11368
except that the second form is considered to be a static expression, and
11369
thus when used as an address clause value is always permitted.
11370
 
11371
@noindent
11372
Additionally, GNAT treats as static an address clause that is an
11373
unchecked_conversion of a static integer value.  This simplifies the porting
11374
of legacy code, and provides a portable equivalent to the GNAT attribute
11375
@code{To_Address}.
11376
 
11377
Another issue with address clauses is the interaction with alignment
11378
requirements.  When an address clause is given for an object, the address
11379
value must be consistent with the alignment of the object (which is usually
11380
the same as the alignment of the type of the object).  If an address clause
11381
is given that specifies an inappropriately aligned address value, then the
11382
program execution is erroneous.
11383
 
11384
Since this source of erroneous behavior can have unfortunate effects, GNAT
11385
checks (at compile time if possible, generating a warning, or at execution
11386
time with a run-time check) that the alignment is appropriate.  If the
11387
run-time check fails, then @code{Program_Error} is raised.  This run-time
11388
check is suppressed if range checks are suppressed, or if the special GNAT
11389
check Alignment_Check is suppressed, or if
11390
@code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11391
 
11392
Finally, GNAT does not permit overlaying of objects of controlled types or
11393
composite types containing a controlled component. In most cases, the compiler
11394
can detect an attempt at such overlays and will generate a warning at compile
11395
time and a Program_Error exception at run time.
11396
 
11397
@findex Export
11398
An address clause cannot be given for an exported object.  More
11399
understandably the real restriction is that objects with an address
11400
clause cannot be exported.  This is because such variables are not
11401
defined by the Ada program, so there is no external object to export.
11402
 
11403
@findex Import
11404
It is permissible to give an address clause and a pragma Import for the
11405
same object.  In this case, the variable is not really defined by the
11406
Ada program, so there is no external symbol to be linked.  The link name
11407
and the external name are ignored in this case.  The reason that we allow this
11408
combination is that it provides a useful idiom to avoid unwanted
11409
initializations on objects with address clauses.
11410
 
11411
When an address clause is given for an object that has implicit or
11412
explicit initialization, then by default initialization takes place.  This
11413
means that the effect of the object declaration is to overwrite the
11414
memory at the specified address.  This is almost always not what the
11415
programmer wants, so GNAT will output a warning:
11416
 
11417
@smallexample
11418
  with System;
11419
  package G is
11420
     type R is record
11421
        M : Integer := 0;
11422
     end record;
11423
 
11424
     Ext : R;
11425
     for Ext'Address use System'To_Address (16#1234_1234#);
11426
         |
11427
  >>> warning: implicit initialization of "Ext" may
11428
      modify overlaid storage
11429
  >>> warning: use pragma Import for "Ext" to suppress
11430
      initialization (RM B(24))
11431
 
11432
  end G;
11433
@end smallexample
11434
 
11435
@noindent
11436
As indicated by the warning message, the solution is to use a (dummy) pragma
11437
Import to suppress this initialization.  The pragma tell the compiler that the
11438
object is declared and initialized elsewhere.  The following package compiles
11439
without warnings (and the initialization is suppressed):
11440
 
11441
@smallexample @c ada
11442
   with System;
11443
   package G is
11444
      type R is record
11445
         M : Integer := 0;
11446
      end record;
11447
 
11448
      Ext : R;
11449
      for Ext'Address use System'To_Address (16#1234_1234#);
11450
      pragma Import (Ada, Ext);
11451
   end G;
11452
@end smallexample
11453
 
11454
@noindent
11455
A final issue with address clauses involves their use for overlaying
11456
variables, as in the following example:
11457
@cindex Overlaying of objects
11458
 
11459
@smallexample @c ada
11460
  A : Integer;
11461
  B : Integer;
11462
  for B'Address use A'Address;
11463
@end smallexample
11464
 
11465
@noindent
11466
or alternatively, using the form recommended by the RM:
11467
 
11468
@smallexample @c ada
11469
  A    : Integer;
11470
  Addr : constant Address := A'Address;
11471
  B    : Integer;
11472
  for B'Address use Addr;
11473
@end smallexample
11474
 
11475
@noindent
11476
In both of these cases, @code{A}
11477
and @code{B} become aliased to one another via the
11478
address clause. This use of address clauses to overlay
11479
variables, achieving an effect similar to unchecked
11480
conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11481
the effect is implementation defined. Furthermore, the
11482
Ada RM specifically recommends that in a situation
11483
like this, @code{B} should be subject to the following
11484
implementation advice (RM 13.3(19)):
11485
 
11486
@quotation
11487
19  If the Address of an object is specified, or it is imported
11488
    or exported, then the implementation should not perform
11489
    optimizations based on assumptions of no aliases.
11490
@end quotation
11491
 
11492
@noindent
11493
GNAT follows this recommendation, and goes further by also applying
11494
this recommendation to the overlaid variable (@code{A}
11495
in the above example) in this case. This means that the overlay
11496
works "as expected", in that a modification to one of the variables
11497
will affect the value of the other.
11498
 
11499
@node Effect of Convention on Representation
11500
@section Effect of Convention on Representation
11501
@cindex Convention, effect on representation
11502
 
11503
@noindent
11504
Normally the specification of a foreign language convention for a type or
11505
an object has no effect on the chosen representation.  In particular, the
11506
representation chosen for data in GNAT generally meets the standard system
11507
conventions, and for example records are laid out in a manner that is
11508
consistent with C@.  This means that specifying convention C (for example)
11509
has no effect.
11510
 
11511
There are four exceptions to this general rule:
11512
 
11513
@itemize @bullet
11514
 
11515
@item Convention Fortran and array subtypes
11516
If pragma Convention Fortran is specified for an array subtype, then in
11517
accordance with the implementation advice in section 3.6.2(11) of the
11518
Ada Reference Manual, the array will be stored in a Fortran-compatible
11519
column-major manner, instead of the normal default row-major order.
11520
 
11521
@item Convention C and enumeration types
11522
GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11523
to accommodate all values of the type.  For example, for the enumeration
11524
type declared by:
11525
 
11526
@smallexample @c ada
11527
   type Color is (Red, Green, Blue);
11528
@end smallexample
11529
 
11530
@noindent
11531
8 bits is sufficient to store all values of the type, so by default, objects
11532
of type @code{Color} will be represented using 8 bits.  However, normal C
11533
convention is to use 32 bits for all enum values in C, since enum values
11534
are essentially of type int.  If pragma @code{Convention C} is specified for an
11535
Ada enumeration type, then the size is modified as necessary (usually to
11536
32 bits) to be consistent with the C convention for enum values.
11537
 
11538
Note that this treatment applies only to types. If Convention C is given for
11539
an enumeration object, where the enumeration type is not Convention C, then
11540
Object_Size bits are allocated. For example, for a normal enumeration type,
11541
with less than 256 elements, only 8 bits will be allocated for the object.
11542
Since this may be a surprise in terms of what C expects, GNAT will issue a
11543
warning in this situation. The warning can be suppressed by giving an explicit
11544
size clause specifying the desired size.
11545
 
11546
@item Convention C/Fortran and Boolean types
11547
In C, the usual convention for boolean values, that is values used for
11548
conditions, is that zero represents false, and nonzero values represent
11549
true.  In Ada, the normal convention is that two specific values, typically
11550
0/1, are used to represent false/true respectively.
11551
 
11552
Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11553
value represents true).
11554
 
11555
To accommodate the Fortran and C conventions, if a pragma Convention specifies
11556
C or Fortran convention for a derived Boolean, as in the following example:
11557
 
11558
@smallexample @c ada
11559
   type C_Switch is new Boolean;
11560
   pragma Convention (C, C_Switch);
11561
@end smallexample
11562
 
11563
@noindent
11564
then the GNAT generated code will treat any nonzero value as true.  For truth
11565
values generated by GNAT, the conventional value 1 will be used for True, but
11566
when one of these values is read, any nonzero value is treated as True.
11567
 
11568
@item Access types on OpenVMS
11569
For 64-bit OpenVMS systems, access types (other than those for unconstrained
11570
arrays) are 64-bits long. An exception to this rule is for the case of
11571
C-convention access types where there is no explicit size clause present (or
11572
inherited for derived types). In this case, GNAT chooses to make these
11573
pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11574
code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11575
 
11576
@end itemize
11577
 
11578
@node Determining the Representations chosen by GNAT
11579
@section Determining the Representations chosen by GNAT
11580
@cindex Representation, determination of
11581
@cindex @option{-gnatR} switch
11582
 
11583
@noindent
11584
Although the descriptions in this section are intended to be complete, it is
11585
often easier to simply experiment to see what GNAT accepts and what the
11586
effect is on the layout of types and objects.
11587
 
11588
As required by the Ada RM, if a representation clause is not accepted, then
11589
it must be rejected as illegal by the compiler.  However, when a
11590
representation clause or pragma is accepted, there can still be questions
11591
of what the compiler actually does.  For example, if a partial record
11592
representation clause specifies the location of some components and not
11593
others, then where are the non-specified components placed? Or if pragma
11594
@code{Pack} is used on a record, then exactly where are the resulting
11595
fields placed? The section on pragma @code{Pack} in this chapter can be
11596
used to answer the second question, but it is often easier to just see
11597
what the compiler does.
11598
 
11599
For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11600
with this option, then the compiler will output information on the actual
11601
representations chosen, in a format similar to source representation
11602
clauses.  For example, if we compile the package:
11603
 
11604
@smallexample @c ada
11605
package q is
11606
   type r (x : boolean) is tagged record
11607
      case x is
11608
         when True => S : String (1 .. 100);
11609
         when False => null;
11610
      end case;
11611
   end record;
11612
 
11613
   type r2 is new r (false) with record
11614
      y2 : integer;
11615
   end record;
11616
 
11617
   for r2 use record
11618
      y2 at 16 range 0 .. 31;
11619
   end record;
11620
 
11621
   type x is record
11622
      y : character;
11623
   end record;
11624
 
11625
   type x1 is array (1 .. 10) of x;
11626
   for x1'component_size use 11;
11627
 
11628
   type ia is access integer;
11629
 
11630
   type Rb1 is array (1 .. 13) of Boolean;
11631
   pragma Pack (rb1);
11632
 
11633
   type Rb2 is array (1 .. 65) of Boolean;
11634
   pragma Pack (rb2);
11635
 
11636
   type x2 is record
11637
      l1 : Boolean;
11638
      l2 : Duration;
11639
      l3 : Float;
11640
      l4 : Boolean;
11641
      l5 : Rb1;
11642
      l6 : Rb2;
11643
   end record;
11644
   pragma Pack (x2);
11645
end q;
11646
@end smallexample
11647
 
11648
@noindent
11649
using the switch @option{-gnatR} we obtain the following output:
11650
 
11651
@smallexample
11652
Representation information for unit q
11653
-------------------------------------
11654
 
11655
for r'Size use ??;
11656
for r'Alignment use 4;
11657
for r use record
11658
   x    at 4 range  0 .. 7;
11659
   _tag at 0 range  0 .. 31;
11660
   s    at 5 range  0 .. 799;
11661
end record;
11662
 
11663
for r2'Size use 160;
11664
for r2'Alignment use 4;
11665
for r2 use record
11666
   x       at  4 range  0 .. 7;
11667
   _tag    at  0 range  0 .. 31;
11668
   _parent at  0 range  0 .. 63;
11669
   y2      at 16 range  0 .. 31;
11670
end record;
11671
 
11672
for x'Size use 8;
11673
for x'Alignment use 1;
11674
for x use record
11675
   y at 0 range  0 .. 7;
11676
end record;
11677
 
11678
for x1'Size use 112;
11679
for x1'Alignment use 1;
11680
for x1'Component_Size use 11;
11681
 
11682
for rb1'Size use 13;
11683
for rb1'Alignment use 2;
11684
for rb1'Component_Size use 1;
11685
 
11686
for rb2'Size use 72;
11687
for rb2'Alignment use 1;
11688
for rb2'Component_Size use 1;
11689
 
11690
for x2'Size use 224;
11691
for x2'Alignment use 4;
11692
for x2 use record
11693
   l1 at  0 range  0 .. 0;
11694
   l2 at  0 range  1 .. 64;
11695
   l3 at 12 range  0 .. 31;
11696
   l4 at 16 range  0 .. 0;
11697
   l5 at 16 range  1 .. 13;
11698
   l6 at 18 range  0 .. 71;
11699
end record;
11700
@end smallexample
11701
 
11702
@noindent
11703
The Size values are actually the Object_Size, i.e.@: the default size that
11704
will be allocated for objects of the type.
11705
The ?? size for type r indicates that we have a variant record, and the
11706
actual size of objects will depend on the discriminant value.
11707
 
11708
The Alignment values show the actual alignment chosen by the compiler
11709
for each record or array type.
11710
 
11711
The record representation clause for type r shows where all fields
11712
are placed, including the compiler generated tag field (whose location
11713
cannot be controlled by the programmer).
11714
 
11715
The record representation clause for the type extension r2 shows all the
11716
fields present, including the parent field, which is a copy of the fields
11717
of the parent type of r2, i.e.@: r1.
11718
 
11719
The component size and size clauses for types rb1 and rb2 show
11720
the exact effect of pragma @code{Pack} on these arrays, and the record
11721
representation clause for type x2 shows how pragma @code{Pack} affects
11722
this record type.
11723
 
11724
In some cases, it may be useful to cut and paste the representation clauses
11725
generated by the compiler into the original source to fix and guarantee
11726
the actual representation to be used.
11727
 
11728
@node Standard Library Routines
11729
@chapter Standard Library Routines
11730
 
11731
@noindent
11732
The Ada Reference Manual contains in Annex A a full description of an
11733
extensive set of standard library routines that can be used in any Ada
11734
program, and which must be provided by all Ada compilers.  They are
11735
analogous to the standard C library used by C programs.
11736
 
11737
GNAT implements all of the facilities described in annex A, and for most
11738
purposes the description in the Ada Reference Manual, or appropriate Ada
11739
text book, will be sufficient for making use of these facilities.
11740
 
11741
In the case of the input-output facilities,
11742
@xref{The Implementation of Standard I/O},
11743
gives details on exactly how GNAT interfaces to the
11744
file system.  For the remaining packages, the Ada Reference Manual
11745
should be sufficient.  The following is a list of the packages included,
11746
together with a brief description of the functionality that is provided.
11747
 
11748
For completeness, references are included to other predefined library
11749
routines defined in other sections of the Ada Reference Manual (these are
11750
cross-indexed from Annex A).
11751
 
11752
@table @code
11753
@item Ada (A.2)
11754
This is a parent package for all the standard library packages.  It is
11755
usually included implicitly in your program, and itself contains no
11756
useful data or routines.
11757
 
11758
@item Ada.Calendar (9.6)
11759
@code{Calendar} provides time of day access, and routines for
11760
manipulating times and durations.
11761
 
11762
@item Ada.Characters (A.3.1)
11763
This is a dummy parent package that contains no useful entities
11764
 
11765
@item Ada.Characters.Handling (A.3.2)
11766
This package provides some basic character handling capabilities,
11767
including classification functions for classes of characters (e.g.@: test
11768
for letters, or digits).
11769
 
11770
@item Ada.Characters.Latin_1 (A.3.3)
11771
This package includes a complete set of definitions of the characters
11772
that appear in type CHARACTER@.  It is useful for writing programs that
11773
will run in international environments.  For example, if you want an
11774
upper case E with an acute accent in a string, it is often better to use
11775
the definition of @code{UC_E_Acute} in this package.  Then your program
11776
will print in an understandable manner even if your environment does not
11777
support these extended characters.
11778
 
11779
@item Ada.Command_Line (A.15)
11780
This package provides access to the command line parameters and the name
11781
of the current program (analogous to the use of @code{argc} and @code{argv}
11782
in C), and also allows the exit status for the program to be set in a
11783
system-independent manner.
11784
 
11785
@item Ada.Decimal (F.2)
11786
This package provides constants describing the range of decimal numbers
11787
implemented, and also a decimal divide routine (analogous to the COBOL
11788
verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11789
 
11790
@item Ada.Direct_IO (A.8.4)
11791
This package provides input-output using a model of a set of records of
11792
fixed-length, containing an arbitrary definite Ada type, indexed by an
11793
integer record number.
11794
 
11795
@item Ada.Dynamic_Priorities (D.5)
11796
This package allows the priorities of a task to be adjusted dynamically
11797
as the task is running.
11798
 
11799
@item Ada.Exceptions (11.4.1)
11800
This package provides additional information on exceptions, and also
11801
contains facilities for treating exceptions as data objects, and raising
11802
exceptions with associated messages.
11803
 
11804
@item Ada.Finalization (7.6)
11805
This package contains the declarations and subprograms to support the
11806
use of controlled types, providing for automatic initialization and
11807
finalization (analogous to the constructors and destructors of C++)
11808
 
11809
@item Ada.Interrupts (C.3.2)
11810
This package provides facilities for interfacing to interrupts, which
11811
includes the set of signals or conditions that can be raised and
11812
recognized as interrupts.
11813
 
11814
@item Ada.Interrupts.Names (C.3.2)
11815
This package provides the set of interrupt names (actually signal
11816
or condition names) that can be handled by GNAT@.
11817
 
11818
@item Ada.IO_Exceptions (A.13)
11819
This package defines the set of exceptions that can be raised by use of
11820
the standard IO packages.
11821
 
11822
@item Ada.Numerics
11823
This package contains some standard constants and exceptions used
11824
throughout the numerics packages.  Note that the constants pi and e are
11825
defined here, and it is better to use these definitions than rolling
11826
your own.
11827
 
11828
@item Ada.Numerics.Complex_Elementary_Functions
11829
Provides the implementation of standard elementary functions (such as
11830
log and trigonometric functions) operating on complex numbers using the
11831
standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11832
created by the package @code{Numerics.Complex_Types}.
11833
 
11834
@item Ada.Numerics.Complex_Types
11835
This is a predefined instantiation of
11836
@code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11837
build the type @code{Complex} and @code{Imaginary}.
11838
 
11839
@item Ada.Numerics.Discrete_Random
11840
This package provides a random number generator suitable for generating
11841
random integer values from a specified range.
11842
 
11843
@item Ada.Numerics.Float_Random
11844
This package provides a random number generator suitable for generating
11845
uniformly distributed floating point values.
11846
 
11847
@item Ada.Numerics.Generic_Complex_Elementary_Functions
11848
This is a generic version of the package that provides the
11849
implementation of standard elementary functions (such as log and
11850
trigonometric functions) for an arbitrary complex type.
11851
 
11852
The following predefined instantiations of this package are provided:
11853
 
11854
@table @code
11855
@item Short_Float
11856
@code{Ada.Numerics.Short_Complex_Elementary_Functions}
11857
@item Float
11858
@code{Ada.Numerics.Complex_Elementary_Functions}
11859
@item Long_Float
11860
@code{Ada.Numerics.Long_Complex_Elementary_Functions}
11861
@end table
11862
 
11863
@item Ada.Numerics.Generic_Complex_Types
11864
This is a generic package that allows the creation of complex types,
11865
with associated complex arithmetic operations.
11866
 
11867
The following predefined instantiations of this package exist
11868
@table @code
11869
@item Short_Float
11870
@code{Ada.Numerics.Short_Complex_Complex_Types}
11871
@item Float
11872
@code{Ada.Numerics.Complex_Complex_Types}
11873
@item Long_Float
11874
@code{Ada.Numerics.Long_Complex_Complex_Types}
11875
@end table
11876
 
11877
@item Ada.Numerics.Generic_Elementary_Functions
11878
This is a generic package that provides the implementation of standard
11879
elementary functions (such as log an trigonometric functions) for an
11880
arbitrary float type.
11881
 
11882
The following predefined instantiations of this package exist
11883
 
11884
@table @code
11885
@item Short_Float
11886
@code{Ada.Numerics.Short_Elementary_Functions}
11887
@item Float
11888
@code{Ada.Numerics.Elementary_Functions}
11889
@item Long_Float
11890
@code{Ada.Numerics.Long_Elementary_Functions}
11891
@end table
11892
 
11893
@item Ada.Real_Time (D.8)
11894
This package provides facilities similar to those of @code{Calendar}, but
11895
operating with a finer clock suitable for real time control. Note that
11896
annex D requires that there be no backward clock jumps, and GNAT generally
11897
guarantees this behavior, but of course if the external clock on which
11898
the GNAT runtime depends is deliberately reset by some external event,
11899
then such a backward jump may occur.
11900
 
11901
@item Ada.Sequential_IO (A.8.1)
11902
This package provides input-output facilities for sequential files,
11903
which can contain a sequence of values of a single type, which can be
11904
any Ada type, including indefinite (unconstrained) types.
11905
 
11906
@item Ada.Storage_IO (A.9)
11907
This package provides a facility for mapping arbitrary Ada types to and
11908
from a storage buffer.  It is primarily intended for the creation of new
11909
IO packages.
11910
 
11911
@item Ada.Streams (13.13.1)
11912
This is a generic package that provides the basic support for the
11913
concept of streams as used by the stream attributes (@code{Input},
11914
@code{Output}, @code{Read} and @code{Write}).
11915
 
11916
@item Ada.Streams.Stream_IO (A.12.1)
11917
This package is a specialization of the type @code{Streams} defined in
11918
package @code{Streams} together with a set of operations providing
11919
Stream_IO capability.  The Stream_IO model permits both random and
11920
sequential access to a file which can contain an arbitrary set of values
11921
of one or more Ada types.
11922
 
11923
@item Ada.Strings (A.4.1)
11924
This package provides some basic constants used by the string handling
11925
packages.
11926
 
11927
@item Ada.Strings.Bounded (A.4.4)
11928
This package provides facilities for handling variable length
11929
strings.  The bounded model requires a maximum length.  It is thus
11930
somewhat more limited than the unbounded model, but avoids the use of
11931
dynamic allocation or finalization.
11932
 
11933
@item Ada.Strings.Fixed (A.4.3)
11934
This package provides facilities for handling fixed length strings.
11935
 
11936
@item Ada.Strings.Maps (A.4.2)
11937
This package provides facilities for handling character mappings and
11938
arbitrarily defined subsets of characters.  For instance it is useful in
11939
defining specialized translation tables.
11940
 
11941
@item Ada.Strings.Maps.Constants (A.4.6)
11942
This package provides a standard set of predefined mappings and
11943
predefined character sets.  For example, the standard upper to lower case
11944
conversion table is found in this package.  Note that upper to lower case
11945
conversion is non-trivial if you want to take the entire set of
11946
characters, including extended characters like E with an acute accent,
11947
into account.  You should use the mappings in this package (rather than
11948
adding 32 yourself) to do case mappings.
11949
 
11950
@item Ada.Strings.Unbounded (A.4.5)
11951
This package provides facilities for handling variable length
11952
strings.  The unbounded model allows arbitrary length strings, but
11953
requires the use of dynamic allocation and finalization.
11954
 
11955
@item Ada.Strings.Wide_Bounded (A.4.7)
11956
@itemx Ada.Strings.Wide_Fixed (A.4.7)
11957
@itemx Ada.Strings.Wide_Maps (A.4.7)
11958
@itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11959
@itemx Ada.Strings.Wide_Unbounded (A.4.7)
11960
These packages provide analogous capabilities to the corresponding
11961
packages without @samp{Wide_} in the name, but operate with the types
11962
@code{Wide_String} and @code{Wide_Character} instead of @code{String}
11963
and @code{Character}.
11964
 
11965
@item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11966
@itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11967
@itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11968
@itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11969
@itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11970
These packages provide analogous capabilities to the corresponding
11971
packages without @samp{Wide_} in the name, but operate with the types
11972
@code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11973
of @code{String} and @code{Character}.
11974
 
11975
@item Ada.Synchronous_Task_Control (D.10)
11976
This package provides some standard facilities for controlling task
11977
communication in a synchronous manner.
11978
 
11979
@item Ada.Tags
11980
This package contains definitions for manipulation of the tags of tagged
11981
values.
11982
 
11983
@item Ada.Task_Attributes
11984
This package provides the capability of associating arbitrary
11985
task-specific data with separate tasks.
11986
 
11987
@item Ada.Text_IO
11988
This package provides basic text input-output capabilities for
11989
character, string and numeric data.  The subpackages of this
11990
package are listed next.
11991
 
11992
@item Ada.Text_IO.Decimal_IO
11993
Provides input-output facilities for decimal fixed-point types
11994
 
11995
@item Ada.Text_IO.Enumeration_IO
11996
Provides input-output facilities for enumeration types.
11997
 
11998
@item Ada.Text_IO.Fixed_IO
11999
Provides input-output facilities for ordinary fixed-point types.
12000
 
12001
@item Ada.Text_IO.Float_IO
12002
Provides input-output facilities for float types.  The following
12003
predefined instantiations of this generic package are available:
12004
 
12005
@table @code
12006
@item Short_Float
12007
@code{Short_Float_Text_IO}
12008
@item Float
12009
@code{Float_Text_IO}
12010
@item Long_Float
12011
@code{Long_Float_Text_IO}
12012
@end table
12013
 
12014
@item Ada.Text_IO.Integer_IO
12015
Provides input-output facilities for integer types.  The following
12016
predefined instantiations of this generic package are available:
12017
 
12018
@table @code
12019
@item Short_Short_Integer
12020
@code{Ada.Short_Short_Integer_Text_IO}
12021
@item Short_Integer
12022
@code{Ada.Short_Integer_Text_IO}
12023
@item Integer
12024
@code{Ada.Integer_Text_IO}
12025
@item Long_Integer
12026
@code{Ada.Long_Integer_Text_IO}
12027
@item Long_Long_Integer
12028
@code{Ada.Long_Long_Integer_Text_IO}
12029
@end table
12030
 
12031
@item Ada.Text_IO.Modular_IO
12032
Provides input-output facilities for modular (unsigned) types
12033
 
12034
@item Ada.Text_IO.Complex_IO (G.1.3)
12035
This package provides basic text input-output capabilities for complex
12036
data.
12037
 
12038
@item Ada.Text_IO.Editing (F.3.3)
12039
This package contains routines for edited output, analogous to the use
12040
of pictures in COBOL@.  The picture formats used by this package are a
12041
close copy of the facility in COBOL@.
12042
 
12043
@item Ada.Text_IO.Text_Streams (A.12.2)
12044
This package provides a facility that allows Text_IO files to be treated
12045
as streams, so that the stream attributes can be used for writing
12046
arbitrary data, including binary data, to Text_IO files.
12047
 
12048
@item Ada.Unchecked_Conversion (13.9)
12049
This generic package allows arbitrary conversion from one type to
12050
another of the same size, providing for breaking the type safety in
12051
special circumstances.
12052
 
12053
If the types have the same Size (more accurately the same Value_Size),
12054
then the effect is simply to transfer the bits from the source to the
12055
target type without any modification.  This usage is well defined, and
12056
for simple types whose representation is typically the same across
12057
all implementations, gives a portable method of performing such
12058
conversions.
12059
 
12060
If the types do not have the same size, then the result is implementation
12061
defined, and thus may be non-portable.  The following describes how GNAT
12062
handles such unchecked conversion cases.
12063
 
12064
If the types are of different sizes, and are both discrete types, then
12065
the effect is of a normal type conversion without any constraint checking.
12066
In particular if the result type has a larger size, the result will be
12067
zero or sign extended.  If the result type has a smaller size, the result
12068
will be truncated by ignoring high order bits.
12069
 
12070
If the types are of different sizes, and are not both discrete types,
12071
then the conversion works as though pointers were created to the source
12072
and target, and the pointer value is converted.  The effect is that bits
12073
are copied from successive low order storage units and bits of the source
12074
up to the length of the target type.
12075
 
12076
A warning is issued if the lengths differ, since the effect in this
12077
case is implementation dependent, and the above behavior may not match
12078
that of some other compiler.
12079
 
12080
A pointer to one type may be converted to a pointer to another type using
12081
unchecked conversion.  The only case in which the effect is undefined is
12082
when one or both pointers are pointers to unconstrained array types.  In
12083
this case, the bounds information may get incorrectly transferred, and in
12084
particular, GNAT uses double size pointers for such types, and it is
12085
meaningless to convert between such pointer types.  GNAT will issue a
12086
warning if the alignment of the target designated type is more strict
12087
than the alignment of the source designated type (since the result may
12088
be unaligned in this case).
12089
 
12090
A pointer other than a pointer to an unconstrained array type may be
12091
converted to and from System.Address.  Such usage is common in Ada 83
12092
programs, but note that Ada.Address_To_Access_Conversions is the
12093
preferred method of performing such conversions in Ada 95 and Ada 2005.
12094
Neither
12095
unchecked conversion nor Ada.Address_To_Access_Conversions should be
12096
used in conjunction with pointers to unconstrained objects, since
12097
the bounds information cannot be handled correctly in this case.
12098
 
12099
@item Ada.Unchecked_Deallocation (13.11.2)
12100
This generic package allows explicit freeing of storage previously
12101
allocated by use of an allocator.
12102
 
12103
@item Ada.Wide_Text_IO (A.11)
12104
This package is similar to @code{Ada.Text_IO}, except that the external
12105
file supports wide character representations, and the internal types are
12106
@code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12107
and @code{String}.  It contains generic subpackages listed next.
12108
 
12109
@item Ada.Wide_Text_IO.Decimal_IO
12110
Provides input-output facilities for decimal fixed-point types
12111
 
12112
@item Ada.Wide_Text_IO.Enumeration_IO
12113
Provides input-output facilities for enumeration types.
12114
 
12115
@item Ada.Wide_Text_IO.Fixed_IO
12116
Provides input-output facilities for ordinary fixed-point types.
12117
 
12118
@item Ada.Wide_Text_IO.Float_IO
12119
Provides input-output facilities for float types.  The following
12120
predefined instantiations of this generic package are available:
12121
 
12122
@table @code
12123
@item Short_Float
12124
@code{Short_Float_Wide_Text_IO}
12125
@item Float
12126
@code{Float_Wide_Text_IO}
12127
@item Long_Float
12128
@code{Long_Float_Wide_Text_IO}
12129
@end table
12130
 
12131
@item Ada.Wide_Text_IO.Integer_IO
12132
Provides input-output facilities for integer types.  The following
12133
predefined instantiations of this generic package are available:
12134
 
12135
@table @code
12136
@item Short_Short_Integer
12137
@code{Ada.Short_Short_Integer_Wide_Text_IO}
12138
@item Short_Integer
12139
@code{Ada.Short_Integer_Wide_Text_IO}
12140
@item Integer
12141
@code{Ada.Integer_Wide_Text_IO}
12142
@item Long_Integer
12143
@code{Ada.Long_Integer_Wide_Text_IO}
12144
@item Long_Long_Integer
12145
@code{Ada.Long_Long_Integer_Wide_Text_IO}
12146
@end table
12147
 
12148
@item Ada.Wide_Text_IO.Modular_IO
12149
Provides input-output facilities for modular (unsigned) types
12150
 
12151
@item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12152
This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12153
external file supports wide character representations.
12154
 
12155
@item Ada.Wide_Text_IO.Editing (F.3.4)
12156
This package is similar to @code{Ada.Text_IO.Editing}, except that the
12157
types are @code{Wide_Character} and @code{Wide_String} instead of
12158
@code{Character} and @code{String}.
12159
 
12160
@item Ada.Wide_Text_IO.Streams (A.12.3)
12161
This package is similar to @code{Ada.Text_IO.Streams}, except that the
12162
types are @code{Wide_Character} and @code{Wide_String} instead of
12163
@code{Character} and @code{String}.
12164
 
12165
@item Ada.Wide_Wide_Text_IO (A.11)
12166
This package is similar to @code{Ada.Text_IO}, except that the external
12167
file supports wide character representations, and the internal types are
12168
@code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12169
and @code{String}.  It contains generic subpackages listed next.
12170
 
12171
@item Ada.Wide_Wide_Text_IO.Decimal_IO
12172
Provides input-output facilities for decimal fixed-point types
12173
 
12174
@item Ada.Wide_Wide_Text_IO.Enumeration_IO
12175
Provides input-output facilities for enumeration types.
12176
 
12177
@item Ada.Wide_Wide_Text_IO.Fixed_IO
12178
Provides input-output facilities for ordinary fixed-point types.
12179
 
12180
@item Ada.Wide_Wide_Text_IO.Float_IO
12181
Provides input-output facilities for float types.  The following
12182
predefined instantiations of this generic package are available:
12183
 
12184
@table @code
12185
@item Short_Float
12186
@code{Short_Float_Wide_Wide_Text_IO}
12187
@item Float
12188
@code{Float_Wide_Wide_Text_IO}
12189
@item Long_Float
12190
@code{Long_Float_Wide_Wide_Text_IO}
12191
@end table
12192
 
12193
@item Ada.Wide_Wide_Text_IO.Integer_IO
12194
Provides input-output facilities for integer types.  The following
12195
predefined instantiations of this generic package are available:
12196
 
12197
@table @code
12198
@item Short_Short_Integer
12199
@code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12200
@item Short_Integer
12201
@code{Ada.Short_Integer_Wide_Wide_Text_IO}
12202
@item Integer
12203
@code{Ada.Integer_Wide_Wide_Text_IO}
12204
@item Long_Integer
12205
@code{Ada.Long_Integer_Wide_Wide_Text_IO}
12206
@item Long_Long_Integer
12207
@code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12208
@end table
12209
 
12210
@item Ada.Wide_Wide_Text_IO.Modular_IO
12211
Provides input-output facilities for modular (unsigned) types
12212
 
12213
@item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12214
This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12215
external file supports wide character representations.
12216
 
12217
@item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12218
This package is similar to @code{Ada.Text_IO.Editing}, except that the
12219
types are @code{Wide_Character} and @code{Wide_String} instead of
12220
@code{Character} and @code{String}.
12221
 
12222
@item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12223
This package is similar to @code{Ada.Text_IO.Streams}, except that the
12224
types are @code{Wide_Character} and @code{Wide_String} instead of
12225
@code{Character} and @code{String}.
12226
@end table
12227
 
12228
 
12229
 
12230
@node The Implementation of Standard I/O
12231
@chapter The Implementation of Standard I/O
12232
 
12233
@noindent
12234
GNAT implements all the required input-output facilities described in
12235
A.6 through A.14.  These sections of the Ada Reference Manual describe the
12236
required behavior of these packages from the Ada point of view, and if
12237
you are writing a portable Ada program that does not need to know the
12238
exact manner in which Ada maps to the outside world when it comes to
12239
reading or writing external files, then you do not need to read this
12240
chapter.  As long as your files are all regular files (not pipes or
12241
devices), and as long as you write and read the files only from Ada, the
12242
description in the Ada Reference Manual is sufficient.
12243
 
12244
However, if you want to do input-output to pipes or other devices, such
12245
as the keyboard or screen, or if the files you are dealing with are
12246
either generated by some other language, or to be read by some other
12247
language, then you need to know more about the details of how the GNAT
12248
implementation of these input-output facilities behaves.
12249
 
12250
In this chapter we give a detailed description of exactly how GNAT
12251
interfaces to the file system.  As always, the sources of the system are
12252
available to you for answering questions at an even more detailed level,
12253
but for most purposes the information in this chapter will suffice.
12254
 
12255
Another reason that you may need to know more about how input-output is
12256
implemented arises when you have a program written in mixed languages
12257
where, for example, files are shared between the C and Ada sections of
12258
the same program.  GNAT provides some additional facilities, in the form
12259
of additional child library packages, that facilitate this sharing, and
12260
these additional facilities are also described in this chapter.
12261
 
12262
@menu
12263
* Standard I/O Packages::
12264
* FORM Strings::
12265
* Direct_IO::
12266
* Sequential_IO::
12267
* Text_IO::
12268
* Wide_Text_IO::
12269
* Wide_Wide_Text_IO::
12270
* Stream_IO::
12271
* Text Translation::
12272
* Shared Files::
12273
* Filenames encoding::
12274
* Open Modes::
12275
* Operations on C Streams::
12276
* Interfacing to C Streams::
12277
@end menu
12278
 
12279
@node Standard I/O Packages
12280
@section Standard I/O Packages
12281
 
12282
@noindent
12283
The Standard I/O packages described in Annex A for
12284
 
12285
@itemize @bullet
12286
@item
12287
Ada.Text_IO
12288
@item
12289
Ada.Text_IO.Complex_IO
12290
@item
12291
Ada.Text_IO.Text_Streams
12292
@item
12293
Ada.Wide_Text_IO
12294
@item
12295
Ada.Wide_Text_IO.Complex_IO
12296
@item
12297
Ada.Wide_Text_IO.Text_Streams
12298
@item
12299
Ada.Wide_Wide_Text_IO
12300
@item
12301
Ada.Wide_Wide_Text_IO.Complex_IO
12302
@item
12303
Ada.Wide_Wide_Text_IO.Text_Streams
12304
@item
12305
Ada.Stream_IO
12306
@item
12307
Ada.Sequential_IO
12308
@item
12309
Ada.Direct_IO
12310
@end itemize
12311
 
12312
@noindent
12313
are implemented using the C
12314
library streams facility; where
12315
 
12316
@itemize @bullet
12317
@item
12318
All files are opened using @code{fopen}.
12319
@item
12320
All input/output operations use @code{fread}/@code{fwrite}.
12321
@end itemize
12322
 
12323
@noindent
12324
There is no internal buffering of any kind at the Ada library level. The only
12325
buffering is that provided at the system level in the implementation of the
12326
library routines that support streams. This facilitates shared use of these
12327
streams by mixed language programs. Note though that system level buffering is
12328
explicitly enabled at elaboration of the standard I/O packages and that can
12329
have an impact on mixed language programs, in particular those using I/O before
12330
calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12331
the Ada elaboration routine before performing any I/O or when impractical,
12332
flush the common I/O streams and in particular Standard_Output before
12333
elaborating the Ada code.
12334
 
12335
@node FORM Strings
12336
@section FORM Strings
12337
 
12338
@noindent
12339
The format of a FORM string in GNAT is:
12340
 
12341
@smallexample
12342
"keyword=value,keyword=value,@dots{},keyword=value"
12343
@end smallexample
12344
 
12345
@noindent
12346
where letters may be in upper or lower case, and there are no spaces
12347
between values.  The order of the entries is not important.  Currently
12348
the following keywords defined.
12349
 
12350
@smallexample
12351
TEXT_TRANSLATION=[YES|NO]
12352
SHARED=[YES|NO]
12353
WCEM=[n|h|u|s|e|8|b]
12354
ENCODING=[UTF8|8BITS]
12355
@end smallexample
12356
 
12357
@noindent
12358
The use of these parameters is described later in this section.
12359
 
12360
@node Direct_IO
12361
@section Direct_IO
12362
 
12363
@noindent
12364
Direct_IO can only be instantiated for definite types.  This is a
12365
restriction of the Ada language, which means that the records are fixed
12366
length (the length being determined by @code{@var{type}'Size}, rounded
12367
up to the next storage unit boundary if necessary).
12368
 
12369
The records of a Direct_IO file are simply written to the file in index
12370
sequence, with the first record starting at offset zero, and subsequent
12371
records following.  There is no control information of any kind.  For
12372
example, if 32-bit integers are being written, each record takes
12373
4-bytes, so the record at index @var{K} starts at offset
12374
(@var{K}@minus{}1)*4.
12375
 
12376
There is no limit on the size of Direct_IO files, they are expanded as
12377
necessary to accommodate whatever records are written to the file.
12378
 
12379
@node Sequential_IO
12380
@section Sequential_IO
12381
 
12382
@noindent
12383
Sequential_IO may be instantiated with either a definite (constrained)
12384
or indefinite (unconstrained) type.
12385
 
12386
For the definite type case, the elements written to the file are simply
12387
the memory images of the data values with no control information of any
12388
kind.  The resulting file should be read using the same type, no validity
12389
checking is performed on input.
12390
 
12391
For the indefinite type case, the elements written consist of two
12392
parts.  First is the size of the data item, written as the memory image
12393
of a @code{Interfaces.C.size_t} value, followed by the memory image of
12394
the data value.  The resulting file can only be read using the same
12395
(unconstrained) type.  Normal assignment checks are performed on these
12396
read operations, and if these checks fail, @code{Data_Error} is
12397
raised.  In particular, in the array case, the lengths must match, and in
12398
the variant record case, if the variable for a particular read operation
12399
is constrained, the discriminants must match.
12400
 
12401
Note that it is not possible to use Sequential_IO to write variable
12402
length array items, and then read the data back into different length
12403
arrays.  For example, the following will raise @code{Data_Error}:
12404
 
12405
@smallexample @c ada
12406
 package IO is new Sequential_IO (String);
12407
 F : IO.File_Type;
12408
 S : String (1..4);
12409
 @dots{}
12410
 IO.Create (F)
12411
 IO.Write (F, "hello!")
12412
 IO.Reset (F, Mode=>In_File);
12413
 IO.Read (F, S);
12414
 Put_Line (S);
12415
 
12416
@end smallexample
12417
 
12418
@noindent
12419
On some Ada implementations, this will print @code{hell}, but the program is
12420
clearly incorrect, since there is only one element in the file, and that
12421
element is the string @code{hello!}.
12422
 
12423
In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12424
using Stream_IO, and this is the preferred mechanism.  In particular, the
12425
above program fragment rewritten to use Stream_IO will work correctly.
12426
 
12427
@node Text_IO
12428
@section Text_IO
12429
 
12430
@noindent
12431
Text_IO files consist of a stream of characters containing the following
12432
special control characters:
12433
 
12434
@smallexample
12435
LF (line feed, 16#0A#) Line Mark
12436
FF (form feed, 16#0C#) Page Mark
12437
@end smallexample
12438
 
12439
@noindent
12440
A canonical Text_IO file is defined as one in which the following
12441
conditions are met:
12442
 
12443
@itemize @bullet
12444
@item
12445
The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12446
of the line.
12447
 
12448
@item
12449
The character @code{FF} is used only as a page mark, i.e.@: to mark the
12450
end of a page and consequently can appear only immediately following a
12451
@code{LF} (line mark) character.
12452
 
12453
@item
12454
The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12455
(line mark, page mark).  In the former case, the page mark is implicitly
12456
assumed to be present.
12457
@end itemize
12458
 
12459
@noindent
12460
A file written using Text_IO will be in canonical form provided that no
12461
explicit @code{LF} or @code{FF} characters are written using @code{Put}
12462
or @code{Put_Line}.  There will be no @code{FF} character at the end of
12463
the file unless an explicit @code{New_Page} operation was performed
12464
before closing the file.
12465
 
12466
A canonical Text_IO file that is a regular file (i.e., not a device or a
12467
pipe) can be read using any of the routines in Text_IO@.  The
12468
semantics in this case will be exactly as defined in the Ada Reference
12469
Manual, and all the routines in Text_IO are fully implemented.
12470
 
12471
A text file that does not meet the requirements for a canonical Text_IO
12472
file has one of the following:
12473
 
12474
@itemize @bullet
12475
@item
12476
The file contains @code{FF} characters not immediately following a
12477
@code{LF} character.
12478
 
12479
@item
12480
The file contains @code{LF} or @code{FF} characters written by
12481
@code{Put} or @code{Put_Line}, which are not logically considered to be
12482
line marks or page marks.
12483
 
12484
@item
12485
The file ends in a character other than @code{LF} or @code{FF},
12486
i.e.@: there is no explicit line mark or page mark at the end of the file.
12487
@end itemize
12488
 
12489
@noindent
12490
Text_IO can be used to read such non-standard text files but subprograms
12491
to do with line or page numbers do not have defined meanings.  In
12492
particular, a @code{FF} character that does not follow a @code{LF}
12493
character may or may not be treated as a page mark from the point of
12494
view of page and line numbering.  Every @code{LF} character is considered
12495
to end a line, and there is an implied @code{LF} character at the end of
12496
the file.
12497
 
12498
@menu
12499
* Text_IO Stream Pointer Positioning::
12500
* Text_IO Reading and Writing Non-Regular Files::
12501
* Get_Immediate::
12502
* Treating Text_IO Files as Streams::
12503
* Text_IO Extensions::
12504
* Text_IO Facilities for Unbounded Strings::
12505
@end menu
12506
 
12507
@node Text_IO Stream Pointer Positioning
12508
@subsection Stream Pointer Positioning
12509
 
12510
@noindent
12511
@code{Ada.Text_IO} has a definition of current position for a file that
12512
is being read.  No internal buffering occurs in Text_IO, and usually the
12513
physical position in the stream used to implement the file corresponds
12514
to this logical position defined by Text_IO@.  There are two exceptions:
12515
 
12516
@itemize @bullet
12517
@item
12518
After a call to @code{End_Of_Page} that returns @code{True}, the stream
12519
is positioned past the @code{LF} (line mark) that precedes the page
12520
mark.  Text_IO maintains an internal flag so that subsequent read
12521
operations properly handle the logical position which is unchanged by
12522
the @code{End_Of_Page} call.
12523
 
12524
@item
12525
After a call to @code{End_Of_File} that returns @code{True}, if the
12526
Text_IO file was positioned before the line mark at the end of file
12527
before the call, then the logical position is unchanged, but the stream
12528
is physically positioned right at the end of file (past the line mark,
12529
and past a possible page mark following the line mark.  Again Text_IO
12530
maintains internal flags so that subsequent read operations properly
12531
handle the logical position.
12532
@end itemize
12533
 
12534
@noindent
12535
These discrepancies have no effect on the observable behavior of
12536
Text_IO, but if a single Ada stream is shared between a C program and
12537
Ada program, or shared (using @samp{shared=yes} in the form string)
12538
between two Ada files, then the difference may be observable in some
12539
situations.
12540
 
12541
@node Text_IO Reading and Writing Non-Regular Files
12542
@subsection Reading and Writing Non-Regular Files
12543
 
12544
@noindent
12545
A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12546
can be used for reading and writing.  Writing is not affected and the
12547
sequence of characters output is identical to the normal file case, but
12548
for reading, the behavior of Text_IO is modified to avoid undesirable
12549
look-ahead as follows:
12550
 
12551
An input file that is not a regular file is considered to have no page
12552
marks.  Any @code{Ascii.FF} characters (the character normally used for a
12553
page mark) appearing in the file are considered to be data
12554
characters.  In particular:
12555
 
12556
@itemize @bullet
12557
@item
12558
@code{Get_Line} and @code{Skip_Line} do not test for a page mark
12559
following a line mark.  If a page mark appears, it will be treated as a
12560
data character.
12561
 
12562
@item
12563
This avoids the need to wait for an extra character to be typed or
12564
entered from the pipe to complete one of these operations.
12565
 
12566
@item
12567
@code{End_Of_Page} always returns @code{False}
12568
 
12569
@item
12570
@code{End_Of_File} will return @code{False} if there is a page mark at
12571
the end of the file.
12572
@end itemize
12573
 
12574
@noindent
12575
Output to non-regular files is the same as for regular files.  Page marks
12576
may be written to non-regular files using @code{New_Page}, but as noted
12577
above they will not be treated as page marks on input if the output is
12578
piped to another Ada program.
12579
 
12580
Another important discrepancy when reading non-regular files is that the end
12581
of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12582
pressing the @key{EOT} key,
12583
then end of file
12584
is signaled once (i.e.@: the test @code{End_Of_File}
12585
will yield @code{True}, or a read will
12586
raise @code{End_Error}), but then reading can resume
12587
to read data past that end of
12588
file indication, until another end of file indication is entered.
12589
 
12590
@node Get_Immediate
12591
@subsection Get_Immediate
12592
@cindex Get_Immediate
12593
 
12594
@noindent
12595
Get_Immediate returns the next character (including control characters)
12596
from the input file.  In particular, Get_Immediate will return LF or FF
12597
characters used as line marks or page marks.  Such operations leave the
12598
file positioned past the control character, and it is thus not treated
12599
as having its normal function.  This means that page, line and column
12600
counts after this kind of Get_Immediate call are set as though the mark
12601
did not occur.  In the case where a Get_Immediate leaves the file
12602
positioned between the line mark and page mark (which is not normally
12603
possible), it is undefined whether the FF character will be treated as a
12604
page mark.
12605
 
12606
@node Treating Text_IO Files as Streams
12607
@subsection Treating Text_IO Files as Streams
12608
@cindex Stream files
12609
 
12610
@noindent
12611
The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12612
as a stream.  Data written to a Text_IO file in this stream mode is
12613
binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12614
16#0C# (@code{FF}), the resulting file may have non-standard
12615
format.  Similarly if read operations are used to read from a Text_IO
12616
file treated as a stream, then @code{LF} and @code{FF} characters may be
12617
skipped and the effect is similar to that described above for
12618
@code{Get_Immediate}.
12619
 
12620
@node Text_IO Extensions
12621
@subsection Text_IO Extensions
12622
@cindex Text_IO extensions
12623
 
12624
@noindent
12625
A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12626
to the standard @code{Text_IO} package:
12627
 
12628
@itemize @bullet
12629
@item function File_Exists (Name : String) return Boolean;
12630
Determines if a file of the given name exists.
12631
 
12632
@item function Get_Line return String;
12633
Reads a string from the standard input file.  The value returned is exactly
12634
the length of the line that was read.
12635
 
12636
@item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12637
Similar, except that the parameter File specifies the file from which
12638
the string is to be read.
12639
 
12640
@end itemize
12641
 
12642
@node Text_IO Facilities for Unbounded Strings
12643
@subsection Text_IO Facilities for Unbounded Strings
12644
@cindex Text_IO for unbounded strings
12645
@cindex Unbounded_String, Text_IO operations
12646
 
12647
@noindent
12648
The package @code{Ada.Strings.Unbounded.Text_IO}
12649
in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12650
subprograms useful for Text_IO operations on unbounded strings:
12651
 
12652
@itemize @bullet
12653
 
12654
@item function Get_Line (File : File_Type) return Unbounded_String;
12655
Reads a line from the specified file
12656
and returns the result as an unbounded string.
12657
 
12658
@item procedure Put (File : File_Type; U : Unbounded_String);
12659
Writes the value of the given unbounded string to the specified file
12660
Similar to the effect of
12661
@code{Put (To_String (U))} except that an extra copy is avoided.
12662
 
12663
@item procedure Put_Line (File : File_Type; U : Unbounded_String);
12664
Writes the value of the given unbounded string to the specified file,
12665
followed by a @code{New_Line}.
12666
Similar to the effect of @code{Put_Line (To_String (U))} except
12667
that an extra copy is avoided.
12668
@end itemize
12669
 
12670
@noindent
12671
In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12672
and is optional.  If the parameter is omitted, then the standard input or
12673
output file is referenced as appropriate.
12674
 
12675
The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12676
files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12677
@code{Wide_Text_IO} functionality for unbounded wide strings.
12678
 
12679
The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12680
files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12681
@code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12682
 
12683
@node Wide_Text_IO
12684
@section Wide_Text_IO
12685
 
12686
@noindent
12687
@code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12688
both input and output files may contain special sequences that represent
12689
wide character values.  The encoding scheme for a given file may be
12690
specified using a FORM parameter:
12691
 
12692
@smallexample
12693
WCEM=@var{x}
12694
@end smallexample
12695
 
12696
@noindent
12697
as part of the FORM string (WCEM = wide character encoding method),
12698
where @var{x} is one of the following characters
12699
 
12700
@table @samp
12701
@item h
12702
Hex ESC encoding
12703
@item u
12704
Upper half encoding
12705
@item s
12706
Shift-JIS encoding
12707
@item e
12708
EUC Encoding
12709
@item 8
12710
UTF-8 encoding
12711
@item b
12712
Brackets encoding
12713
@end table
12714
 
12715
@noindent
12716
The encoding methods match those that
12717
can be used in a source
12718
program, but there is no requirement that the encoding method used for
12719
the source program be the same as the encoding method used for files,
12720
and different files may use different encoding methods.
12721
 
12722
The default encoding method for the standard files, and for opened files
12723
for which no WCEM parameter is given in the FORM string matches the
12724
wide character encoding specified for the main program (the default
12725
being brackets encoding if no coding method was specified with -gnatW).
12726
 
12727
@table @asis
12728
@item Hex Coding
12729
In this encoding, a wide character is represented by a five character
12730
sequence:
12731
 
12732
@smallexample
12733
ESC a b c d
12734
@end smallexample
12735
 
12736
@noindent
12737
where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12738
characters (using upper case letters) of the wide character code.  For
12739
example, ESC A345 is used to represent the wide character with code
12740
16#A345#.  This scheme is compatible with use of the full
12741
@code{Wide_Character} set.
12742
 
12743
@item Upper Half Coding
12744
The wide character with encoding 16#abcd#, where the upper bit is on
12745
(i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12746
16#cd#.  The second byte may never be a format control character, but is
12747
not required to be in the upper half.  This method can be also used for
12748
shift-JIS or EUC where the internal coding matches the external coding.
12749
 
12750
@item Shift JIS Coding
12751
A wide character is represented by a two character sequence 16#ab# and
12752
16#cd#, with the restrictions described for upper half encoding as
12753
described above.  The internal character code is the corresponding JIS
12754
character according to the standard algorithm for Shift-JIS
12755
conversion.  Only characters defined in the JIS code set table can be
12756
used with this encoding method.
12757
 
12758
@item EUC Coding
12759
A wide character is represented by a two character sequence 16#ab# and
12760
16#cd#, with both characters being in the upper half.  The internal
12761
character code is the corresponding JIS character according to the EUC
12762
encoding algorithm.  Only characters defined in the JIS code set table
12763
can be used with this encoding method.
12764
 
12765
@item UTF-8 Coding
12766
A wide character is represented using
12767
UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12768
10646-1/Am.2.  Depending on the character value, the representation
12769
is a one, two, or three byte sequence:
12770
 
12771
@smallexample
12772
16#0000#-16#007f#: 2#0xxxxxxx#
12773
16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12774
16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12775
@end smallexample
12776
 
12777
@noindent
12778
where the @var{xxx} bits correspond to the left-padded bits of the
12779
16-bit character value.  Note that all lower half ASCII characters
12780
are represented as ASCII bytes and all upper half characters and
12781
other wide characters are represented as sequences of upper-half
12782
(The full UTF-8 scheme allows for encoding 31-bit characters as
12783
6-byte sequences, but in this implementation, all UTF-8 sequences
12784
of four or more bytes length will raise a Constraint_Error, as
12785
will all invalid UTF-8 sequences.)
12786
 
12787
@item Brackets Coding
12788
In this encoding, a wide character is represented by the following eight
12789
character sequence:
12790
 
12791
@smallexample
12792
[ " a b c d " ]
12793
@end smallexample
12794
 
12795
@noindent
12796
where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12797
characters (using uppercase letters) of the wide character code.  For
12798
example, @code{["A345"]} is used to represent the wide character with code
12799
@code{16#A345#}.
12800
This scheme is compatible with use of the full Wide_Character set.
12801
On input, brackets coding can also be used for upper half characters,
12802
e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12803
is only used for wide characters with a code greater than @code{16#FF#}.
12804
 
12805
Note that brackets coding is not normally used in the context of
12806
Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12807
a portable way of encoding source files. In the context of Wide_Text_IO
12808
or Wide_Wide_Text_IO, it can only be used if the file does not contain
12809
any instance of the left bracket character other than to encode wide
12810
character values using the brackets encoding method. In practice it is
12811
expected that some standard wide character encoding method such
12812
as UTF-8 will be used for text input output.
12813
 
12814
If brackets notation is used, then any occurrence of a left bracket
12815
in the input file which is not the start of a valid wide character
12816
sequence will cause Constraint_Error to be raised. It is possible to
12817
encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12818
input will interpret this as a left bracket.
12819
 
12820
However, when a left bracket is output, it will be output as a left bracket
12821
and not as ["5B"]. We make this decision because for normal use of
12822
Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12823
brackets. For example, if we write:
12824
 
12825
@smallexample
12826
   Put_Line ("Start of output [first run]");
12827
@end smallexample
12828
 
12829
@noindent
12830
we really do not want to have the left bracket in this message clobbered so
12831
that the output reads:
12832
 
12833
@smallexample
12834
   Start of output ["5B"]first run]
12835
@end smallexample
12836
 
12837
@noindent
12838
In practice brackets encoding is reasonably useful for normal Put_Line use
12839
since we won't get confused between left brackets and wide character
12840
sequences in the output. But for input, or when files are written out
12841
and read back in, it really makes better sense to use one of the standard
12842
encoding methods such as UTF-8.
12843
 
12844
@end table
12845
 
12846
@noindent
12847
For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12848
not all wide character
12849
values can be represented.  An attempt to output a character that cannot
12850
be represented using the encoding scheme for the file causes
12851
Constraint_Error to be raised.  An invalid wide character sequence on
12852
input also causes Constraint_Error to be raised.
12853
 
12854
@menu
12855
* Wide_Text_IO Stream Pointer Positioning::
12856
* Wide_Text_IO Reading and Writing Non-Regular Files::
12857
@end menu
12858
 
12859
@node Wide_Text_IO Stream Pointer Positioning
12860
@subsection Stream Pointer Positioning
12861
 
12862
@noindent
12863
@code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12864
of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12865
case:
12866
 
12867
If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12868
normal lower ASCII set (i.e.@: a character in the range:
12869
 
12870
@smallexample @c ada
12871
Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12872
@end smallexample
12873
 
12874
@noindent
12875
then although the logical position of the file pointer is unchanged by
12876
the @code{Look_Ahead} call, the stream is physically positioned past the
12877
wide character sequence.  Again this is to avoid the need for buffering
12878
or backup, and all @code{Wide_Text_IO} routines check the internal
12879
indication that this situation has occurred so that this is not visible
12880
to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12881
can be observed if the wide text file shares a stream with another file.
12882
 
12883
@node Wide_Text_IO Reading and Writing Non-Regular Files
12884
@subsection Reading and Writing Non-Regular Files
12885
 
12886
@noindent
12887
As in the case of Text_IO, when a non-regular file is read, it is
12888
assumed that the file contains no page marks (any form characters are
12889
treated as data characters), and @code{End_Of_Page} always returns
12890
@code{False}.  Similarly, the end of file indication is not sticky, so
12891
it is possible to read beyond an end of file.
12892
 
12893
@node Wide_Wide_Text_IO
12894
@section Wide_Wide_Text_IO
12895
 
12896
@noindent
12897
@code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12898
both input and output files may contain special sequences that represent
12899
wide wide character values.  The encoding scheme for a given file may be
12900
specified using a FORM parameter:
12901
 
12902
@smallexample
12903
WCEM=@var{x}
12904
@end smallexample
12905
 
12906
@noindent
12907
as part of the FORM string (WCEM = wide character encoding method),
12908
where @var{x} is one of the following characters
12909
 
12910
@table @samp
12911
@item h
12912
Hex ESC encoding
12913
@item u
12914
Upper half encoding
12915
@item s
12916
Shift-JIS encoding
12917
@item e
12918
EUC Encoding
12919
@item 8
12920
UTF-8 encoding
12921
@item b
12922
Brackets encoding
12923
@end table
12924
 
12925
@noindent
12926
The encoding methods match those that
12927
can be used in a source
12928
program, but there is no requirement that the encoding method used for
12929
the source program be the same as the encoding method used for files,
12930
and different files may use different encoding methods.
12931
 
12932
The default encoding method for the standard files, and for opened files
12933
for which no WCEM parameter is given in the FORM string matches the
12934
wide character encoding specified for the main program (the default
12935
being brackets encoding if no coding method was specified with -gnatW).
12936
 
12937
@table @asis
12938
 
12939
@item UTF-8 Coding
12940
A wide character is represented using
12941
UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12942
10646-1/Am.2.  Depending on the character value, the representation
12943
is a one, two, three, or four byte sequence:
12944
 
12945
@smallexample
12946
16#000000#-16#00007f#: 2#0xxxxxxx#
12947
16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12948
16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12949
16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12950
@end smallexample
12951
 
12952
@noindent
12953
where the @var{xxx} bits correspond to the left-padded bits of the
12954
21-bit character value.  Note that all lower half ASCII characters
12955
are represented as ASCII bytes and all upper half characters and
12956
other wide characters are represented as sequences of upper-half
12957
characters.
12958
 
12959
@item Brackets Coding
12960
In this encoding, a wide wide character is represented by the following eight
12961
character sequence if is in wide character range
12962
 
12963
@smallexample
12964
[ " a b c d " ]
12965
@end smallexample
12966
 
12967
and by the following ten character sequence if not
12968
 
12969
@smallexample
12970
[ " a b c d e f " ]
12971
@end smallexample
12972
 
12973
@noindent
12974
where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12975
are the four or six hexadecimal
12976
characters (using uppercase letters) of the wide wide character code.  For
12977
example, @code{["01A345"]} is used to represent the wide wide character
12978
with code @code{16#01A345#}.
12979
 
12980
This scheme is compatible with use of the full Wide_Wide_Character set.
12981
On input, brackets coding can also be used for upper half characters,
12982
e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12983
is only used for wide characters with a code greater than @code{16#FF#}.
12984
 
12985
@end table
12986
 
12987
@noindent
12988
If is also possible to use the other Wide_Character encoding methods,
12989
such as Shift-JIS, but the other schemes cannot support the full range
12990
of wide wide characters.
12991
An attempt to output a character that cannot
12992
be represented using the encoding scheme for the file causes
12993
Constraint_Error to be raised.  An invalid wide character sequence on
12994
input also causes Constraint_Error to be raised.
12995
 
12996
@menu
12997
* Wide_Wide_Text_IO Stream Pointer Positioning::
12998
* Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12999
@end menu
13000
 
13001
@node Wide_Wide_Text_IO Stream Pointer Positioning
13002
@subsection Stream Pointer Positioning
13003
 
13004
@noindent
13005
@code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13006
of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13007
case:
13008
 
13009
If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13010
normal lower ASCII set (i.e.@: a character in the range:
13011
 
13012
@smallexample @c ada
13013
Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13014
@end smallexample
13015
 
13016
@noindent
13017
then although the logical position of the file pointer is unchanged by
13018
the @code{Look_Ahead} call, the stream is physically positioned past the
13019
wide character sequence.  Again this is to avoid the need for buffering
13020
or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13021
indication that this situation has occurred so that this is not visible
13022
to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13023
can be observed if the wide text file shares a stream with another file.
13024
 
13025
@node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13026
@subsection Reading and Writing Non-Regular Files
13027
 
13028
@noindent
13029
As in the case of Text_IO, when a non-regular file is read, it is
13030
assumed that the file contains no page marks (any form characters are
13031
treated as data characters), and @code{End_Of_Page} always returns
13032
@code{False}.  Similarly, the end of file indication is not sticky, so
13033
it is possible to read beyond an end of file.
13034
 
13035
@node Stream_IO
13036
@section Stream_IO
13037
 
13038
@noindent
13039
A stream file is a sequence of bytes, where individual elements are
13040
written to the file as described in the Ada Reference Manual.  The type
13041
@code{Stream_Element} is simply a byte.  There are two ways to read or
13042
write a stream file.
13043
 
13044
@itemize @bullet
13045
@item
13046
The operations @code{Read} and @code{Write} directly read or write a
13047
sequence of stream elements with no control information.
13048
 
13049
@item
13050
The stream attributes applied to a stream file transfer data in the
13051
manner described for stream attributes.
13052
@end itemize
13053
 
13054
@node Text Translation
13055
@section Text Translation
13056
 
13057
@noindent
13058
@samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13059
passed to Text_IO.Create and Text_IO.Open:
13060
@samp{Text_Translation=@var{Yes}} is the default, which means to
13061
translate LF to/from CR/LF on Windows systems.
13062
@samp{Text_Translation=@var{No}} disables this translation; i.e. it
13063
uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13064
may be used to create Unix-style files on
13065
Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13066
systems.
13067
 
13068
@node Shared Files
13069
@section Shared Files
13070
 
13071
@noindent
13072
Section A.14 of the Ada Reference Manual allows implementations to
13073
provide a wide variety of behavior if an attempt is made to access the
13074
same external file with two or more internal files.
13075
 
13076
To provide a full range of functionality, while at the same time
13077
minimizing the problems of portability caused by this implementation
13078
dependence, GNAT handles file sharing as follows:
13079
 
13080
@itemize @bullet
13081
@item
13082
In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13083
to open two or more files with the same full name is considered an error
13084
and is not supported.  The exception @code{Use_Error} will be
13085
raised.  Note that a file that is not explicitly closed by the program
13086
remains open until the program terminates.
13087
 
13088
@item
13089
If the form parameter @samp{shared=no} appears in the form string, the
13090
file can be opened or created with its own separate stream identifier,
13091
regardless of whether other files sharing the same external file are
13092
opened.  The exact effect depends on how the C stream routines handle
13093
multiple accesses to the same external files using separate streams.
13094
 
13095
@item
13096
If the form parameter @samp{shared=yes} appears in the form string for
13097
each of two or more files opened using the same full name, the same
13098
stream is shared between these files, and the semantics are as described
13099
in Ada Reference Manual, Section A.14.
13100
@end itemize
13101
 
13102
@noindent
13103
When a program that opens multiple files with the same name is ported
13104
from another Ada compiler to GNAT, the effect will be that
13105
@code{Use_Error} is raised.
13106
 
13107
The documentation of the original compiler and the documentation of the
13108
program should then be examined to determine if file sharing was
13109
expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13110
and @code{Create} calls as required.
13111
 
13112
When a program is ported from GNAT to some other Ada compiler, no
13113
special attention is required unless the @samp{shared=@var{xxx}} form
13114
parameter is used in the program.  In this case, you must examine the
13115
documentation of the new compiler to see if it supports the required
13116
file sharing semantics, and form strings modified appropriately.  Of
13117
course it may be the case that the program cannot be ported if the
13118
target compiler does not support the required functionality.  The best
13119
approach in writing portable code is to avoid file sharing (and hence
13120
the use of the @samp{shared=@var{xxx}} parameter in the form string)
13121
completely.
13122
 
13123
One common use of file sharing in Ada 83 is the use of instantiations of
13124
Sequential_IO on the same file with different types, to achieve
13125
heterogeneous input-output.  Although this approach will work in GNAT if
13126
@samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13127
for this purpose (using the stream attributes)
13128
 
13129
@node Filenames encoding
13130
@section Filenames encoding
13131
 
13132
@noindent
13133
An encoding form parameter can be used to specify the filename
13134
encoding @samp{encoding=@var{xxx}}.
13135
 
13136
@itemize @bullet
13137
@item
13138
If the form parameter @samp{encoding=utf8} appears in the form string, the
13139
filename must be encoded in UTF-8.
13140
 
13141
@item
13142
If the form parameter @samp{encoding=8bits} appears in the form
13143
string, the filename must be a standard 8bits string.
13144
@end itemize
13145
 
13146
In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13147
encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13148
variable. And if not set @samp{utf8} is assumed.
13149
 
13150
@table @samp
13151
@item CP_ACP
13152
The current system Windows ANSI code page.
13153
@item CP_UTF8
13154
UTF-8 encoding
13155
@end table
13156
 
13157
This encoding form parameter is only supported on the Windows
13158
platform. On the other Operating Systems the run-time is supporting
13159
UTF-8 natively.
13160
 
13161
@node Open Modes
13162
@section Open Modes
13163
 
13164
@noindent
13165
@code{Open} and @code{Create} calls result in a call to @code{fopen}
13166
using the mode shown in the following table:
13167
 
13168
@sp 2
13169
@center @code{Open} and @code{Create} Call Modes
13170
@smallexample
13171
                               @b{OPEN }           @b{CREATE}
13172
Append_File                    "r+"             "w+"
13173
In_File                        "r"              "w+"
13174
Out_File (Direct_IO)           "r+"             "w"
13175
Out_File (all other cases)     "w"              "w"
13176
Inout_File                     "r+"             "w+"
13177
@end smallexample
13178
 
13179
@noindent
13180
If text file translation is required, then either @samp{b} or @samp{t}
13181
is added to the mode, depending on the setting of Text.  Text file
13182
translation refers to the mapping of CR/LF sequences in an external file
13183
to LF characters internally.  This mapping only occurs in DOS and
13184
DOS-like systems, and is not relevant to other systems.
13185
 
13186
A special case occurs with Stream_IO@.  As shown in the above table, the
13187
file is initially opened in @samp{r} or @samp{w} mode for the
13188
@code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13189
subsequently requires switching from reading to writing or vice-versa,
13190
then the file is reopened in @samp{r+} mode to permit the required operation.
13191
 
13192
@node Operations on C Streams
13193
@section Operations on C Streams
13194
The package @code{Interfaces.C_Streams} provides an Ada program with direct
13195
access to the C library functions for operations on C streams:
13196
 
13197
@smallexample @c adanocomment
13198
package Interfaces.C_Streams is
13199
  -- Note: the reason we do not use the types that are in
13200
  -- Interfaces.C is that we want to avoid dragging in the
13201
  -- code in this unit if possible.
13202
  subtype chars is System.Address;
13203
  -- Pointer to null-terminated array of characters
13204
  subtype FILEs is System.Address;
13205
  -- Corresponds to the C type FILE*
13206
  subtype voids is System.Address;
13207
  -- Corresponds to the C type void*
13208
  subtype int is Integer;
13209
  subtype long is Long_Integer;
13210
  -- Note: the above types are subtypes deliberately, and it
13211
  -- is part of this spec that the above correspondences are
13212
  -- guaranteed.  This means that it is legitimate to, for
13213
  -- example, use Integer instead of int.  We provide these
13214
  -- synonyms for clarity, but in some cases it may be
13215
  -- convenient to use the underlying types (for example to
13216
  -- avoid an unnecessary dependency of a spec on the spec
13217
  -- of this unit).
13218
  type size_t is mod 2 ** Standard'Address_Size;
13219
  NULL_Stream : constant FILEs;
13220
  -- Value returned (NULL in C) to indicate an
13221
  -- fdopen/fopen/tmpfile error
13222
  ----------------------------------
13223
  -- Constants Defined in stdio.h --
13224
  ----------------------------------
13225
  EOF : constant int;
13226
  -- Used by a number of routines to indicate error or
13227
  -- end of file
13228
  IOFBF : constant int;
13229
  IOLBF : constant int;
13230
  IONBF : constant int;
13231
  -- Used to indicate buffering mode for setvbuf call
13232
  SEEK_CUR : constant int;
13233
  SEEK_END : constant int;
13234
  SEEK_SET : constant int;
13235
  -- Used to indicate origin for fseek call
13236
  function stdin return FILEs;
13237
  function stdout return FILEs;
13238
  function stderr return FILEs;
13239
  -- Streams associated with standard files
13240
  --------------------------
13241
  -- Standard C functions --
13242
  --------------------------
13243
  -- The functions selected below are ones that are
13244
  -- available in DOS, OS/2, UNIX and Xenix (but not
13245
  -- necessarily in ANSI C).  These are very thin interfaces
13246
  -- which copy exactly the C headers.  For more
13247
  -- documentation on these functions, see the Microsoft C
13248
  -- "Run-Time Library Reference" (Microsoft Press, 1990,
13249
  -- ISBN 1-55615-225-6), which includes useful information
13250
  -- on system compatibility.
13251
  procedure clearerr (stream : FILEs);
13252
  function fclose (stream : FILEs) return int;
13253
  function fdopen (handle : int; mode : chars) return FILEs;
13254
  function feof (stream : FILEs) return int;
13255
  function ferror (stream : FILEs) return int;
13256
  function fflush (stream : FILEs) return int;
13257
  function fgetc (stream : FILEs) return int;
13258
  function fgets (strng : chars; n : int; stream : FILEs)
13259
      return chars;
13260
  function fileno (stream : FILEs) return int;
13261
  function fopen (filename : chars; Mode : chars)
13262
      return FILEs;
13263
  -- Note: to maintain target independence, use
13264
  -- text_translation_required, a boolean variable defined in
13265
  -- a-sysdep.c to deal with the target dependent text
13266
  -- translation requirement.  If this variable is set,
13267
  -- then  b/t should be appended to the standard mode
13268
  -- argument to set the text translation mode off or on
13269
  -- as required.
13270
  function fputc (C : int; stream : FILEs) return int;
13271
  function fputs (Strng : chars; Stream : FILEs) return int;
13272
  function fread
13273
     (buffer : voids;
13274
      size : size_t;
13275
      count : size_t;
13276
      stream : FILEs)
13277
      return size_t;
13278
  function freopen
13279
     (filename : chars;
13280
      mode : chars;
13281
      stream : FILEs)
13282
      return FILEs;
13283
  function fseek
13284
     (stream : FILEs;
13285
      offset : long;
13286
      origin : int)
13287
      return int;
13288
  function ftell (stream : FILEs) return long;
13289
  function fwrite
13290
     (buffer : voids;
13291
      size : size_t;
13292
      count : size_t;
13293
      stream : FILEs)
13294
      return size_t;
13295
  function isatty (handle : int) return int;
13296
  procedure mktemp (template : chars);
13297
  -- The return value (which is just a pointer to template)
13298
  -- is discarded
13299
  procedure rewind (stream : FILEs);
13300
  function rmtmp return int;
13301
  function setvbuf
13302
     (stream : FILEs;
13303
      buffer : chars;
13304
      mode : int;
13305
      size : size_t)
13306
      return int;
13307
 
13308
  function tmpfile return FILEs;
13309
  function ungetc (c : int; stream : FILEs) return int;
13310
  function unlink (filename : chars) return int;
13311
  ---------------------
13312
  -- Extra functions --
13313
  ---------------------
13314
  -- These functions supply slightly thicker bindings than
13315
  -- those above.  They are derived from functions in the
13316
  -- C Run-Time Library, but may do a bit more work than
13317
  -- just directly calling one of the Library functions.
13318
  function is_regular_file (handle : int) return int;
13319
  -- Tests if given handle is for a regular file (result 1)
13320
  -- or for a non-regular file (pipe or device, result 0).
13321
  ---------------------------------
13322
  -- Control of Text/Binary Mode --
13323
  ---------------------------------
13324
  -- If text_translation_required is true, then the following
13325
  -- functions may be used to dynamically switch a file from
13326
  -- binary to text mode or vice versa.  These functions have
13327
  -- no effect if text_translation_required is false (i.e.@: in
13328
  -- normal UNIX mode).  Use fileno to get a stream handle.
13329
  procedure set_binary_mode (handle : int);
13330
  procedure set_text_mode (handle : int);
13331
  ----------------------------
13332
  -- Full Path Name support --
13333
  ----------------------------
13334
  procedure full_name (nam : chars; buffer : chars);
13335
  -- Given a NUL terminated string representing a file
13336
  -- name, returns in buffer a NUL terminated string
13337
  -- representing the full path name for the file name.
13338
  -- On systems where it is relevant the   drive is also
13339
  -- part of the full path name.  It is the responsibility
13340
  -- of the caller to pass an actual parameter for buffer
13341
  -- that is big enough for any full path name.  Use
13342
  -- max_path_len given below as the size of buffer.
13343
  max_path_len : integer;
13344
  -- Maximum length of an allowable full path name on the
13345
  -- system, including a terminating NUL character.
13346
end Interfaces.C_Streams;
13347
@end smallexample
13348
 
13349
@node Interfacing to C Streams
13350
@section Interfacing to C Streams
13351
 
13352
@noindent
13353
The packages in this section permit interfacing Ada files to C Stream
13354
operations.
13355
 
13356
@smallexample @c ada
13357
 with Interfaces.C_Streams;
13358
 package Ada.Sequential_IO.C_Streams is
13359
    function C_Stream (F : File_Type)
13360
       return Interfaces.C_Streams.FILEs;
13361
    procedure Open
13362
      (File : in out File_Type;
13363
       Mode : in File_Mode;
13364
       C_Stream : in Interfaces.C_Streams.FILEs;
13365
       Form : in String := "");
13366
 end Ada.Sequential_IO.C_Streams;
13367
 
13368
  with Interfaces.C_Streams;
13369
  package Ada.Direct_IO.C_Streams is
13370
     function C_Stream (F : File_Type)
13371
        return Interfaces.C_Streams.FILEs;
13372
     procedure Open
13373
       (File : in out File_Type;
13374
        Mode : in File_Mode;
13375
        C_Stream : in Interfaces.C_Streams.FILEs;
13376
        Form : in String := "");
13377
  end Ada.Direct_IO.C_Streams;
13378
 
13379
  with Interfaces.C_Streams;
13380
  package Ada.Text_IO.C_Streams is
13381
     function C_Stream (F : File_Type)
13382
        return Interfaces.C_Streams.FILEs;
13383
     procedure Open
13384
       (File : in out File_Type;
13385
        Mode : in File_Mode;
13386
        C_Stream : in Interfaces.C_Streams.FILEs;
13387
        Form : in String := "");
13388
  end Ada.Text_IO.C_Streams;
13389
 
13390
  with Interfaces.C_Streams;
13391
  package Ada.Wide_Text_IO.C_Streams is
13392
     function C_Stream (F : File_Type)
13393
        return Interfaces.C_Streams.FILEs;
13394
     procedure Open
13395
       (File : in out File_Type;
13396
        Mode : in File_Mode;
13397
        C_Stream : in Interfaces.C_Streams.FILEs;
13398
        Form : in String := "");
13399
 end Ada.Wide_Text_IO.C_Streams;
13400
 
13401
  with Interfaces.C_Streams;
13402
  package Ada.Wide_Wide_Text_IO.C_Streams is
13403
     function C_Stream (F : File_Type)
13404
        return Interfaces.C_Streams.FILEs;
13405
     procedure Open
13406
       (File : in out File_Type;
13407
        Mode : in File_Mode;
13408
        C_Stream : in Interfaces.C_Streams.FILEs;
13409
        Form : in String := "");
13410
 end Ada.Wide_Wide_Text_IO.C_Streams;
13411
 
13412
 with Interfaces.C_Streams;
13413
 package Ada.Stream_IO.C_Streams is
13414
    function C_Stream (F : File_Type)
13415
       return Interfaces.C_Streams.FILEs;
13416
    procedure Open
13417
      (File : in out File_Type;
13418
       Mode : in File_Mode;
13419
       C_Stream : in Interfaces.C_Streams.FILEs;
13420
       Form : in String := "");
13421
 end Ada.Stream_IO.C_Streams;
13422
@end smallexample
13423
 
13424
@noindent
13425
In each of these six packages, the @code{C_Stream} function obtains the
13426
@code{FILE} pointer from a currently opened Ada file.  It is then
13427
possible to use the @code{Interfaces.C_Streams} package to operate on
13428
this stream, or the stream can be passed to a C program which can
13429
operate on it directly.  Of course the program is responsible for
13430
ensuring that only appropriate sequences of operations are executed.
13431
 
13432
One particular use of relevance to an Ada program is that the
13433
@code{setvbuf} function can be used to control the buffering of the
13434
stream used by an Ada file.  In the absence of such a call the standard
13435
default buffering is used.
13436
 
13437
The @code{Open} procedures in these packages open a file giving an
13438
existing C Stream instead of a file name.  Typically this stream is
13439
imported from a C program, allowing an Ada file to operate on an
13440
existing C file.
13441
 
13442
@node The GNAT Library
13443
@chapter The GNAT Library
13444
 
13445
@noindent
13446
The GNAT library contains a number of general and special purpose packages.
13447
It represents functionality that the GNAT developers have found useful, and
13448
which is made available to GNAT users.  The packages described here are fully
13449
supported, and upwards compatibility will be maintained in future releases,
13450
so you can use these facilities with the confidence that the same functionality
13451
will be available in future releases.
13452
 
13453
The chapter here simply gives a brief summary of the facilities available.
13454
The full documentation is found in the spec file for the package.  The full
13455
sources of these library packages, including both spec and body, are provided
13456
with all GNAT releases.  For example, to find out the full specifications of
13457
the SPITBOL pattern matching capability, including a full tutorial and
13458
extensive examples, look in the @file{g-spipat.ads} file in the library.
13459
 
13460
For each entry here, the package name (as it would appear in a @code{with}
13461
clause) is given, followed by the name of the corresponding spec file in
13462
parentheses.  The packages are children in four hierarchies, @code{Ada},
13463
@code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13464
GNAT-specific hierarchy.
13465
 
13466
Note that an application program should only use packages in one of these
13467
four hierarchies if the package is defined in the Ada Reference Manual,
13468
or is listed in this section of the GNAT Programmers Reference Manual.
13469
All other units should be considered internal implementation units and
13470
should not be directly @code{with}'ed by application code.  The use of
13471
a @code{with} statement that references one of these internal implementation
13472
units makes an application potentially dependent on changes in versions
13473
of GNAT, and will generate a warning message.
13474
 
13475
@menu
13476
* Ada.Characters.Latin_9 (a-chlat9.ads)::
13477
* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13478
* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13479
* Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13480
* Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13481
* Ada.Command_Line.Environment (a-colien.ads)::
13482
* Ada.Command_Line.Remove (a-colire.ads)::
13483
* Ada.Command_Line.Response_File (a-clrefi.ads)::
13484
* Ada.Direct_IO.C_Streams (a-diocst.ads)::
13485
* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13486
* Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13487
* Ada.Exceptions.Traceback (a-exctra.ads)::
13488
* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13489
* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13490
* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13491
* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13492
* Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13493
* Ada.Text_IO.C_Streams (a-tiocst.ads)::
13494
* Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13495
* Ada.Wide_Characters.Unicode (a-wichun.ads)::
13496
* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13497
* Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13498
* Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13499
* Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13500
* Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13501
* GNAT.Altivec (g-altive.ads)::
13502
* GNAT.Altivec.Conversions (g-altcon.ads)::
13503
* GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13504
* GNAT.Altivec.Vector_Types (g-alvety.ads)::
13505
* GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13506
* GNAT.Array_Split (g-arrspl.ads)::
13507
* GNAT.AWK (g-awk.ads)::
13508
* GNAT.Bounded_Buffers (g-boubuf.ads)::
13509
* GNAT.Bounded_Mailboxes (g-boumai.ads)::
13510
* GNAT.Bubble_Sort (g-bubsor.ads)::
13511
* GNAT.Bubble_Sort_A (g-busora.ads)::
13512
* GNAT.Bubble_Sort_G (g-busorg.ads)::
13513
* GNAT.Byte_Order_Mark (g-byorma.ads)::
13514
* GNAT.Byte_Swapping (g-bytswa.ads)::
13515
* GNAT.Calendar (g-calend.ads)::
13516
* GNAT.Calendar.Time_IO (g-catiio.ads)::
13517
* GNAT.Case_Util (g-casuti.ads)::
13518
* GNAT.CGI (g-cgi.ads)::
13519
* GNAT.CGI.Cookie (g-cgicoo.ads)::
13520
* GNAT.CGI.Debug (g-cgideb.ads)::
13521
* GNAT.Command_Line (g-comlin.ads)::
13522
* GNAT.Compiler_Version (g-comver.ads)::
13523
* GNAT.Ctrl_C (g-ctrl_c.ads)::
13524
* GNAT.CRC32 (g-crc32.ads)::
13525
* GNAT.Current_Exception (g-curexc.ads)::
13526
* GNAT.Debug_Pools (g-debpoo.ads)::
13527
* GNAT.Debug_Utilities (g-debuti.ads)::
13528
* GNAT.Decode_String (g-decstr.ads)::
13529
* GNAT.Decode_UTF8_String (g-deutst.ads)::
13530
* GNAT.Directory_Operations (g-dirope.ads)::
13531
* GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13532
* GNAT.Dynamic_HTables (g-dynhta.ads)::
13533
* GNAT.Dynamic_Tables (g-dyntab.ads)::
13534
* GNAT.Encode_String (g-encstr.ads)::
13535
* GNAT.Encode_UTF8_String (g-enutst.ads)::
13536
* GNAT.Exception_Actions (g-excact.ads)::
13537
* GNAT.Exception_Traces (g-exctra.ads)::
13538
* GNAT.Exceptions (g-except.ads)::
13539
* GNAT.Expect (g-expect.ads)::
13540
* GNAT.Float_Control (g-flocon.ads)::
13541
* GNAT.Heap_Sort (g-heasor.ads)::
13542
* GNAT.Heap_Sort_A (g-hesora.ads)::
13543
* GNAT.Heap_Sort_G (g-hesorg.ads)::
13544
* GNAT.HTable (g-htable.ads)::
13545
* GNAT.IO (g-io.ads)::
13546
* GNAT.IO_Aux (g-io_aux.ads)::
13547
* GNAT.Lock_Files (g-locfil.ads)::
13548
* GNAT.MD5 (g-md5.ads)::
13549
* GNAT.Memory_Dump (g-memdum.ads)::
13550
* GNAT.Most_Recent_Exception (g-moreex.ads)::
13551
* GNAT.OS_Lib (g-os_lib.ads)::
13552
* GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13553
* GNAT.Random_Numbers (g-rannum.ads)::
13554
* GNAT.Regexp (g-regexp.ads)::
13555
* GNAT.Registry (g-regist.ads)::
13556
* GNAT.Regpat (g-regpat.ads)::
13557
* GNAT.Secondary_Stack_Info (g-sestin.ads)::
13558
* GNAT.Semaphores (g-semaph.ads)::
13559
* GNAT.Serial_Communications (g-sercom.ads)::
13560
* GNAT.SHA1 (g-sha1.ads)::
13561
* GNAT.SHA224 (g-sha224.ads)::
13562
* GNAT.SHA256 (g-sha256.ads)::
13563
* GNAT.SHA384 (g-sha384.ads)::
13564
* GNAT.SHA512 (g-sha512.ads)::
13565
* GNAT.Signals (g-signal.ads)::
13566
* GNAT.Sockets (g-socket.ads)::
13567
* GNAT.Source_Info (g-souinf.ads)::
13568
* GNAT.Spelling_Checker (g-speche.ads)::
13569
* GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13570
* GNAT.Spitbol.Patterns (g-spipat.ads)::
13571
* GNAT.Spitbol (g-spitbo.ads)::
13572
* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13573
* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13574
* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13575
* GNAT.SSE (g-sse.ads)::
13576
* GNAT.SSE.Vector_Types (g-ssvety.ads)::
13577
* GNAT.Strings (g-string.ads)::
13578
* GNAT.String_Split (g-strspl.ads)::
13579
* GNAT.Table (g-table.ads)::
13580
* GNAT.Task_Lock (g-tasloc.ads)::
13581
* GNAT.Threads (g-thread.ads)::
13582
* GNAT.Time_Stamp (g-timsta.ads)::
13583
* GNAT.Traceback (g-traceb.ads)::
13584
* GNAT.Traceback.Symbolic (g-trasym.ads)::
13585
* GNAT.UTF_32 (g-utf_32.ads)::
13586
* GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13587
* GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13588
* GNAT.Wide_String_Split (g-wistsp.ads)::
13589
* GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13590
* GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13591
* Interfaces.C.Extensions (i-cexten.ads)::
13592
* Interfaces.C.Streams (i-cstrea.ads)::
13593
* Interfaces.CPP (i-cpp.ads)::
13594
* Interfaces.Packed_Decimal (i-pacdec.ads)::
13595
* Interfaces.VxWorks (i-vxwork.ads)::
13596
* Interfaces.VxWorks.IO (i-vxwoio.ads)::
13597
* System.Address_Image (s-addima.ads)::
13598
* System.Assertions (s-assert.ads)::
13599
* System.Memory (s-memory.ads)::
13600
* System.Partition_Interface (s-parint.ads)::
13601
* System.Pool_Global (s-pooglo.ads)::
13602
* System.Pool_Local (s-pooloc.ads)::
13603
* System.Restrictions (s-restri.ads)::
13604
* System.Rident (s-rident.ads)::
13605
* System.Strings.Stream_Ops (s-ststop.ads)::
13606
* System.Task_Info (s-tasinf.ads)::
13607
* System.Wch_Cnv (s-wchcnv.ads)::
13608
* System.Wch_Con (s-wchcon.ads)::
13609
@end menu
13610
 
13611
@node Ada.Characters.Latin_9 (a-chlat9.ads)
13612
@section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13613
@cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13614
@cindex Latin_9 constants for Character
13615
 
13616
@noindent
13617
This child of @code{Ada.Characters}
13618
provides a set of definitions corresponding to those in the
13619
RM-defined package @code{Ada.Characters.Latin_1} but with the
13620
few modifications required for @code{Latin-9}
13621
The provision of such a package
13622
is specifically authorized by the Ada Reference Manual
13623
(RM A.3.3(27)).
13624
 
13625
@node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13626
@section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13627
@cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13628
@cindex Latin_1 constants for Wide_Character
13629
 
13630
@noindent
13631
This child of @code{Ada.Characters}
13632
provides a set of definitions corresponding to those in the
13633
RM-defined package @code{Ada.Characters.Latin_1} but with the
13634
types of the constants being @code{Wide_Character}
13635
instead of @code{Character}.  The provision of such a package
13636
is specifically authorized by the Ada Reference Manual
13637
(RM A.3.3(27)).
13638
 
13639
@node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13640
@section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13641
@cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13642
@cindex Latin_9 constants for Wide_Character
13643
 
13644
@noindent
13645
This child of @code{Ada.Characters}
13646
provides a set of definitions corresponding to those in the
13647
GNAT defined package @code{Ada.Characters.Latin_9} but with the
13648
types of the constants being @code{Wide_Character}
13649
instead of @code{Character}.  The provision of such a package
13650
is specifically authorized by the Ada Reference Manual
13651
(RM A.3.3(27)).
13652
 
13653
@node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13654
@section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13655
@cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13656
@cindex Latin_1 constants for Wide_Wide_Character
13657
 
13658
@noindent
13659
This child of @code{Ada.Characters}
13660
provides a set of definitions corresponding to those in the
13661
RM-defined package @code{Ada.Characters.Latin_1} but with the
13662
types of the constants being @code{Wide_Wide_Character}
13663
instead of @code{Character}.  The provision of such a package
13664
is specifically authorized by the Ada Reference Manual
13665
(RM A.3.3(27)).
13666
 
13667
@node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13668
@section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13669
@cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13670
@cindex Latin_9 constants for Wide_Wide_Character
13671
 
13672
@noindent
13673
This child of @code{Ada.Characters}
13674
provides a set of definitions corresponding to those in the
13675
GNAT defined package @code{Ada.Characters.Latin_9} but with the
13676
types of the constants being @code{Wide_Wide_Character}
13677
instead of @code{Character}.  The provision of such a package
13678
is specifically authorized by the Ada Reference Manual
13679
(RM A.3.3(27)).
13680
 
13681
@node Ada.Command_Line.Environment (a-colien.ads)
13682
@section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13683
@cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13684
@cindex Environment entries
13685
 
13686
@noindent
13687
This child of @code{Ada.Command_Line}
13688
provides a mechanism for obtaining environment values on systems
13689
where this concept makes sense.
13690
 
13691
@node Ada.Command_Line.Remove (a-colire.ads)
13692
@section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13693
@cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13694
@cindex Removing command line arguments
13695
@cindex Command line, argument removal
13696
 
13697
@noindent
13698
This child of @code{Ada.Command_Line}
13699
provides a mechanism for logically removing
13700
arguments from the argument list.  Once removed, an argument is not visible
13701
to further calls on the subprograms in @code{Ada.Command_Line} will not
13702
see the removed argument.
13703
 
13704
@node Ada.Command_Line.Response_File (a-clrefi.ads)
13705
@section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13706
@cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13707
@cindex Response file for command line
13708
@cindex Command line, response file
13709
@cindex Command line, handling long command lines
13710
 
13711
@noindent
13712
This child of @code{Ada.Command_Line} provides a mechanism facilities for
13713
getting command line arguments from a text file, called a "response file".
13714
Using a response file allow passing a set of arguments to an executable longer
13715
than the maximum allowed by the system on the command line.
13716
 
13717
@node Ada.Direct_IO.C_Streams (a-diocst.ads)
13718
@section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13719
@cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13720
@cindex C Streams, Interfacing with Direct_IO
13721
 
13722
@noindent
13723
This package provides subprograms that allow interfacing between
13724
C streams and @code{Direct_IO}.  The stream identifier can be
13725
extracted from a file opened on the Ada side, and an Ada file
13726
can be constructed from a stream opened on the C side.
13727
 
13728
@node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13729
@section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13730
@cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13731
@cindex Null_Occurrence, testing for
13732
 
13733
@noindent
13734
This child subprogram provides a way of testing for the null
13735
exception occurrence (@code{Null_Occurrence}) without raising
13736
an exception.
13737
 
13738
@node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13739
@section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13740
@cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13741
@cindex Null_Occurrence, testing for
13742
 
13743
@noindent
13744
This child subprogram is used for handling otherwise unhandled
13745
exceptions (hence the name last chance), and perform clean ups before
13746
terminating the program. Note that this subprogram never returns.
13747
 
13748
@node Ada.Exceptions.Traceback (a-exctra.ads)
13749
@section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13750
@cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13751
@cindex Traceback for Exception Occurrence
13752
 
13753
@noindent
13754
This child package provides the subprogram (@code{Tracebacks}) to
13755
give a traceback array of addresses based on an exception
13756
occurrence.
13757
 
13758
@node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13759
@section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13760
@cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13761
@cindex C Streams, Interfacing with Sequential_IO
13762
 
13763
@noindent
13764
This package provides subprograms that allow interfacing between
13765
C streams and @code{Sequential_IO}.  The stream identifier can be
13766
extracted from a file opened on the Ada side, and an Ada file
13767
can be constructed from a stream opened on the C side.
13768
 
13769
@node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13770
@section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13771
@cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13772
@cindex C Streams, Interfacing with Stream_IO
13773
 
13774
@noindent
13775
This package provides subprograms that allow interfacing between
13776
C streams and @code{Stream_IO}.  The stream identifier can be
13777
extracted from a file opened on the Ada side, and an Ada file
13778
can be constructed from a stream opened on the C side.
13779
 
13780
@node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13781
@section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13782
@cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13783
@cindex @code{Unbounded_String}, IO support
13784
@cindex @code{Text_IO}, extensions for unbounded strings
13785
 
13786
@noindent
13787
This package provides subprograms for Text_IO for unbounded
13788
strings, avoiding the necessity for an intermediate operation
13789
with ordinary strings.
13790
 
13791
@node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13792
@section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13793
@cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13794
@cindex @code{Unbounded_Wide_String}, IO support
13795
@cindex @code{Text_IO}, extensions for unbounded wide strings
13796
 
13797
@noindent
13798
This package provides subprograms for Text_IO for unbounded
13799
wide strings, avoiding the necessity for an intermediate operation
13800
with ordinary wide strings.
13801
 
13802
@node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13803
@section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13804
@cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13805
@cindex @code{Unbounded_Wide_Wide_String}, IO support
13806
@cindex @code{Text_IO}, extensions for unbounded wide wide strings
13807
 
13808
@noindent
13809
This package provides subprograms for Text_IO for unbounded
13810
wide wide strings, avoiding the necessity for an intermediate operation
13811
with ordinary wide wide strings.
13812
 
13813
@node Ada.Text_IO.C_Streams (a-tiocst.ads)
13814
@section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13815
@cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13816
@cindex C Streams, Interfacing with @code{Text_IO}
13817
 
13818
@noindent
13819
This package provides subprograms that allow interfacing between
13820
C streams and @code{Text_IO}.  The stream identifier can be
13821
extracted from a file opened on the Ada side, and an Ada file
13822
can be constructed from a stream opened on the C side.
13823
 
13824
@node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
13825
@section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13826
@cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13827
@cindex @code{Text_IO} resetting standard files
13828
 
13829
@noindent
13830
This procedure is used to reset the status of the standard files used
13831
by Ada.Text_IO.  This is useful in a situation (such as a restart in an
13832
embedded application) where the status of the files may change during
13833
execution (for example a standard input file may be redefined to be
13834
interactive).
13835
 
13836
@node Ada.Wide_Characters.Unicode (a-wichun.ads)
13837
@section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13838
@cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13839
@cindex Unicode categorization, Wide_Character
13840
 
13841
@noindent
13842
This package provides subprograms that allow categorization of
13843
Wide_Character values according to Unicode categories.
13844
 
13845
@node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13846
@section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13847
@cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13848
@cindex C Streams, Interfacing with @code{Wide_Text_IO}
13849
 
13850
@noindent
13851
This package provides subprograms that allow interfacing between
13852
C streams and @code{Wide_Text_IO}.  The stream identifier can be
13853
extracted from a file opened on the Ada side, and an Ada file
13854
can be constructed from a stream opened on the C side.
13855
 
13856
@node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
13857
@section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13858
@cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13859
@cindex @code{Wide_Text_IO} resetting standard files
13860
 
13861
@noindent
13862
This procedure is used to reset the status of the standard files used
13863
by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
13864
embedded application) where the status of the files may change during
13865
execution (for example a standard input file may be redefined to be
13866
interactive).
13867
 
13868
@node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13869
@section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13870
@cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13871
@cindex Unicode categorization, Wide_Wide_Character
13872
 
13873
@noindent
13874
This package provides subprograms that allow categorization of
13875
Wide_Wide_Character values according to Unicode categories.
13876
 
13877
@node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13878
@section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13879
@cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13880
@cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13881
 
13882
@noindent
13883
This package provides subprograms that allow interfacing between
13884
C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13885
extracted from a file opened on the Ada side, and an Ada file
13886
can be constructed from a stream opened on the C side.
13887
 
13888
@node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
13889
@section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13890
@cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13891
@cindex @code{Wide_Wide_Text_IO} resetting standard files
13892
 
13893
@noindent
13894
This procedure is used to reset the status of the standard files used
13895
by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
13896
restart in an embedded application) where the status of the files may
13897
change during execution (for example a standard input file may be
13898
redefined to be interactive).
13899
 
13900
@node GNAT.Altivec (g-altive.ads)
13901
@section @code{GNAT.Altivec} (@file{g-altive.ads})
13902
@cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13903
@cindex AltiVec
13904
 
13905
@noindent
13906
This is the root package of the GNAT AltiVec binding. It provides
13907
definitions of constants and types common to all the versions of the
13908
binding.
13909
 
13910
@node GNAT.Altivec.Conversions (g-altcon.ads)
13911
@section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13912
@cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13913
@cindex AltiVec
13914
 
13915
@noindent
13916
This package provides the Vector/View conversion routines.
13917
 
13918
@node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13919
@section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13920
@cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13921
@cindex AltiVec
13922
 
13923
@noindent
13924
This package exposes the Ada interface to the AltiVec operations on
13925
vector objects. A soft emulation is included by default in the GNAT
13926
library. The hard binding is provided as a separate package. This unit
13927
is common to both bindings.
13928
 
13929
@node GNAT.Altivec.Vector_Types (g-alvety.ads)
13930
@section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13931
@cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13932
@cindex AltiVec
13933
 
13934
@noindent
13935
This package exposes the various vector types part of the Ada binding
13936
to AltiVec facilities.
13937
 
13938
@node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13939
@section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13940
@cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13941
@cindex AltiVec
13942
 
13943
@noindent
13944
This package provides public 'View' data types from/to which private
13945
vector representations can be converted via
13946
GNAT.Altivec.Conversions. This allows convenient access to individual
13947
vector elements and provides a simple way to initialize vector
13948
objects.
13949
 
13950
@node GNAT.Array_Split (g-arrspl.ads)
13951
@section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13952
@cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13953
@cindex Array splitter
13954
 
13955
@noindent
13956
Useful array-manipulation routines: given a set of separators, split
13957
an array wherever the separators appear, and provide direct access
13958
to the resulting slices.
13959
 
13960
@node GNAT.AWK (g-awk.ads)
13961
@section @code{GNAT.AWK} (@file{g-awk.ads})
13962
@cindex @code{GNAT.AWK} (@file{g-awk.ads})
13963
@cindex Parsing
13964
@cindex AWK
13965
 
13966
@noindent
13967
Provides AWK-like parsing functions, with an easy interface for parsing one
13968
or more files containing formatted data.  The file is viewed as a database
13969
where each record is a line and a field is a data element in this line.
13970
 
13971
@node GNAT.Bounded_Buffers (g-boubuf.ads)
13972
@section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13973
@cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13974
@cindex Parsing
13975
@cindex Bounded Buffers
13976
 
13977
@noindent
13978
Provides a concurrent generic bounded buffer abstraction.  Instances are
13979
useful directly or as parts of the implementations of other abstractions,
13980
such as mailboxes.
13981
 
13982
@node GNAT.Bounded_Mailboxes (g-boumai.ads)
13983
@section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13984
@cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13985
@cindex Parsing
13986
@cindex Mailboxes
13987
 
13988
@noindent
13989
Provides a thread-safe asynchronous intertask mailbox communication facility.
13990
 
13991
@node GNAT.Bubble_Sort (g-bubsor.ads)
13992
@section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13993
@cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13994
@cindex Sorting
13995
@cindex Bubble sort
13996
 
13997
@noindent
13998
Provides a general implementation of bubble sort usable for sorting arbitrary
13999
data items.  Exchange and comparison procedures are provided by passing
14000
access-to-procedure values.
14001
 
14002
@node GNAT.Bubble_Sort_A (g-busora.ads)
14003
@section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14004
@cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14005
@cindex Sorting
14006
@cindex Bubble sort
14007
 
14008
@noindent
14009
Provides a general implementation of bubble sort usable for sorting arbitrary
14010
data items.  Move and comparison procedures are provided by passing
14011
access-to-procedure values. This is an older version, retained for
14012
compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14013
 
14014
@node GNAT.Bubble_Sort_G (g-busorg.ads)
14015
@section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14016
@cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14017
@cindex Sorting
14018
@cindex Bubble sort
14019
 
14020
@noindent
14021
Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14022
are provided as generic parameters, this improves efficiency, especially
14023
if the procedures can be inlined, at the expense of duplicating code for
14024
multiple instantiations.
14025
 
14026
@node GNAT.Byte_Order_Mark (g-byorma.ads)
14027
@section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14028
@cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14029
@cindex UTF-8 representation
14030
@cindex Wide characte representations
14031
 
14032
@noindent
14033
Provides a routine which given a string, reads the start of the string to
14034
see whether it is one of the standard byte order marks (BOM's) which signal
14035
the encoding of the string. The routine includes detection of special XML
14036
sequences for various UCS input formats.
14037
 
14038
@node GNAT.Byte_Swapping (g-bytswa.ads)
14039
@section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14040
@cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14041
@cindex Byte swapping
14042
@cindex Endian
14043
 
14044
@noindent
14045
General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14046
Machine-specific implementations are available in some cases.
14047
 
14048
@node GNAT.Calendar (g-calend.ads)
14049
@section @code{GNAT.Calendar} (@file{g-calend.ads})
14050
@cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14051
@cindex @code{Calendar}
14052
 
14053
@noindent
14054
Extends the facilities provided by @code{Ada.Calendar} to include handling
14055
of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14056
Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14057
C @code{timeval} format.
14058
 
14059
@node GNAT.Calendar.Time_IO (g-catiio.ads)
14060
@section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14061
@cindex @code{Calendar}
14062
@cindex Time
14063
@cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14064
 
14065
@node GNAT.CRC32 (g-crc32.ads)
14066
@section @code{GNAT.CRC32} (@file{g-crc32.ads})
14067
@cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14068
@cindex CRC32
14069
@cindex Cyclic Redundancy Check
14070
 
14071
@noindent
14072
This package implements the CRC-32 algorithm.  For a full description
14073
of this algorithm see
14074
``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14075
@cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14076
Aug.@: 1988.  Sarwate, D.V@.
14077
 
14078
@node GNAT.Case_Util (g-casuti.ads)
14079
@section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14080
@cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14081
@cindex Casing utilities
14082
@cindex Character handling (@code{GNAT.Case_Util})
14083
 
14084
@noindent
14085
A set of simple routines for handling upper and lower casing of strings
14086
without the overhead of the full casing tables
14087
in @code{Ada.Characters.Handling}.
14088
 
14089
@node GNAT.CGI (g-cgi.ads)
14090
@section @code{GNAT.CGI} (@file{g-cgi.ads})
14091
@cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14092
@cindex CGI (Common Gateway Interface)
14093
 
14094
@noindent
14095
This is a package for interfacing a GNAT program with a Web server via the
14096
Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14097
parameters, which are a set of key/value pairs sent by the Web server.  It
14098
builds a table whose index is the key and provides some services to deal
14099
with this table.
14100
 
14101
@node GNAT.CGI.Cookie (g-cgicoo.ads)
14102
@section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14103
@cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14104
@cindex CGI (Common Gateway Interface) cookie support
14105
@cindex Cookie support in CGI
14106
 
14107
@noindent
14108
This is a package to interface a GNAT program with a Web server via the
14109
Common Gateway Interface (CGI).  It exports services to deal with Web
14110
cookies (piece of information kept in the Web client software).
14111
 
14112
@node GNAT.CGI.Debug (g-cgideb.ads)
14113
@section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14114
@cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14115
@cindex CGI (Common Gateway Interface) debugging
14116
 
14117
@noindent
14118
This is a package to help debugging CGI (Common Gateway Interface)
14119
programs written in Ada.
14120
 
14121
@node GNAT.Command_Line (g-comlin.ads)
14122
@section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14123
@cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14124
@cindex Command line
14125
 
14126
@noindent
14127
Provides a high level interface to @code{Ada.Command_Line} facilities,
14128
including the ability to scan for named switches with optional parameters
14129
and expand file names using wild card notations.
14130
 
14131
@node GNAT.Compiler_Version (g-comver.ads)
14132
@section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14133
@cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14134
@cindex Compiler Version
14135
@cindex Version, of compiler
14136
 
14137
@noindent
14138
Provides a routine for obtaining the version of the compiler used to
14139
compile the program. More accurately this is the version of the binder
14140
used to bind the program (this will normally be the same as the version
14141
of the compiler if a consistent tool set is used to compile all units
14142
of a partition).
14143
 
14144
@node GNAT.Ctrl_C (g-ctrl_c.ads)
14145
@section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14146
@cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14147
@cindex Interrupt
14148
 
14149
@noindent
14150
Provides a simple interface to handle Ctrl-C keyboard events.
14151
 
14152
@node GNAT.Current_Exception (g-curexc.ads)
14153
@section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14154
@cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14155
@cindex Current exception
14156
@cindex Exception retrieval
14157
 
14158
@noindent
14159
Provides access to information on the current exception that has been raised
14160
without the need for using the Ada 95 / Ada 2005 exception choice parameter
14161
specification syntax.
14162
This is particularly useful in simulating typical facilities for
14163
obtaining information about exceptions provided by Ada 83 compilers.
14164
 
14165
@node GNAT.Debug_Pools (g-debpoo.ads)
14166
@section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14167
@cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14168
@cindex Debugging
14169
@cindex Debug pools
14170
@cindex Memory corruption debugging
14171
 
14172
@noindent
14173
Provide a debugging storage pools that helps tracking memory corruption
14174
problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14175
@value{EDITION} User's Guide}.
14176
 
14177
@node GNAT.Debug_Utilities (g-debuti.ads)
14178
@section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14179
@cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14180
@cindex Debugging
14181
 
14182
@noindent
14183
Provides a few useful utilities for debugging purposes, including conversion
14184
to and from string images of address values. Supports both C and Ada formats
14185
for hexadecimal literals.
14186
 
14187
@node GNAT.Decode_String (g-decstr.ads)
14188
@section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14189
@cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14190
@cindex Decoding strings
14191
@cindex String decoding
14192
@cindex Wide character encoding
14193
@cindex UTF-8
14194
@cindex Unicode
14195
 
14196
@noindent
14197
A generic package providing routines for decoding wide character and wide wide
14198
character strings encoded as sequences of 8-bit characters using a specified
14199
encoding method. Includes validation routines, and also routines for stepping
14200
to next or previous encoded character in an encoded string.
14201
Useful in conjunction with Unicode character coding. Note there is a
14202
preinstantiation for UTF-8. See next entry.
14203
 
14204
@node GNAT.Decode_UTF8_String (g-deutst.ads)
14205
@section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14206
@cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14207
@cindex Decoding strings
14208
@cindex Decoding UTF-8 strings
14209
@cindex UTF-8 string decoding
14210
@cindex Wide character decoding
14211
@cindex UTF-8
14212
@cindex Unicode
14213
 
14214
@noindent
14215
A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14216
 
14217
@node GNAT.Directory_Operations (g-dirope.ads)
14218
@section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14219
@cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14220
@cindex Directory operations
14221
 
14222
@noindent
14223
Provides a set of routines for manipulating directories, including changing
14224
the current directory, making new directories, and scanning the files in a
14225
directory.
14226
 
14227
@node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14228
@section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14229
@cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14230
@cindex Directory operations iteration
14231
 
14232
@noindent
14233
A child unit of GNAT.Directory_Operations providing additional operations
14234
for iterating through directories.
14235
 
14236
@node GNAT.Dynamic_HTables (g-dynhta.ads)
14237
@section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14238
@cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14239
@cindex Hash tables
14240
 
14241
@noindent
14242
A generic implementation of hash tables that can be used to hash arbitrary
14243
data.  Provided in two forms, a simple form with built in hash functions,
14244
and a more complex form in which the hash function is supplied.
14245
 
14246
@noindent
14247
This package provides a facility similar to that of @code{GNAT.HTable},
14248
except that this package declares a type that can be used to define
14249
dynamic instances of the hash table, while an instantiation of
14250
@code{GNAT.HTable} creates a single instance of the hash table.
14251
 
14252
@node GNAT.Dynamic_Tables (g-dyntab.ads)
14253
@section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14254
@cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14255
@cindex Table implementation
14256
@cindex Arrays, extendable
14257
 
14258
@noindent
14259
A generic package providing a single dimension array abstraction where the
14260
length of the array can be dynamically modified.
14261
 
14262
@noindent
14263
This package provides a facility similar to that of @code{GNAT.Table},
14264
except that this package declares a type that can be used to define
14265
dynamic instances of the table, while an instantiation of
14266
@code{GNAT.Table} creates a single instance of the table type.
14267
 
14268
@node GNAT.Encode_String (g-encstr.ads)
14269
@section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14270
@cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14271
@cindex Encoding strings
14272
@cindex String encoding
14273
@cindex Wide character encoding
14274
@cindex UTF-8
14275
@cindex Unicode
14276
 
14277
@noindent
14278
A generic package providing routines for encoding wide character and wide
14279
wide character strings as sequences of 8-bit characters using a specified
14280
encoding method. Useful in conjunction with Unicode character coding.
14281
Note there is a preinstantiation for UTF-8. See next entry.
14282
 
14283
@node GNAT.Encode_UTF8_String (g-enutst.ads)
14284
@section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14285
@cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14286
@cindex Encoding strings
14287
@cindex Encoding UTF-8 strings
14288
@cindex UTF-8 string encoding
14289
@cindex Wide character encoding
14290
@cindex UTF-8
14291
@cindex Unicode
14292
 
14293
@noindent
14294
A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14295
 
14296
@node GNAT.Exception_Actions (g-excact.ads)
14297
@section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14298
@cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14299
@cindex Exception actions
14300
 
14301
@noindent
14302
Provides callbacks when an exception is raised. Callbacks can be registered
14303
for specific exceptions, or when any exception is raised. This
14304
can be used for instance to force a core dump to ease debugging.
14305
 
14306
@node GNAT.Exception_Traces (g-exctra.ads)
14307
@section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14308
@cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14309
@cindex Exception traces
14310
@cindex Debugging
14311
 
14312
@noindent
14313
Provides an interface allowing to control automatic output upon exception
14314
occurrences.
14315
 
14316
@node GNAT.Exceptions (g-except.ads)
14317
@section @code{GNAT.Exceptions} (@file{g-expect.ads})
14318
@cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14319
@cindex Exceptions, Pure
14320
@cindex Pure packages, exceptions
14321
 
14322
@noindent
14323
Normally it is not possible to raise an exception with
14324
a message from a subprogram in a pure package, since the
14325
necessary types and subprograms are in @code{Ada.Exceptions}
14326
which is not a pure unit. @code{GNAT.Exceptions} provides a
14327
facility for getting around this limitation for a few
14328
predefined exceptions, and for example allow raising
14329
@code{Constraint_Error} with a message from a pure subprogram.
14330
 
14331
@node GNAT.Expect (g-expect.ads)
14332
@section @code{GNAT.Expect} (@file{g-expect.ads})
14333
@cindex @code{GNAT.Expect} (@file{g-expect.ads})
14334
 
14335
@noindent
14336
Provides a set of subprograms similar to what is available
14337
with the standard Tcl Expect tool.
14338
It allows you to easily spawn and communicate with an external process.
14339
You can send commands or inputs to the process, and compare the output
14340
with some expected regular expression. Currently @code{GNAT.Expect}
14341
is implemented on all native GNAT ports except for OpenVMS@.
14342
It is not implemented for cross ports, and in particular is not
14343
implemented for VxWorks or LynxOS@.
14344
 
14345
@node GNAT.Float_Control (g-flocon.ads)
14346
@section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14347
@cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14348
@cindex Floating-Point Processor
14349
 
14350
@noindent
14351
Provides an interface for resetting the floating-point processor into the
14352
mode required for correct semantic operation in Ada.  Some third party
14353
library calls may cause this mode to be modified, and the Reset procedure
14354
in this package can be used to reestablish the required mode.
14355
 
14356
@node GNAT.Heap_Sort (g-heasor.ads)
14357
@section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14358
@cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14359
@cindex Sorting
14360
 
14361
@noindent
14362
Provides a general implementation of heap sort usable for sorting arbitrary
14363
data items. Exchange and comparison procedures are provided by passing
14364
access-to-procedure values.  The algorithm used is a modified heap sort
14365
that performs approximately N*log(N) comparisons in the worst case.
14366
 
14367
@node GNAT.Heap_Sort_A (g-hesora.ads)
14368
@section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14369
@cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14370
@cindex Sorting
14371
 
14372
@noindent
14373
Provides a general implementation of heap sort usable for sorting arbitrary
14374
data items. Move and comparison procedures are provided by passing
14375
access-to-procedure values.  The algorithm used is a modified heap sort
14376
that performs approximately N*log(N) comparisons in the worst case.
14377
This differs from @code{GNAT.Heap_Sort} in having a less convenient
14378
interface, but may be slightly more efficient.
14379
 
14380
@node GNAT.Heap_Sort_G (g-hesorg.ads)
14381
@section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14382
@cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14383
@cindex Sorting
14384
 
14385
@noindent
14386
Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14387
are provided as generic parameters, this improves efficiency, especially
14388
if the procedures can be inlined, at the expense of duplicating code for
14389
multiple instantiations.
14390
 
14391
@node GNAT.HTable (g-htable.ads)
14392
@section @code{GNAT.HTable} (@file{g-htable.ads})
14393
@cindex @code{GNAT.HTable} (@file{g-htable.ads})
14394
@cindex Hash tables
14395
 
14396
@noindent
14397
A generic implementation of hash tables that can be used to hash arbitrary
14398
data.  Provides two approaches, one a simple static approach, and the other
14399
allowing arbitrary dynamic hash tables.
14400
 
14401
@node GNAT.IO (g-io.ads)
14402
@section @code{GNAT.IO} (@file{g-io.ads})
14403
@cindex @code{GNAT.IO} (@file{g-io.ads})
14404
@cindex Simple I/O
14405
@cindex Input/Output facilities
14406
 
14407
@noindent
14408
A simple preelaborable input-output package that provides a subset of
14409
simple Text_IO functions for reading characters and strings from
14410
Standard_Input, and writing characters, strings and integers to either
14411
Standard_Output or Standard_Error.
14412
 
14413
@node GNAT.IO_Aux (g-io_aux.ads)
14414
@section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14415
@cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14416
@cindex Text_IO
14417
@cindex Input/Output facilities
14418
 
14419
Provides some auxiliary functions for use with Text_IO, including a test
14420
for whether a file exists, and functions for reading a line of text.
14421
 
14422
@node GNAT.Lock_Files (g-locfil.ads)
14423
@section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14424
@cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14425
@cindex File locking
14426
@cindex Locking using files
14427
 
14428
@noindent
14429
Provides a general interface for using files as locks.  Can be used for
14430
providing program level synchronization.
14431
 
14432
@node GNAT.MD5 (g-md5.ads)
14433
@section @code{GNAT.MD5} (@file{g-md5.ads})
14434
@cindex @code{GNAT.MD5} (@file{g-md5.ads})
14435
@cindex Message Digest MD5
14436
 
14437
@noindent
14438
Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14439
 
14440
@node GNAT.Memory_Dump (g-memdum.ads)
14441
@section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14442
@cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14443
@cindex Dump Memory
14444
 
14445
@noindent
14446
Provides a convenient routine for dumping raw memory to either the
14447
standard output or standard error files. Uses GNAT.IO for actual
14448
output.
14449
 
14450
@node GNAT.Most_Recent_Exception (g-moreex.ads)
14451
@section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14452
@cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14453
@cindex Exception, obtaining most recent
14454
 
14455
@noindent
14456
Provides access to the most recently raised exception.  Can be used for
14457
various logging purposes, including duplicating functionality of some
14458
Ada 83 implementation dependent extensions.
14459
 
14460
@node GNAT.OS_Lib (g-os_lib.ads)
14461
@section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14462
@cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14463
@cindex Operating System interface
14464
@cindex Spawn capability
14465
 
14466
@noindent
14467
Provides a range of target independent operating system interface functions,
14468
including time/date management, file operations, subprocess management,
14469
including a portable spawn procedure, and access to environment variables
14470
and error return codes.
14471
 
14472
@node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14473
@section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14474
@cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14475
@cindex Hash functions
14476
 
14477
@noindent
14478
Provides a generator of static minimal perfect hash functions. No
14479
collisions occur and each item can be retrieved from the table in one
14480
probe (perfect property). The hash table size corresponds to the exact
14481
size of the key set and no larger (minimal property). The key set has to
14482
be know in advance (static property). The hash functions are also order
14483
preserving. If w2 is inserted after w1 in the generator, their
14484
hashcode are in the same order. These hashing functions are very
14485
convenient for use with realtime applications.
14486
 
14487
@node GNAT.Random_Numbers (g-rannum.ads)
14488
@section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14489
@cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14490
@cindex Random number generation
14491
 
14492
@noindent
14493
Provides random number capabilities which extend those available in the
14494
standard Ada library and are more convenient to use.
14495
 
14496
@node GNAT.Regexp (g-regexp.ads)
14497
@section @code{GNAT.Regexp} (@file{g-regexp.ads})
14498
@cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14499
@cindex Regular expressions
14500
@cindex Pattern matching
14501
 
14502
@noindent
14503
A simple implementation of regular expressions, using a subset of regular
14504
expression syntax copied from familiar Unix style utilities.  This is the
14505
simples of the three pattern matching packages provided, and is particularly
14506
suitable for ``file globbing'' applications.
14507
 
14508
@node GNAT.Registry (g-regist.ads)
14509
@section @code{GNAT.Registry} (@file{g-regist.ads})
14510
@cindex @code{GNAT.Registry} (@file{g-regist.ads})
14511
@cindex Windows Registry
14512
 
14513
@noindent
14514
This is a high level binding to the Windows registry.  It is possible to
14515
do simple things like reading a key value, creating a new key.  For full
14516
registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14517
package provided with the Win32Ada binding
14518
 
14519
@node GNAT.Regpat (g-regpat.ads)
14520
@section @code{GNAT.Regpat} (@file{g-regpat.ads})
14521
@cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14522
@cindex Regular expressions
14523
@cindex Pattern matching
14524
 
14525
@noindent
14526
A complete implementation of Unix-style regular expression matching, copied
14527
from the original V7 style regular expression library written in C by
14528
Henry Spencer (and binary compatible with this C library).
14529
 
14530
@node GNAT.Secondary_Stack_Info (g-sestin.ads)
14531
@section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14532
@cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14533
@cindex Secondary Stack Info
14534
 
14535
@noindent
14536
Provide the capability to query the high water mark of the current task's
14537
secondary stack.
14538
 
14539
@node GNAT.Semaphores (g-semaph.ads)
14540
@section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14541
@cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14542
@cindex Semaphores
14543
 
14544
@noindent
14545
Provides classic counting and binary semaphores using protected types.
14546
 
14547
@node GNAT.Serial_Communications (g-sercom.ads)
14548
@section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14549
@cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14550
@cindex Serial_Communications
14551
 
14552
@noindent
14553
Provides a simple interface to send and receive data over a serial
14554
port. This is only supported on GNU/Linux and Windows.
14555
 
14556
@node GNAT.SHA1 (g-sha1.ads)
14557
@section @code{GNAT.SHA1} (@file{g-sha1.ads})
14558
@cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14559
@cindex Secure Hash Algorithm SHA-1
14560
 
14561
@noindent
14562
Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14563
and RFC 3174.
14564
 
14565
@node GNAT.SHA224 (g-sha224.ads)
14566
@section @code{GNAT.SHA224} (@file{g-sha224.ads})
14567
@cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14568
@cindex Secure Hash Algorithm SHA-224
14569
 
14570
@noindent
14571
Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14572
 
14573
@node GNAT.SHA256 (g-sha256.ads)
14574
@section @code{GNAT.SHA256} (@file{g-sha256.ads})
14575
@cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14576
@cindex Secure Hash Algorithm SHA-256
14577
 
14578
@noindent
14579
Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14580
 
14581
@node GNAT.SHA384 (g-sha384.ads)
14582
@section @code{GNAT.SHA384} (@file{g-sha384.ads})
14583
@cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14584
@cindex Secure Hash Algorithm SHA-384
14585
 
14586
@noindent
14587
Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14588
 
14589
@node GNAT.SHA512 (g-sha512.ads)
14590
@section @code{GNAT.SHA512} (@file{g-sha512.ads})
14591
@cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14592
@cindex Secure Hash Algorithm SHA-512
14593
 
14594
@noindent
14595
Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14596
 
14597
@node GNAT.Signals (g-signal.ads)
14598
@section @code{GNAT.Signals} (@file{g-signal.ads})
14599
@cindex @code{GNAT.Signals} (@file{g-signal.ads})
14600
@cindex Signals
14601
 
14602
@noindent
14603
Provides the ability to manipulate the blocked status of signals on supported
14604
targets.
14605
 
14606
@node GNAT.Sockets (g-socket.ads)
14607
@section @code{GNAT.Sockets} (@file{g-socket.ads})
14608
@cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14609
@cindex Sockets
14610
 
14611
@noindent
14612
A high level and portable interface to develop sockets based applications.
14613
This package is based on the sockets thin binding found in
14614
@code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14615
on all native GNAT ports except for OpenVMS@.  It is not implemented
14616
for the LynxOS@ cross port.
14617
 
14618
@node GNAT.Source_Info (g-souinf.ads)
14619
@section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14620
@cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14621
@cindex Source Information
14622
 
14623
@noindent
14624
Provides subprograms that give access to source code information known at
14625
compile time, such as the current file name and line number.
14626
 
14627
@node GNAT.Spelling_Checker (g-speche.ads)
14628
@section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14629
@cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14630
@cindex Spell checking
14631
 
14632
@noindent
14633
Provides a function for determining whether one string is a plausible
14634
near misspelling of another string.
14635
 
14636
@node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14637
@section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14638
@cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14639
@cindex Spell checking
14640
 
14641
@noindent
14642
Provides a generic function that can be instantiated with a string type for
14643
determining whether one string is a plausible near misspelling of another
14644
string.
14645
 
14646
@node GNAT.Spitbol.Patterns (g-spipat.ads)
14647
@section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14648
@cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14649
@cindex SPITBOL pattern matching
14650
@cindex Pattern matching
14651
 
14652
@noindent
14653
A complete implementation of SNOBOL4 style pattern matching.  This is the
14654
most elaborate of the pattern matching packages provided.  It fully duplicates
14655
the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14656
efficient algorithm developed by Robert Dewar for the SPITBOL system.
14657
 
14658
@node GNAT.Spitbol (g-spitbo.ads)
14659
@section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14660
@cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14661
@cindex SPITBOL interface
14662
 
14663
@noindent
14664
The top level package of the collection of SPITBOL-style functionality, this
14665
package provides basic SNOBOL4 string manipulation functions, such as
14666
Pad, Reverse, Trim, Substr capability, as well as a generic table function
14667
useful for constructing arbitrary mappings from strings in the style of
14668
the SNOBOL4 TABLE function.
14669
 
14670
@node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14671
@section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14672
@cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14673
@cindex Sets of strings
14674
@cindex SPITBOL Tables
14675
 
14676
@noindent
14677
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14678
for type @code{Standard.Boolean}, giving an implementation of sets of
14679
string values.
14680
 
14681
@node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14682
@section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14683
@cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14684
@cindex Integer maps
14685
@cindex Maps
14686
@cindex SPITBOL Tables
14687
 
14688
@noindent
14689
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14690
for type @code{Standard.Integer}, giving an implementation of maps
14691
from string to integer values.
14692
 
14693
@node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14694
@section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14695
@cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14696
@cindex String maps
14697
@cindex Maps
14698
@cindex SPITBOL Tables
14699
 
14700
@noindent
14701
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14702
a variable length string type, giving an implementation of general
14703
maps from strings to strings.
14704
 
14705
@node GNAT.SSE (g-sse.ads)
14706
@section @code{GNAT.SSE} (@file{g-sse.ads})
14707
@cindex @code{GNAT.SSE} (@file{g-sse.ads})
14708
 
14709
@noindent
14710
Root of a set of units aimed at offering Ada bindings to a subset of
14711
the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14712
targets.  It exposes vector component types together with a general
14713
introduction to the binding contents and use.
14714
 
14715
@node GNAT.SSE.Vector_Types (g-ssvety.ads)
14716
@section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14717
@cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14718
 
14719
@noindent
14720
SSE vector types for use with SSE related intrinsics.
14721
 
14722
@node GNAT.Strings (g-string.ads)
14723
@section @code{GNAT.Strings} (@file{g-string.ads})
14724
@cindex @code{GNAT.Strings} (@file{g-string.ads})
14725
 
14726
@noindent
14727
Common String access types and related subprograms. Basically it
14728
defines a string access and an array of string access types.
14729
 
14730
@node GNAT.String_Split (g-strspl.ads)
14731
@section @code{GNAT.String_Split} (@file{g-strspl.ads})
14732
@cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14733
@cindex String splitter
14734
 
14735
@noindent
14736
Useful string manipulation routines: given a set of separators, split
14737
a string wherever the separators appear, and provide direct access
14738
to the resulting slices. This package is instantiated from
14739
@code{GNAT.Array_Split}.
14740
 
14741
@node GNAT.Table (g-table.ads)
14742
@section @code{GNAT.Table} (@file{g-table.ads})
14743
@cindex @code{GNAT.Table} (@file{g-table.ads})
14744
@cindex Table implementation
14745
@cindex Arrays, extendable
14746
 
14747
@noindent
14748
A generic package providing a single dimension array abstraction where the
14749
length of the array can be dynamically modified.
14750
 
14751
@noindent
14752
This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14753
except that this package declares a single instance of the table type,
14754
while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14755
used to define dynamic instances of the table.
14756
 
14757
@node GNAT.Task_Lock (g-tasloc.ads)
14758
@section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14759
@cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14760
@cindex Task synchronization
14761
@cindex Task locking
14762
@cindex Locking
14763
 
14764
@noindent
14765
A very simple facility for locking and unlocking sections of code using a
14766
single global task lock.  Appropriate for use in situations where contention
14767
between tasks is very rarely expected.
14768
 
14769
@node GNAT.Time_Stamp (g-timsta.ads)
14770
@section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14771
@cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14772
@cindex Time stamp
14773
@cindex Current time
14774
 
14775
@noindent
14776
Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14777
represents the current date and time in ISO 8601 format. This is a very simple
14778
routine with minimal code and there are no dependencies on any other unit.
14779
 
14780
@node GNAT.Threads (g-thread.ads)
14781
@section @code{GNAT.Threads} (@file{g-thread.ads})
14782
@cindex @code{GNAT.Threads} (@file{g-thread.ads})
14783
@cindex Foreign threads
14784
@cindex Threads, foreign
14785
 
14786
@noindent
14787
Provides facilities for dealing with foreign threads which need to be known
14788
by the GNAT run-time system. Consult the documentation of this package for
14789
further details if your program has threads that are created by a non-Ada
14790
environment which then accesses Ada code.
14791
 
14792
@node GNAT.Traceback (g-traceb.ads)
14793
@section @code{GNAT.Traceback} (@file{g-traceb.ads})
14794
@cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14795
@cindex Trace back facilities
14796
 
14797
@noindent
14798
Provides a facility for obtaining non-symbolic traceback information, useful
14799
in various debugging situations.
14800
 
14801
@node GNAT.Traceback.Symbolic (g-trasym.ads)
14802
@section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14803
@cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14804
@cindex Trace back facilities
14805
 
14806
@node GNAT.UTF_32 (g-utf_32.ads)
14807
@section @code{GNAT.UTF_32} (@file{g-table.ads})
14808
@cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14809
@cindex Wide character codes
14810
 
14811
@noindent
14812
This is a package intended to be used in conjunction with the
14813
@code{Wide_Character} type in Ada 95 and the
14814
@code{Wide_Wide_Character} type in Ada 2005 (available
14815
in @code{GNAT} in Ada 2005 mode). This package contains
14816
Unicode categorization routines, as well as lexical
14817
categorization routines corresponding to the Ada 2005
14818
lexical rules for identifiers and strings, and also a
14819
lower case to upper case fold routine corresponding to
14820
the Ada 2005 rules for identifier equivalence.
14821
 
14822
@node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14823
@section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14824
@cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14825
@cindex Spell checking
14826
 
14827
@noindent
14828
Provides a function for determining whether one wide wide string is a plausible
14829
near misspelling of another wide wide string, where the strings are represented
14830
using the UTF_32_String type defined in System.Wch_Cnv.
14831
 
14832
@node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14833
@section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14834
@cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14835
@cindex Spell checking
14836
 
14837
@noindent
14838
Provides a function for determining whether one wide string is a plausible
14839
near misspelling of another wide string.
14840
 
14841
@node GNAT.Wide_String_Split (g-wistsp.ads)
14842
@section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14843
@cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14844
@cindex Wide_String splitter
14845
 
14846
@noindent
14847
Useful wide string manipulation routines: given a set of separators, split
14848
a wide string wherever the separators appear, and provide direct access
14849
to the resulting slices. This package is instantiated from
14850
@code{GNAT.Array_Split}.
14851
 
14852
@node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14853
@section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14854
@cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14855
@cindex Spell checking
14856
 
14857
@noindent
14858
Provides a function for determining whether one wide wide string is a plausible
14859
near misspelling of another wide wide string.
14860
 
14861
@node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14862
@section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14863
@cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14864
@cindex Wide_Wide_String splitter
14865
 
14866
@noindent
14867
Useful wide wide string manipulation routines: given a set of separators, split
14868
a wide wide string wherever the separators appear, and provide direct access
14869
to the resulting slices. This package is instantiated from
14870
@code{GNAT.Array_Split}.
14871
 
14872
@node Interfaces.C.Extensions (i-cexten.ads)
14873
@section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14874
@cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14875
 
14876
@noindent
14877
This package contains additional C-related definitions, intended
14878
for use with either manually or automatically generated bindings
14879
to C libraries.
14880
 
14881
@node Interfaces.C.Streams (i-cstrea.ads)
14882
@section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14883
@cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14884
@cindex  C streams, interfacing
14885
 
14886
@noindent
14887
This package is a binding for the most commonly used operations
14888
on C streams.
14889
 
14890
@node Interfaces.CPP (i-cpp.ads)
14891
@section @code{Interfaces.CPP} (@file{i-cpp.ads})
14892
@cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14893
@cindex  C++ interfacing
14894
@cindex  Interfacing, to C++
14895
 
14896
@noindent
14897
This package provides facilities for use in interfacing to C++.  It
14898
is primarily intended to be used in connection with automated tools
14899
for the generation of C++ interfaces.
14900
 
14901
@node Interfaces.Packed_Decimal (i-pacdec.ads)
14902
@section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14903
@cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14904
@cindex  IBM Packed Format
14905
@cindex  Packed Decimal
14906
 
14907
@noindent
14908
This package provides a set of routines for conversions to and
14909
from a packed decimal format compatible with that used on IBM
14910
mainframes.
14911
 
14912
@node Interfaces.VxWorks (i-vxwork.ads)
14913
@section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14914
@cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14915
@cindex Interfacing to VxWorks
14916
@cindex VxWorks, interfacing
14917
 
14918
@noindent
14919
This package provides a limited binding to the VxWorks API.
14920
In particular, it interfaces with the
14921
VxWorks hardware interrupt facilities.
14922
 
14923
@node Interfaces.VxWorks.IO (i-vxwoio.ads)
14924
@section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14925
@cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14926
@cindex Interfacing to VxWorks' I/O
14927
@cindex VxWorks, I/O interfacing
14928
@cindex VxWorks, Get_Immediate
14929
@cindex Get_Immediate, VxWorks
14930
 
14931
@noindent
14932
This package provides a binding to the ioctl (IO/Control)
14933
function of VxWorks, defining a set of option values and
14934
function codes. A particular use of this package is
14935
to enable the use of Get_Immediate under VxWorks.
14936
 
14937
@node System.Address_Image (s-addima.ads)
14938
@section @code{System.Address_Image} (@file{s-addima.ads})
14939
@cindex @code{System.Address_Image} (@file{s-addima.ads})
14940
@cindex Address image
14941
@cindex Image, of an address
14942
 
14943
@noindent
14944
This function provides a useful debugging
14945
function that gives an (implementation dependent)
14946
string which identifies an address.
14947
 
14948
@node System.Assertions (s-assert.ads)
14949
@section @code{System.Assertions} (@file{s-assert.ads})
14950
@cindex @code{System.Assertions} (@file{s-assert.ads})
14951
@cindex Assertions
14952
@cindex Assert_Failure, exception
14953
 
14954
@noindent
14955
This package provides the declaration of the exception raised
14956
by an run-time assertion failure, as well as the routine that
14957
is used internally to raise this assertion.
14958
 
14959
@node System.Memory (s-memory.ads)
14960
@section @code{System.Memory} (@file{s-memory.ads})
14961
@cindex @code{System.Memory} (@file{s-memory.ads})
14962
@cindex Memory allocation
14963
 
14964
@noindent
14965
This package provides the interface to the low level routines used
14966
by the generated code for allocation and freeing storage for the
14967
default storage pool (analogous to the C routines malloc and free.
14968
It also provides a reallocation interface analogous to the C routine
14969
realloc. The body of this unit may be modified to provide alternative
14970
allocation mechanisms for the default pool, and in addition, direct
14971
calls to this unit may be made for low level allocation uses (for
14972
example see the body of @code{GNAT.Tables}).
14973
 
14974
@node System.Partition_Interface (s-parint.ads)
14975
@section @code{System.Partition_Interface} (@file{s-parint.ads})
14976
@cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14977
@cindex Partition interfacing functions
14978
 
14979
@noindent
14980
This package provides facilities for partition interfacing.  It
14981
is used primarily in a distribution context when using Annex E
14982
with @code{GLADE}.
14983
 
14984
@node System.Pool_Global (s-pooglo.ads)
14985
@section @code{System.Pool_Global} (@file{s-pooglo.ads})
14986
@cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14987
@cindex Storage pool, global
14988
@cindex Global storage pool
14989
 
14990
@noindent
14991
This package provides a storage pool that is equivalent to the default
14992
storage pool used for access types for which no pool is specifically
14993
declared. It uses malloc/free to allocate/free and does not attempt to
14994
do any automatic reclamation.
14995
 
14996
@node System.Pool_Local (s-pooloc.ads)
14997
@section @code{System.Pool_Local} (@file{s-pooloc.ads})
14998
@cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14999
@cindex Storage pool, local
15000
@cindex Local storage pool
15001
 
15002
@noindent
15003
This package provides a storage pool that is intended for use with locally
15004
defined access types. It uses malloc/free for allocate/free, and maintains
15005
a list of allocated blocks, so that all storage allocated for the pool can
15006
be freed automatically when the pool is finalized.
15007
 
15008
@node System.Restrictions (s-restri.ads)
15009
@section @code{System.Restrictions} (@file{s-restri.ads})
15010
@cindex @code{System.Restrictions} (@file{s-restri.ads})
15011
@cindex Run-time restrictions access
15012
 
15013
@noindent
15014
This package provides facilities for accessing at run time
15015
the status of restrictions specified at compile time for
15016
the partition. Information is available both with regard
15017
to actual restrictions specified, and with regard to
15018
compiler determined information on which restrictions
15019
are violated by one or more packages in the partition.
15020
 
15021
@node System.Rident (s-rident.ads)
15022
@section @code{System.Rident} (@file{s-rident.ads})
15023
@cindex @code{System.Rident} (@file{s-rident.ads})
15024
@cindex Restrictions definitions
15025
 
15026
@noindent
15027
This package provides definitions of the restrictions
15028
identifiers supported by GNAT, and also the format of
15029
the restrictions provided in package System.Restrictions.
15030
It is not normally necessary to @code{with} this generic package
15031
since the necessary instantiation is included in
15032
package System.Restrictions.
15033
 
15034
@node System.Strings.Stream_Ops (s-ststop.ads)
15035
@section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15036
@cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15037
@cindex Stream operations
15038
@cindex String stream operations
15039
 
15040
@noindent
15041
This package provides a set of stream subprograms for standard string types.
15042
It is intended primarily to support implicit use of such subprograms when
15043
stream attributes are applied to string types, but the subprograms in this
15044
package can be used directly by application programs.
15045
 
15046
@node System.Task_Info (s-tasinf.ads)
15047
@section @code{System.Task_Info} (@file{s-tasinf.ads})
15048
@cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15049
@cindex Task_Info pragma
15050
 
15051
@noindent
15052
This package provides target dependent functionality that is used
15053
to support the @code{Task_Info} pragma
15054
 
15055
@node System.Wch_Cnv (s-wchcnv.ads)
15056
@section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15057
@cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15058
@cindex Wide Character, Representation
15059
@cindex Wide String, Conversion
15060
@cindex Representation of wide characters
15061
 
15062
@noindent
15063
This package provides routines for converting between
15064
wide and wide wide characters and a representation as a value of type
15065
@code{Standard.String}, using a specified wide character
15066
encoding method.  It uses definitions in
15067
package @code{System.Wch_Con}.
15068
 
15069
@node System.Wch_Con (s-wchcon.ads)
15070
@section @code{System.Wch_Con} (@file{s-wchcon.ads})
15071
@cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15072
 
15073
@noindent
15074
This package provides definitions and descriptions of
15075
the various methods used for encoding wide characters
15076
in ordinary strings.  These definitions are used by
15077
the package @code{System.Wch_Cnv}.
15078
 
15079
@node Interfacing to Other Languages
15080
@chapter Interfacing to Other Languages
15081
@noindent
15082
The facilities in annex B of the Ada Reference Manual are fully
15083
implemented in GNAT, and in addition, a full interface to C++ is
15084
provided.
15085
 
15086
@menu
15087
* Interfacing to C::
15088
* Interfacing to C++::
15089
* Interfacing to COBOL::
15090
* Interfacing to Fortran::
15091
* Interfacing to non-GNAT Ada code::
15092
@end menu
15093
 
15094
@node Interfacing to C
15095
@section Interfacing to C
15096
 
15097
@noindent
15098
Interfacing to C with GNAT can use one of two approaches:
15099
 
15100
@itemize @bullet
15101
@item
15102
The types in the package @code{Interfaces.C} may be used.
15103
@item
15104
Standard Ada types may be used directly.  This may be less portable to
15105
other compilers, but will work on all GNAT compilers, which guarantee
15106
correspondence between the C and Ada types.
15107
@end itemize
15108
 
15109
@noindent
15110
Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15111
effect, since this is the default.  The following table shows the
15112
correspondence between Ada scalar types and the corresponding C types.
15113
 
15114
@table @code
15115
@item Integer
15116
@code{int}
15117
@item Short_Integer
15118
@code{short}
15119
@item Short_Short_Integer
15120
@code{signed char}
15121
@item Long_Integer
15122
@code{long}
15123
@item Long_Long_Integer
15124
@code{long long}
15125
@item Short_Float
15126
@code{float}
15127
@item Float
15128
@code{float}
15129
@item Long_Float
15130
@code{double}
15131
@item Long_Long_Float
15132
This is the longest floating-point type supported by the hardware.
15133
@end table
15134
 
15135
@noindent
15136
Additionally, there are the following general correspondences between Ada
15137
and C types:
15138
@itemize @bullet
15139
@item
15140
Ada enumeration types map to C enumeration types directly if pragma
15141
@code{Convention C} is specified, which causes them to have int
15142
length.  Without pragma @code{Convention C}, Ada enumeration types map to
15143
8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15144
@code{int}, respectively) depending on the number of values passed.
15145
This is the only case in which pragma @code{Convention C} affects the
15146
representation of an Ada type.
15147
 
15148
@item
15149
Ada access types map to C pointers, except for the case of pointers to
15150
unconstrained types in Ada, which have no direct C equivalent.
15151
 
15152
@item
15153
Ada arrays map directly to C arrays.
15154
 
15155
@item
15156
Ada records map directly to C structures.
15157
 
15158
@item
15159
Packed Ada records map to C structures where all members are bit fields
15160
of the length corresponding to the @code{@var{type}'Size} value in Ada.
15161
@end itemize
15162
 
15163
@node Interfacing to C++
15164
@section Interfacing to C++
15165
 
15166
@noindent
15167
The interface to C++ makes use of the following pragmas, which are
15168
primarily intended to be constructed automatically using a binding generator
15169
tool, although it is possible to construct them by hand.  No suitable binding
15170
generator tool is supplied with GNAT though.
15171
 
15172
Using these pragmas it is possible to achieve complete
15173
inter-operability between Ada tagged types and C++ class definitions.
15174
See @ref{Implementation Defined Pragmas}, for more details.
15175
 
15176
@table @code
15177
@item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15178
The argument denotes an entity in the current declarative region that is
15179
declared as a tagged or untagged record type. It indicates that the type
15180
corresponds to an externally declared C++ class type, and is to be laid
15181
out the same way that C++ would lay out the type.
15182
 
15183
Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15184
for backward compatibility but its functionality is available
15185
using pragma @code{Import} with @code{Convention} = @code{CPP}.
15186
 
15187
@item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15188
This pragma identifies an imported function (imported in the usual way
15189
with pragma @code{Import}) as corresponding to a C++ constructor.
15190
@end table
15191
 
15192
@node Interfacing to COBOL
15193
@section Interfacing to COBOL
15194
 
15195
@noindent
15196
Interfacing to COBOL is achieved as described in section B.4 of
15197
the Ada Reference Manual.
15198
 
15199
@node Interfacing to Fortran
15200
@section Interfacing to Fortran
15201
 
15202
@noindent
15203
Interfacing to Fortran is achieved as described in section B.5 of the
15204
Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15205
multi-dimensional array causes the array to be stored in column-major
15206
order as required for convenient interface to Fortran.
15207
 
15208
@node Interfacing to non-GNAT Ada code
15209
@section Interfacing to non-GNAT Ada code
15210
 
15211
It is possible to specify the convention @code{Ada} in a pragma
15212
@code{Import} or pragma @code{Export}.  However this refers to
15213
the calling conventions used by GNAT, which may or may not be
15214
similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15215
compiler to allow interoperation.
15216
 
15217
If arguments types are kept simple, and if the foreign compiler generally
15218
follows system calling conventions, then it may be possible to integrate
15219
files compiled by other Ada compilers, provided that the elaboration
15220
issues are adequately addressed (for example by eliminating the
15221
need for any load time elaboration).
15222
 
15223
In particular, GNAT running on VMS is designed to
15224
be highly compatible with the DEC Ada 83 compiler, so this is one
15225
case in which it is possible to import foreign units of this type,
15226
provided that the data items passed are restricted to simple scalar
15227
values or simple record types without variants, or simple array
15228
types with fixed bounds.
15229
 
15230
@node Specialized Needs Annexes
15231
@chapter Specialized Needs Annexes
15232
 
15233
@noindent
15234
Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15235
required in all implementations.  However, as described in this chapter,
15236
GNAT implements all of these annexes:
15237
 
15238
@table @asis
15239
@item Systems Programming (Annex C)
15240
The Systems Programming Annex is fully implemented.
15241
 
15242
@item Real-Time Systems (Annex D)
15243
The Real-Time Systems Annex is fully implemented.
15244
 
15245
@item Distributed Systems (Annex E)
15246
Stub generation is fully implemented in the GNAT compiler.  In addition,
15247
a complete compatible PCS is available as part of the GLADE system,
15248
a separate product.  When the two
15249
products are used in conjunction, this annex is fully implemented.
15250
 
15251
@item Information Systems (Annex F)
15252
The Information Systems annex is fully implemented.
15253
 
15254
@item Numerics (Annex G)
15255
The Numerics Annex is fully implemented.
15256
 
15257
@item Safety and Security / High-Integrity Systems (Annex H)
15258
The Safety and Security Annex (termed the High-Integrity Systems Annex
15259
in Ada 2005) is fully implemented.
15260
@end table
15261
 
15262
@node Implementation of Specific Ada Features
15263
@chapter Implementation of Specific Ada Features
15264
 
15265
@noindent
15266
This chapter describes the GNAT implementation of several Ada language
15267
facilities.
15268
 
15269
@menu
15270
* Machine Code Insertions::
15271
* GNAT Implementation of Tasking::
15272
* GNAT Implementation of Shared Passive Packages::
15273
* Code Generation for Array Aggregates::
15274
* The Size of Discriminated Records with Default Discriminants::
15275
* Strict Conformance to the Ada Reference Manual::
15276
@end menu
15277
 
15278
@node Machine Code Insertions
15279
@section Machine Code Insertions
15280
@cindex Machine Code insertions
15281
 
15282
@noindent
15283
Package @code{Machine_Code} provides machine code support as described
15284
in the Ada Reference Manual in two separate forms:
15285
@itemize @bullet
15286
@item
15287
Machine code statements, consisting of qualified expressions that
15288
fit the requirements of RM section 13.8.
15289
@item
15290
An intrinsic callable procedure, providing an alternative mechanism of
15291
including machine instructions in a subprogram.
15292
@end itemize
15293
 
15294
@noindent
15295
The two features are similar, and both are closely related to the mechanism
15296
provided by the asm instruction in the GNU C compiler.  Full understanding
15297
and use of the facilities in this package requires understanding the asm
15298
instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15299
Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15300
 
15301
Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15302
semantic restrictions and effects as described below.  Both are provided so
15303
that the procedure call can be used as a statement, and the function call
15304
can be used to form a code_statement.
15305
 
15306
The first example given in the GCC documentation is the C @code{asm}
15307
instruction:
15308
@smallexample
15309
   asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15310
@end smallexample
15311
 
15312
@noindent
15313
The equivalent can be written for GNAT as:
15314
 
15315
@smallexample @c ada
15316
Asm ("fsinx %1 %0",
15317
     My_Float'Asm_Output ("=f", result),
15318
     My_Float'Asm_Input  ("f",  angle));
15319
@end smallexample
15320
 
15321
@noindent
15322
The first argument to @code{Asm} is the assembler template, and is
15323
identical to what is used in GNU C@.  This string must be a static
15324
expression.  The second argument is the output operand list.  It is
15325
either a single @code{Asm_Output} attribute reference, or a list of such
15326
references enclosed in parentheses (technically an array aggregate of
15327
such references).
15328
 
15329
The @code{Asm_Output} attribute denotes a function that takes two
15330
parameters.  The first is a string, the second is the name of a variable
15331
of the type designated by the attribute prefix.  The first (string)
15332
argument is required to be a static expression and designates the
15333
constraint for the parameter (e.g.@: what kind of register is
15334
required).  The second argument is the variable to be updated with the
15335
result.  The possible values for constraint are the same as those used in
15336
the RTL, and are dependent on the configuration file used to build the
15337
GCC back end.  If there are no output operands, then this argument may
15338
either be omitted, or explicitly given as @code{No_Output_Operands}.
15339
 
15340
The second argument of @code{@var{my_float}'Asm_Output} functions as
15341
though it were an @code{out} parameter, which is a little curious, but
15342
all names have the form of expressions, so there is no syntactic
15343
irregularity, even though normally functions would not be permitted
15344
@code{out} parameters.  The third argument is the list of input
15345
operands.  It is either a single @code{Asm_Input} attribute reference, or
15346
a list of such references enclosed in parentheses (technically an array
15347
aggregate of such references).
15348
 
15349
The @code{Asm_Input} attribute denotes a function that takes two
15350
parameters.  The first is a string, the second is an expression of the
15351
type designated by the prefix.  The first (string) argument is required
15352
to be a static expression, and is the constraint for the parameter,
15353
(e.g.@: what kind of register is required).  The second argument is the
15354
value to be used as the input argument.  The possible values for the
15355
constant are the same as those used in the RTL, and are dependent on
15356
the configuration file used to built the GCC back end.
15357
 
15358
If there are no input operands, this argument may either be omitted, or
15359
explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15360
present in the above example, is a list of register names, called the
15361
@dfn{clobber} argument.  This argument, if given, must be a static string
15362
expression, and is a space or comma separated list of names of registers
15363
that must be considered destroyed as a result of the @code{Asm} call.  If
15364
this argument is the null string (the default value), then the code
15365
generator assumes that no additional registers are destroyed.
15366
 
15367
The fifth argument, not present in the above example, called the
15368
@dfn{volatile} argument, is by default @code{False}.  It can be set to
15369
the literal value @code{True} to indicate to the code generator that all
15370
optimizations with respect to the instruction specified should be
15371
suppressed, and that in particular, for an instruction that has outputs,
15372
the instruction will still be generated, even if none of the outputs are
15373
used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15374
gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15375
Generally it is strongly advisable to use Volatile for any ASM statement
15376
that is missing either input or output operands, or when two or more ASM
15377
statements appear in sequence, to avoid unwanted optimizations. A warning
15378
is generated if this advice is not followed.
15379
 
15380
The @code{Asm} subprograms may be used in two ways.  First the procedure
15381
forms can be used anywhere a procedure call would be valid, and
15382
correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15383
be used to intersperse machine instructions with other Ada statements.
15384
Second, the function forms, which return a dummy value of the limited
15385
private type @code{Asm_Insn}, can be used in code statements, and indeed
15386
this is the only context where such calls are allowed.  Code statements
15387
appear as aggregates of the form:
15388
 
15389
@smallexample @c ada
15390
Asm_Insn'(Asm (@dots{}));
15391
Asm_Insn'(Asm_Volatile (@dots{}));
15392
@end smallexample
15393
 
15394
@noindent
15395
In accordance with RM rules, such code statements are allowed only
15396
within subprograms whose entire body consists of such statements.  It is
15397
not permissible to intermix such statements with other Ada statements.
15398
 
15399
Typically the form using intrinsic procedure calls is more convenient
15400
and more flexible.  The code statement form is provided to meet the RM
15401
suggestion that such a facility should be made available.  The following
15402
is the exact syntax of the call to @code{Asm}. As usual, if named notation
15403
is used, the arguments may be given in arbitrary order, following the
15404
normal rules for use of positional and named arguments)
15405
 
15406
@smallexample
15407
ASM_CALL ::= Asm (
15408
                 [Template =>] static_string_EXPRESSION
15409
               [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15410
               [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15411
               [,[Clobber  =>] static_string_EXPRESSION ]
15412
               [,[Volatile =>] static_boolean_EXPRESSION] )
15413
 
15414
OUTPUT_OPERAND_LIST ::=
15415
  [PREFIX.]No_Output_Operands
15416
| OUTPUT_OPERAND_ATTRIBUTE
15417
| (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15418
 
15419
OUTPUT_OPERAND_ATTRIBUTE ::=
15420
  SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15421
 
15422
INPUT_OPERAND_LIST ::=
15423
  [PREFIX.]No_Input_Operands
15424
| INPUT_OPERAND_ATTRIBUTE
15425
| (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15426
 
15427
INPUT_OPERAND_ATTRIBUTE ::=
15428
  SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15429
@end smallexample
15430
 
15431
@noindent
15432
The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15433
are declared in the package @code{Machine_Code} and must be referenced
15434
according to normal visibility rules. In particular if there is no
15435
@code{use} clause for this package, then appropriate package name
15436
qualification is required.
15437
 
15438
@node GNAT Implementation of Tasking
15439
@section GNAT Implementation of Tasking
15440
 
15441
@noindent
15442
This chapter outlines the basic GNAT approach to tasking (in particular,
15443
a multi-layered library for portability) and discusses issues related
15444
to compliance with the Real-Time Systems Annex.
15445
 
15446
@menu
15447
* Mapping Ada Tasks onto the Underlying Kernel Threads::
15448
* Ensuring Compliance with the Real-Time Annex::
15449
@end menu
15450
 
15451
@node Mapping Ada Tasks onto the Underlying Kernel Threads
15452
@subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15453
 
15454
@noindent
15455
GNAT's run-time support comprises two layers:
15456
 
15457
@itemize @bullet
15458
@item GNARL (GNAT Run-time Layer)
15459
@item GNULL (GNAT Low-level Library)
15460
@end itemize
15461
 
15462
@noindent
15463
In GNAT, Ada's tasking services rely on a platform and OS independent
15464
layer known as GNARL@.  This code is responsible for implementing the
15465
correct semantics of Ada's task creation, rendezvous, protected
15466
operations etc.
15467
 
15468
GNARL decomposes Ada's tasking semantics into simpler lower level
15469
operations such as create a thread, set the priority of a thread,
15470
yield, create a lock, lock/unlock, etc.  The spec for these low-level
15471
operations constitutes GNULLI, the GNULL Interface.  This interface is
15472
directly inspired from the POSIX real-time API@.
15473
 
15474
If the underlying executive or OS implements the POSIX standard
15475
faithfully, the GNULL Interface maps as is to the services offered by
15476
the underlying kernel.  Otherwise, some target dependent glue code maps
15477
the services offered by the underlying kernel to the semantics expected
15478
by GNARL@.
15479
 
15480
Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15481
key point is that each Ada task is mapped on a thread in the underlying
15482
kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15483
 
15484
In addition Ada task priorities map onto the underlying thread priorities.
15485
Mapping Ada tasks onto the underlying kernel threads has several advantages:
15486
 
15487
@itemize @bullet
15488
@item
15489
The underlying scheduler is used to schedule the Ada tasks.  This
15490
makes Ada tasks as efficient as kernel threads from a scheduling
15491
standpoint.
15492
 
15493
@item
15494
Interaction with code written in C containing threads is eased
15495
since at the lowest level Ada tasks and C threads map onto the same
15496
underlying kernel concept.
15497
 
15498
@item
15499
When an Ada task is blocked during I/O the remaining Ada tasks are
15500
able to proceed.
15501
 
15502
@item
15503
On multiprocessor systems Ada tasks can execute in parallel.
15504
@end itemize
15505
 
15506
@noindent
15507
Some threads libraries offer a mechanism to fork a new process, with the
15508
child process duplicating the threads from the parent.
15509
GNAT does not
15510
support this functionality when the parent contains more than one task.
15511
@cindex Forking a new process
15512
 
15513
@node Ensuring Compliance with the Real-Time Annex
15514
@subsection Ensuring Compliance with the Real-Time Annex
15515
@cindex Real-Time Systems Annex compliance
15516
 
15517
@noindent
15518
Although mapping Ada tasks onto
15519
the underlying threads has significant advantages, it does create some
15520
complications when it comes to respecting the scheduling semantics
15521
specified in the real-time annex (Annex D).
15522
 
15523
For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15524
scheduling policy states:
15525
 
15526
@quotation
15527
@emph{When the active priority of a ready task that is not running
15528
changes, or the setting of its base priority takes effect, the
15529
task is removed from the ready queue for its old active priority
15530
and is added at the tail of the ready queue for its new active
15531
priority, except in the case where the active priority is lowered
15532
due to the loss of inherited priority, in which case the task is
15533
added at the head of the ready queue for its new active priority.}
15534
@end quotation
15535
 
15536
@noindent
15537
While most kernels do put tasks at the end of the priority queue when
15538
a task changes its priority, (which respects the main
15539
FIFO_Within_Priorities requirement), almost none keep a thread at the
15540
beginning of its priority queue when its priority drops from the loss
15541
of inherited priority.
15542
 
15543
As a result most vendors have provided incomplete Annex D implementations.
15544
 
15545
The GNAT run-time, has a nice cooperative solution to this problem
15546
which ensures that accurate FIFO_Within_Priorities semantics are
15547
respected.
15548
 
15549
The principle is as follows.  When an Ada task T is about to start
15550
running, it checks whether some other Ada task R with the same
15551
priority as T has been suspended due to the loss of priority
15552
inheritance.  If this is the case, T yields and is placed at the end of
15553
its priority queue.  When R arrives at the front of the queue it
15554
executes.
15555
 
15556
Note that this simple scheme preserves the relative order of the tasks
15557
that were ready to execute in the priority queue where R has been
15558
placed at the end.
15559
 
15560
@node GNAT Implementation of Shared Passive Packages
15561
@section GNAT Implementation of Shared Passive Packages
15562
@cindex Shared passive packages
15563
 
15564
@noindent
15565
GNAT fully implements the pragma @code{Shared_Passive} for
15566
@cindex pragma @code{Shared_Passive}
15567
the purpose of designating shared passive packages.
15568
This allows the use of passive partitions in the
15569
context described in the Ada Reference Manual; i.e., for communication
15570
between separate partitions of a distributed application using the
15571
features in Annex E.
15572
@cindex Annex E
15573
@cindex Distribution Systems Annex
15574
 
15575
However, the implementation approach used by GNAT provides for more
15576
extensive usage as follows:
15577
 
15578
@table @emph
15579
@item Communication between separate programs
15580
 
15581
This allows separate programs to access the data in passive
15582
partitions, using protected objects for synchronization where
15583
needed. The only requirement is that the two programs have a
15584
common shared file system. It is even possible for programs
15585
running on different machines with different architectures
15586
(e.g.@: different endianness) to communicate via the data in
15587
a passive partition.
15588
 
15589
@item Persistence between program runs
15590
 
15591
The data in a passive package can persist from one run of a
15592
program to another, so that a later program sees the final
15593
values stored by a previous run of the same program.
15594
 
15595
@end table
15596
 
15597
@noindent
15598
The implementation approach used is to store the data in files. A
15599
separate stream file is created for each object in the package, and
15600
an access to an object causes the corresponding file to be read or
15601
written.
15602
 
15603
The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15604
@cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15605
set to the directory to be used for these files.
15606
The files in this directory
15607
have names that correspond to their fully qualified names. For
15608
example, if we have the package
15609
 
15610
@smallexample @c ada
15611
package X is
15612
  pragma Shared_Passive (X);
15613
  Y : Integer;
15614
  Z : Float;
15615
end X;
15616
@end smallexample
15617
 
15618
@noindent
15619
and the environment variable is set to @code{/stemp/}, then the files created
15620
will have the names:
15621
 
15622
@smallexample
15623
/stemp/x.y
15624
/stemp/x.z
15625
@end smallexample
15626
 
15627
@noindent
15628
These files are created when a value is initially written to the object, and
15629
the files are retained until manually deleted. This provides the persistence
15630
semantics. If no file exists, it means that no partition has assigned a value
15631
to the variable; in this case the initial value declared in the package
15632
will be used. This model ensures that there are no issues in synchronizing
15633
the elaboration process, since elaboration of passive packages elaborates the
15634
initial values, but does not create the files.
15635
 
15636
The files are written using normal @code{Stream_IO} access.
15637
If you want to be able
15638
to communicate between programs or partitions running on different
15639
architectures, then you should use the XDR versions of the stream attribute
15640
routines, since these are architecture independent.
15641
 
15642
If active synchronization is required for access to the variables in the
15643
shared passive package, then as described in the Ada Reference Manual, the
15644
package may contain protected objects used for this purpose. In this case
15645
a lock file (whose name is @file{___lock} (three underscores)
15646
is created in the shared memory directory.
15647
@cindex @file{___lock} file (for shared passive packages)
15648
This is used to provide the required locking
15649
semantics for proper protected object synchronization.
15650
 
15651
As of January 2003, GNAT supports shared passive packages on all platforms
15652
except for OpenVMS.
15653
 
15654
@node Code Generation for Array Aggregates
15655
@section Code Generation for Array Aggregates
15656
 
15657
@menu
15658
* Static constant aggregates with static bounds::
15659
* Constant aggregates with unconstrained nominal types::
15660
* Aggregates with static bounds::
15661
* Aggregates with non-static bounds::
15662
* Aggregates in assignment statements::
15663
@end menu
15664
 
15665
@noindent
15666
Aggregates have a rich syntax and allow the user to specify the values of
15667
complex data structures by means of a single construct.  As a result, the
15668
code generated for aggregates can be quite complex and involve loops, case
15669
statements and multiple assignments.  In the simplest cases, however, the
15670
compiler will recognize aggregates whose components and constraints are
15671
fully static, and in those cases the compiler will generate little or no
15672
executable code.  The following is an outline of the code that GNAT generates
15673
for various aggregate constructs.  For further details, you will find it
15674
useful to examine the output produced by the -gnatG flag to see the expanded
15675
source that is input to the code generator.  You may also want to examine
15676
the assembly code generated at various levels of optimization.
15677
 
15678
The code generated for aggregates depends on the context, the component values,
15679
and the type.  In the context of an object declaration the code generated is
15680
generally simpler than in the case of an assignment.  As a general rule, static
15681
component values and static subtypes also lead to simpler code.
15682
 
15683
@node Static constant aggregates with static bounds
15684
@subsection Static constant aggregates with static bounds
15685
 
15686
@noindent
15687
For the declarations:
15688
@smallexample @c ada
15689
    type One_Dim is array (1..10) of integer;
15690
    ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15691
@end smallexample
15692
 
15693
@noindent
15694
GNAT generates no executable code: the constant ar0 is placed in static memory.
15695
The same is true for constant aggregates with named associations:
15696
 
15697
@smallexample @c ada
15698
    Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15699
    Cr3 : constant One_Dim := (others => 7777);
15700
@end smallexample
15701
 
15702
@noindent
15703
The same is true for multidimensional constant arrays such as:
15704
 
15705
@smallexample @c ada
15706
    type two_dim is array (1..3, 1..3) of integer;
15707
    Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15708
@end smallexample
15709
 
15710
@noindent
15711
The same is true for arrays of one-dimensional arrays: the following are
15712
static:
15713
 
15714
@smallexample @c ada
15715
type ar1b  is array (1..3) of boolean;
15716
type ar_ar is array (1..3) of ar1b;
15717
None  : constant ar1b := (others => false);     --  fully static
15718
None2 : constant ar_ar := (1..3 => None);       --  fully static
15719
@end smallexample
15720
 
15721
@noindent
15722
However, for multidimensional aggregates with named associations, GNAT will
15723
generate assignments and loops, even if all associations are static.  The
15724
following two declarations generate a loop for the first dimension, and
15725
individual component assignments for the second dimension:
15726
 
15727
@smallexample @c ada
15728
Zero1: constant two_dim := (1..3 => (1..3 => 0));
15729
Zero2: constant two_dim := (others => (others => 0));
15730
@end smallexample
15731
 
15732
@node Constant aggregates with unconstrained nominal types
15733
@subsection Constant aggregates with unconstrained nominal types
15734
 
15735
@noindent
15736
In such cases the aggregate itself establishes the subtype, so that
15737
associations with @code{others} cannot be used.  GNAT determines the
15738
bounds for the actual subtype of the aggregate, and allocates the
15739
aggregate statically as well.  No code is generated for the following:
15740
 
15741
@smallexample @c ada
15742
    type One_Unc is array (natural range <>) of integer;
15743
    Cr_Unc : constant One_Unc := (12,24,36);
15744
@end smallexample
15745
 
15746
@node Aggregates with static bounds
15747
@subsection Aggregates with static bounds
15748
 
15749
@noindent
15750
In all previous examples the aggregate was the initial (and immutable) value
15751
of a constant.  If the aggregate initializes a variable, then code is generated
15752
for it as a combination of individual assignments and loops over the target
15753
object.  The declarations
15754
 
15755
@smallexample @c ada
15756
       Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15757
       Cr_Var2 : One_Dim := (others > -1);
15758
@end smallexample
15759
 
15760
@noindent
15761
generate the equivalent of
15762
 
15763
@smallexample @c ada
15764
       Cr_Var1 (1) := 2;
15765
       Cr_Var1 (2) := 3;
15766
       Cr_Var1 (3) := 5;
15767
       Cr_Var1 (4) := 11;
15768
 
15769
       for I in Cr_Var2'range loop
15770
          Cr_Var2 (I) := -1;
15771
       end loop;
15772
@end smallexample
15773
 
15774
@node Aggregates with non-static bounds
15775
@subsection Aggregates with non-static bounds
15776
 
15777
@noindent
15778
If the bounds of the aggregate are not statically compatible with the bounds
15779
of the nominal subtype  of the target, then constraint checks have to be
15780
generated on the bounds.  For a multidimensional array, constraint checks may
15781
have to be applied to sub-arrays individually, if they do not have statically
15782
compatible subtypes.
15783
 
15784
@node Aggregates in assignment statements
15785
@subsection Aggregates in assignment statements
15786
 
15787
@noindent
15788
In general, aggregate assignment requires the construction of a temporary,
15789
and a copy from the temporary to the target of the assignment.  This is because
15790
it is not always possible to convert the assignment into a series of individual
15791
component assignments.  For example, consider the simple case:
15792
 
15793
@smallexample @c ada
15794
        A := (A(2), A(1));
15795
@end smallexample
15796
 
15797
@noindent
15798
This cannot be converted into:
15799
 
15800
@smallexample @c ada
15801
        A(1) := A(2);
15802
        A(2) := A(1);
15803
@end smallexample
15804
 
15805
@noindent
15806
So the aggregate has to be built first in a separate location, and then
15807
copied into the target.  GNAT recognizes simple cases where this intermediate
15808
step is not required, and the assignments can be performed in place, directly
15809
into the target.  The following sufficient criteria are applied:
15810
 
15811
@itemize @bullet
15812
@item
15813
The bounds of the aggregate are static, and the associations are static.
15814
@item
15815
The components of the aggregate are static constants, names of
15816
simple variables that are not renamings, or expressions not involving
15817
indexed components whose operands obey these rules.
15818
@end itemize
15819
 
15820
@noindent
15821
If any of these conditions are violated, the aggregate will be built in
15822
a temporary (created either by the front-end or the code generator) and then
15823
that temporary will be copied onto the target.
15824
 
15825
 
15826
@node The Size of Discriminated Records with Default Discriminants
15827
@section The Size of Discriminated Records with Default Discriminants
15828
 
15829
@noindent
15830
If a discriminated type @code{T} has discriminants with default values, it is
15831
possible to declare an object of this type without providing an explicit
15832
constraint:
15833
 
15834
@smallexample @c ada
15835
@group
15836
type Size is range 1..100;
15837
 
15838
type Rec (D : Size := 15) is record
15839
   Name : String (1..D);
15840
end T;
15841
 
15842
Word : Rec;
15843
@end group
15844
@end smallexample
15845
 
15846
@noindent
15847
Such an object is said to be @emph{unconstrained}.
15848
The discriminant of the object
15849
can be modified by a full assignment to the object, as long as it preserves the
15850
relation between the value of the discriminant, and the value of the components
15851
that depend on it:
15852
 
15853
@smallexample @c ada
15854
@group
15855
Word := (3, "yes");
15856
 
15857
Word := (5, "maybe");
15858
 
15859
Word := (5, "no"); -- raises Constraint_Error
15860
@end group
15861
@end smallexample
15862
 
15863
@noindent
15864
In order to support this behavior efficiently, an unconstrained object is
15865
given the maximum size that any value of the type requires. In the case
15866
above, @code{Word} has storage for the discriminant and for
15867
a @code{String} of length 100.
15868
It is important to note that unconstrained objects do not require dynamic
15869
allocation. It would be an improper implementation to place on the heap those
15870
components whose size depends on discriminants. (This improper implementation
15871
was used by some Ada83 compilers, where the @code{Name} component above
15872
would have
15873
been stored as a pointer to a dynamic string). Following the principle that
15874
dynamic storage management should never be introduced implicitly,
15875
an Ada compiler should reserve the full size for an unconstrained declared
15876
object, and place it on the stack.
15877
 
15878
This maximum size approach
15879
has been a source of surprise to some users, who expect the default
15880
values of the discriminants to determine the size reserved for an
15881
unconstrained object: ``If the default is 15, why should the object occupy
15882
a larger size?''
15883
The answer, of course, is that the discriminant may be later modified,
15884
and its full range of values must be taken into account. This is why the
15885
declaration:
15886
 
15887
@smallexample
15888
@group
15889
type Rec (D : Positive := 15) is record
15890
   Name : String (1..D);
15891
end record;
15892
 
15893
Too_Large : Rec;
15894
@end group
15895
@end smallexample
15896
 
15897
@noindent
15898
is flagged by the compiler with a warning:
15899
an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15900
because the required size includes @code{Positive'Last}
15901
bytes. As the first example indicates, the proper approach is to declare an
15902
index type of ``reasonable'' range so that unconstrained objects are not too
15903
large.
15904
 
15905
One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15906
created in the heap by means of an allocator, then it is @emph{not}
15907
unconstrained:
15908
it is constrained by the default values of the discriminants, and those values
15909
cannot be modified by full assignment. This is because in the presence of
15910
aliasing all views of the object (which may be manipulated by different tasks,
15911
say) must be consistent, so it is imperative that the object, once created,
15912
remain invariant.
15913
 
15914
@node Strict Conformance to the Ada Reference Manual
15915
@section Strict Conformance to the Ada Reference Manual
15916
 
15917
@noindent
15918
The dynamic semantics defined by the Ada Reference Manual impose a set of
15919
run-time checks to be generated. By default, the GNAT compiler will insert many
15920
run-time checks into the compiled code, including most of those required by the
15921
Ada Reference Manual. However, there are three checks that are not enabled
15922
in the default mode for efficiency reasons: arithmetic overflow checking for
15923
integer operations (including division by zero), checks for access before
15924
elaboration on subprogram calls, and stack overflow checking (most operating
15925
systems do not perform this check by default).
15926
 
15927
Strict conformance to the Ada Reference Manual can be achieved by adding
15928
three compiler options for overflow checking for integer operations
15929
(@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15930
calls and generic instantiations (@option{-gnatE}), and stack overflow
15931
checking (@option{-fstack-check}).
15932
 
15933
Note that the result of a floating point arithmetic operation in overflow and
15934
invalid situations, when the @code{Machine_Overflows} attribute of the result
15935
type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15936
case for machines compliant with the IEEE floating-point standard, but on
15937
machines that are not fully compliant with this standard, such as Alpha, the
15938
@option{-mieee} compiler flag must be used for achieving IEEE confirming
15939
behavior (although at the cost of a significant performance penalty), so
15940
infinite and and NaN values are properly generated.
15941
 
15942
 
15943
@node Project File Reference
15944
@chapter Project File Reference
15945
 
15946
@noindent
15947
This chapter describes the syntax and semantics of project files.
15948
Project files specify the options to be used when building a system.
15949
Project files can specify global settings for all tools,
15950
as well as tool-specific settings.
15951
@xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15952
for examples of use.
15953
 
15954
@menu
15955
* Reserved Words::
15956
* Lexical Elements::
15957
* Declarations::
15958
* Empty declarations::
15959
* Typed string declarations::
15960
* Variables::
15961
* Expressions::
15962
* Attributes::
15963
* Project Attributes::
15964
* Attribute References::
15965
* External Values::
15966
* Case Construction::
15967
* Packages::
15968
* Package Renamings::
15969
* Projects::
15970
* Project Extensions::
15971
* Project File Elaboration::
15972
@end menu
15973
 
15974
@node Reserved Words
15975
@section Reserved Words
15976
 
15977
@noindent
15978
All Ada reserved words are reserved in project files, and cannot be used
15979
as variable names or project names. In addition, the following are
15980
also reserved in project files:
15981
 
15982
@itemize
15983
@item @code{extends}
15984
 
15985
@item @code{external}
15986
 
15987
@item @code{project}
15988
 
15989
@end itemize
15990
 
15991
@node Lexical Elements
15992
@section Lexical Elements
15993
 
15994
@noindent
15995
Rules for identifiers are the same as in Ada. Identifiers
15996
are case-insensitive.  Strings are case sensitive, except where noted.
15997
Comments have the same form as in Ada.
15998
 
15999
@noindent
16000
Syntax:
16001
 
16002
@smallexample
16003
simple_name ::=
16004
  identifier
16005
 
16006
name ::=
16007
  simple_name @{. simple_name@}
16008
@end smallexample
16009
 
16010
@node Declarations
16011
@section Declarations
16012
 
16013
@noindent
16014
Declarations introduce new entities that denote types, variables, attributes,
16015
and packages. Some declarations can only appear immediately within a project
16016
declaration. Others can appear within a project or within a package.
16017
 
16018
Syntax:
16019
@smallexample
16020
declarative_item ::=
16021
  simple_declarative_item |
16022
  typed_string_declaration |
16023
  package_declaration
16024
 
16025
simple_declarative_item ::=
16026
  variable_declaration |
16027
  typed_variable_declaration |
16028
  attribute_declaration |
16029
  case_construction |
16030
  empty_declaration
16031
@end smallexample
16032
 
16033
@node Empty declarations
16034
@section Empty declarations
16035
 
16036
@smallexample
16037
empty_declaration ::=
16038
  @b{null} ;
16039
@end smallexample
16040
 
16041
An empty declaration is allowed anywhere a declaration is allowed.
16042
It has no effect.
16043
 
16044
@node Typed string declarations
16045
@section Typed string declarations
16046
 
16047
@noindent
16048
Typed strings are sequences of string literals. Typed strings are the only
16049
named types in project files. They are used in case constructions, where they
16050
provide support for conditional attribute definitions.
16051
 
16052
Syntax:
16053
@smallexample
16054
typed_string_declaration ::=
16055
  @b{type} <typed_string_>_simple_name @b{is}
16056
   ( string_literal @{, string_literal@} );
16057
@end smallexample
16058
 
16059
@noindent
16060
A typed string declaration can only appear immediately within a project
16061
declaration.
16062
 
16063
All the string literals in a typed string declaration must be distinct.
16064
 
16065
@node Variables
16066
@section Variables
16067
 
16068
@noindent
16069
Variables denote values, and appear as constituents of expressions.
16070
 
16071
@smallexample
16072
typed_variable_declaration ::=
16073
  <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
16074
 
16075
variable_declaration ::=
16076
  <variable_>simple_name := expression;
16077
@end smallexample
16078
 
16079
@noindent
16080
The elaboration of a variable declaration introduces the variable and
16081
assigns to it the value of the expression. The name of the variable is
16082
available after the assignment symbol.
16083
 
16084
@noindent
16085
A typed_variable can only be declare once.
16086
 
16087
@noindent
16088
a non-typed variable can be declared multiple times.
16089
 
16090
@noindent
16091
Before the completion of its first declaration, the value of variable
16092
is the null string.
16093
 
16094
@node Expressions
16095
@section Expressions
16096
 
16097
@noindent
16098
An expression is a formula that defines a computation or retrieval of a value.
16099
In a project file the value of an expression is either a string or a list
16100
of strings. A string value in an expression is either a literal, the current
16101
value of a variable, an external value, an attribute reference, or a
16102
concatenation operation.
16103
 
16104
Syntax:
16105
 
16106
@smallexample
16107
expression ::=
16108
  term @{& term@}
16109
 
16110
term ::=
16111
  string_literal |
16112
  string_list |
16113
  <variable_>name |
16114
  external_value |
16115
  attribute_reference
16116
 
16117
string_literal ::=
16118
  (same as Ada)
16119
 
16120
string_list ::=
16121
  ( <string_>expression @{ , <string_>expression @} )
16122
@end smallexample
16123
 
16124
@subsection Concatenation
16125
@noindent
16126
The following concatenation functions are defined:
16127
 
16128
@smallexample @c ada
16129
  function "&" (X : String;      Y : String)      return String;
16130
  function "&" (X : String_List; Y : String)      return String_List;
16131
  function "&" (X : String_List; Y : String_List) return String_List;
16132
@end smallexample
16133
 
16134
@node Attributes
16135
@section Attributes
16136
 
16137
@noindent
16138
An attribute declaration defines a property of a project or package. This
16139
property can later be queried by means of an attribute reference.
16140
Attribute values are strings or string lists.
16141
 
16142
Some attributes are associative arrays. These attributes are mappings whose
16143
domain is a set of strings. These attributes are declared one association
16144
at a time, by specifying a point in the domain and the corresponding image
16145
of the attribute. They may also be declared as a full associative array,
16146
getting the same associations as the corresponding attribute in an imported
16147
or extended project.
16148
 
16149
Attributes that are not associative arrays are called simple attributes.
16150
 
16151
Syntax:
16152
@smallexample
16153
attribute_declaration ::=
16154
  full_associative_array_declaration |
16155
  @b{for} attribute_designator @b{use} expression ;
16156
 
16157
full_associative_array_declaration ::=
16158
  @b{for} <associative_array_attribute_>simple_name @b{use}
16159
  <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16160
 
16161
attribute_designator ::=
16162
  <simple_attribute_>simple_name |
16163
  <associative_array_attribute_>simple_name ( string_literal )
16164
@end smallexample
16165
 
16166
@noindent
16167
Some attributes are project-specific, and can only appear immediately within
16168
a project declaration. Others are package-specific, and can only appear within
16169
the proper package.
16170
 
16171
The expression in an attribute definition must be a string or a string_list.
16172
The string literal appearing in the attribute_designator of an associative
16173
array attribute is case-insensitive.
16174
 
16175
@node Project Attributes
16176
@section Project Attributes
16177
 
16178
@noindent
16179
The following attributes apply to a project. All of them are simple
16180
attributes.
16181
 
16182
@table @code
16183
@item   Object_Dir
16184
Expression must be a path name. The attribute defines the
16185
directory in which the object files created by the build are to be placed. If
16186
not specified, object files are placed in the project directory.
16187
 
16188
@item   Exec_Dir
16189
Expression must be a path name. The attribute defines the
16190
directory in which the executables created by the build are to be placed.
16191
If not specified, executables are placed in the object directory.
16192
 
16193
@item  Source_Dirs
16194
Expression must be a list of path names. The attribute
16195
defines the directories in which the source files for the project are to be
16196
found. If not specified, source files are found in the project directory.
16197
If a string in the list ends with "/**", then the directory that precedes
16198
"/**" and all of its subdirectories (recursively) are included in the list
16199
of source directories.
16200
 
16201
@item  Excluded_Source_Dirs
16202
Expression must be a list of strings. Each entry designates a directory that
16203
is not to be included in the list of source directories of the project.
16204
This is normally used when there are strings ending with "/**" in the value
16205
of attribute Source_Dirs.
16206
 
16207
@item  Source_Files
16208
Expression must be a list of file names. The attribute
16209
defines the individual files, in the project directory, which are to be used
16210
as sources for the project. File names are path_names that contain no directory
16211
information. If the project has no sources the attribute must be declared
16212
explicitly with an empty list.
16213
 
16214
@item  Excluded_Source_Files (Locally_Removed_Files)
16215
Expression must be a list of strings that are legal file names.
16216
Each file name must designate a source that would normally be a source file
16217
in the source directories of the project or, if the project file is an
16218
extending project file, inherited by the current project file. It cannot
16219
designate an immediate source that is not inherited. Each of the source files
16220
in the list are not considered to be sources of the project file: they are not
16221
inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16222
Excluded_Source_Files is preferred.
16223
 
16224
@item  Source_List_File
16225
Expression must a single path name. The attribute
16226
defines a text file that contains a list of source file names to be used
16227
as sources for the project
16228
 
16229
@item  Library_Dir
16230
Expression must be a path name. The attribute defines the
16231
directory in which a  library is to be built.  The directory must exist, must
16232
be distinct from the project's object directory, and must be writable.
16233
 
16234
@item  Library_Name
16235
Expression must be a string that is a legal file name,
16236
without extension. The attribute defines a string that is used to generate
16237
the name of the library to be built by the project.
16238
 
16239
@item  Library_Kind
16240
Argument must be a string value that must be one of the
16241
following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16242
string is case-insensitive. If this attribute is not specified, the library is
16243
a static library. Otherwise, the library may be dynamic or relocatable. This
16244
distinction is operating-system dependent.
16245
 
16246
@item  Library_Version
16247
Expression must be a string value whose interpretation
16248
is platform dependent. On UNIX, it is used only for dynamic/relocatable
16249
libraries as the internal name of the library (the @code{"soname"}). If the
16250
library file name (built from the @code{Library_Name}) is different from the
16251
@code{Library_Version}, then the library file will be a symbolic link to the
16252
actual file whose name will be @code{Library_Version}.
16253
 
16254
@item Library_Interface
16255
Expression must be a string list. Each element of the string list
16256
must designate a unit of the project.
16257
If this attribute is present in a Library Project File, then the project
16258
file is a Stand-alone Library_Project_File.
16259
 
16260
@item Library_Auto_Init
16261
Expression must be a single string "true" or "false", case-insensitive.
16262
If this attribute is present in a Stand-alone Library Project File,
16263
it indicates if initialization is automatic when the dynamic library
16264
is loaded.
16265
 
16266
@item Library_Options
16267
Expression must be a string list. Indicates additional switches that
16268
are to be used when building a shared library.
16269
 
16270
@item Library_GCC
16271
Expression must be a single string. Designates an alternative to "gcc"
16272
for building shared libraries.
16273
 
16274
@item  Library_Src_Dir
16275
Expression must be a path name. The attribute defines the
16276
directory in which the sources of the interfaces of a Stand-alone Library will
16277
be copied.  The directory must exist, must be distinct from the project's
16278
object directory and source directories of all projects in the project tree,
16279
and must be writable.
16280
 
16281
@item  Library_Src_Dir
16282
Expression must be a path name. The attribute defines the
16283
directory in which the ALI files of a Library will
16284
be copied.  The directory must exist, must be distinct from the project's
16285
object directory and source directories of all projects in the project tree,
16286
and must be writable.
16287
 
16288
@item  Library_Symbol_File
16289
Expression must be a single string. Its value is the single file name of a
16290
symbol file to be created when building a stand-alone library when the
16291
symbol policy is either "compliant", "controlled" or "restricted",
16292
on platforms that support symbol control, such as VMS. When symbol policy
16293
is "direct", then a file with this name must exist in the object directory.
16294
 
16295
@item   Library_Reference_Symbol_File
16296
Expression must be a single string. Its value is the path name of a
16297
reference symbol file that is read when the symbol policy is either
16298
"compliant" or "controlled", on platforms that support symbol control,
16299
such as VMS, when building a stand-alone library. The path may be an absolute
16300
path or a path relative to the project directory.
16301
 
16302
@item  Library_Symbol_Policy
16303
Expression must be a single string. Its case-insensitive value can only be
16304
"autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16305
 
16306
This attribute is not taken into account on all platforms. It controls the
16307
policy for exported symbols and, on some platforms (like VMS) that have the
16308
notions of major and minor IDs built in the library files, it controls
16309
the setting of these IDs.
16310
 
16311
"autonomous" or "default": exported symbols are not controlled.
16312
 
16313
"compliant": if attribute Library_Reference_Symbol_File is not defined, then
16314
it is equivalent to policy "autonomous". If there are exported symbols in
16315
the reference symbol file that are not in the object files of the interfaces,
16316
the major ID of the library is increased. If there are symbols in the
16317
object files of the interfaces that are not in the reference symbol file,
16318
these symbols are put at the end of the list in the newly created symbol file
16319
and the minor ID is increased.
16320
 
16321
"controlled": the attribute Library_Reference_Symbol_File must be defined.
16322
The library will fail to build if the exported symbols in the object files of
16323
the interfaces do not match exactly the symbol in the symbol file.
16324
 
16325
"restricted": The attribute Library_Symbol_File must be defined. The library
16326
will fail to build if there are symbols in the symbol file that are not in
16327
the exported symbols of the object files of the interfaces. Additional symbols
16328
in the object files are not added to the symbol file.
16329
 
16330
"direct": The attribute Library_Symbol_File must be defined and must designate
16331
an existing file in the object directory. This symbol file is passed directly
16332
to the underlying linker without any symbol processing.
16333
 
16334
@item  Main
16335
Expression must be a list of strings that are legal file names.
16336
These file names designate existing compilation units in the source directory
16337
that are legal main subprograms.
16338
 
16339
When a project file is elaborated, as part of the execution of a gnatmake
16340
command, one or several executables are built and placed in the Exec_Dir.
16341
If the gnatmake command does not include explicit file names, the executables
16342
that are built correspond to the files specified by this attribute.
16343
 
16344
@item  Externally_Built
16345
Expression must be a single string. Its value must be either "true" of "false",
16346
case-insensitive. The default is "false". When the value of this attribute is
16347
"true", no attempt is made to compile the sources or to build the library,
16348
when the project is a library project.
16349
 
16350
@item Main_Language
16351
This is a simple attribute. Its value is a string that specifies the
16352
language of the main program.
16353
 
16354
@item  Languages
16355
Expression must be a string list. Each string designates
16356
a programming language that is known to GNAT. The strings are case-insensitive.
16357
 
16358
@end table
16359
 
16360
@node Attribute References
16361
@section Attribute References
16362
 
16363
@noindent
16364
Attribute references are used to retrieve the value of previously defined
16365
attribute for a package or project.
16366
Syntax:
16367
@smallexample
16368
attribute_reference ::=
16369
  attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16370
 
16371
attribute_prefix ::=
16372
  @b{project} |
16373
  <project_simple_name | package_identifier |
16374
  <project_>simple_name . package_identifier
16375
@end smallexample
16376
 
16377
@noindent
16378
If an attribute has not been specified for a given package or project, its
16379
value is the null string or the empty list.
16380
 
16381
@node External Values
16382
@section External Values
16383
 
16384
@noindent
16385
An external value is an expression whose value is obtained from the command
16386
that invoked the processing of the current project file (typically a
16387
gnatmake command).
16388
 
16389
Syntax:
16390
@smallexample
16391
external_value ::=
16392
  @b{external} ( string_literal [, string_literal] )
16393
@end smallexample
16394
 
16395
@noindent
16396
The first string_literal is the string to be used on the command line or
16397
in the environment to specify the external value. The second string_literal,
16398
if present, is the default to use if there is no specification for this
16399
external value either on the command line or in the environment.
16400
 
16401
@node Case Construction
16402
@section Case Construction
16403
 
16404
@noindent
16405
A case construction supports attribute and variable declarations that depend
16406
on the value of a previously declared variable.
16407
 
16408
Syntax:
16409
@smallexample
16410
case_construction ::=
16411
  @b{case} <typed_variable_>name @b{is}
16412
    @{case_item@}
16413
  @b{end case} ;
16414
 
16415
case_item ::=
16416
  @b{when} discrete_choice_list =>
16417
    @{case_construction |
16418
      attribute_declaration |
16419
      variable_declaration |
16420
      empty_declaration@}
16421
 
16422
discrete_choice_list ::=
16423
  string_literal @{| string_literal@} |
16424
    @b{others}
16425
@end smallexample
16426
 
16427
@noindent
16428
Inside a case construction, variable declarations must be for variables that
16429
have already been declared before the case construction.
16430
 
16431
All choices in a choice list must be distinct. The choice lists of two
16432
distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16433
alternatives do not need to include all values of the type. An @code{others}
16434
choice must appear last in the list of alternatives.
16435
 
16436
@node Packages
16437
@section Packages
16438
 
16439
@noindent
16440
A package provides a grouping of variable declarations and attribute
16441
declarations to be used when invoking various GNAT tools. The name of
16442
the package indicates the tool(s) to which it applies.
16443
Syntax:
16444
 
16445
@smallexample
16446
package_declaration ::=
16447
  package_spec | package_renaming
16448
 
16449
package_spec ::=
16450
  @b{package} package_identifier @b{is}
16451
    @{simple_declarative_item@}
16452
  @b{end} package_identifier ;
16453
 
16454
package_identifier ::=
16455
  @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16456
  @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16457
  @code{gnatls} | @code{IDE}     | @code{Pretty_Printer} | @code{Check}
16458
@end smallexample
16459
 
16460
@subsection Package Naming
16461
 
16462
@noindent
16463
The attributes of a @code{Naming} package specifies the naming conventions
16464
that apply to the source files in a project. When invoking other GNAT tools,
16465
they will use the sources in the source directories that satisfy these
16466
naming conventions.
16467
 
16468
The following attributes apply to a @code{Naming} package:
16469
 
16470
@table @code
16471
@item Casing
16472
This is a simple attribute whose value is a string. Legal values of this
16473
string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16474
These strings are themselves case insensitive.
16475
 
16476
@noindent
16477
If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16478
 
16479
@item Dot_Replacement
16480
This is a simple attribute whose string value satisfies the following
16481
requirements:
16482
 
16483
@itemize @bullet
16484
@item It must not be empty
16485
@item It cannot start or end with an alphanumeric character
16486
@item It cannot be a single underscore
16487
@item It cannot start with an underscore followed by an alphanumeric
16488
@item It cannot contain a dot @code{'.'} if longer than one character
16489
@end itemize
16490
 
16491
@noindent
16492
If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16493
 
16494
@item Spec_Suffix
16495
This is an associative array attribute, defined on language names,
16496
whose image is a string that must satisfy the following
16497
conditions:
16498
 
16499
@itemize @bullet
16500
@item It must not be empty
16501
@item It cannot start with an alphanumeric character
16502
@item It cannot start with an underscore followed by an alphanumeric character
16503
@end itemize
16504
 
16505
@noindent
16506
For Ada, the attribute denotes the suffix used in file names that contain
16507
library unit declarations, that is to say units that are package and
16508
subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16509
specified, then the default is @code{".ads"}.
16510
 
16511
For C and C++, the attribute denotes the suffix used in file names that
16512
contain prototypes.
16513
 
16514
@item Body_Suffix
16515
This is an associative array attribute defined on language names,
16516
whose image is a string that must satisfy the following
16517
conditions:
16518
 
16519
@itemize @bullet
16520
@item It must not be empty
16521
@item It cannot start with an alphanumeric character
16522
@item It cannot start with an underscore followed by an alphanumeric character
16523
@item It cannot be a suffix of @code{Spec_Suffix}
16524
@end itemize
16525
 
16526
@noindent
16527
For Ada, the attribute denotes the suffix used in file names that contain
16528
library bodies, that is to say units that are package and subprogram bodies.
16529
If @code{Body_Suffix ("Ada")} is not specified, then the default is
16530
@code{".adb"}.
16531
 
16532
For C and C++, the attribute denotes the suffix used in file names that contain
16533
source code.
16534
 
16535
@item Separate_Suffix
16536
This is a simple attribute whose value satisfies the same conditions as
16537
@code{Body_Suffix}.
16538
 
16539
This attribute is specific to Ada. It denotes the suffix used in file names
16540
that contain separate bodies. If it is not specified, then it defaults to same
16541
value as @code{Body_Suffix ("Ada")}.
16542
 
16543
@item Spec
16544
This is an associative array attribute, specific to Ada, defined over
16545
compilation unit names. The image is a string that is the name of the file
16546
that contains that library unit. The file name is case sensitive if the
16547
conventions of the host operating system require it.
16548
 
16549
@item Body
16550
This is an associative array attribute, specific to Ada, defined over
16551
compilation unit names. The image is a string that is the name of the file
16552
that contains the library unit body for the named unit. The file name is case
16553
sensitive if the conventions of the host operating system require it.
16554
 
16555
@item Specification_Exceptions
16556
This is an associative array attribute defined on language names,
16557
whose value is a list of strings.
16558
 
16559
This attribute is not significant for Ada.
16560
 
16561
For C and C++, each string in the list denotes the name of a file that
16562
contains prototypes, but whose suffix is not necessarily the
16563
@code{Spec_Suffix} for the language.
16564
 
16565
@item Implementation_Exceptions
16566
This is an associative array attribute defined on language names,
16567
whose value is a list of strings.
16568
 
16569
This attribute is not significant for Ada.
16570
 
16571
For C and C++, each string in the list denotes the name of a file that
16572
contains source code, but whose suffix is not necessarily the
16573
@code{Body_Suffix} for the language.
16574
@end table
16575
 
16576
The following attributes of package @code{Naming} are obsolescent. They are
16577
kept as synonyms of other attributes for compatibility with previous versions
16578
of the Project Manager.
16579
 
16580
@table @code
16581
@item Specification_Suffix
16582
This is a synonym of @code{Spec_Suffix}.
16583
 
16584
@item Implementation_Suffix
16585
This is a synonym of @code{Body_Suffix}.
16586
 
16587
@item Specification
16588
This is a synonym of @code{Spec}.
16589
 
16590
@item Implementation
16591
This is a synonym of @code{Body}.
16592
@end table
16593
 
16594
@subsection package Compiler
16595
 
16596
@noindent
16597
The attributes of the @code{Compiler} package specify the compilation options
16598
to be used by the underlying compiler.
16599
 
16600
@table @code
16601
@item  Default_Switches
16602
This is an associative array attribute. Its
16603
domain is a set of language names. Its range is a string list that
16604
specifies the compilation options to be used when compiling a component
16605
written in that language, for which no file-specific switches have been
16606
specified.
16607
 
16608
@item  Switches
16609
This is an associative array attribute. Its domain is
16610
a set of file names. Its range is a string list that specifies the
16611
compilation options to be used when compiling the named file. If a file
16612
is not specified in the Switches attribute, it is compiled with the
16613
options specified by Default_Switches of its language, if defined.
16614
 
16615
@item  Local_Configuration_Pragmas.
16616
This is a simple attribute, whose
16617
value is a path name that designates a file containing configuration pragmas
16618
to be used for all invocations of the compiler for immediate sources of the
16619
project.
16620
@end table
16621
 
16622
@subsection package Builder
16623
 
16624
@noindent
16625
The attributes of package @code{Builder} specify the compilation, binding, and
16626
linking options to be used when building an executable for a project. The
16627
following attributes apply to package @code{Builder}:
16628
 
16629
@table @code
16630
@item Default_Switches
16631
This is an associative array attribute. Its
16632
domain is a set of language names. Its range is a string list that
16633
specifies options to be used when building a main
16634
written in that language, for which no file-specific switches have been
16635
specified.
16636
 
16637
@item Switches
16638
This is an associative array attribute. Its domain is
16639
a set of file names. Its range is a string list that specifies
16640
options to be used when building the named main file. If a main file
16641
is not specified in the Switches attribute, it is built with the
16642
options specified by Default_Switches of its language, if defined.
16643
 
16644
@item Global_Configuration_Pragmas
16645
This is a simple attribute, whose
16646
value is a path name that designates a file that contains configuration pragmas
16647
to be used in every build of an executable. If both local and global
16648
configuration pragmas are specified, a compilation makes use of both sets.
16649
 
16650
 
16651
@item Executable
16652
This is an associative array attribute. Its domain is
16653
a set of main source file names. Its range is a simple string that specifies
16654
the executable file name to be used when linking the specified main source.
16655
If a main source is not specified in the Executable attribute, the executable
16656
file name is deducted from the main source file name.
16657
This attribute has no effect if its value is the empty string.
16658
 
16659
@item Executable_Suffix
16660
This is a simple attribute whose value is the suffix to be added to
16661
the executables that don't have an attribute Executable specified.
16662
@end table
16663
 
16664
@subsection package Gnatls
16665
 
16666
@noindent
16667
The attributes of package @code{Gnatls} specify the tool options to be used
16668
when invoking the library browser @command{gnatls}.
16669
The following attributes apply to package @code{Gnatls}:
16670
 
16671
@table @code
16672
@item Switches
16673
This is a single attribute with a string list value. Each nonempty string
16674
in the list is an option when invoking @code{gnatls}.
16675
@end table
16676
 
16677
@subsection package Binder
16678
 
16679
@noindent
16680
The attributes of package @code{Binder} specify the options to be used
16681
when invoking the binder in the construction of an executable.
16682
The following attributes apply to package @code{Binder}:
16683
 
16684
@table @code
16685
@item     Default_Switches
16686
This is an associative array attribute. Its
16687
domain is a set of language names. Its range is a string list that
16688
specifies options to be used when binding a main
16689
written in that language, for which no file-specific switches have been
16690
specified.
16691
 
16692
@item Switches
16693
This is an associative array attribute. Its domain is
16694
a set of file names. Its range is a string list that specifies
16695
options to be used when binding the named main file. If a main file
16696
is not specified in the Switches attribute, it is bound with the
16697
options specified by Default_Switches of its language, if defined.
16698
@end table
16699
 
16700
@subsection package Linker
16701
 
16702
@noindent
16703
The attributes of package @code{Linker} specify the options to be used when
16704
invoking the linker in the construction of an executable.
16705
The following attributes apply to package @code{Linker}:
16706
 
16707
@table @code
16708
@item     Default_Switches
16709
This is an associative array attribute. Its
16710
domain is a set of language names. Its range is a string list that
16711
specifies options to be used when linking a main
16712
written in that language, for which no file-specific switches have been
16713
specified.
16714
 
16715
@item Switches
16716
This is an associative array attribute. Its domain is
16717
a set of file names. Its range is a string list that specifies
16718
options to be used when linking the named main file. If a main file
16719
is not specified in the Switches attribute, it is linked with the
16720
options specified by Default_Switches of its language, if defined.
16721
 
16722
@item  Linker_Options
16723
This is a string list attribute. Its value specifies additional options that
16724
be given to the linker when linking an executable. This attribute is not
16725
used in the main project, only in projects imported directly or indirectly.
16726
 
16727
@end table
16728
 
16729
@subsection package Cross_Reference
16730
 
16731
@noindent
16732
The attributes of package @code{Cross_Reference} specify the tool options
16733
to be used
16734
when invoking the library tool @command{gnatxref}.
16735
The following attributes apply to package @code{Cross_Reference}:
16736
 
16737
@table @code
16738
@item     Default_Switches
16739
This is an associative array attribute. Its
16740
domain is a set of language names. Its range is a string list that
16741
specifies options to be used when calling @command{gnatxref} on a source
16742
written in that language, for which no file-specific switches have been
16743
specified.
16744
 
16745
@item Switches
16746
This is an associative array attribute. Its domain is
16747
a set of file names. Its range is a string list that specifies
16748
options to be used when calling @command{gnatxref} on the named main source.
16749
If a source is not specified in the Switches attribute, @command{gnatxref} will
16750
be called with the options specified by Default_Switches of its language,
16751
if defined.
16752
@end table
16753
 
16754
@subsection package   Finder
16755
 
16756
@noindent
16757
The attributes of package @code{Finder} specify the tool options to be used
16758
when invoking the search tool @command{gnatfind}.
16759
The following attributes apply to package @code{Finder}:
16760
 
16761
@table @code
16762
@item     Default_Switches
16763
This is an associative array attribute. Its
16764
domain is a set of language names. Its range is a string list that
16765
specifies options to be used when calling @command{gnatfind} on a source
16766
written in that language, for which no file-specific switches have been
16767
specified.
16768
 
16769
@item Switches
16770
This is an associative array attribute. Its domain is
16771
a set of file names. Its range is a string list that specifies
16772
options to be used when calling @command{gnatfind} on the named main source.
16773
If a source is not specified in the Switches attribute, @command{gnatfind} will
16774
be called with the options specified by Default_Switches of its language,
16775
if defined.
16776
@end table
16777
 
16778
@subsection package Check
16779
 
16780
@noindent
16781
The attributes of package @code{Check}
16782
specify the checking rule options to be used
16783
when invoking the checking tool @command{gnatcheck}.
16784
The following attributes apply to package @code{Check}:
16785
 
16786
@table @code
16787
@item     Default_switches
16788
This is an associative array attribute. Its
16789
domain is a set of language names. Its range is a string list that
16790
specifies options to be used when calling @command{gnatcheck} on a source
16791
written in that language. The first string in the range should always be
16792
@code{"-rules"} to specify that all the other options belong to the
16793
@code{-rules} section of the parameters of @command{gnatcheck} call.
16794
 
16795
@end table
16796
 
16797
@subsection package Pretty_Printer
16798
 
16799
@noindent
16800
The attributes of package @code{Pretty_Printer}
16801
specify the tool options to be used
16802
when invoking the formatting tool @command{gnatpp}.
16803
The following attributes apply to package @code{Pretty_Printer}:
16804
 
16805
@table @code
16806
@item     Default_switches
16807
This is an associative array attribute. Its
16808
domain is a set of language names. Its range is a string list that
16809
specifies options to be used when calling @command{gnatpp} on a source
16810
written in that language, for which no file-specific switches have been
16811
specified.
16812
 
16813
@item Switches
16814
This is an associative array attribute. Its domain is
16815
a set of file names. Its range is a string list that specifies
16816
options to be used when calling @command{gnatpp} on the named main source.
16817
If a source is not specified in the Switches attribute, @command{gnatpp} will
16818
be called with the options specified by Default_Switches of its language,
16819
if defined.
16820
@end table
16821
 
16822
@subsection package gnatstub
16823
 
16824
@noindent
16825
The attributes of package @code{gnatstub}
16826
specify the tool options to be used
16827
when invoking the tool @command{gnatstub}.
16828
The following attributes apply to package @code{gnatstub}:
16829
 
16830
@table @code
16831
@item     Default_switches
16832
This is an associative array attribute. Its
16833
domain is a set of language names. Its range is a string list that
16834
specifies options to be used when calling @command{gnatstub} on a source
16835
written in that language, for which no file-specific switches have been
16836
specified.
16837
 
16838
@item Switches
16839
This is an associative array attribute. Its domain is
16840
a set of file names. Its range is a string list that specifies
16841
options to be used when calling @command{gnatstub} on the named main source.
16842
If a source is not specified in the Switches attribute, @command{gnatpp} will
16843
be called with the options specified by Default_Switches of its language,
16844
if defined.
16845
@end table
16846
 
16847
@subsection package Eliminate
16848
 
16849
@noindent
16850
The attributes of package @code{Eliminate}
16851
specify the tool options to be used
16852
when invoking the tool @command{gnatelim}.
16853
The following attributes apply to package @code{Eliminate}:
16854
 
16855
@table @code
16856
@item     Default_switches
16857
This is an associative array attribute. Its
16858
domain is a set of language names. Its range is a string list that
16859
specifies options to be used when calling @command{gnatelim} on a source
16860
written in that language, for which no file-specific switches have been
16861
specified.
16862
 
16863
@item Switches
16864
This is an associative array attribute. Its domain is
16865
a set of file names. Its range is a string list that specifies
16866
options to be used when calling @command{gnatelim} on the named main source.
16867
If a source is not specified in the Switches attribute, @command{gnatelim} will
16868
be called with the options specified by Default_Switches of its language,
16869
if defined.
16870
@end table
16871
 
16872
@subsection package Metrics
16873
 
16874
@noindent
16875
The attributes of package @code{Metrics}
16876
specify the tool options to be used
16877
when invoking the tool @command{gnatmetric}.
16878
The following attributes apply to package @code{Metrics}:
16879
 
16880
@table @code
16881
@item     Default_switches
16882
This is an associative array attribute. Its
16883
domain is a set of language names. Its range is a string list that
16884
specifies options to be used when calling @command{gnatmetric} on a source
16885
written in that language, for which no file-specific switches have been
16886
specified.
16887
 
16888
@item Switches
16889
This is an associative array attribute. Its domain is
16890
a set of file names. Its range is a string list that specifies
16891
options to be used when calling @command{gnatmetric} on the named main source.
16892
If a source is not specified in the Switches attribute, @command{gnatmetric}
16893
will be called with the options specified by Default_Switches of its language,
16894
if defined.
16895
@end table
16896
 
16897
@subsection  package IDE
16898
 
16899
@noindent
16900
The attributes of package @code{IDE} specify the options to be used when using
16901
an Integrated Development Environment such as @command{GPS}.
16902
 
16903
@table @code
16904
@item Remote_Host
16905
This is a simple attribute. Its value is a string that designates the remote
16906
host in a cross-compilation environment, to be used for remote compilation and
16907
debugging. This field should not be specified when running on the local
16908
machine.
16909
 
16910
@item Program_Host
16911
This is a simple attribute. Its value is a string that specifies the
16912
name of IP address of the embedded target in a cross-compilation environment,
16913
on which the program should execute.
16914
 
16915
@item Communication_Protocol
16916
This is a simple string attribute. Its value is the name of the protocol
16917
to use to communicate with the target in a cross-compilation environment,
16918
e.g.@: @code{"wtx"} or @code{"vxworks"}.
16919
 
16920
@item Compiler_Command
16921
This is an associative array attribute, whose domain is a language name. Its
16922
value is  string that denotes the command to be used to invoke the compiler.
16923
The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16924
gnatmake, in particular in the handling of switches.
16925
 
16926
@item Debugger_Command
16927
This is simple attribute, Its value is a string that specifies the name of
16928
the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16929
 
16930
@item Default_Switches
16931
This is an associative array attribute. Its indexes are the name of the
16932
external tools that the GNAT Programming System (GPS) is supporting. Its
16933
value is a list of switches to use when invoking that tool.
16934
 
16935
@item  Gnatlist
16936
This is a simple attribute.  Its value is a string that specifies the name
16937
of the @command{gnatls} utility to be used to retrieve information about the
16938
predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16939
 
16940
@item VCS_Kind
16941
This is a simple attribute. Its value is a string used to specify the
16942
Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16943
ClearCase or Perforce.
16944
 
16945
@item VCS_File_Check
16946
This is a simple attribute. Its value is a string that specifies the
16947
command used by the VCS to check the validity of a file, either
16948
when the user explicitly asks for a check, or as a sanity check before
16949
doing the check-in.
16950
 
16951
@item VCS_Log_Check
16952
This is a simple attribute. Its value is a string that specifies
16953
the command used by the VCS to check the validity of a log file.
16954
 
16955
@item VCS_Repository_Root
16956
The VCS repository root path. This is used to create tags or branches
16957
of the repository. For subversion the value should be the @code{URL}
16958
as specified to check-out the working copy of the repository.
16959
 
16960
@item VCS_Patch_Root
16961
The local root directory to use for building patch file. All patch chunks
16962
will be relative to this path. The root project directory is used if
16963
this value is not defined.
16964
 
16965
@end table
16966
 
16967
@node Package Renamings
16968
@section Package Renamings
16969
 
16970
@noindent
16971
A package can be defined by a renaming declaration. The new package renames
16972
a package declared in a different project file, and has the same attributes
16973
as the package it renames.
16974
Syntax:
16975
@smallexample
16976
package_renaming ::==
16977
  @b{package} package_identifier @b{renames}
16978
       <project_>simple_name.package_identifier ;
16979
@end smallexample
16980
 
16981
@noindent
16982
The package_identifier of the renamed package must be the same as the
16983
package_identifier. The project whose name is the prefix of the renamed
16984
package must contain a package declaration with this name. This project
16985
must appear in the context_clause of the enclosing project declaration,
16986
or be the parent project of the enclosing child project.
16987
 
16988
@node Projects
16989
@section Projects
16990
 
16991
@noindent
16992
A project file specifies a set of rules for constructing a software system.
16993
A project file can be self-contained, or depend on other project files.
16994
Dependencies are expressed through a context clause that names other projects.
16995
 
16996
Syntax:
16997
 
16998
@smallexample
16999
project ::=
17000
  context_clause project_declaration
17001
 
17002
project_declaration ::=
17003
  simple_project_declaration | project_extension
17004
 
17005
simple_project_declaration ::=
17006
  @b{project} <project_>simple_name @b{is}
17007
    @{declarative_item@}
17008
  @b{end} <project_>simple_name;
17009
 
17010
context_clause ::=
17011
  @{with_clause@}
17012
 
17013
with_clause ::=
17014
  [@b{limited}] @b{with} path_name @{ , path_name @} ;
17015
 
17016
path_name ::=
17017
   string_literal
17018
@end smallexample
17019
 
17020
@noindent
17021
A path name denotes a project file. A path name can be absolute or relative.
17022
An absolute path name includes a sequence of directories, in the syntax of
17023
the host operating system, that identifies uniquely the project file in the
17024
file system. A relative path name identifies the project file, relative
17025
to the directory that contains the current project, or relative to a
17026
directory listed in the environment variable ADA_PROJECT_PATH.
17027
Path names are case sensitive if file names in the host operating system
17028
are case sensitive.
17029
 
17030
The syntax of the environment variable ADA_PROJECT_PATH is a list of
17031
directory names separated by colons (semicolons on Windows).
17032
 
17033
A given project name can appear only once in a context_clause.
17034
 
17035
It is illegal for a project imported by a context clause to refer, directly
17036
or indirectly, to the project in which this context clause appears (the
17037
dependency graph cannot contain cycles), except when one of the with_clause
17038
in the cycle is a @code{limited with}.
17039
 
17040
@node Project Extensions
17041
@section Project Extensions
17042
 
17043
@noindent
17044
A project extension introduces a new project, which inherits the declarations
17045
of another project.
17046
Syntax:
17047
@smallexample
17048
 
17049
project_extension ::=
17050
  @b{project} <project_>simple_name  @b{extends} path_name @b{is}
17051
    @{declarative_item@}
17052
  @b{end} <project_>simple_name;
17053
@end smallexample
17054
 
17055
@noindent
17056
The project extension declares a child project. The child project inherits
17057
all the declarations and all the files of the parent project, These inherited
17058
declaration can be overridden in the child project, by means of suitable
17059
declarations.
17060
 
17061
@node Project File Elaboration
17062
@section Project File Elaboration
17063
 
17064
@noindent
17065
A project file is processed as part of the invocation of a gnat tool that
17066
uses the project option. Elaboration of the process file consists in the
17067
sequential elaboration of all its declarations. The computed values of
17068
attributes and variables in the project are then used to establish the
17069
environment in which the gnat tool will execute.
17070
 
17071
@node Obsolescent Features
17072
@chapter Obsolescent Features
17073
 
17074
@noindent
17075
This chapter describes features that are provided by GNAT, but are
17076
considered obsolescent since there are preferred ways of achieving
17077
the same effect. These features are provided solely for historical
17078
compatibility purposes.
17079
 
17080
@menu
17081
* pragma No_Run_Time::
17082
* pragma Ravenscar::
17083
* pragma Restricted_Run_Time::
17084
@end menu
17085
 
17086
@node pragma No_Run_Time
17087
@section pragma No_Run_Time
17088
 
17089
The pragma @code{No_Run_Time} is used to achieve an affect similar
17090
to the use of the "Zero Foot Print" configurable run time, but without
17091
requiring a specially configured run time. The result of using this
17092
pragma, which must be used for all units in a partition, is to restrict
17093
the use of any language features requiring run-time support code. The
17094
preferred usage is to use an appropriately configured run-time that
17095
includes just those features that are to be made accessible.
17096
 
17097
@node pragma Ravenscar
17098
@section pragma Ravenscar
17099
 
17100
The pragma @code{Ravenscar} has exactly the same effect as pragma
17101
@code{Profile (Ravenscar)}. The latter usage is preferred since it
17102
is part of the new Ada 2005 standard.
17103
 
17104
@node pragma Restricted_Run_Time
17105
@section pragma Restricted_Run_Time
17106
 
17107
The pragma @code{Restricted_Run_Time} has exactly the same effect as
17108
pragma @code{Profile (Restricted)}. The latter usage is
17109
preferred since the Ada 2005 pragma @code{Profile} is intended for
17110
this kind of implementation dependent addition.
17111
 
17112
@include fdl.texi
17113
@c GNU Free Documentation License
17114
 
17115
@node Index,,GNU Free Documentation License, Top
17116
@unnumbered Index
17117
 
17118
@printindex cp
17119
 
17120
@contents
17121
 
17122
@bye

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.