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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [gnat_rm.texi] - Blame information for rev 801

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

Line No. Rev Author Line
1 706 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.3 or
22
any later version published by the Free Software Foundation; with no
23
Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24
Manual'', and with no Back-Cover Texts.  A copy of the license is
25
included in the section entitled ``GNU Free Documentation License''.
26
@end copying
27
 
28
@set EDITION GNAT
29
@set DEFAULTLANGUAGEVERSION Ada 2005
30
@set NONDEFAULTLANGUAGEVERSION Ada 95
31
 
32
@settitle GNAT Reference Manual
33
 
34
@setchapternewpage odd
35
@syncodeindex fn cp
36
 
37
@include gcc-common.texi
38
 
39
@dircategory GNU Ada tools
40
@direntry
41
* GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42
@end direntry
43
 
44
@titlepage
45
@title GNAT Reference Manual
46
@subtitle GNAT, The GNU Ada Compiler
47
@versionsubtitle
48
@author AdaCore
49
@page
50
@vskip 0pt plus 1filll
51
 
52
@insertcopying
53
 
54
@end titlepage
55
 
56
@ifnottex
57
@node Top, About This Guide, (dir), (dir)
58
@top GNAT Reference Manual
59
 
60
@noindent
61
GNAT Reference Manual
62
 
63
@noindent
64
GNAT, The GNU Ada Compiler@*
65
GCC version @value{version-GCC}@*
66
 
67
@noindent
68
AdaCore
69
 
70
@menu
71
* About This Guide::
72
* Implementation Defined Pragmas::
73
* Implementation Defined Attributes::
74
* Implementation Defined Restrictions::
75
* Implementation Advice::
76
* Implementation Defined Characteristics::
77
* Intrinsic Subprograms::
78
* Representation Clauses and Pragmas::
79
* Standard Library Routines::
80
* The Implementation of Standard I/O::
81
* The GNAT Library::
82
* Interfacing to Other Languages::
83
* Specialized Needs Annexes::
84
* Implementation of Specific Ada Features::
85
* Implementation of Ada 2012 Features::
86
* Obsolescent Features::
87
* GNU Free Documentation License::
88
* Index::
89
 
90
 --- The Detailed Node Listing ---
91
 
92
About This Guide
93
 
94
* What This Reference Manual Contains::
95
* Related Information::
96
 
97
Implementation Defined Pragmas
98
 
99
* Pragma Abort_Defer::
100
* Pragma Ada_83::
101
* Pragma Ada_95::
102
* Pragma Ada_05::
103
* Pragma Ada_2005::
104
* Pragma Ada_12::
105
* Pragma Ada_2012::
106
* Pragma Annotate::
107
* Pragma Assert::
108
* Pragma Assertion_Policy::
109
* Pragma Assume_No_Invalid_Values::
110
* Pragma Ast_Entry::
111
* Pragma C_Pass_By_Copy::
112
* Pragma Check::
113
* Pragma Check_Name::
114
* Pragma Check_Policy::
115
* Pragma Comment::
116
* Pragma Common_Object::
117
* Pragma Compile_Time_Error::
118
* Pragma Compile_Time_Warning::
119
* Pragma Compiler_Unit::
120
* Pragma Complete_Representation::
121
* Pragma Complex_Representation::
122
* Pragma Component_Alignment::
123
* Pragma Convention_Identifier::
124
* Pragma CPP_Class::
125
* Pragma CPP_Constructor::
126
* Pragma CPP_Virtual::
127
* Pragma CPP_Vtable::
128
* Pragma Debug::
129
* Pragma Debug_Policy::
130
* Pragma Detect_Blocking::
131
* Pragma Elaboration_Checks::
132
* Pragma Eliminate::
133
* Pragma Export_Exception::
134
* Pragma Export_Function::
135
* Pragma Export_Object::
136
* Pragma Export_Procedure::
137
* Pragma Export_Value::
138
* Pragma Export_Valued_Procedure::
139
* Pragma Extend_System::
140
* Pragma Extensions_Allowed::
141
* Pragma External::
142
* Pragma External_Name_Casing::
143
* Pragma Fast_Math::
144
* Pragma Favor_Top_Level::
145
* Pragma Finalize_Storage_Only::
146
* Pragma Float_Representation::
147
* Pragma Ident::
148
* Pragma Implemented::
149
* Pragma Implicit_Packing::
150
* Pragma Import_Exception::
151
* Pragma Import_Function::
152
* Pragma Import_Object::
153
* Pragma Import_Procedure::
154
* Pragma Import_Valued_Procedure::
155
* Pragma Initialize_Scalars::
156
* Pragma Inline_Always::
157
* Pragma Inline_Generic::
158
* Pragma Interface::
159
* Pragma Interface_Name::
160
* Pragma Interrupt_Handler::
161
* Pragma Interrupt_State::
162
* Pragma Invariant::
163
* Pragma Keep_Names::
164
* Pragma License::
165
* Pragma Link_With::
166
* Pragma Linker_Alias::
167
* Pragma Linker_Constructor::
168
* Pragma Linker_Destructor::
169
* Pragma Linker_Section::
170
* Pragma Long_Float::
171
* Pragma Machine_Attribute::
172
* Pragma Main::
173
* Pragma Main_Storage::
174
* Pragma No_Body::
175
* Pragma No_Return::
176
* Pragma No_Strict_Aliasing ::
177
* Pragma Normalize_Scalars::
178
* Pragma Obsolescent::
179
* Pragma Optimize_Alignment::
180
* Pragma Ordered::
181
* Pragma Passive::
182
* Pragma Persistent_BSS::
183
* Pragma Polling::
184
* Pragma Postcondition::
185
* Pragma Precondition::
186
* Pragma Profile (Ravenscar)::
187
* Pragma Profile (Restricted)::
188
* Pragma Psect_Object::
189
* Pragma Pure_Function::
190
* Pragma Remote_Access_Type::
191
* Pragma Restriction_Warnings::
192
* Pragma Shared::
193
* Pragma Short_Circuit_And_Or::
194
* Pragma Short_Descriptors::
195
* Pragma Simple_Storage_Pool_Type::
196
* Pragma Source_File_Name::
197
* Pragma Source_File_Name_Project::
198
* Pragma Source_Reference::
199
* Pragma Static_Elaboration_Desired::
200
* Pragma Stream_Convert::
201
* Pragma Style_Checks::
202
* Pragma Subtitle::
203
* Pragma Suppress::
204
* Pragma Suppress_All::
205
* Pragma Suppress_Exception_Locations::
206
* Pragma Suppress_Initialization::
207
* Pragma Task_Info::
208
* Pragma Task_Name::
209
* Pragma Task_Storage::
210
* Pragma Test_Case::
211
* Pragma Thread_Local_Storage::
212
* Pragma Time_Slice::
213
* Pragma Title::
214
* Pragma Unchecked_Union::
215
* Pragma Unimplemented_Unit::
216
* Pragma Universal_Aliasing ::
217
* Pragma Universal_Data::
218
* Pragma Unmodified::
219
* Pragma Unreferenced::
220
* Pragma Unreferenced_Objects::
221
* Pragma Unreserve_All_Interrupts::
222
* Pragma Unsuppress::
223
* Pragma Use_VADS_Size::
224
* Pragma Validity_Checks::
225
* Pragma Volatile::
226
* Pragma Warnings::
227
* Pragma Weak_External::
228
* Pragma Wide_Character_Encoding::
229
 
230
Implementation Defined Attributes
231
 
232
* Abort_Signal::
233
* Address_Size::
234
* Asm_Input::
235
* Asm_Output::
236
* AST_Entry::
237
* Bit::
238
* Bit_Position::
239
* Compiler_Version::
240
* Code_Address::
241
* Default_Bit_Order::
242
* Descriptor_Size::
243
* Elaborated::
244
* Elab_Body::
245
* Elab_Spec::
246
* Elab_Subp_Body::
247
* Emax::
248
* Enabled::
249
* Enum_Rep::
250
* Enum_Val::
251
* Epsilon::
252
* Fixed_Value::
253
* Has_Access_Values::
254
* Has_Discriminants::
255
* Img::
256
* Integer_Value::
257
* Invalid_Value::
258
* Large::
259
* Machine_Size::
260
* Mantissa::
261
* Max_Interrupt_Priority::
262
* Max_Priority::
263
* Maximum_Alignment::
264
* Mechanism_Code::
265
* Null_Parameter::
266
* Object_Size::
267
* Old::
268
* Passed_By_Reference::
269
* Pool_Address::
270
* Range_Length::
271
* Result::
272
* Safe_Emax::
273
* Safe_Large::
274
* Simple_Storage_Pool::
275
* Small::
276
* Storage_Unit::
277
* Stub_Type::
278
* System_Allocator_Alignment::
279
* Target_Name::
280
* Tick::
281
* To_Address::
282
* Type_Class::
283
* UET_Address::
284
* Unconstrained_Array::
285
* Universal_Literal_String::
286
* Unrestricted_Access::
287
* VADS_Size::
288
* Value_Size::
289
* Wchar_T_Size::
290
* Word_Size::
291
 
292
Implementation Defined Restrictions
293
 
294
* Partition-Wide Restrictions::
295
* Program Unit Level Restrictions::
296
 
297
Partition-Wide Restrictions
298
 
299
* Immediate_Reclamation::
300
* Max_Asynchronous_Select_Nesting::
301
* Max_Entry_Queue_Length::
302
* Max_Protected_Entries::
303
* Max_Select_Alternatives::
304
* Max_Storage_At_Blocking::
305
* Max_Task_Entries::
306
* Max_Tasks::
307
* No_Abort_Statements::
308
* No_Access_Parameter_Allocators::
309
* No_Access_Subprograms::
310
* No_Allocators::
311
* No_Anonymous_Allocators::
312
* No_Calendar::
313
* No_Coextensions::
314
* No_Default_Initialization::
315
* No_Delay::
316
* No_Dependence::
317
* No_Direct_Boolean_Operators::
318
* No_Dispatch::
319
* No_Dispatching_Calls::
320
* No_Dynamic_Attachment::
321
* No_Dynamic_Priorities::
322
* No_Entry_Calls_In_Elaboration_Code::
323
* No_Enumeration_Maps::
324
* No_Exception_Handlers::
325
* No_Exception_Propagation::
326
* No_Exception_Registration::
327
* No_Exceptions::
328
* No_Finalization::
329
* No_Fixed_Point::
330
* No_Floating_Point::
331
* No_Implicit_Conditionals::
332
* No_Implicit_Dynamic_Code::
333
* No_Implicit_Heap_Allocations::
334
* No_Implicit_Loops::
335
* No_Initialize_Scalars::
336
* No_IO::
337
* No_Local_Allocators::
338
* No_Local_Protected_Objects::
339
* No_Local_Timing_Events::
340
* No_Nested_Finalization::
341
* No_Protected_Type_Allocators::
342
* No_Protected_Types::
343
* No_Recursion::
344
* No_Reentrancy::
345
* No_Relative_Delay::
346
* No_Requeue_Statements::
347
* No_Secondary_Stack::
348
* No_Select_Statements::
349
* No_Specific_Termination_Handlers::
350
* No_Specification_of_Aspect::
351
* No_Standard_Allocators_After_Elaboration::
352
* No_Standard_Storage_Pools::
353
* No_Stream_Optimizations::
354
* No_Streams::
355
* No_Task_Allocators::
356
* No_Task_Attributes_Package::
357
* No_Task_Hierarchy::
358
* No_Task_Termination::
359
* No_Tasking::
360
* No_Terminate_Alternatives::
361
* No_Unchecked_Access::
362
* Simple_Barriers::
363
* Static_Priorities::
364
* Static_Storage_Size::
365
 
366
Program Unit Level Restrictions
367
 
368
* No_Elaboration_Code::
369
* No_Entry_Queue::
370
* No_Implementation_Aspect_Specifications::
371
* No_Implementation_Attributes::
372
* No_Implementation_Identifiers::
373
* No_Implementation_Pragmas::
374
* No_Implementation_Restrictions::
375
* No_Implementation_Units::
376
* No_Implicit_Aliasing::
377
* No_Obsolescent_Features::
378
* No_Wide_Characters::
379
* SPARK::
380
 
381
The Implementation of Standard I/O
382
 
383
* Standard I/O Packages::
384
* FORM Strings::
385
* Direct_IO::
386
* Sequential_IO::
387
* Text_IO::
388
* Wide_Text_IO::
389
* Wide_Wide_Text_IO::
390
* Stream_IO::
391
* Text Translation::
392
* Shared Files::
393
* Filenames encoding::
394
* Open Modes::
395
* Operations on C Streams::
396
* Interfacing to C Streams::
397
 
398
The GNAT Library
399
 
400
* Ada.Characters.Latin_9 (a-chlat9.ads)::
401
* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
402
* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
403
* Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
404
* Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
405
* Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
406
* Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
407
* Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
408
* Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
409
* Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
410
* Ada.Containers.Formal_Vectors (a-cofove.ads)::
411
* Ada.Command_Line.Environment (a-colien.ads)::
412
* Ada.Command_Line.Remove (a-colire.ads)::
413
* Ada.Command_Line.Response_File (a-clrefi.ads)::
414
* Ada.Direct_IO.C_Streams (a-diocst.ads)::
415
* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
416
* Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
417
* Ada.Exceptions.Traceback (a-exctra.ads)::
418
* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
419
* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
420
* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
421
* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
422
* Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
423
* Ada.Text_IO.C_Streams (a-tiocst.ads)::
424
* Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
425
* Ada.Wide_Characters.Unicode (a-wichun.ads)::
426
* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
427
* Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
428
* Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
429
* Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
430
* Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
431
* GNAT.Altivec (g-altive.ads)::
432
* GNAT.Altivec.Conversions (g-altcon.ads)::
433
* GNAT.Altivec.Vector_Operations (g-alveop.ads)::
434
* GNAT.Altivec.Vector_Types (g-alvety.ads)::
435
* GNAT.Altivec.Vector_Views (g-alvevi.ads)::
436
* GNAT.Array_Split (g-arrspl.ads)::
437
* GNAT.AWK (g-awk.ads)::
438
* GNAT.Bounded_Buffers (g-boubuf.ads)::
439
* GNAT.Bounded_Mailboxes (g-boumai.ads)::
440
* GNAT.Bubble_Sort (g-bubsor.ads)::
441
* GNAT.Bubble_Sort_A (g-busora.ads)::
442
* GNAT.Bubble_Sort_G (g-busorg.ads)::
443
* GNAT.Byte_Order_Mark (g-byorma.ads)::
444
* GNAT.Byte_Swapping (g-bytswa.ads)::
445
* GNAT.Calendar (g-calend.ads)::
446
* GNAT.Calendar.Time_IO (g-catiio.ads)::
447
* GNAT.Case_Util (g-casuti.ads)::
448
* GNAT.CGI (g-cgi.ads)::
449
* GNAT.CGI.Cookie (g-cgicoo.ads)::
450
* GNAT.CGI.Debug (g-cgideb.ads)::
451
* GNAT.Command_Line (g-comlin.ads)::
452
* GNAT.Compiler_Version (g-comver.ads)::
453
* GNAT.Ctrl_C (g-ctrl_c.ads)::
454
* GNAT.CRC32 (g-crc32.ads)::
455
* GNAT.Current_Exception (g-curexc.ads)::
456
* GNAT.Debug_Pools (g-debpoo.ads)::
457
* GNAT.Debug_Utilities (g-debuti.ads)::
458
* GNAT.Decode_String (g-decstr.ads)::
459
* GNAT.Decode_UTF8_String (g-deutst.ads)::
460
* GNAT.Directory_Operations (g-dirope.ads)::
461
* GNAT.Directory_Operations.Iteration (g-diopit.ads)::
462
* GNAT.Dynamic_HTables (g-dynhta.ads)::
463
* GNAT.Dynamic_Tables (g-dyntab.ads)::
464
* GNAT.Encode_String (g-encstr.ads)::
465
* GNAT.Encode_UTF8_String (g-enutst.ads)::
466
* GNAT.Exception_Actions (g-excact.ads)::
467
* GNAT.Exception_Traces (g-exctra.ads)::
468
* GNAT.Exceptions (g-except.ads)::
469
* GNAT.Expect (g-expect.ads)::
470
* GNAT.Expect.TTY (g-exptty.ads)::
471
* GNAT.Float_Control (g-flocon.ads)::
472
* GNAT.Heap_Sort (g-heasor.ads)::
473
* GNAT.Heap_Sort_A (g-hesora.ads)::
474
* GNAT.Heap_Sort_G (g-hesorg.ads)::
475
* GNAT.HTable (g-htable.ads)::
476
* GNAT.IO (g-io.ads)::
477
* GNAT.IO_Aux (g-io_aux.ads)::
478
* GNAT.Lock_Files (g-locfil.ads)::
479
* GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
480
* GNAT.MBBS_Float_Random (g-mbflra.ads)::
481
* GNAT.MD5 (g-md5.ads)::
482
* GNAT.Memory_Dump (g-memdum.ads)::
483
* GNAT.Most_Recent_Exception (g-moreex.ads)::
484
* GNAT.OS_Lib (g-os_lib.ads)::
485
* GNAT.Perfect_Hash_Generators (g-pehage.ads)::
486
* GNAT.Random_Numbers (g-rannum.ads)::
487
* GNAT.Regexp (g-regexp.ads)::
488
* GNAT.Registry (g-regist.ads)::
489
* GNAT.Regpat (g-regpat.ads)::
490
* GNAT.Secondary_Stack_Info (g-sestin.ads)::
491
* GNAT.Semaphores (g-semaph.ads)::
492
* GNAT.Serial_Communications (g-sercom.ads)::
493
* GNAT.SHA1 (g-sha1.ads)::
494
* GNAT.SHA224 (g-sha224.ads)::
495
* GNAT.SHA256 (g-sha256.ads)::
496
* GNAT.SHA384 (g-sha384.ads)::
497
* GNAT.SHA512 (g-sha512.ads)::
498
* GNAT.Signals (g-signal.ads)::
499
* GNAT.Sockets (g-socket.ads)::
500
* GNAT.Source_Info (g-souinf.ads)::
501
* GNAT.Spelling_Checker (g-speche.ads)::
502
* GNAT.Spelling_Checker_Generic (g-spchge.ads)::
503
* GNAT.Spitbol.Patterns (g-spipat.ads)::
504
* GNAT.Spitbol (g-spitbo.ads)::
505
* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
506
* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
507
* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
508
* GNAT.SSE (g-sse.ads)::
509
* GNAT.SSE.Vector_Types (g-ssvety.ads)::
510
* GNAT.Strings (g-string.ads)::
511
* GNAT.String_Split (g-strspl.ads)::
512
* GNAT.Table (g-table.ads)::
513
* GNAT.Task_Lock (g-tasloc.ads)::
514
* GNAT.Threads (g-thread.ads)::
515
* GNAT.Time_Stamp (g-timsta.ads)::
516
* GNAT.Traceback (g-traceb.ads)::
517
* GNAT.Traceback.Symbolic (g-trasym.ads)::
518
* GNAT.UTF_32 (g-utf_32.ads)::
519
* GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
520
* GNAT.Wide_Spelling_Checker (g-wispch.ads)::
521
* GNAT.Wide_String_Split (g-wistsp.ads)::
522
* GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
523
* GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
524
* Interfaces.C.Extensions (i-cexten.ads)::
525
* Interfaces.C.Streams (i-cstrea.ads)::
526
* Interfaces.CPP (i-cpp.ads)::
527
* Interfaces.Packed_Decimal (i-pacdec.ads)::
528
* Interfaces.VxWorks (i-vxwork.ads)::
529
* Interfaces.VxWorks.IO (i-vxwoio.ads)::
530
* System.Address_Image (s-addima.ads)::
531
* System.Assertions (s-assert.ads)::
532
* System.Memory (s-memory.ads)::
533
* System.Partition_Interface (s-parint.ads)::
534
* System.Pool_Global (s-pooglo.ads)::
535
* System.Pool_Local (s-pooloc.ads)::
536
* System.Restrictions (s-restri.ads)::
537
* System.Rident (s-rident.ads)::
538
* System.Strings.Stream_Ops (s-ststop.ads)::
539
* System.Task_Info (s-tasinf.ads)::
540
* System.Wch_Cnv (s-wchcnv.ads)::
541
* System.Wch_Con (s-wchcon.ads)::
542
 
543
Text_IO
544
 
545
* Text_IO Stream Pointer Positioning::
546
* Text_IO Reading and Writing Non-Regular Files::
547
* Get_Immediate::
548
* Treating Text_IO Files as Streams::
549
* Text_IO Extensions::
550
* Text_IO Facilities for Unbounded Strings::
551
 
552
Wide_Text_IO
553
 
554
* Wide_Text_IO Stream Pointer Positioning::
555
* Wide_Text_IO Reading and Writing Non-Regular Files::
556
 
557
Wide_Wide_Text_IO
558
 
559
* Wide_Wide_Text_IO Stream Pointer Positioning::
560
* Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
561
 
562
Interfacing to Other Languages
563
 
564
* Interfacing to C::
565
* Interfacing to C++::
566
* Interfacing to COBOL::
567
* Interfacing to Fortran::
568
* Interfacing to non-GNAT Ada code::
569
 
570
Specialized Needs Annexes
571
 
572
Implementation of Specific Ada Features
573
* Machine Code Insertions::
574
* GNAT Implementation of Tasking::
575
* GNAT Implementation of Shared Passive Packages::
576
* Code Generation for Array Aggregates::
577
* The Size of Discriminated Records with Default Discriminants::
578
* Strict Conformance to the Ada Reference Manual::
579
 
580
Implementation of Ada 2012 Features
581
 
582
Obsolescent Features
583
 
584
GNU Free Documentation License
585
 
586
Index
587
@end menu
588
 
589
@end ifnottex
590
 
591
@node About This Guide
592
@unnumbered About This Guide
593
 
594
@noindent
595
This manual contains useful information in writing programs using the
596
@value{EDITION} compiler.  It includes information on implementation dependent
597
characteristics of @value{EDITION}, including all the information required by
598
Annex M of the Ada language standard.
599
 
600
@value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
601
Ada 83 compatibility mode.
602
By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
603
but you can override with a compiler switch
604
to explicitly specify the language version.
605
(Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
606
@value{EDITION} User's Guide}, for details on these switches.)
607
Throughout this manual, references to ``Ada'' without a year suffix
608
apply to both the Ada 95 and Ada 2005 versions of the language.
609
 
610
Ada is designed to be highly portable.
611
In general, a program will have the same effect even when compiled by
612
different compilers on different platforms.
613
However, since Ada is designed to be used in a
614
wide variety of applications, it also contains a number of system
615
dependent features to be used in interfacing to the external world.
616
@cindex Implementation-dependent features
617
@cindex Portability
618
 
619
Note: Any program that makes use of implementation-dependent features
620
may be non-portable.  You should follow good programming practice and
621
isolate and clearly document any sections of your program that make use
622
of these features in a non-portable manner.
623
 
624
@ifset PROEDITION
625
For ease of exposition, ``@value{EDITION}'' will be referred to simply as
626
``GNAT'' in the remainder of this document.
627
@end ifset
628
 
629
@menu
630
* What This Reference Manual Contains::
631
* Conventions::
632
* Related Information::
633
@end menu
634
 
635
@node What This Reference Manual Contains
636
@unnumberedsec What This Reference Manual Contains
637
 
638
@noindent
639
This reference manual contains the following chapters:
640
 
641
@itemize @bullet
642
@item
643
@ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
644
pragmas, which can be used to extend and enhance the functionality of the
645
compiler.
646
 
647
@item
648
@ref{Implementation Defined Attributes}, lists GNAT
649
implementation-dependent attributes, which can be used to extend and
650
enhance the functionality of the compiler.
651
 
652
@item
653
@ref{Implementation Defined Restrictions}, lists GNAT
654
implementation-dependent restrictions, which can be used to extend and
655
enhance the functionality of the compiler.
656
 
657
@item
658
@ref{Implementation Advice}, provides information on generally
659
desirable behavior which are not requirements that all compilers must
660
follow since it cannot be provided on all systems, or which may be
661
undesirable on some systems.
662
 
663
@item
664
@ref{Implementation Defined Characteristics}, provides a guide to
665
minimizing implementation dependent features.
666
 
667
@item
668
@ref{Intrinsic Subprograms}, describes the intrinsic subprograms
669
implemented by GNAT, and how they can be imported into user
670
application programs.
671
 
672
@item
673
@ref{Representation Clauses and Pragmas}, describes in detail the
674
way that GNAT represents data, and in particular the exact set
675
of representation clauses and pragmas that is accepted.
676
 
677
@item
678
@ref{Standard Library Routines}, provides a listing of packages and a
679
brief description of the functionality that is provided by Ada's
680
extensive set of standard library routines as implemented by GNAT@.
681
 
682
@item
683
@ref{The Implementation of Standard I/O}, details how the GNAT
684
implementation of the input-output facilities.
685
 
686
@item
687
@ref{The GNAT Library}, is a catalog of packages that complement
688
the Ada predefined library.
689
 
690
@item
691
@ref{Interfacing to Other Languages}, describes how programs
692
written in Ada using GNAT can be interfaced to other programming
693
languages.
694
 
695
@ref{Specialized Needs Annexes}, describes the GNAT implementation of all
696
of the specialized needs annexes.
697
 
698
@item
699
@ref{Implementation of Specific Ada Features}, discusses issues related
700
to GNAT's implementation of machine code insertions, tasking, and several
701
other features.
702
 
703
@item
704
@ref{Implementation of Ada 2012 Features}, describes the status of the
705
GNAT implementation of the Ada 2012 language standard.
706
 
707
@item
708
@ref{Obsolescent Features} documents implementation dependent features,
709
including pragmas and attributes, which are considered obsolescent, since
710
there are other preferred ways of achieving the same results. These
711
obsolescent forms are retained for backwards compatibility.
712
 
713
@end itemize
714
 
715
@cindex Ada 95 Language Reference Manual
716
@cindex Ada 2005 Language Reference Manual
717
@noindent
718
This reference manual assumes a basic familiarity with the Ada 95 language, as
719
described in the International Standard ANSI/ISO/IEC-8652:1995,
720
January 1995.
721
It does not require knowledge of the new features introduced by Ada 2005,
722
(officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
723
and Amendment 1).
724
Both reference manuals are included in the GNAT documentation
725
package.
726
 
727
@node Conventions
728
@unnumberedsec Conventions
729
@cindex Conventions, typographical
730
@cindex Typographical conventions
731
 
732
@noindent
733
Following are examples of the typographical and graphic conventions used
734
in this guide:
735
 
736
@itemize @bullet
737
@item
738
@code{Functions}, @code{utility program names}, @code{standard names},
739
and @code{classes}.
740
 
741
@item
742
@code{Option flags}
743
 
744
@item
745
@file{File names}, @samp{button names}, and @samp{field names}.
746
 
747
@item
748
@code{Variables}, @env{environment variables}, and @var{metasyntactic
749
variables}.
750
 
751
@item
752
@emph{Emphasis}.
753
 
754
@item
755
[optional information or parameters]
756
 
757
@item
758
Examples are described by text
759
@smallexample
760
and then shown this way.
761
@end smallexample
762
@end itemize
763
 
764
@noindent
765
Commands that are entered by the user are preceded in this manual by the
766
characters @samp{$ } (dollar sign followed by space).  If your system uses this
767
sequence as a prompt, then the commands will appear exactly as you see them
768
in the manual.  If your system uses some other prompt, then the command will
769
appear with the @samp{$} replaced by whatever prompt character you are using.
770
 
771
@node Related Information
772
@unnumberedsec Related Information
773
@noindent
774
See the following documents for further information on GNAT:
775
 
776
@itemize @bullet
777
@item
778
@xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
779
@value{EDITION} User's Guide}, which provides information on how to use the
780
GNAT compiler system.
781
 
782
@item
783
@cite{Ada 95 Reference Manual}, which contains all reference
784
material for the Ada 95 programming language.
785
 
786
@item
787
@cite{Ada 95 Annotated Reference Manual}, which is an annotated version
788
of the Ada 95 standard.  The annotations describe
789
detailed aspects of the design decision, and in particular contain useful
790
sections on Ada 83 compatibility.
791
 
792
@item
793
@cite{Ada 2005 Reference Manual}, which contains all reference
794
material for the Ada 2005 programming language.
795
 
796
@item
797
@cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
798
of the Ada 2005 standard.  The annotations describe
799
detailed aspects of the design decision, and in particular contain useful
800
sections on Ada 83 and Ada 95 compatibility.
801
 
802
@item
803
@cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
804
which contains specific information on compatibility between GNAT and
805
DEC Ada 83 systems.
806
 
807
@item
808
@cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
809
describes in detail the pragmas and attributes provided by the DEC Ada 83
810
compiler system.
811
 
812
@end itemize
813
 
814
@node Implementation Defined Pragmas
815
@chapter Implementation Defined Pragmas
816
 
817
@noindent
818
Ada defines a set of pragmas that can be used to supply additional
819
information to the compiler.  These language defined pragmas are
820
implemented in GNAT and work as described in the Ada Reference Manual.
821
 
822
In addition, Ada allows implementations to define additional pragmas
823
whose meaning is defined by the implementation.  GNAT provides a number
824
of these implementation-defined pragmas, which can be used to extend
825
and enhance the functionality of the compiler.  This section of the GNAT
826
Reference Manual describes these additional pragmas.
827
 
828
Note that any program using these pragmas might not be portable to other
829
compilers (although GNAT implements this set of pragmas on all
830
platforms).  Therefore if portability to other compilers is an important
831
consideration, the use of these pragmas should be minimized.
832
 
833
@menu
834
* Pragma Abort_Defer::
835
* Pragma Ada_83::
836
* Pragma Ada_95::
837
* Pragma Ada_05::
838
* Pragma Ada_2005::
839
* Pragma Ada_12::
840
* Pragma Ada_2012::
841
* Pragma Annotate::
842
* Pragma Assert::
843
* Pragma Assertion_Policy::
844
* Pragma Assume_No_Invalid_Values::
845
* Pragma Ast_Entry::
846
* Pragma C_Pass_By_Copy::
847
* Pragma Check::
848
* Pragma Check_Name::
849
* Pragma Check_Policy::
850
* Pragma Comment::
851
* Pragma Common_Object::
852
* Pragma Compile_Time_Error::
853
* Pragma Compile_Time_Warning::
854
* Pragma Compiler_Unit::
855
* Pragma Complete_Representation::
856
* Pragma Complex_Representation::
857
* Pragma Component_Alignment::
858
* Pragma Convention_Identifier::
859
* Pragma CPP_Class::
860
* Pragma CPP_Constructor::
861
* Pragma CPP_Virtual::
862
* Pragma CPP_Vtable::
863
* Pragma Debug::
864
* Pragma Debug_Policy::
865
* Pragma Detect_Blocking::
866
* Pragma Elaboration_Checks::
867
* Pragma Eliminate::
868
* Pragma Export_Exception::
869
* Pragma Export_Function::
870
* Pragma Export_Object::
871
* Pragma Export_Procedure::
872
* Pragma Export_Value::
873
* Pragma Export_Valued_Procedure::
874
* Pragma Extend_System::
875
* Pragma Extensions_Allowed::
876
* Pragma External::
877
* Pragma External_Name_Casing::
878
* Pragma Fast_Math::
879
* Pragma Favor_Top_Level::
880
* Pragma Finalize_Storage_Only::
881
* Pragma Float_Representation::
882
* Pragma Ident::
883
* Pragma Implemented::
884
* Pragma Implicit_Packing::
885
* Pragma Import_Exception::
886
* Pragma Import_Function::
887
* Pragma Import_Object::
888
* Pragma Import_Procedure::
889
* Pragma Import_Valued_Procedure::
890
* Pragma Initialize_Scalars::
891
* Pragma Inline_Always::
892
* Pragma Inline_Generic::
893
* Pragma Interface::
894
* Pragma Interface_Name::
895
* Pragma Interrupt_Handler::
896
* Pragma Interrupt_State::
897
* Pragma Invariant::
898
* Pragma Keep_Names::
899
* Pragma License::
900
* Pragma Link_With::
901
* Pragma Linker_Alias::
902
* Pragma Linker_Constructor::
903
* Pragma Linker_Destructor::
904
* Pragma Linker_Section::
905
* Pragma Long_Float::
906
* Pragma Machine_Attribute::
907
* Pragma Main::
908
* Pragma Main_Storage::
909
* Pragma No_Body::
910
* Pragma No_Return::
911
* Pragma No_Strict_Aliasing::
912
* Pragma Normalize_Scalars::
913
* Pragma Obsolescent::
914
* Pragma Optimize_Alignment::
915
* Pragma Ordered::
916
* Pragma Passive::
917
* Pragma Persistent_BSS::
918
* Pragma Polling::
919
* Pragma Postcondition::
920
* Pragma Precondition::
921
* Pragma Profile (Ravenscar)::
922
* Pragma Profile (Restricted)::
923
* Pragma Psect_Object::
924
* Pragma Pure_Function::
925
* Pragma Remote_Access_Type::
926
* Pragma Restriction_Warnings::
927
* Pragma Shared::
928
* Pragma Short_Circuit_And_Or::
929
* Pragma Short_Descriptors::
930
* Pragma Simple_Storage_Pool_Type::
931
* Pragma Source_File_Name::
932
* Pragma Source_File_Name_Project::
933
* Pragma Source_Reference::
934
* Pragma Static_Elaboration_Desired::
935
* Pragma Stream_Convert::
936
* Pragma Style_Checks::
937
* Pragma Subtitle::
938
* Pragma Suppress::
939
* Pragma Suppress_All::
940
* Pragma Suppress_Exception_Locations::
941
* Pragma Suppress_Initialization::
942
* Pragma Task_Info::
943
* Pragma Task_Name::
944
* Pragma Task_Storage::
945
* Pragma Test_Case::
946
* Pragma Thread_Local_Storage::
947
* Pragma Time_Slice::
948
* Pragma Title::
949
* Pragma Unchecked_Union::
950
* Pragma Unimplemented_Unit::
951
* Pragma Universal_Aliasing ::
952
* Pragma Universal_Data::
953
* Pragma Unmodified::
954
* Pragma Unreferenced::
955
* Pragma Unreferenced_Objects::
956
* Pragma Unreserve_All_Interrupts::
957
* Pragma Unsuppress::
958
* Pragma Use_VADS_Size::
959
* Pragma Validity_Checks::
960
* Pragma Volatile::
961
* Pragma Warnings::
962
* Pragma Weak_External::
963
* Pragma Wide_Character_Encoding::
964
@end menu
965
 
966
@node Pragma Abort_Defer
967
@unnumberedsec Pragma Abort_Defer
968
@findex Abort_Defer
969
@cindex Deferring aborts
970
@noindent
971
Syntax:
972
@smallexample
973
pragma Abort_Defer;
974
@end smallexample
975
 
976
@noindent
977
This pragma must appear at the start of the statement sequence of a
978
handled sequence of statements (right after the @code{begin}).  It has
979
the effect of deferring aborts for the sequence of statements (but not
980
for the declarations or handlers, if any, associated with this statement
981
sequence).
982
 
983
@node Pragma Ada_83
984
@unnumberedsec Pragma Ada_83
985
@findex Ada_83
986
@noindent
987
Syntax:
988
@smallexample @c ada
989
pragma Ada_83;
990
@end smallexample
991
 
992
@noindent
993
A configuration pragma that establishes Ada 83 mode for the unit to
994
which it applies, regardless of the mode set by the command line
995
switches.  In Ada 83 mode, GNAT attempts to be as compatible with
996
the syntax and semantics of Ada 83, as defined in the original Ada
997
83 Reference Manual as possible.  In particular, the keywords added by Ada 95
998
and Ada 2005 are not recognized, optional package bodies are allowed,
999
and generics may name types with unknown discriminants without using
1000
the @code{(<>)} notation.  In addition, some but not all of the additional
1001
restrictions of Ada 83 are enforced.
1002
 
1003
Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1004
Ada 83 code to be compiled and adapted to GNAT with less effort.
1005
Secondly, it aids in keeping code backwards compatible with Ada 83.
1006
However, there is no guarantee that code that is processed correctly
1007
by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1008
83 compiler, since GNAT does not enforce all the additional checks
1009
required by Ada 83.
1010
 
1011
@node Pragma Ada_95
1012
@unnumberedsec Pragma Ada_95
1013
@findex Ada_95
1014
@noindent
1015
Syntax:
1016
@smallexample @c ada
1017
pragma Ada_95;
1018
@end smallexample
1019
 
1020
@noindent
1021
A configuration pragma that establishes Ada 95 mode for the unit to which
1022
it applies, regardless of the mode set by the command line switches.
1023
This mode is set automatically for the @code{Ada} and @code{System}
1024
packages and their children, so you need not specify it in these
1025
contexts.  This pragma is useful when writing a reusable component that
1026
itself uses Ada 95 features, but which is intended to be usable from
1027
either Ada 83 or Ada 95 programs.
1028
 
1029
@node Pragma Ada_05
1030
@unnumberedsec Pragma Ada_05
1031
@findex Ada_05
1032
@noindent
1033
Syntax:
1034
@smallexample @c ada
1035
pragma Ada_05;
1036
@end smallexample
1037
 
1038
@noindent
1039
A configuration pragma that establishes Ada 2005 mode for the unit to which
1040
it applies, regardless of the mode set by the command line switches.
1041
This pragma is useful when writing a reusable component that
1042
itself uses Ada 2005 features, but which is intended to be usable from
1043
either Ada 83 or Ada 95 programs.
1044
 
1045
@node Pragma Ada_2005
1046
@unnumberedsec Pragma Ada_2005
1047
@findex Ada_2005
1048
@noindent
1049
Syntax:
1050
@smallexample @c ada
1051
pragma Ada_2005;
1052
@end smallexample
1053
 
1054
@noindent
1055
This configuration pragma is a synonym for pragma Ada_05 and has the
1056
same syntax and effect.
1057
 
1058
@node Pragma Ada_12
1059
@unnumberedsec Pragma Ada_12
1060
@findex Ada_12
1061
@noindent
1062
Syntax:
1063
@smallexample @c ada
1064
pragma Ada_12;
1065
@end smallexample
1066
 
1067
@noindent
1068
A configuration pragma that establishes Ada 2012 mode for the unit to which
1069
it applies, regardless of the mode set by the command line switches.
1070
This mode is set automatically for the @code{Ada} and @code{System}
1071
packages and their children, so you need not specify it in these
1072
contexts.  This pragma is useful when writing a reusable component that
1073
itself uses Ada 2012 features, but which is intended to be usable from
1074
Ada 83, Ada 95, or Ada 2005 programs.
1075
 
1076
@node Pragma Ada_2012
1077
@unnumberedsec Pragma Ada_2012
1078
@findex Ada_2005
1079
@noindent
1080
Syntax:
1081
@smallexample @c ada
1082
pragma Ada_2012;
1083
@end smallexample
1084
 
1085
@noindent
1086
This configuration pragma is a synonym for pragma Ada_12 and has the
1087
same syntax and effect.
1088
 
1089
@node Pragma Annotate
1090
@unnumberedsec Pragma Annotate
1091
@findex Annotate
1092
@noindent
1093
Syntax:
1094
@smallexample @c ada
1095
pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1096
 
1097
ARG ::= NAME | EXPRESSION
1098
@end smallexample
1099
 
1100
@noindent
1101
This pragma is used to annotate programs.  @var{identifier} identifies
1102
the type of annotation.  GNAT verifies that it is an identifier, but does
1103
not otherwise analyze it. The second optional identifier is also left
1104
unanalyzed, and by convention is used to control the action of the tool to
1105
which the annotation is addressed.  The remaining @var{arg} arguments
1106
can be either string literals or more generally expressions.
1107
String literals are assumed to be either of type
1108
@code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1109
depending on the character literals they contain.
1110
All other kinds of arguments are analyzed as expressions, and must be
1111
unambiguous.
1112
 
1113
The analyzed pragma is retained in the tree, but not otherwise processed
1114
by any part of the GNAT compiler, except to generate corresponding note
1115
lines in the generated ALI file. For the format of these note lines, see
1116
the compiler source file lib-writ.ads. This pragma is intended for use by
1117
external tools, including ASIS@. The use of pragma Annotate does not
1118
affect the compilation process in any way. This pragma may be used as
1119
a configuration pragma.
1120
 
1121
@node Pragma Assert
1122
@unnumberedsec Pragma Assert
1123
@findex Assert
1124
@noindent
1125
Syntax:
1126
@smallexample @c ada
1127
pragma Assert (
1128
  boolean_EXPRESSION
1129
  [, string_EXPRESSION]);
1130
@end smallexample
1131
 
1132
@noindent
1133
The effect of this pragma depends on whether the corresponding command
1134
line switch is set to activate assertions.  The pragma expands into code
1135
equivalent to the following:
1136
 
1137
@smallexample @c ada
1138
if assertions-enabled then
1139
   if not boolean_EXPRESSION then
1140
      System.Assertions.Raise_Assert_Failure
1141
        (string_EXPRESSION);
1142
   end if;
1143
end if;
1144
@end smallexample
1145
 
1146
@noindent
1147
The string argument, if given, is the message that will be associated
1148
with the exception occurrence if the exception is raised.  If no second
1149
argument is given, the default message is @samp{@var{file}:@var{nnn}},
1150
where @var{file} is the name of the source file containing the assert,
1151
and @var{nnn} is the line number of the assert.  A pragma is not a
1152
statement, so if a statement sequence contains nothing but a pragma
1153
assert, then a null statement is required in addition, as in:
1154
 
1155
@smallexample @c ada
1156
@dots{}
1157
if J > 3 then
1158
   pragma Assert (K > 3, "Bad value for K");
1159
   null;
1160
end if;
1161
@end smallexample
1162
 
1163
@noindent
1164
Note that, as with the @code{if} statement to which it is equivalent, the
1165
type of the expression is either @code{Standard.Boolean}, or any type derived
1166
from this standard type.
1167
 
1168
If assertions are disabled (switch @option{-gnata} not used), then there
1169
is no run-time effect (and in particular, any side effects from the
1170
expression will not occur at run time).  (The expression is still
1171
analyzed at compile time, and may cause types to be frozen if they are
1172
mentioned here for the first time).
1173
 
1174
If assertions are enabled, then the given expression is tested, and if
1175
it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1176
which results in the raising of @code{Assert_Failure} with the given message.
1177
 
1178
You should generally avoid side effects in the expression arguments of
1179
this pragma, because these side effects will turn on and off with the
1180
setting of the assertions mode, resulting in assertions that have an
1181
effect on the program.  However, the expressions are analyzed for
1182
semantic correctness whether or not assertions are enabled, so turning
1183
assertions on and off cannot affect the legality of a program.
1184
 
1185
Note that the implementation defined policy @code{DISABLE}, given in a
1186
pragma Assertion_Policy, can be used to suppress this semantic analysis.
1187
 
1188
Note: this is a standard language-defined pragma in versions
1189
of Ada from 2005 on. In GNAT, it is implemented in all versions
1190
of Ada, and the DISABLE policy is an implementation-defined
1191
addition.
1192
 
1193
 
1194
@node Pragma Assertion_Policy
1195
@unnumberedsec Pragma Assertion_Policy
1196
@findex Debug_Policy
1197
@noindent
1198
Syntax:
1199
 
1200
@smallexample @c ada
1201
pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1202
@end smallexample
1203
 
1204
@noindent
1205
If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1206
If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1207
This pragma overrides the effect of the @option{-gnata} switch on the
1208
command line.
1209
 
1210
The implementation defined policy @code{DISABLE} is like
1211
@code{IGNORE} except that it completely disables semantic
1212
checking of the argument to @code{pragma Assert}. This may
1213
be useful when the pragma argument references subprograms
1214
in a with'ed package which is replaced by a dummy package
1215
for the final build.
1216
 
1217
Note: this is a standard language-defined pragma in versions
1218
of Ada from 2005 on. In GNAT, it is implemented in all versions
1219
of Ada, and the DISABLE policy is an implementation-defined
1220
addition.
1221
 
1222
@node Pragma Assume_No_Invalid_Values
1223
@unnumberedsec Pragma Assume_No_Invalid_Values
1224
@findex Assume_No_Invalid_Values
1225
@cindex Invalid representations
1226
@cindex Invalid values
1227
@noindent
1228
Syntax:
1229
@smallexample @c ada
1230
pragma Assume_No_Invalid_Values (On | Off);
1231
@end smallexample
1232
 
1233
@noindent
1234
This is a configuration pragma that controls the assumptions made by the
1235
compiler about the occurrence of invalid representations (invalid values)
1236
in the code.
1237
 
1238
The default behavior (corresponding to an Off argument for this pragma), is
1239
to assume that values may in general be invalid unless the compiler can
1240
prove they are valid. Consider the following example:
1241
 
1242
@smallexample @c ada
1243
V1 : Integer range 1 .. 10;
1244
V2 : Integer range 11 .. 20;
1245
...
1246
for J in V2 .. V1 loop
1247
   ...
1248
end loop;
1249
@end smallexample
1250
 
1251
@noindent
1252
if V1 and V2 have valid values, then the loop is known at compile
1253
time not to execute since the lower bound must be greater than the
1254
upper bound. However in default mode, no such assumption is made,
1255
and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1256
is given, the compiler will assume that any occurrence of a variable
1257
other than in an explicit @code{'Valid} test always has a valid
1258
value, and the loop above will be optimized away.
1259
 
1260
The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1261
you know your code is free of uninitialized variables and other
1262
possible sources of invalid representations, and may result in
1263
more efficient code. A program that accesses an invalid representation
1264
with this pragma in effect is erroneous, so no guarantees can be made
1265
about its behavior.
1266
 
1267
It is peculiar though permissible to use this pragma in conjunction
1268
with validity checking (-gnatVa). In such cases, accessing invalid
1269
values will generally give an exception, though formally the program
1270
is erroneous so there are no guarantees that this will always be the
1271
case, and it is recommended that these two options not be used together.
1272
 
1273
@node Pragma Ast_Entry
1274
@unnumberedsec Pragma Ast_Entry
1275
@cindex OpenVMS
1276
@findex Ast_Entry
1277
@noindent
1278
Syntax:
1279
@smallexample @c ada
1280
pragma AST_Entry (entry_IDENTIFIER);
1281
@end smallexample
1282
 
1283
@noindent
1284
This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1285
argument is the simple name of a single entry; at most one @code{AST_Entry}
1286
pragma is allowed for any given entry.  This pragma must be used in
1287
conjunction with the @code{AST_Entry} attribute, and is only allowed after
1288
the entry declaration and in the same task type specification or single task
1289
as the entry to which it applies.  This pragma specifies that the given entry
1290
may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1291
resulting from an OpenVMS system service call.  The pragma does not affect
1292
normal use of the entry.  For further details on this pragma, see the
1293
DEC Ada Language Reference Manual, section 9.12a.
1294
 
1295
@node Pragma C_Pass_By_Copy
1296
@unnumberedsec Pragma C_Pass_By_Copy
1297
@cindex Passing by copy
1298
@findex C_Pass_By_Copy
1299
@noindent
1300
Syntax:
1301
@smallexample @c ada
1302
pragma C_Pass_By_Copy
1303
  ([Max_Size =>] static_integer_EXPRESSION);
1304
@end smallexample
1305
 
1306
@noindent
1307
Normally the default mechanism for passing C convention records to C
1308
convention subprograms is to pass them by reference, as suggested by RM
1309
B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1310
this default, by requiring that record formal parameters be passed by
1311
copy if all of the following conditions are met:
1312
 
1313
@itemize @bullet
1314
@item
1315
The size of the record type does not exceed the value specified for
1316
@code{Max_Size}.
1317
@item
1318
The record type has @code{Convention C}.
1319
@item
1320
The formal parameter has this record type, and the subprogram has a
1321
foreign (non-Ada) convention.
1322
@end itemize
1323
 
1324
@noindent
1325
If these conditions are met the argument is passed by copy, i.e.@: in a
1326
manner consistent with what C expects if the corresponding formal in the
1327
C prototype is a struct (rather than a pointer to a struct).
1328
 
1329
You can also pass records by copy by specifying the convention
1330
@code{C_Pass_By_Copy} for the record type, or by using the extended
1331
@code{Import} and @code{Export} pragmas, which allow specification of
1332
passing mechanisms on a parameter by parameter basis.
1333
 
1334
@node Pragma Check
1335
@unnumberedsec Pragma Check
1336
@cindex Assertions
1337
@cindex Named assertions
1338
@findex Check
1339
@noindent
1340
Syntax:
1341
@smallexample @c ada
1342
pragma Check (
1343
     [Name    =>] Identifier,
1344
     [Check   =>] Boolean_EXPRESSION
1345
  [, [Message =>] string_EXPRESSION] );
1346
@end smallexample
1347
 
1348
@noindent
1349
This pragma is similar to the predefined pragma @code{Assert} except that an
1350
extra identifier argument is present. In conjunction with pragma
1351
@code{Check_Policy}, this can be used to define groups of assertions that can
1352
be independently controlled. The identifier @code{Assertion} is special, it
1353
refers to the normal set of pragma @code{Assert} statements. The identifiers
1354
@code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1355
names, so these three names would normally not be used directly in a pragma
1356
@code{Check}.
1357
 
1358
Checks introduced by this pragma are normally deactivated by default. They can
1359
be activated either by the command line option @option{-gnata}, which turns on
1360
all checks, or individually controlled using pragma @code{Check_Policy}.
1361
 
1362
@node Pragma Check_Name
1363
@unnumberedsec Pragma Check_Name
1364
@cindex Defining check names
1365
@cindex Check names, defining
1366
@findex Check_Name
1367
@noindent
1368
Syntax:
1369
@smallexample @c ada
1370
pragma Check_Name (check_name_IDENTIFIER);
1371
@end smallexample
1372
 
1373
@noindent
1374
This is a configuration pragma that defines a new implementation
1375
defined check name (unless IDENTIFIER matches one of the predefined
1376
check names, in which case the pragma has no effect). Check names
1377
are global to a partition, so if two or more configuration pragmas
1378
are present in a partition mentioning the same name, only one new
1379
check name is introduced.
1380
 
1381
An implementation defined check name introduced with this pragma may
1382
be used in only three contexts: @code{pragma Suppress},
1383
@code{pragma Unsuppress},
1384
and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1385
any of these three cases, the check name must be visible. A check
1386
name is visible if it is in the configuration pragmas applying to
1387
the current unit, or if it appears at the start of any unit that
1388
is part of the dependency set of the current unit (e.g., units that
1389
are mentioned in @code{with} clauses).
1390
 
1391
@node Pragma Check_Policy
1392
@unnumberedsec Pragma Check_Policy
1393
@cindex Controlling assertions
1394
@cindex Assertions, control
1395
@cindex Check pragma control
1396
@cindex Named assertions
1397
@findex Check
1398
@noindent
1399
Syntax:
1400
@smallexample @c ada
1401
pragma Check_Policy
1402
 ([Name   =>] Identifier,
1403
  [Policy =>] POLICY_IDENTIFIER);
1404
 
1405
POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1406
@end smallexample
1407
 
1408
@noindent
1409
This pragma is similar to the predefined pragma @code{Assertion_Policy},
1410
except that it controls sets of named assertions introduced using the
1411
@code{Check} pragmas. It can be used as a configuration pragma or (unlike
1412
@code{Assertion_Policy}) can be used within a declarative part, in which case
1413
it controls the status to the end of the corresponding construct (in a manner
1414
identical to pragma @code{Suppress)}.
1415
 
1416
The identifier given as the first argument corresponds to a name used in
1417
associated @code{Check} pragmas. For example, if the pragma:
1418
 
1419
@smallexample @c ada
1420
pragma Check_Policy (Critical_Error, OFF);
1421
@end smallexample
1422
 
1423
@noindent
1424
is given, then subsequent @code{Check} pragmas whose first argument is also
1425
@code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1426
controls the behavior of normal @code{Assert} pragmas (thus a pragma
1427
@code{Check_Policy} with this identifier is similar to the normal
1428
@code{Assertion_Policy} pragma except that it can appear within a
1429
declarative part).
1430
 
1431
The special identifiers @code{Precondition} and @code{Postcondition} control
1432
the status of preconditions and postconditions. If a @code{Precondition} pragma
1433
is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1434
that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1435
of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1436
are recognized.
1437
 
1438
The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1439
to turn on corresponding checks. The default for a set of checks for which no
1440
@code{Check_Policy} is given is @code{OFF} unless the compiler switch
1441
@option{-gnata} is given, which turns on all checks by default.
1442
 
1443
The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1444
as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1445
compatibility with the standard @code{Assertion_Policy} pragma.
1446
 
1447
The implementation defined policy @code{DISABLE} is like
1448
@code{OFF} except that it completely disables semantic
1449
checking of the argument to the corresponding class of
1450
pragmas. This may be useful when the pragma arguments reference
1451
subprograms in a with'ed package which is replaced by a dummy package
1452
for the final build.
1453
 
1454
@node Pragma Comment
1455
@unnumberedsec Pragma Comment
1456
@findex Comment
1457
@noindent
1458
Syntax:
1459
 
1460
@smallexample @c ada
1461
pragma Comment (static_string_EXPRESSION);
1462
@end smallexample
1463
 
1464
@noindent
1465
This is almost identical in effect to pragma @code{Ident}.  It allows the
1466
placement of a comment into the object file and hence into the
1467
executable file if the operating system permits such usage.  The
1468
difference is that @code{Comment}, unlike @code{Ident}, has
1469
no limitations on placement of the pragma (it can be placed
1470
anywhere in the main source unit), and if more than one pragma
1471
is used, all comments are retained.
1472
 
1473
@node Pragma Common_Object
1474
@unnumberedsec Pragma Common_Object
1475
@findex Common_Object
1476
@noindent
1477
Syntax:
1478
 
1479
@smallexample @c ada
1480
pragma Common_Object (
1481
     [Internal =>] LOCAL_NAME
1482
  [, [External =>] EXTERNAL_SYMBOL]
1483
  [, [Size     =>] EXTERNAL_SYMBOL] );
1484
 
1485
EXTERNAL_SYMBOL ::=
1486
  IDENTIFIER
1487
| static_string_EXPRESSION
1488
@end smallexample
1489
 
1490
@noindent
1491
This pragma enables the shared use of variables stored in overlaid
1492
linker areas corresponding to the use of @code{COMMON}
1493
in Fortran.  The single
1494
object @var{LOCAL_NAME} is assigned to the area designated by
1495
the @var{External} argument.
1496
You may define a record to correspond to a series
1497
of fields.  The @var{Size} argument
1498
is syntax checked in GNAT, but otherwise ignored.
1499
 
1500
@code{Common_Object} is not supported on all platforms.  If no
1501
support is available, then the code generator will issue a message
1502
indicating that the necessary attribute for implementation of this
1503
pragma is not available.
1504
 
1505
@node Pragma Compile_Time_Error
1506
@unnumberedsec Pragma Compile_Time_Error
1507
@findex Compile_Time_Error
1508
@noindent
1509
Syntax:
1510
 
1511
@smallexample @c ada
1512
pragma Compile_Time_Error
1513
         (boolean_EXPRESSION, static_string_EXPRESSION);
1514
@end smallexample
1515
 
1516
@noindent
1517
This pragma can be used to generate additional compile time
1518
error messages. It
1519
is particularly useful in generics, where errors can be issued for
1520
specific problematic instantiations. The first parameter is a boolean
1521
expression. The pragma is effective only if the value of this expression
1522
is known at compile time, and has the value True. The set of expressions
1523
whose values are known at compile time includes all static boolean
1524
expressions, and also other values which the compiler can determine
1525
at compile time (e.g., the size of a record type set by an explicit
1526
size representation clause, or the value of a variable which was
1527
initialized to a constant and is known not to have been modified).
1528
If these conditions are met, an error message is generated using
1529
the value given as the second argument. This string value may contain
1530
embedded ASCII.LF characters to break the message into multiple lines.
1531
 
1532
@node Pragma Compile_Time_Warning
1533
@unnumberedsec Pragma Compile_Time_Warning
1534
@findex Compile_Time_Warning
1535
@noindent
1536
Syntax:
1537
 
1538
@smallexample @c ada
1539
pragma Compile_Time_Warning
1540
         (boolean_EXPRESSION, static_string_EXPRESSION);
1541
@end smallexample
1542
 
1543
@noindent
1544
Same as pragma Compile_Time_Error, except a warning is issued instead
1545
of an error message. Note that if this pragma is used in a package that
1546
is with'ed by a client, the client will get the warning even though it
1547
is issued by a with'ed package (normally warnings in with'ed units are
1548
suppressed, but this is a special exception to that rule).
1549
 
1550
One typical use is within a generic where compile time known characteristics
1551
of formal parameters are tested, and warnings given appropriately. Another use
1552
with a first parameter of True is to warn a client about use of a package,
1553
for example that it is not fully implemented.
1554
 
1555
@node Pragma Compiler_Unit
1556
@unnumberedsec Pragma Compiler_Unit
1557
@findex Compiler_Unit
1558
@noindent
1559
Syntax:
1560
 
1561
@smallexample @c ada
1562
pragma Compiler_Unit;
1563
@end smallexample
1564
 
1565
@noindent
1566
This pragma is intended only for internal use in the GNAT run-time library.
1567
It indicates that the unit is used as part of the compiler build. The effect
1568
is to disallow constructs (raise with message, conditional expressions etc)
1569
that would cause trouble when bootstrapping using an older version of GNAT.
1570
For the exact list of restrictions, see the compiler sources and references
1571
to Is_Compiler_Unit.
1572
 
1573
@node Pragma Complete_Representation
1574
@unnumberedsec Pragma Complete_Representation
1575
@findex Complete_Representation
1576
@noindent
1577
Syntax:
1578
 
1579
@smallexample @c ada
1580
pragma Complete_Representation;
1581
@end smallexample
1582
 
1583
@noindent
1584
This pragma must appear immediately within a record representation
1585
clause. Typical placements are before the first component clause
1586
or after the last component clause. The effect is to give an error
1587
message if any component is missing a component clause. This pragma
1588
may be used to ensure that a record representation clause is
1589
complete, and that this invariant is maintained if fields are
1590
added to the record in the future.
1591
 
1592
@node Pragma Complex_Representation
1593
@unnumberedsec Pragma Complex_Representation
1594
@findex Complex_Representation
1595
@noindent
1596
Syntax:
1597
 
1598
@smallexample @c ada
1599
pragma Complex_Representation
1600
        ([Entity =>] LOCAL_NAME);
1601
@end smallexample
1602
 
1603
@noindent
1604
The @var{Entity} argument must be the name of a record type which has
1605
two fields of the same floating-point type.  The effect of this pragma is
1606
to force gcc to use the special internal complex representation form for
1607
this record, which may be more efficient.  Note that this may result in
1608
the code for this type not conforming to standard ABI (application
1609
binary interface) requirements for the handling of record types.  For
1610
example, in some environments, there is a requirement for passing
1611
records by pointer, and the use of this pragma may result in passing
1612
this type in floating-point registers.
1613
 
1614
@node Pragma Component_Alignment
1615
@unnumberedsec Pragma Component_Alignment
1616
@cindex Alignments of components
1617
@findex Component_Alignment
1618
@noindent
1619
Syntax:
1620
 
1621
@smallexample @c ada
1622
pragma Component_Alignment (
1623
     [Form =>] ALIGNMENT_CHOICE
1624
  [, [Name =>] type_LOCAL_NAME]);
1625
 
1626
ALIGNMENT_CHOICE ::=
1627
  Component_Size
1628
| Component_Size_4
1629
| Storage_Unit
1630
| Default
1631
@end smallexample
1632
 
1633
@noindent
1634
Specifies the alignment of components in array or record types.
1635
The meaning of the @var{Form} argument is as follows:
1636
 
1637
@table @code
1638
@findex Component_Size
1639
@item Component_Size
1640
Aligns scalar components and subcomponents of the array or record type
1641
on boundaries appropriate to their inherent size (naturally
1642
aligned).  For example, 1-byte components are aligned on byte boundaries,
1643
2-byte integer components are aligned on 2-byte boundaries, 4-byte
1644
integer components are aligned on 4-byte boundaries and so on.  These
1645
alignment rules correspond to the normal rules for C compilers on all
1646
machines except the VAX@.
1647
 
1648
@findex Component_Size_4
1649
@item Component_Size_4
1650
Naturally aligns components with a size of four or fewer
1651
bytes.  Components that are larger than 4 bytes are placed on the next
1652
4-byte boundary.
1653
 
1654
@findex Storage_Unit
1655
@item Storage_Unit
1656
Specifies that array or record components are byte aligned, i.e.@:
1657
aligned on boundaries determined by the value of the constant
1658
@code{System.Storage_Unit}.
1659
 
1660
@cindex OpenVMS
1661
@item Default
1662
Specifies that array or record components are aligned on default
1663
boundaries, appropriate to the underlying hardware or operating system or
1664
both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1665
the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1666
the @code{Default} choice is the same as @code{Component_Size} (natural
1667
alignment).
1668
@end table
1669
 
1670
@noindent
1671
If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1672
refer to a local record or array type, and the specified alignment
1673
choice applies to the specified type.  The use of
1674
@code{Component_Alignment} together with a pragma @code{Pack} causes the
1675
@code{Component_Alignment} pragma to be ignored.  The use of
1676
@code{Component_Alignment} together with a record representation clause
1677
is only effective for fields not specified by the representation clause.
1678
 
1679
If the @code{Name} parameter is absent, the pragma can be used as either
1680
a configuration pragma, in which case it applies to one or more units in
1681
accordance with the normal rules for configuration pragmas, or it can be
1682
used within a declarative part, in which case it applies to types that
1683
are declared within this declarative part, or within any nested scope
1684
within this declarative part.  In either case it specifies the alignment
1685
to be applied to any record or array type which has otherwise standard
1686
representation.
1687
 
1688
If the alignment for a record or array type is not specified (using
1689
pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1690
clause), the GNAT uses the default alignment as described previously.
1691
 
1692
@node Pragma Convention_Identifier
1693
@unnumberedsec Pragma Convention_Identifier
1694
@findex Convention_Identifier
1695
@cindex Conventions, synonyms
1696
@noindent
1697
Syntax:
1698
 
1699
@smallexample @c ada
1700
pragma Convention_Identifier (
1701
         [Name =>]       IDENTIFIER,
1702
         [Convention =>] convention_IDENTIFIER);
1703
@end smallexample
1704
 
1705
@noindent
1706
This pragma provides a mechanism for supplying synonyms for existing
1707
convention identifiers. The @code{Name} identifier can subsequently
1708
be used as a synonym for the given convention in other pragmas (including
1709
for example pragma @code{Import} or another @code{Convention_Identifier}
1710
pragma). As an example of the use of this, suppose you had legacy code
1711
which used Fortran77 as the identifier for Fortran. Then the pragma:
1712
 
1713
@smallexample @c ada
1714
pragma Convention_Identifier (Fortran77, Fortran);
1715
@end smallexample
1716
 
1717
@noindent
1718
would allow the use of the convention identifier @code{Fortran77} in
1719
subsequent code, avoiding the need to modify the sources. As another
1720
example, you could use this to parameterize convention requirements
1721
according to systems. Suppose you needed to use @code{Stdcall} on
1722
windows systems, and @code{C} on some other system, then you could
1723
define a convention identifier @code{Library} and use a single
1724
@code{Convention_Identifier} pragma to specify which convention
1725
would be used system-wide.
1726
 
1727
@node Pragma CPP_Class
1728
@unnumberedsec Pragma CPP_Class
1729
@findex CPP_Class
1730
@cindex Interfacing with C++
1731
@noindent
1732
Syntax:
1733
 
1734
@smallexample @c ada
1735
pragma CPP_Class ([Entity =>] LOCAL_NAME);
1736
@end smallexample
1737
 
1738
@noindent
1739
The argument denotes an entity in the current declarative region that is
1740
declared as a record type. It indicates that the type corresponds to an
1741
externally declared C++ class type, and is to be laid out the same way
1742
that C++ would lay out the type. If the C++ class has virtual primitives
1743
then the record must be declared as a tagged record type.
1744
 
1745
Types for which @code{CPP_Class} is specified do not have assignment or
1746
equality operators defined (such operations can be imported or declared
1747
as subprograms as required). Initialization is allowed only by constructor
1748
functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1749
limited if not explicitly declared as limited or derived from a limited
1750
type, and an error is issued in that case.
1751
 
1752
Pragma @code{CPP_Class} is intended primarily for automatic generation
1753
using an automatic binding generator tool.
1754
See @ref{Interfacing to C++} for related information.
1755
 
1756
Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1757
for backward compatibility but its functionality is available
1758
using pragma @code{Import} with @code{Convention} = @code{CPP}.
1759
 
1760
@node Pragma CPP_Constructor
1761
@unnumberedsec Pragma CPP_Constructor
1762
@cindex Interfacing with C++
1763
@findex CPP_Constructor
1764
@noindent
1765
Syntax:
1766
 
1767
@smallexample @c ada
1768
pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1769
  [, [External_Name =>] static_string_EXPRESSION ]
1770
  [, [Link_Name     =>] static_string_EXPRESSION ]);
1771
@end smallexample
1772
 
1773
@noindent
1774
This pragma identifies an imported function (imported in the usual way
1775
with pragma @code{Import}) as corresponding to a C++ constructor. If
1776
@code{External_Name} and @code{Link_Name} are not specified then the
1777
@code{Entity} argument is a name that must have been previously mentioned
1778
in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1779
must be of one of the following forms:
1780
 
1781
@itemize @bullet
1782
@item
1783
@code{function @var{Fname} return @var{T}}
1784
 
1785
@itemize @bullet
1786
@item
1787
@code{function @var{Fname} return @var{T}'Class}
1788
 
1789
@item
1790
@code{function @var{Fname} (@dots{}) return @var{T}}
1791
@end itemize
1792
 
1793
@item
1794
@code{function @var{Fname} (@dots{}) return @var{T}'Class}
1795
@end itemize
1796
 
1797
@noindent
1798
where @var{T} is a limited record type imported from C++ with pragma
1799
@code{Import} and @code{Convention} = @code{CPP}.
1800
 
1801
The first two forms import the default constructor, used when an object
1802
of type @var{T} is created on the Ada side with no explicit constructor.
1803
The latter two forms cover all the non-default constructors of the type.
1804
See the GNAT users guide for details.
1805
 
1806
If no constructors are imported, it is impossible to create any objects
1807
on the Ada side and the type is implicitly declared abstract.
1808
 
1809
Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1810
using an automatic binding generator tool.
1811
See @ref{Interfacing to C++} for more related information.
1812
 
1813
Note: The use of functions returning class-wide types for constructors is
1814
currently obsolete. They are supported for backward compatibility. The
1815
use of functions returning the type T leave the Ada sources more clear
1816
because the imported C++ constructors always return an object of type T;
1817
that is, they never return an object whose type is a descendant of type T.
1818
 
1819
@node Pragma CPP_Virtual
1820
@unnumberedsec Pragma CPP_Virtual
1821
@cindex Interfacing to C++
1822
@findex CPP_Virtual
1823
@noindent
1824
This pragma is now obsolete has has no effect because GNAT generates
1825
the same object layout than the G++ compiler.
1826
 
1827
See @ref{Interfacing to C++} for related information.
1828
 
1829
@node Pragma CPP_Vtable
1830
@unnumberedsec Pragma CPP_Vtable
1831
@cindex Interfacing with C++
1832
@findex CPP_Vtable
1833
@noindent
1834
This pragma is now obsolete has has no effect because GNAT generates
1835
the same object layout than the G++ compiler.
1836
 
1837
See @ref{Interfacing to C++} for related information.
1838
 
1839
@node Pragma Debug
1840
@unnumberedsec Pragma Debug
1841
@findex Debug
1842
@noindent
1843
Syntax:
1844
 
1845
@smallexample @c ada
1846
pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1847
 
1848
PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1849
  PROCEDURE_NAME
1850
| PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1851
@end smallexample
1852
 
1853
@noindent
1854
The procedure call argument has the syntactic form of an expression, meeting
1855
the syntactic requirements for pragmas.
1856
 
1857
If debug pragmas are not enabled or if the condition is present and evaluates
1858
to False, this pragma has no effect. If debug pragmas are enabled, the
1859
semantics of the pragma is exactly equivalent to the procedure call statement
1860
corresponding to the argument with a terminating semicolon. Pragmas are
1861
permitted in sequences of declarations, so you can use pragma @code{Debug} to
1862
intersperse calls to debug procedures in the middle of declarations. Debug
1863
pragmas can be enabled either by use of the command line switch @option{-gnata}
1864
or by use of the configuration pragma @code{Debug_Policy}.
1865
 
1866
@node Pragma Debug_Policy
1867
@unnumberedsec Pragma Debug_Policy
1868
@findex Debug_Policy
1869
@noindent
1870
Syntax:
1871
 
1872
@smallexample @c ada
1873
pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1874
@end smallexample
1875
 
1876
@noindent
1877
If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1878
If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1879
This pragma overrides the effect of the @option{-gnata} switch on the
1880
command line.
1881
 
1882
The implementation defined policy @code{DISABLE} is like
1883
@code{IGNORE} except that it completely disables semantic
1884
checking of the argument to @code{pragma Debug}. This may
1885
be useful when the pragma argument references subprograms
1886
in a with'ed package which is replaced by a dummy package
1887
for the final build.
1888
 
1889
@node Pragma Detect_Blocking
1890
@unnumberedsec Pragma Detect_Blocking
1891
@findex Detect_Blocking
1892
@noindent
1893
Syntax:
1894
 
1895
@smallexample @c ada
1896
pragma Detect_Blocking;
1897
@end smallexample
1898
 
1899
@noindent
1900
This is a configuration pragma that forces the detection of potentially
1901
blocking operations within a protected operation, and to raise Program_Error
1902
if that happens.
1903
 
1904
@node Pragma Elaboration_Checks
1905
@unnumberedsec Pragma Elaboration_Checks
1906
@cindex Elaboration control
1907
@findex Elaboration_Checks
1908
@noindent
1909
Syntax:
1910
 
1911
@smallexample @c ada
1912
pragma Elaboration_Checks (Dynamic | Static);
1913
@end smallexample
1914
 
1915
@noindent
1916
This is a configuration pragma that provides control over the
1917
elaboration model used by the compilation affected by the
1918
pragma.  If the parameter is @code{Dynamic},
1919
then the dynamic elaboration
1920
model described in the Ada Reference Manual is used, as though
1921
the @option{-gnatE} switch had been specified on the command
1922
line.  If the parameter is @code{Static}, then the default GNAT static
1923
model is used.  This configuration pragma overrides the setting
1924
of the command line.  For full details on the elaboration models
1925
used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1926
gnat_ugn, @value{EDITION} User's Guide}.
1927
 
1928
@node Pragma Eliminate
1929
@unnumberedsec Pragma Eliminate
1930
@cindex Elimination of unused subprograms
1931
@findex Eliminate
1932
@noindent
1933
Syntax:
1934
 
1935
@smallexample @c ada
1936
pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
1937
                  [Source_Location =>] STRING_LITERAL);
1938
@end smallexample
1939
 
1940
@noindent
1941
The string literal given for the source location is a string which
1942
specifies the line number of the occurrence of the entity, using
1943
the syntax for SOURCE_TRACE given below:
1944
 
1945
@smallexample @c ada
1946
 SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1947
 
1948
 LBRACKET         ::= [
1949
 RBRACKET         ::= ]
1950
 
1951
 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1952
 
1953
 LINE_NUMBER      ::= DIGIT @{DIGIT@}
1954
@end smallexample
1955
 
1956
@noindent
1957
Spaces around the colon in a @code{Source_Reference} are optional.
1958
 
1959
The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1960
explicit subprogram declaration, where the @code{entity} name in this
1961
designator appears on the source line specified by the source location.
1962
 
1963
The source trace that is given as the @code{Source_Location} shall obey the
1964
following rules. The @code{FILE_NAME} is the short name (with no directory
1965
information) of an Ada source file, given using exactly the required syntax
1966
for the underlying file system (e.g. case is important if the underlying
1967
operating system is case sensitive). @code{LINE_NUMBER} gives the line
1968
number of the occurrence of the @code{entity}
1969
as a decimal literal without an exponent or point. If an @code{entity} is not
1970
declared in a generic instantiation (this includes generic subprogram
1971
instances), the source trace includes only one source reference. If an entity
1972
is declared inside a generic instantiation, its source trace (when parsing
1973
from left to right) starts with the source location of the declaration of the
1974
entity in the generic unit and ends with the source location of the
1975
instantiation (it is given in square brackets). This approach is recursively
1976
used in case of nested instantiations: the rightmost (nested most deeply in
1977
square brackets) element of the source trace is the location of the outermost
1978
instantiation, the next to left element is the location of the next (first
1979
nested) instantiation in the code of the corresponding generic unit, and so
1980
on, and the leftmost element (that is out of any square brackets) is the
1981
location of the declaration of the entity to eliminate in a generic unit.
1982
 
1983
Note that the @code{Source_Location} argument specifies which of a set of
1984
similarly named entities is being eliminated, dealing both with overloading,
1985
and also appearence of the same entity name in different scopes.
1986
 
1987
This pragma indicates that the given entity is not used in the program to be
1988
compiled and built. The effect of the pragma is to allow the compiler to
1989
eliminate the code or data associated with the named entity. Any reference to
1990
an eliminated entity causes a compile-time or link-time error.
1991
 
1992
The intention of pragma @code{Eliminate} is to allow a program to be compiled
1993
in a system-independent manner, with unused entities eliminated, without
1994
needing to modify the source text. Normally the required set of
1995
@code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1996
 
1997
Any source file change that removes, splits, or
1998
adds lines may make the set of Eliminate pragmas invalid because their
1999
@code{Source_Location} argument values may get out of date.
2000
 
2001
Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2002
operation. In this case all the subprograms to which the given operation can
2003
dispatch are considered to be unused (are never called as a result of a direct
2004
or a dispatching call).
2005
 
2006
@node Pragma Export_Exception
2007
@unnumberedsec Pragma Export_Exception
2008
@cindex OpenVMS
2009
@findex Export_Exception
2010
@noindent
2011
Syntax:
2012
 
2013
@smallexample @c ada
2014
pragma Export_Exception (
2015
     [Internal =>] LOCAL_NAME
2016
  [, [External =>] EXTERNAL_SYMBOL]
2017
  [, [Form     =>] Ada | VMS]
2018
  [, [Code     =>] static_integer_EXPRESSION]);
2019
 
2020
EXTERNAL_SYMBOL ::=
2021
  IDENTIFIER
2022
| static_string_EXPRESSION
2023
@end smallexample
2024
 
2025
@noindent
2026
This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2027
causes the specified exception to be propagated outside of the Ada program,
2028
so that it can be handled by programs written in other OpenVMS languages.
2029
This pragma establishes an external name for an Ada exception and makes the
2030
name available to the OpenVMS Linker as a global symbol.  For further details
2031
on this pragma, see the
2032
DEC Ada Language Reference Manual, section 13.9a3.2.
2033
 
2034
@node Pragma Export_Function
2035
@unnumberedsec Pragma Export_Function
2036
@cindex Argument passing mechanisms
2037
@findex Export_Function
2038
 
2039
@noindent
2040
Syntax:
2041
 
2042
@smallexample @c ada
2043
pragma Export_Function (
2044
     [Internal         =>] LOCAL_NAME
2045
  [, [External         =>] EXTERNAL_SYMBOL]
2046
  [, [Parameter_Types  =>] PARAMETER_TYPES]
2047
  [, [Result_Type      =>] result_SUBTYPE_MARK]
2048
  [, [Mechanism        =>] MECHANISM]
2049
  [, [Result_Mechanism =>] MECHANISM_NAME]);
2050
 
2051
EXTERNAL_SYMBOL ::=
2052
  IDENTIFIER
2053
| static_string_EXPRESSION
2054
| ""
2055
 
2056
PARAMETER_TYPES ::=
2057
  null
2058
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2059
 
2060
TYPE_DESIGNATOR ::=
2061
  subtype_NAME
2062
| subtype_Name ' Access
2063
 
2064
MECHANISM ::=
2065
  MECHANISM_NAME
2066
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2067
 
2068
MECHANISM_ASSOCIATION ::=
2069
  [formal_parameter_NAME =>] MECHANISM_NAME
2070
 
2071
MECHANISM_NAME ::=
2072
  Value
2073
| Reference
2074
| Descriptor [([Class =>] CLASS_NAME)]
2075
| Short_Descriptor [([Class =>] CLASS_NAME)]
2076
 
2077
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2078
@end smallexample
2079
 
2080
@noindent
2081
Use this pragma to make a function externally callable and optionally
2082
provide information on mechanisms to be used for passing parameter and
2083
result values.  We recommend, for the purposes of improving portability,
2084
this pragma always be used in conjunction with a separate pragma
2085
@code{Export}, which must precede the pragma @code{Export_Function}.
2086
GNAT does not require a separate pragma @code{Export}, but if none is
2087
present, @code{Convention Ada} is assumed, which is usually
2088
not what is wanted, so it is usually appropriate to use this
2089
pragma in conjunction with a @code{Export} or @code{Convention}
2090
pragma that specifies the desired foreign convention.
2091
Pragma @code{Export_Function}
2092
(and @code{Export}, if present) must appear in the same declarative
2093
region as the function to which they apply.
2094
 
2095
@var{internal_name} must uniquely designate the function to which the
2096
pragma applies.  If more than one function name exists of this name in
2097
the declarative part you must use the @code{Parameter_Types} and
2098
@code{Result_Type} parameters is mandatory to achieve the required
2099
unique designation.  @var{subtype_mark}s in these parameters must
2100
exactly match the subtypes in the corresponding function specification,
2101
using positional notation to match parameters with subtype marks.
2102
The form with an @code{'Access} attribute can be used to match an
2103
anonymous access parameter.
2104
 
2105
@cindex OpenVMS
2106
@cindex Passing by descriptor
2107
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2108
The default behavior for Export_Function is to accept either 64bit or
2109
32bit descriptors unless short_descriptor is specified, then only 32bit
2110
descriptors are accepted.
2111
 
2112
@cindex Suppressing external name
2113
Special treatment is given if the EXTERNAL is an explicit null
2114
string or a static string expressions that evaluates to the null
2115
string. In this case, no external name is generated. This form
2116
still allows the specification of parameter mechanisms.
2117
 
2118
@node Pragma Export_Object
2119
@unnumberedsec Pragma Export_Object
2120
@findex Export_Object
2121
@noindent
2122
Syntax:
2123
 
2124
@smallexample @c ada
2125
pragma Export_Object
2126
      [Internal =>] LOCAL_NAME
2127
   [, [External =>] EXTERNAL_SYMBOL]
2128
   [, [Size     =>] EXTERNAL_SYMBOL]
2129
 
2130
EXTERNAL_SYMBOL ::=
2131
  IDENTIFIER
2132
| static_string_EXPRESSION
2133
@end smallexample
2134
 
2135
@noindent
2136
This pragma designates an object as exported, and apart from the
2137
extended rules for external symbols, is identical in effect to the use of
2138
the normal @code{Export} pragma applied to an object.  You may use a
2139
separate Export pragma (and you probably should from the point of view
2140
of portability), but it is not required.  @var{Size} is syntax checked,
2141
but otherwise ignored by GNAT@.
2142
 
2143
@node Pragma Export_Procedure
2144
@unnumberedsec Pragma Export_Procedure
2145
@findex Export_Procedure
2146
@noindent
2147
Syntax:
2148
 
2149
@smallexample @c ada
2150
pragma Export_Procedure (
2151
     [Internal        =>] LOCAL_NAME
2152
  [, [External        =>] EXTERNAL_SYMBOL]
2153
  [, [Parameter_Types =>] PARAMETER_TYPES]
2154
  [, [Mechanism       =>] MECHANISM]);
2155
 
2156
EXTERNAL_SYMBOL ::=
2157
  IDENTIFIER
2158
| static_string_EXPRESSION
2159
| ""
2160
 
2161
PARAMETER_TYPES ::=
2162
  null
2163
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2164
 
2165
TYPE_DESIGNATOR ::=
2166
  subtype_NAME
2167
| subtype_Name ' Access
2168
 
2169
MECHANISM ::=
2170
  MECHANISM_NAME
2171
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2172
 
2173
MECHANISM_ASSOCIATION ::=
2174
  [formal_parameter_NAME =>] MECHANISM_NAME
2175
 
2176
MECHANISM_NAME ::=
2177
  Value
2178
| Reference
2179
| Descriptor [([Class =>] CLASS_NAME)]
2180
| Short_Descriptor [([Class =>] CLASS_NAME)]
2181
 
2182
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2183
@end smallexample
2184
 
2185
@noindent
2186
This pragma is identical to @code{Export_Function} except that it
2187
applies to a procedure rather than a function and the parameters
2188
@code{Result_Type} and @code{Result_Mechanism} are not permitted.
2189
GNAT does not require a separate pragma @code{Export}, but if none is
2190
present, @code{Convention Ada} is assumed, which is usually
2191
not what is wanted, so it is usually appropriate to use this
2192
pragma in conjunction with a @code{Export} or @code{Convention}
2193
pragma that specifies the desired foreign convention.
2194
 
2195
@cindex OpenVMS
2196
@cindex Passing by descriptor
2197
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2198
The default behavior for Export_Procedure is to accept either 64bit or
2199
32bit descriptors unless short_descriptor is specified, then only 32bit
2200
descriptors are accepted.
2201
 
2202
@cindex Suppressing external name
2203
Special treatment is given if the EXTERNAL is an explicit null
2204
string or a static string expressions that evaluates to the null
2205
string. In this case, no external name is generated. This form
2206
still allows the specification of parameter mechanisms.
2207
 
2208
@node Pragma Export_Value
2209
@unnumberedsec Pragma Export_Value
2210
@findex Export_Value
2211
@noindent
2212
Syntax:
2213
 
2214
@smallexample @c ada
2215
pragma Export_Value (
2216
  [Value     =>] static_integer_EXPRESSION,
2217
  [Link_Name =>] static_string_EXPRESSION);
2218
@end smallexample
2219
 
2220
@noindent
2221
This pragma serves to export a static integer value for external use.
2222
The first argument specifies the value to be exported. The Link_Name
2223
argument specifies the symbolic name to be associated with the integer
2224
value. This pragma is useful for defining a named static value in Ada
2225
that can be referenced in assembly language units to be linked with
2226
the application. This pragma is currently supported only for the
2227
AAMP target and is ignored for other targets.
2228
 
2229
@node Pragma Export_Valued_Procedure
2230
@unnumberedsec Pragma Export_Valued_Procedure
2231
@findex Export_Valued_Procedure
2232
@noindent
2233
Syntax:
2234
 
2235
@smallexample @c ada
2236
pragma Export_Valued_Procedure (
2237
     [Internal        =>] LOCAL_NAME
2238
  [, [External        =>] EXTERNAL_SYMBOL]
2239
  [, [Parameter_Types =>] PARAMETER_TYPES]
2240
  [, [Mechanism       =>] MECHANISM]);
2241
 
2242
EXTERNAL_SYMBOL ::=
2243
  IDENTIFIER
2244
| static_string_EXPRESSION
2245
| ""
2246
 
2247
PARAMETER_TYPES ::=
2248
  null
2249
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2250
 
2251
TYPE_DESIGNATOR ::=
2252
  subtype_NAME
2253
| subtype_Name ' Access
2254
 
2255
MECHANISM ::=
2256
  MECHANISM_NAME
2257
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2258
 
2259
MECHANISM_ASSOCIATION ::=
2260
  [formal_parameter_NAME =>] MECHANISM_NAME
2261
 
2262
MECHANISM_NAME ::=
2263
  Value
2264
| Reference
2265
| Descriptor [([Class =>] CLASS_NAME)]
2266
| Short_Descriptor [([Class =>] CLASS_NAME)]
2267
 
2268
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2269
@end smallexample
2270
 
2271
@noindent
2272
This pragma is identical to @code{Export_Procedure} except that the
2273
first parameter of @var{LOCAL_NAME}, which must be present, must be of
2274
mode @code{OUT}, and externally the subprogram is treated as a function
2275
with this parameter as the result of the function.  GNAT provides for
2276
this capability to allow the use of @code{OUT} and @code{IN OUT}
2277
parameters in interfacing to external functions (which are not permitted
2278
in Ada functions).
2279
GNAT does not require a separate pragma @code{Export}, but if none is
2280
present, @code{Convention Ada} is assumed, which is almost certainly
2281
not what is wanted since the whole point of this pragma is to interface
2282
with foreign language functions, so it is usually appropriate to use this
2283
pragma in conjunction with a @code{Export} or @code{Convention}
2284
pragma that specifies the desired foreign convention.
2285
 
2286
@cindex OpenVMS
2287
@cindex Passing by descriptor
2288
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2289
The default behavior for Export_Valued_Procedure is to accept either 64bit or
2290
32bit descriptors unless short_descriptor is specified, then only 32bit
2291
descriptors are accepted.
2292
 
2293
@cindex Suppressing external name
2294
Special treatment is given if the EXTERNAL is an explicit null
2295
string or a static string expressions that evaluates to the null
2296
string. In this case, no external name is generated. This form
2297
still allows the specification of parameter mechanisms.
2298
 
2299
@node Pragma Extend_System
2300
@unnumberedsec Pragma Extend_System
2301
@cindex @code{system}, extending
2302
@cindex Dec Ada 83
2303
@findex Extend_System
2304
@noindent
2305
Syntax:
2306
 
2307
@smallexample @c ada
2308
pragma Extend_System ([Name =>] IDENTIFIER);
2309
@end smallexample
2310
 
2311
@noindent
2312
This pragma is used to provide backwards compatibility with other
2313
implementations that extend the facilities of package @code{System}.  In
2314
GNAT, @code{System} contains only the definitions that are present in
2315
the Ada RM@.  However, other implementations, notably the DEC Ada 83
2316
implementation, provide many extensions to package @code{System}.
2317
 
2318
For each such implementation accommodated by this pragma, GNAT provides a
2319
package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2320
implementation, which provides the required additional definitions.  You
2321
can use this package in two ways.  You can @code{with} it in the normal
2322
way and access entities either by selection or using a @code{use}
2323
clause.  In this case no special processing is required.
2324
 
2325
However, if existing code contains references such as
2326
@code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2327
definitions provided in package @code{System}, you may use this pragma
2328
to extend visibility in @code{System} in a non-standard way that
2329
provides greater compatibility with the existing code.  Pragma
2330
@code{Extend_System} is a configuration pragma whose single argument is
2331
the name of the package containing the extended definition
2332
(e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2333
control of this pragma will be processed using special visibility
2334
processing that looks in package @code{System.Aux_@var{xxx}} where
2335
@code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2336
package @code{System}, but not found in package @code{System}.
2337
 
2338
You can use this pragma either to access a predefined @code{System}
2339
extension supplied with the compiler, for example @code{Aux_DEC} or
2340
you can construct your own extension unit following the above
2341
definition.  Note that such a package is a child of @code{System}
2342
and thus is considered part of the implementation.  To compile
2343
it you will have to use the appropriate switch for compiling
2344
system units.
2345
@xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2346
for details.
2347
 
2348
@node Pragma Extensions_Allowed
2349
@unnumberedsec Pragma Extensions_Allowed
2350
@cindex Ada Extensions
2351
@cindex GNAT Extensions
2352
@findex Extensions_Allowed
2353
@noindent
2354
Syntax:
2355
 
2356
@smallexample @c ada
2357
pragma Extensions_Allowed (On | Off);
2358
@end smallexample
2359
 
2360
@noindent
2361
This configuration pragma enables or disables the implementation
2362
extension mode (the use of Off as a parameter cancels the effect
2363
of the @option{-gnatX} command switch).
2364
 
2365
In extension mode, the latest version of the Ada language is
2366
implemented (currently Ada 2012), and in addition a small number
2367
of GNAT specific extensions are recognized as follows:
2368
 
2369
@table @asis
2370
@item Constrained attribute for generic objects
2371
The @code{Constrained} attribute is permitted for objects of
2372
generic types. The result indicates if the corresponding actual
2373
is constrained.
2374
 
2375
@end table
2376
 
2377
@node Pragma External
2378
@unnumberedsec Pragma External
2379
@findex External
2380
@noindent
2381
Syntax:
2382
 
2383
@smallexample @c ada
2384
pragma External (
2385
  [   Convention    =>] convention_IDENTIFIER,
2386
  [   Entity        =>] LOCAL_NAME
2387
  [, [External_Name =>] static_string_EXPRESSION ]
2388
  [, [Link_Name     =>] static_string_EXPRESSION ]);
2389
@end smallexample
2390
 
2391
@noindent
2392
This pragma is identical in syntax and semantics to pragma
2393
@code{Export} as defined in the Ada Reference Manual.  It is
2394
provided for compatibility with some Ada 83 compilers that
2395
used this pragma for exactly the same purposes as pragma
2396
@code{Export} before the latter was standardized.
2397
 
2398
@node Pragma External_Name_Casing
2399
@unnumberedsec Pragma External_Name_Casing
2400
@cindex Dec Ada 83 casing compatibility
2401
@cindex External Names, casing
2402
@cindex Casing of External names
2403
@findex External_Name_Casing
2404
@noindent
2405
Syntax:
2406
 
2407
@smallexample @c ada
2408
pragma External_Name_Casing (
2409
  Uppercase | Lowercase
2410
  [, Uppercase | Lowercase | As_Is]);
2411
@end smallexample
2412
 
2413
@noindent
2414
This pragma provides control over the casing of external names associated
2415
with Import and Export pragmas.  There are two cases to consider:
2416
 
2417
@table @asis
2418
@item Implicit external names
2419
Implicit external names are derived from identifiers.  The most common case
2420
arises when a standard Ada Import or Export pragma is used with only two
2421
arguments, as in:
2422
 
2423
@smallexample @c ada
2424
   pragma Import (C, C_Routine);
2425
@end smallexample
2426
 
2427
@noindent
2428
Since Ada is a case-insensitive language, the spelling of the identifier in
2429
the Ada source program does not provide any information on the desired
2430
casing of the external name, and so a convention is needed.  In GNAT the
2431
default treatment is that such names are converted to all lower case
2432
letters.  This corresponds to the normal C style in many environments.
2433
The first argument of pragma @code{External_Name_Casing} can be used to
2434
control this treatment.  If @code{Uppercase} is specified, then the name
2435
will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2436
then the normal default of all lower case letters will be used.
2437
 
2438
This same implicit treatment is also used in the case of extended DEC Ada 83
2439
compatible Import and Export pragmas where an external name is explicitly
2440
specified using an identifier rather than a string.
2441
 
2442
@item Explicit external names
2443
Explicit external names are given as string literals.  The most common case
2444
arises when a standard Ada Import or Export pragma is used with three
2445
arguments, as in:
2446
 
2447
@smallexample @c ada
2448
pragma Import (C, C_Routine, "C_routine");
2449
@end smallexample
2450
 
2451
@noindent
2452
In this case, the string literal normally provides the exact casing required
2453
for the external name.  The second argument of pragma
2454
@code{External_Name_Casing} may be used to modify this behavior.
2455
If @code{Uppercase} is specified, then the name
2456
will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2457
then the name will be forced to all lowercase letters.  A specification of
2458
@code{As_Is} provides the normal default behavior in which the casing is
2459
taken from the string provided.
2460
@end table
2461
 
2462
@noindent
2463
This pragma may appear anywhere that a pragma is valid.  In particular, it
2464
can be used as a configuration pragma in the @file{gnat.adc} file, in which
2465
case it applies to all subsequent compilations, or it can be used as a program
2466
unit pragma, in which case it only applies to the current unit, or it can
2467
be used more locally to control individual Import/Export pragmas.
2468
 
2469
It is primarily intended for use with OpenVMS systems, where many
2470
compilers convert all symbols to upper case by default.  For interfacing to
2471
such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2472
the pragma:
2473
 
2474
@smallexample @c ada
2475
pragma External_Name_Casing (Uppercase, Uppercase);
2476
@end smallexample
2477
 
2478
@noindent
2479
to enforce the upper casing of all external symbols.
2480
 
2481
@node Pragma Fast_Math
2482
@unnumberedsec Pragma Fast_Math
2483
@findex Fast_Math
2484
@noindent
2485
Syntax:
2486
 
2487
@smallexample @c ada
2488
pragma Fast_Math;
2489
@end smallexample
2490
 
2491
@noindent
2492
This is a configuration pragma which activates a mode in which speed is
2493
considered more important for floating-point operations than absolutely
2494
accurate adherence to the requirements of the standard. Currently the
2495
following operations are affected:
2496
 
2497
@table @asis
2498
@item Complex Multiplication
2499
The normal simple formula for complex multiplication can result in intermediate
2500
overflows for numbers near the end of the range. The Ada standard requires that
2501
this situation be detected and corrected by scaling, but in Fast_Math mode such
2502
cases will simply result in overflow. Note that to take advantage of this you
2503
must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2504
under control of the pragma, rather than use the preinstantiated versions.
2505
@end table
2506
 
2507
@node Pragma Favor_Top_Level
2508
@unnumberedsec Pragma Favor_Top_Level
2509
@findex Favor_Top_Level
2510
@noindent
2511
Syntax:
2512
 
2513
@smallexample @c ada
2514
pragma Favor_Top_Level (type_NAME);
2515
@end smallexample
2516
 
2517
@noindent
2518
The named type must be an access-to-subprogram type. This pragma is an
2519
efficiency hint to the compiler, regarding the use of 'Access or
2520
'Unrestricted_Access on nested (non-library-level) subprograms. The
2521
pragma means that nested subprograms are not used with this type, or
2522
are rare, so that the generated code should be efficient in the
2523
top-level case. When this pragma is used, dynamically generated
2524
trampolines may be used on some targets for nested subprograms.
2525
See also the No_Implicit_Dynamic_Code restriction.
2526
 
2527
@node Pragma Finalize_Storage_Only
2528
@unnumberedsec Pragma Finalize_Storage_Only
2529
@findex Finalize_Storage_Only
2530
@noindent
2531
Syntax:
2532
 
2533
@smallexample @c ada
2534
pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2535
@end smallexample
2536
 
2537
@noindent
2538
This pragma allows the compiler not to emit a Finalize call for objects
2539
defined at the library level.  This is mostly useful for types where
2540
finalization is only used to deal with storage reclamation since in most
2541
environments it is not necessary to reclaim memory just before terminating
2542
execution, hence the name.
2543
 
2544
@node Pragma Float_Representation
2545
@unnumberedsec Pragma Float_Representation
2546
@cindex OpenVMS
2547
@findex Float_Representation
2548
@noindent
2549
Syntax:
2550
 
2551
@smallexample @c ada
2552
pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2553
 
2554
FLOAT_REP ::= VAX_Float | IEEE_Float
2555
@end smallexample
2556
 
2557
@noindent
2558
In the one argument form, this pragma is a configuration pragma which
2559
allows control over the internal representation chosen for the predefined
2560
floating point types declared in the packages @code{Standard} and
2561
@code{System}. On all systems other than OpenVMS, the argument must
2562
be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2563
argument may be @code{VAX_Float} to specify the use of the VAX float
2564
format for the floating-point types in Standard. This requires that
2565
the standard runtime libraries be recompiled.
2566
 
2567
The two argument form specifies the representation to be used for
2568
the specified floating-point type. On all systems other than OpenVMS,
2569
the argument must
2570
be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2571
argument may be @code{VAX_Float} to specify the use of the VAX float
2572
format, as follows:
2573
 
2574
@itemize @bullet
2575
@item
2576
For digits values up to 6, F float format will be used.
2577
@item
2578
For digits values from 7 to 9, D float format will be used.
2579
@item
2580
For digits values from 10 to 15, G float format will be used.
2581
@item
2582
Digits values above 15 are not allowed.
2583
@end itemize
2584
 
2585
@node Pragma Ident
2586
@unnumberedsec Pragma Ident
2587
@findex Ident
2588
@noindent
2589
Syntax:
2590
 
2591
@smallexample @c ada
2592
pragma Ident (static_string_EXPRESSION);
2593
@end smallexample
2594
 
2595
@noindent
2596
This pragma provides a string identification in the generated object file,
2597
if the system supports the concept of this kind of identification string.
2598
This pragma is allowed only in the outermost declarative part or
2599
declarative items of a compilation unit. If more than one @code{Ident}
2600
pragma is given, only the last one processed is effective.
2601
@cindex OpenVMS
2602
On OpenVMS systems, the effect of the pragma is identical to the effect of
2603
the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2604
maximum allowed length is 31 characters, so if it is important to
2605
maintain compatibility with this compiler, you should obey this length
2606
limit.
2607
 
2608
@node Pragma Implemented
2609
@unnumberedsec Pragma Implemented
2610
@findex Implemented
2611
@noindent
2612
Syntax:
2613
 
2614
@smallexample @c ada
2615
pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2616
 
2617
implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2618
@end smallexample
2619
 
2620
@noindent
2621
This is an Ada 2012 representation pragma which applies to protected, task
2622
and synchronized interface primitives. The use of pragma Implemented provides
2623
a way to impose a static requirement on the overriding operation by adhering
2624
to one of the three implementation kids: entry, protected procedure or any of
2625
the above.
2626
 
2627
@smallexample @c ada
2628
type Synch_Iface is synchronized interface;
2629
procedure Prim_Op (Obj : in out Iface) is abstract;
2630
pragma Implemented (Prim_Op, By_Protected_Procedure);
2631
 
2632
protected type Prot_1 is new Synch_Iface with
2633
   procedure Prim_Op;  --  Legal
2634
end Prot_1;
2635
 
2636
protected type Prot_2 is new Synch_Iface with
2637
   entry Prim_Op;      --  Illegal
2638
end Prot_2;
2639
 
2640
task type Task_Typ is new Synch_Iface with
2641
   entry Prim_Op;      --  Illegal
2642
end Task_Typ;
2643
@end smallexample
2644
 
2645
@noindent
2646
When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2647
Implemented determines the runtime behavior of the requeue. Implementation kind
2648
By_Entry guarantees that the action of requeueing will proceed from an entry to
2649
another entry. Implementation kind By_Protected_Procedure transforms the
2650
requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2651
By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2652
the target's overriding subprogram kind.
2653
 
2654
@node Pragma Implicit_Packing
2655
@unnumberedsec Pragma Implicit_Packing
2656
@findex Implicit_Packing
2657
@noindent
2658
Syntax:
2659
 
2660
@smallexample @c ada
2661
pragma Implicit_Packing;
2662
@end smallexample
2663
 
2664
@noindent
2665
This is a configuration pragma that requests implicit packing for packed
2666
arrays for which a size clause is given but no explicit pragma Pack or
2667
specification of Component_Size is present. It also applies to records
2668
where no record representation clause is present. Consider this example:
2669
 
2670
@smallexample @c ada
2671
type R is array (0 .. 7) of Boolean;
2672
for R'Size use 8;
2673
@end smallexample
2674
 
2675
@noindent
2676
In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2677
does not change the layout of a composite object. So the Size clause in the
2678
above example is normally rejected, since the default layout of the array uses
2679
8-bit components, and thus the array requires a minimum of 64 bits.
2680
 
2681
If this declaration is compiled in a region of code covered by an occurrence
2682
of the configuration pragma Implicit_Packing, then the Size clause in this
2683
and similar examples will cause implicit packing and thus be accepted. For
2684
this implicit packing to occur, the type in question must be an array of small
2685
components whose size is known at compile time, and the Size clause must
2686
specify the exact size that corresponds to the length of the array multiplied
2687
by the size in bits of the component type.
2688
@cindex Array packing
2689
 
2690
Similarly, the following example shows the use in the record case
2691
 
2692
@smallexample @c ada
2693
type r is record
2694
   a, b, c, d, e, f, g, h : boolean;
2695
   chr                    : character;
2696
end record;
2697
for r'size use 16;
2698
@end smallexample
2699
 
2700
@noindent
2701
Without a pragma Pack, each Boolean field requires 8 bits, so the
2702
minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2703
sufficient. The use of pragma Implicit_Packing allows this record
2704
declaration to compile without an explicit pragma Pack.
2705
@node Pragma Import_Exception
2706
@unnumberedsec Pragma Import_Exception
2707
@cindex OpenVMS
2708
@findex Import_Exception
2709
@noindent
2710
Syntax:
2711
 
2712
@smallexample @c ada
2713
pragma Import_Exception (
2714
     [Internal =>] LOCAL_NAME
2715
  [, [External =>] EXTERNAL_SYMBOL]
2716
  [, [Form     =>] Ada | VMS]
2717
  [, [Code     =>] static_integer_EXPRESSION]);
2718
 
2719
EXTERNAL_SYMBOL ::=
2720
  IDENTIFIER
2721
| static_string_EXPRESSION
2722
@end smallexample
2723
 
2724
@noindent
2725
This pragma is implemented only in the OpenVMS implementation of GNAT@.
2726
It allows OpenVMS conditions (for example, from OpenVMS system services or
2727
other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2728
The pragma specifies that the exception associated with an exception
2729
declaration in an Ada program be defined externally (in non-Ada code).
2730
For further details on this pragma, see the
2731
DEC Ada Language Reference Manual, section 13.9a.3.1.
2732
 
2733
@node Pragma Import_Function
2734
@unnumberedsec Pragma Import_Function
2735
@findex Import_Function
2736
@noindent
2737
Syntax:
2738
 
2739
@smallexample @c ada
2740
pragma Import_Function (
2741
     [Internal                 =>] LOCAL_NAME,
2742
  [, [External                 =>] EXTERNAL_SYMBOL]
2743
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2744
  [, [Result_Type              =>] SUBTYPE_MARK]
2745
  [, [Mechanism                =>] MECHANISM]
2746
  [, [Result_Mechanism         =>] MECHANISM_NAME]
2747
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2748
 
2749
EXTERNAL_SYMBOL ::=
2750
  IDENTIFIER
2751
| static_string_EXPRESSION
2752
 
2753
PARAMETER_TYPES ::=
2754
  null
2755
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2756
 
2757
TYPE_DESIGNATOR ::=
2758
  subtype_NAME
2759
| subtype_Name ' Access
2760
 
2761
MECHANISM ::=
2762
  MECHANISM_NAME
2763
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2764
 
2765
MECHANISM_ASSOCIATION ::=
2766
  [formal_parameter_NAME =>] MECHANISM_NAME
2767
 
2768
MECHANISM_NAME ::=
2769
  Value
2770
| Reference
2771
| Descriptor [([Class =>] CLASS_NAME)]
2772
| Short_Descriptor [([Class =>] CLASS_NAME)]
2773
 
2774
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2775
@end smallexample
2776
 
2777
@noindent
2778
This pragma is used in conjunction with a pragma @code{Import} to
2779
specify additional information for an imported function.  The pragma
2780
@code{Import} (or equivalent pragma @code{Interface}) must precede the
2781
@code{Import_Function} pragma and both must appear in the same
2782
declarative part as the function specification.
2783
 
2784
The @var{Internal} argument must uniquely designate
2785
the function to which the
2786
pragma applies.  If more than one function name exists of this name in
2787
the declarative part you must use the @code{Parameter_Types} and
2788
@var{Result_Type} parameters to achieve the required unique
2789
designation.  Subtype marks in these parameters must exactly match the
2790
subtypes in the corresponding function specification, using positional
2791
notation to match parameters with subtype marks.
2792
The form with an @code{'Access} attribute can be used to match an
2793
anonymous access parameter.
2794
 
2795
You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2796
parameters to specify passing mechanisms for the
2797
parameters and result.  If you specify a single mechanism name, it
2798
applies to all parameters.  Otherwise you may specify a mechanism on a
2799
parameter by parameter basis using either positional or named
2800
notation.  If the mechanism is not specified, the default mechanism
2801
is used.
2802
 
2803
@cindex OpenVMS
2804
@cindex Passing by descriptor
2805
Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2806
The default behavior for Import_Function is to pass a 64bit descriptor
2807
unless short_descriptor is specified, then a 32bit descriptor is passed.
2808
 
2809
@code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2810
It specifies that the designated parameter and all following parameters
2811
are optional, meaning that they are not passed at the generated code
2812
level (this is distinct from the notion of optional parameters in Ada
2813
where the parameters are passed anyway with the designated optional
2814
parameters).  All optional parameters must be of mode @code{IN} and have
2815
default parameter values that are either known at compile time
2816
expressions, or uses of the @code{'Null_Parameter} attribute.
2817
 
2818
@node Pragma Import_Object
2819
@unnumberedsec Pragma Import_Object
2820
@findex Import_Object
2821
@noindent
2822
Syntax:
2823
 
2824
@smallexample @c ada
2825
pragma Import_Object
2826
     [Internal =>] LOCAL_NAME
2827
  [, [External =>] EXTERNAL_SYMBOL]
2828
  [, [Size     =>] EXTERNAL_SYMBOL]);
2829
 
2830
EXTERNAL_SYMBOL ::=
2831
  IDENTIFIER
2832
| static_string_EXPRESSION
2833
@end smallexample
2834
 
2835
@noindent
2836
This pragma designates an object as imported, and apart from the
2837
extended rules for external symbols, is identical in effect to the use of
2838
the normal @code{Import} pragma applied to an object.  Unlike the
2839
subprogram case, you need not use a separate @code{Import} pragma,
2840
although you may do so (and probably should do so from a portability
2841
point of view).  @var{size} is syntax checked, but otherwise ignored by
2842
GNAT@.
2843
 
2844
@node Pragma Import_Procedure
2845
@unnumberedsec Pragma Import_Procedure
2846
@findex Import_Procedure
2847
@noindent
2848
Syntax:
2849
 
2850
@smallexample @c ada
2851
pragma Import_Procedure (
2852
     [Internal                 =>] LOCAL_NAME
2853
  [, [External                 =>] EXTERNAL_SYMBOL]
2854
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2855
  [, [Mechanism                =>] MECHANISM]
2856
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2857
 
2858
EXTERNAL_SYMBOL ::=
2859
  IDENTIFIER
2860
| static_string_EXPRESSION
2861
 
2862
PARAMETER_TYPES ::=
2863
  null
2864
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2865
 
2866
TYPE_DESIGNATOR ::=
2867
  subtype_NAME
2868
| subtype_Name ' Access
2869
 
2870
MECHANISM ::=
2871
  MECHANISM_NAME
2872
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2873
 
2874
MECHANISM_ASSOCIATION ::=
2875
  [formal_parameter_NAME =>] MECHANISM_NAME
2876
 
2877
MECHANISM_NAME ::=
2878
  Value
2879
| Reference
2880
| Descriptor [([Class =>] CLASS_NAME)]
2881
| Short_Descriptor [([Class =>] CLASS_NAME)]
2882
 
2883
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2884
@end smallexample
2885
 
2886
@noindent
2887
This pragma is identical to @code{Import_Function} except that it
2888
applies to a procedure rather than a function and the parameters
2889
@code{Result_Type} and @code{Result_Mechanism} are not permitted.
2890
 
2891
@node Pragma Import_Valued_Procedure
2892
@unnumberedsec Pragma Import_Valued_Procedure
2893
@findex Import_Valued_Procedure
2894
@noindent
2895
Syntax:
2896
 
2897
@smallexample @c ada
2898
pragma Import_Valued_Procedure (
2899
     [Internal                 =>] LOCAL_NAME
2900
  [, [External                 =>] EXTERNAL_SYMBOL]
2901
  [, [Parameter_Types          =>] PARAMETER_TYPES]
2902
  [, [Mechanism                =>] MECHANISM]
2903
  [, [First_Optional_Parameter =>] IDENTIFIER]);
2904
 
2905
EXTERNAL_SYMBOL ::=
2906
  IDENTIFIER
2907
| static_string_EXPRESSION
2908
 
2909
PARAMETER_TYPES ::=
2910
  null
2911
| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2912
 
2913
TYPE_DESIGNATOR ::=
2914
  subtype_NAME
2915
| subtype_Name ' Access
2916
 
2917
MECHANISM ::=
2918
  MECHANISM_NAME
2919
| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2920
 
2921
MECHANISM_ASSOCIATION ::=
2922
  [formal_parameter_NAME =>] MECHANISM_NAME
2923
 
2924
MECHANISM_NAME ::=
2925
  Value
2926
| Reference
2927
| Descriptor [([Class =>] CLASS_NAME)]
2928
| Short_Descriptor [([Class =>] CLASS_NAME)]
2929
 
2930
CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2931
@end smallexample
2932
 
2933
@noindent
2934
This pragma is identical to @code{Import_Procedure} except that the
2935
first parameter of @var{LOCAL_NAME}, which must be present, must be of
2936
mode @code{OUT}, and externally the subprogram is treated as a function
2937
with this parameter as the result of the function.  The purpose of this
2938
capability is to allow the use of @code{OUT} and @code{IN OUT}
2939
parameters in interfacing to external functions (which are not permitted
2940
in Ada functions).  You may optionally use the @code{Mechanism}
2941
parameters to specify passing mechanisms for the parameters.
2942
If you specify a single mechanism name, it applies to all parameters.
2943
Otherwise you may specify a mechanism on a parameter by parameter
2944
basis using either positional or named notation.  If the mechanism is not
2945
specified, the default mechanism is used.
2946
 
2947
Note that it is important to use this pragma in conjunction with a separate
2948
pragma Import that specifies the desired convention, since otherwise the
2949
default convention is Ada, which is almost certainly not what is required.
2950
 
2951
@node Pragma Initialize_Scalars
2952
@unnumberedsec Pragma Initialize_Scalars
2953
@findex Initialize_Scalars
2954
@cindex debugging with Initialize_Scalars
2955
@noindent
2956
Syntax:
2957
 
2958
@smallexample @c ada
2959
pragma Initialize_Scalars;
2960
@end smallexample
2961
 
2962
@noindent
2963
This pragma is similar to @code{Normalize_Scalars} conceptually but has
2964
two important differences.  First, there is no requirement for the pragma
2965
to be used uniformly in all units of a partition, in particular, it is fine
2966
to use this just for some or all of the application units of a partition,
2967
without needing to recompile the run-time library.
2968
 
2969
In the case where some units are compiled with the pragma, and some without,
2970
then a declaration of a variable where the type is defined in package
2971
Standard or is locally declared will always be subject to initialization,
2972
as will any declaration of a scalar variable.  For composite variables,
2973
whether the variable is initialized may also depend on whether the package
2974
in which the type of the variable is declared is compiled with the pragma.
2975
 
2976
The other important difference is that you can control the value used
2977
for initializing scalar objects.  At bind time, you can select several
2978
options for initialization. You can
2979
initialize with invalid values (similar to Normalize_Scalars, though for
2980
Initialize_Scalars it is not always possible to determine the invalid
2981
values in complex cases like signed component fields with non-standard
2982
sizes). You can also initialize with high or
2983
low values, or with a specified bit pattern.  See the users guide for binder
2984
options for specifying these cases.
2985
 
2986
This means that you can compile a program, and then without having to
2987
recompile the program, you can run it with different values being used
2988
for initializing otherwise uninitialized values, to test if your program
2989
behavior depends on the choice.  Of course the behavior should not change,
2990
and if it does, then most likely you have an erroneous reference to an
2991
uninitialized value.
2992
 
2993
It is even possible to change the value at execution time eliminating even
2994
the need to rebind with a different switch using an environment variable.
2995
See the GNAT users guide for details.
2996
 
2997
Note that pragma @code{Initialize_Scalars} is particularly useful in
2998
conjunction with the enhanced validity checking that is now provided
2999
in GNAT, which checks for invalid values under more conditions.
3000
Using this feature (see description of the @option{-gnatV} flag in the
3001
users guide) in conjunction with pragma @code{Initialize_Scalars}
3002
provides a powerful new tool to assist in the detection of problems
3003
caused by uninitialized variables.
3004
 
3005
Note: the use of @code{Initialize_Scalars} has a fairly extensive
3006
effect on the generated code. This may cause your code to be
3007
substantially larger. It may also cause an increase in the amount
3008
of stack required, so it is probably a good idea to turn on stack
3009
checking (see description of stack checking in the GNAT users guide)
3010
when using this pragma.
3011
 
3012
@node Pragma Inline_Always
3013
@unnumberedsec Pragma Inline_Always
3014
@findex Inline_Always
3015
@noindent
3016
Syntax:
3017
 
3018
@smallexample @c ada
3019
pragma Inline_Always (NAME [, NAME]);
3020
@end smallexample
3021
 
3022
@noindent
3023
Similar to pragma @code{Inline} except that inlining is not subject to
3024
the use of option @option{-gnatn} and the inlining happens regardless of
3025
whether this option is used.
3026
 
3027
@node Pragma Inline_Generic
3028
@unnumberedsec Pragma Inline_Generic
3029
@findex Inline_Generic
3030
@noindent
3031
Syntax:
3032
 
3033
@smallexample @c ada
3034
pragma Inline_Generic (generic_package_NAME);
3035
@end smallexample
3036
 
3037
@noindent
3038
This is implemented for compatibility with DEC Ada 83 and is recognized,
3039
but otherwise ignored, by GNAT@.  All generic instantiations are inlined
3040
by default when using GNAT@.
3041
 
3042
@node Pragma Interface
3043
@unnumberedsec Pragma Interface
3044
@findex Interface
3045
@noindent
3046
Syntax:
3047
 
3048
@smallexample @c ada
3049
pragma Interface (
3050
     [Convention    =>] convention_identifier,
3051
     [Entity        =>] local_NAME
3052
  [, [External_Name =>] static_string_expression]
3053
  [, [Link_Name     =>] static_string_expression]);
3054
@end smallexample
3055
 
3056
@noindent
3057
This pragma is identical in syntax and semantics to
3058
the standard Ada pragma @code{Import}.  It is provided for compatibility
3059
with Ada 83.  The definition is upwards compatible both with pragma
3060
@code{Interface} as defined in the Ada 83 Reference Manual, and also
3061
with some extended implementations of this pragma in certain Ada 83
3062
implementations.  The only difference between pragma @code{Interface}
3063
and pragma @code{Import} is that there is special circuitry to allow
3064
both pragmas to appear for the same subprogram entity (normally it
3065
is illegal to have multiple @code{Import} pragmas. This is useful in
3066
maintaining Ada 83/Ada 95 compatibility and is compatible with other
3067
Ada 83 compilers.
3068
 
3069
@node Pragma Interface_Name
3070
@unnumberedsec Pragma Interface_Name
3071
@findex Interface_Name
3072
@noindent
3073
Syntax:
3074
 
3075
@smallexample @c ada
3076
pragma Interface_Name (
3077
     [Entity        =>] LOCAL_NAME
3078
  [, [External_Name =>] static_string_EXPRESSION]
3079
  [, [Link_Name     =>] static_string_EXPRESSION]);
3080
@end smallexample
3081
 
3082
@noindent
3083
This pragma provides an alternative way of specifying the interface name
3084
for an interfaced subprogram, and is provided for compatibility with Ada
3085
83 compilers that use the pragma for this purpose.  You must provide at
3086
least one of @var{External_Name} or @var{Link_Name}.
3087
 
3088
@node Pragma Interrupt_Handler
3089
@unnumberedsec Pragma Interrupt_Handler
3090
@findex Interrupt_Handler
3091
@noindent
3092
Syntax:
3093
 
3094
@smallexample @c ada
3095
pragma Interrupt_Handler (procedure_LOCAL_NAME);
3096
@end smallexample
3097
 
3098
@noindent
3099
This program unit pragma is supported for parameterless protected procedures
3100
as described in Annex C of the Ada Reference Manual. On the AAMP target
3101
the pragma can also be specified for nonprotected parameterless procedures
3102
that are declared at the library level (which includes procedures
3103
declared at the top level of a library package). In the case of AAMP,
3104
when this pragma is applied to a nonprotected procedure, the instruction
3105
@code{IERET} is generated for returns from the procedure, enabling
3106
maskable interrupts, in place of the normal return instruction.
3107
 
3108
@node Pragma Interrupt_State
3109
@unnumberedsec Pragma Interrupt_State
3110
@findex Interrupt_State
3111
@noindent
3112
Syntax:
3113
 
3114
@smallexample @c ada
3115
pragma Interrupt_State
3116
 ([Name  =>] value,
3117
  [State =>] SYSTEM | RUNTIME | USER);
3118
@end smallexample
3119
 
3120
@noindent
3121
Normally certain interrupts are reserved to the implementation.  Any attempt
3122
to attach an interrupt causes Program_Error to be raised, as described in
3123
RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3124
many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3125
reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3126
interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3127
@code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3128
Ada exceptions, or used to implement run-time functions such as the
3129
@code{abort} statement and stack overflow checking.
3130
 
3131
Pragma @code{Interrupt_State} provides a general mechanism for overriding
3132
such uses of interrupts.  It subsumes the functionality of pragma
3133
@code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3134
available on Windows or VMS.  On all other platforms than VxWorks,
3135
it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3136
and may be used to mark interrupts required by the board support package
3137
as reserved.
3138
 
3139
Interrupts can be in one of three states:
3140
@itemize @bullet
3141
@item System
3142
 
3143
The interrupt is reserved (no Ada handler can be installed), and the
3144
Ada run-time may not install a handler. As a result you are guaranteed
3145
standard system default action if this interrupt is raised.
3146
 
3147
@item Runtime
3148
 
3149
The interrupt is reserved (no Ada handler can be installed). The run time
3150
is allowed to install a handler for internal control purposes, but is
3151
not required to do so.
3152
 
3153
@item User
3154
 
3155
The interrupt is unreserved.  The user may install a handler to provide
3156
some other action.
3157
@end itemize
3158
 
3159
@noindent
3160
These states are the allowed values of the @code{State} parameter of the
3161
pragma.  The @code{Name} parameter is a value of the type
3162
@code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3163
@code{Ada.Interrupts.Names}.
3164
 
3165
This is a configuration pragma, and the binder will check that there
3166
are no inconsistencies between different units in a partition in how a
3167
given interrupt is specified. It may appear anywhere a pragma is legal.
3168
 
3169
The effect is to move the interrupt to the specified state.
3170
 
3171
By declaring interrupts to be SYSTEM, you guarantee the standard system
3172
action, such as a core dump.
3173
 
3174
By declaring interrupts to be USER, you guarantee that you can install
3175
a handler.
3176
 
3177
Note that certain signals on many operating systems cannot be caught and
3178
handled by applications.  In such cases, the pragma is ignored.  See the
3179
operating system documentation, or the value of the array @code{Reserved}
3180
declared in the spec of package @code{System.OS_Interface}.
3181
 
3182
Overriding the default state of signals used by the Ada runtime may interfere
3183
with an application's runtime behavior in the cases of the synchronous signals,
3184
and in the case of the signal used to implement the @code{abort} statement.
3185
 
3186
@node Pragma Invariant
3187
@unnumberedsec Pragma Invariant
3188
@findex Invariant
3189
@noindent
3190
Syntax:
3191
 
3192
@smallexample @c ada
3193
pragma Invariant
3194
  ([Entity =>]    private_type_LOCAL_NAME,
3195
   [Check  =>]    EXPRESSION
3196
   [,[Message =>] String_Expression]);
3197
@end smallexample
3198
 
3199
@noindent
3200
This pragma provides exactly the same capabilities as the Invariant aspect
3201
defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3202
aspect is fully implemented in Ada 2012 mode, but since it requires the use
3203
of the aspect syntax, which is not available exception in 2012 mode, it is
3204
not possible to use the Invariant aspect in earlier versions of Ada. However
3205
the Invariant pragma may be used in any version of Ada.
3206
 
3207
The pragma must appear within the visible part of the package specification,
3208
after the type to which its Entity argument appears. As with the Invariant
3209
aspect, the Check expression is not analyzed until the end of the visible
3210
part of the package, so it may contain forward references. The Message
3211
argument, if present, provides the exception message used if the invariant
3212
is violated. If no Message parameter is provided, a default message that
3213
identifies the line on which the pragma appears is used.
3214
 
3215
It is permissible to have multiple Invariants for the same type entity, in
3216
which case they are and'ed together. It is permissible to use this pragma
3217
in Ada 2012 mode, but you cannot have both an invariant aspect and an
3218
invariant pragma for the same entity.
3219
 
3220
For further details on the use of this pragma, see the Ada 2012 documentation
3221
of the Invariant aspect.
3222
 
3223
@node Pragma Keep_Names
3224
@unnumberedsec Pragma Keep_Names
3225
@findex Keep_Names
3226
@noindent
3227
Syntax:
3228
 
3229
@smallexample @c ada
3230
pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3231
@end smallexample
3232
 
3233
@noindent
3234
The @var{LOCAL_NAME} argument
3235
must refer to an enumeration first subtype
3236
in the current declarative part. The effect is to retain the enumeration
3237
literal names for use by @code{Image} and @code{Value} even if a global
3238
@code{Discard_Names} pragma applies. This is useful when you want to
3239
generally suppress enumeration literal names and for example you therefore
3240
use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3241
want to retain the names for specific enumeration types.
3242
 
3243
@node Pragma License
3244
@unnumberedsec Pragma License
3245
@findex License
3246
@cindex License checking
3247
@noindent
3248
Syntax:
3249
 
3250
@smallexample @c ada
3251
pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3252
@end smallexample
3253
 
3254
@noindent
3255
This pragma is provided to allow automated checking for appropriate license
3256
conditions with respect to the standard and modified GPL@.  A pragma
3257
@code{License}, which is a configuration pragma that typically appears at
3258
the start of a source file or in a separate @file{gnat.adc} file, specifies
3259
the licensing conditions of a unit as follows:
3260
 
3261
@itemize @bullet
3262
@item Unrestricted
3263
This is used for a unit that can be freely used with no license restrictions.
3264
Examples of such units are public domain units, and units from the Ada
3265
Reference Manual.
3266
 
3267
@item GPL
3268
This is used for a unit that is licensed under the unmodified GPL, and which
3269
therefore cannot be @code{with}'ed by a restricted unit.
3270
 
3271
@item Modified_GPL
3272
This is used for a unit licensed under the GNAT modified GPL that includes
3273
a special exception paragraph that specifically permits the inclusion of
3274
the unit in programs without requiring the entire program to be released
3275
under the GPL@.
3276
 
3277
@item Restricted
3278
This is used for a unit that is restricted in that it is not permitted to
3279
depend on units that are licensed under the GPL@.  Typical examples are
3280
proprietary code that is to be released under more restrictive license
3281
conditions.  Note that restricted units are permitted to @code{with} units
3282
which are licensed under the modified GPL (this is the whole point of the
3283
modified GPL).
3284
 
3285
@end itemize
3286
 
3287
@noindent
3288
Normally a unit with no @code{License} pragma is considered to have an
3289
unknown license, and no checking is done.  However, standard GNAT headers
3290
are recognized, and license information is derived from them as follows.
3291
 
3292
@itemize @bullet
3293
 
3294
A GNAT license header starts with a line containing 78 hyphens.  The following
3295
comment text is searched for the appearance of any of the following strings.
3296
 
3297
If the string ``GNU General Public License'' is found, then the unit is assumed
3298
to have GPL license, unless the string ``As a special exception'' follows, in
3299
which case the license is assumed to be modified GPL@.
3300
 
3301
If one of the strings
3302
``This specification is adapted from the Ada Semantic Interface'' or
3303
``This specification is derived from the Ada Reference Manual'' is found
3304
then the unit is assumed to be unrestricted.
3305
@end itemize
3306
 
3307
@noindent
3308
These default actions means that a program with a restricted license pragma
3309
will automatically get warnings if a GPL unit is inappropriately
3310
@code{with}'ed.  For example, the program:
3311
 
3312
@smallexample @c ada
3313
with Sem_Ch3;
3314
with GNAT.Sockets;
3315
procedure Secret_Stuff is
3316
  @dots{}
3317
end Secret_Stuff
3318
@end smallexample
3319
 
3320
@noindent
3321
if compiled with pragma @code{License} (@code{Restricted}) in a
3322
@file{gnat.adc} file will generate the warning:
3323
 
3324
@smallexample
3325
1.  with Sem_Ch3;
3326
        |
3327
   >>> license of withed unit "Sem_Ch3" is incompatible
3328
 
3329
2.  with GNAT.Sockets;
3330
3.  procedure Secret_Stuff is
3331
@end smallexample
3332
 
3333
@noindent
3334
Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3335
compiler and is licensed under the
3336
GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3337
run time, and is therefore licensed under the modified GPL@.
3338
 
3339
@node Pragma Link_With
3340
@unnumberedsec Pragma Link_With
3341
@findex Link_With
3342
@noindent
3343
Syntax:
3344
 
3345
@smallexample @c ada
3346
pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3347
@end smallexample
3348
 
3349
@noindent
3350
This pragma is provided for compatibility with certain Ada 83 compilers.
3351
It has exactly the same effect as pragma @code{Linker_Options} except
3352
that spaces occurring within one of the string expressions are treated
3353
as separators. For example, in the following case:
3354
 
3355
@smallexample @c ada
3356
pragma Link_With ("-labc -ldef");
3357
@end smallexample
3358
 
3359
@noindent
3360
results in passing the strings @code{-labc} and @code{-ldef} as two
3361
separate arguments to the linker. In addition pragma Link_With allows
3362
multiple arguments, with the same effect as successive pragmas.
3363
 
3364
@node Pragma Linker_Alias
3365
@unnumberedsec Pragma Linker_Alias
3366
@findex Linker_Alias
3367
@noindent
3368
Syntax:
3369
 
3370
@smallexample @c ada
3371
pragma Linker_Alias (
3372
  [Entity =>] LOCAL_NAME,
3373
  [Target =>] static_string_EXPRESSION);
3374
@end smallexample
3375
 
3376
@noindent
3377
@var{LOCAL_NAME} must refer to an object that is declared at the library
3378
level. This pragma establishes the given entity as a linker alias for the
3379
given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3380
and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3381
@var{static_string_EXPRESSION} in the object file, that is to say no space
3382
is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3383
to the same address as @var{static_string_EXPRESSION} by the linker.
3384
 
3385
The actual linker name for the target must be used (e.g.@: the fully
3386
encoded name with qualification in Ada, or the mangled name in C++),
3387
or it must be declared using the C convention with @code{pragma Import}
3388
or @code{pragma Export}.
3389
 
3390
Not all target machines support this pragma. On some of them it is accepted
3391
only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3392
 
3393
@smallexample @c ada
3394
--  Example of the use of pragma Linker_Alias
3395
 
3396
package p is
3397
  i : Integer := 1;
3398
  pragma Export (C, i);
3399
 
3400
  new_name_for_i : Integer;
3401
  pragma Linker_Alias (new_name_for_i, "i");
3402
end p;
3403
@end smallexample
3404
 
3405
@node Pragma Linker_Constructor
3406
@unnumberedsec Pragma Linker_Constructor
3407
@findex Linker_Constructor
3408
@noindent
3409
Syntax:
3410
 
3411
@smallexample @c ada
3412
pragma Linker_Constructor (procedure_LOCAL_NAME);
3413
@end smallexample
3414
 
3415
@noindent
3416
@var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3417
is declared at the library level. A procedure to which this pragma is
3418
applied will be treated as an initialization routine by the linker.
3419
It is equivalent to @code{__attribute__((constructor))} in GNU C and
3420
causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3421
of the executable is called (or immediately after the shared library is
3422
loaded if the procedure is linked in a shared library), in particular
3423
before the Ada run-time environment is set up.
3424
 
3425
Because of these specific contexts, the set of operations such a procedure
3426
can perform is very limited and the type of objects it can manipulate is
3427
essentially restricted to the elementary types. In particular, it must only
3428
contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3429
 
3430
This pragma is used by GNAT to implement auto-initialization of shared Stand
3431
Alone Libraries, which provides a related capability without the restrictions
3432
listed above. Where possible, the use of Stand Alone Libraries is preferable
3433
to the use of this pragma.
3434
 
3435
@node Pragma Linker_Destructor
3436
@unnumberedsec Pragma Linker_Destructor
3437
@findex Linker_Destructor
3438
@noindent
3439
Syntax:
3440
 
3441
@smallexample @c ada
3442
pragma Linker_Destructor (procedure_LOCAL_NAME);
3443
@end smallexample
3444
 
3445
@noindent
3446
@var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3447
is declared at the library level. A procedure to which this pragma is
3448
applied will be treated as a finalization routine by the linker.
3449
It is equivalent to @code{__attribute__((destructor))} in GNU C and
3450
causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3451
of the executable has exited (or immediately before the shared library
3452
is unloaded if the procedure is linked in a shared library), in particular
3453
after the Ada run-time environment is shut down.
3454
 
3455
See @code{pragma Linker_Constructor} for the set of restrictions that apply
3456
because of these specific contexts.
3457
 
3458
@node Pragma Linker_Section
3459
@unnumberedsec Pragma Linker_Section
3460
@findex Linker_Section
3461
@noindent
3462
Syntax:
3463
 
3464
@smallexample @c ada
3465
pragma Linker_Section (
3466
  [Entity  =>] LOCAL_NAME,
3467
  [Section =>] static_string_EXPRESSION);
3468
@end smallexample
3469
 
3470
@noindent
3471
@var{LOCAL_NAME} must refer to an object that is declared at the library
3472
level. This pragma specifies the name of the linker section for the given
3473
entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3474
causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3475
section of the executable (assuming the linker doesn't rename the section).
3476
 
3477
The compiler normally places library-level objects in standard sections
3478
depending on their type: procedures and functions generally go in the
3479
@code{.text} section, initialized variables in the @code{.data} section
3480
and uninitialized variables in the @code{.bss} section.
3481
 
3482
Other, special sections may exist on given target machines to map special
3483
hardware, for example I/O ports or flash memory. This pragma is a means to
3484
defer the final layout of the executable to the linker, thus fully working
3485
at the symbolic level with the compiler.
3486
 
3487
Some file formats do not support arbitrary sections so not all target
3488
machines support this pragma. The use of this pragma may cause a program
3489
execution to be erroneous if it is used to place an entity into an
3490
inappropriate section (e.g.@: a modified variable into the @code{.text}
3491
section). See also @code{pragma Persistent_BSS}.
3492
 
3493
@smallexample @c ada
3494
--  Example of the use of pragma Linker_Section
3495
 
3496
package IO_Card is
3497
  Port_A : Integer;
3498
  pragma Volatile (Port_A);
3499
  pragma Linker_Section (Port_A, ".bss.port_a");
3500
 
3501
  Port_B : Integer;
3502
  pragma Volatile (Port_B);
3503
  pragma Linker_Section (Port_B, ".bss.port_b");
3504
end IO_Card;
3505
@end smallexample
3506
 
3507
@node Pragma Long_Float
3508
@unnumberedsec Pragma Long_Float
3509
@cindex OpenVMS
3510
@findex Long_Float
3511
@noindent
3512
Syntax:
3513
 
3514
@smallexample @c ada
3515
pragma Long_Float (FLOAT_FORMAT);
3516
 
3517
FLOAT_FORMAT ::= D_Float | G_Float
3518
@end smallexample
3519
 
3520
@noindent
3521
This pragma is implemented only in the OpenVMS implementation of GNAT@.
3522
It allows control over the internal representation chosen for the predefined
3523
type @code{Long_Float} and for floating point type representations with
3524
@code{digits} specified in the range 7 through 15.
3525
For further details on this pragma, see the
3526
@cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3527
this pragma, the standard runtime libraries must be recompiled.
3528
 
3529
@node Pragma Machine_Attribute
3530
@unnumberedsec Pragma Machine_Attribute
3531
@findex Machine_Attribute
3532
@noindent
3533
Syntax:
3534
 
3535
@smallexample @c ada
3536
pragma Machine_Attribute (
3537
     [Entity         =>] LOCAL_NAME,
3538
     [Attribute_Name =>] static_string_EXPRESSION
3539
  [, [Info           =>] static_EXPRESSION] );
3540
@end smallexample
3541
 
3542
@noindent
3543
Machine-dependent attributes can be specified for types and/or
3544
declarations.  This pragma is semantically equivalent to
3545
@code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3546
specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3547
in GNU C, where @code{@var{attribute_name}} is recognized by the
3548
compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3549
specific macro.  A string literal for the optional parameter @var{info}
3550
is transformed into an identifier, which may make this pragma unusable
3551
for some attributes.  @xref{Target Attributes,, Defining target-specific
3552
uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3553
Internals}, further information.
3554
 
3555
@node Pragma Main
3556
@unnumberedsec Pragma Main
3557
@cindex OpenVMS
3558
@findex Main
3559
@noindent
3560
Syntax:
3561
 
3562
@smallexample @c ada
3563
pragma Main
3564
 (MAIN_OPTION [, MAIN_OPTION]);
3565
 
3566
MAIN_OPTION ::=
3567
  [Stack_Size              =>] static_integer_EXPRESSION
3568
| [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3569
| [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3570
@end smallexample
3571
 
3572
@noindent
3573
This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3574
no effect in GNAT, other than being syntax checked.
3575
 
3576
@node Pragma Main_Storage
3577
@unnumberedsec Pragma Main_Storage
3578
@cindex OpenVMS
3579
@findex Main_Storage
3580
@noindent
3581
Syntax:
3582
 
3583
@smallexample @c ada
3584
pragma Main_Storage
3585
  (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3586
 
3587
MAIN_STORAGE_OPTION ::=
3588
  [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3589
| [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3590
@end smallexample
3591
 
3592
@noindent
3593
This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3594
no effect in GNAT, other than being syntax checked.  Note that the pragma
3595
also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3596
 
3597
@node Pragma No_Body
3598
@unnumberedsec Pragma No_Body
3599
@findex No_Body
3600
@noindent
3601
Syntax:
3602
 
3603
@smallexample @c ada
3604
pragma No_Body;
3605
@end smallexample
3606
 
3607
@noindent
3608
There are a number of cases in which a package spec does not require a body,
3609
and in fact a body is not permitted. GNAT will not permit the spec to be
3610
compiled if there is a body around. The pragma No_Body allows you to provide
3611
a body file, even in a case where no body is allowed. The body file must
3612
contain only comments and a single No_Body pragma. This is recognized by
3613
the compiler as indicating that no body is logically present.
3614
 
3615
This is particularly useful during maintenance when a package is modified in
3616
such a way that a body needed before is no longer needed. The provision of a
3617
dummy body with a No_Body pragma ensures that there is no interference from
3618
earlier versions of the package body.
3619
 
3620
@node Pragma No_Return
3621
@unnumberedsec Pragma No_Return
3622
@findex No_Return
3623
@noindent
3624
Syntax:
3625
 
3626
@smallexample @c ada
3627
pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3628
@end smallexample
3629
 
3630
@noindent
3631
Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3632
declarations in the current declarative part.  A procedure to which this
3633
pragma is applied may not contain any explicit @code{return} statements.
3634
In addition, if the procedure contains any implicit returns from falling
3635
off the end of a statement sequence, then execution of that implicit
3636
return will cause Program_Error to be raised.
3637
 
3638
One use of this pragma is to identify procedures whose only purpose is to raise
3639
an exception. Another use of this pragma is to suppress incorrect warnings
3640
about missing returns in functions, where the last statement of a function
3641
statement sequence is a call to such a procedure.
3642
 
3643
Note that in Ada 2005 mode, this pragma is part of the language, and is
3644
identical in effect to the pragma as implemented in Ada 95 mode.
3645
 
3646
@node Pragma No_Strict_Aliasing
3647
@unnumberedsec Pragma No_Strict_Aliasing
3648
@findex No_Strict_Aliasing
3649
@noindent
3650
Syntax:
3651
 
3652
@smallexample @c ada
3653
pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3654
@end smallexample
3655
 
3656
@noindent
3657
@var{type_LOCAL_NAME} must refer to an access type
3658
declaration in the current declarative part.  The effect is to inhibit
3659
strict aliasing optimization for the given type.  The form with no
3660
arguments is a configuration pragma which applies to all access types
3661
declared in units to which the pragma applies. For a detailed
3662
description of the strict aliasing optimization, and the situations
3663
in which it must be suppressed, see @ref{Optimization and Strict
3664
Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3665
 
3666
This pragma currently has no effects on access to unconstrained array types.
3667
 
3668
@node Pragma Normalize_Scalars
3669
@unnumberedsec Pragma Normalize_Scalars
3670
@findex Normalize_Scalars
3671
@noindent
3672
Syntax:
3673
 
3674
@smallexample @c ada
3675
pragma Normalize_Scalars;
3676
@end smallexample
3677
 
3678
@noindent
3679
This is a language defined pragma which is fully implemented in GNAT@.  The
3680
effect is to cause all scalar objects that are not otherwise initialized
3681
to be initialized.  The initial values are implementation dependent and
3682
are as follows:
3683
 
3684
@table @code
3685
@item Standard.Character
3686
@noindent
3687
Objects whose root type is Standard.Character are initialized to
3688
Character'Last unless the subtype range excludes NUL (in which case
3689
NUL is used). This choice will always generate an invalid value if
3690
one exists.
3691
 
3692
@item Standard.Wide_Character
3693
@noindent
3694
Objects whose root type is Standard.Wide_Character are initialized to
3695
Wide_Character'Last unless the subtype range excludes NUL (in which case
3696
NUL is used). This choice will always generate an invalid value if
3697
one exists.
3698
 
3699
@item Standard.Wide_Wide_Character
3700
@noindent
3701
Objects whose root type is Standard.Wide_Wide_Character are initialized to
3702
the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3703
which case NUL is used). This choice will always generate an invalid value if
3704
one exists.
3705
 
3706
@item Integer types
3707
@noindent
3708
Objects of an integer type are treated differently depending on whether
3709
negative values are present in the subtype. If no negative values are
3710
present, then all one bits is used as the initial value except in the
3711
special case where zero is excluded from the subtype, in which case
3712
all zero bits are used. This choice will always generate an invalid
3713
value if one exists.
3714
 
3715
For subtypes with negative values present, the largest negative number
3716
is used, except in the unusual case where this largest negative number
3717
is in the subtype, and the largest positive number is not, in which case
3718
the largest positive value is used. This choice will always generate
3719
an invalid value if one exists.
3720
 
3721
@item Floating-Point Types
3722
Objects of all floating-point types are initialized to all 1-bits. For
3723
standard IEEE format, this corresponds to a NaN (not a number) which is
3724
indeed an invalid value.
3725
 
3726
@item Fixed-Point Types
3727
Objects of all fixed-point types are treated as described above for integers,
3728
with the rules applying to the underlying integer value used to represent
3729
the fixed-point value.
3730
 
3731
@item Modular types
3732
Objects of a modular type are initialized to all one bits, except in
3733
the special case where zero is excluded from the subtype, in which
3734
case all zero bits are used. This choice will always generate an
3735
invalid value if one exists.
3736
 
3737
@item Enumeration types
3738
Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3739
the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3740
whose Pos value is zero, in which case a code of zero is used. This choice
3741
will always generate an invalid value if one exists.
3742
 
3743
@end table
3744
 
3745
@node Pragma Obsolescent
3746
@unnumberedsec Pragma Obsolescent
3747
@findex Obsolescent
3748
@noindent
3749
Syntax:
3750
 
3751
@smallexample @c ada
3752
pragma Obsolescent;
3753
 
3754
pragma Obsolescent (
3755
  [Message =>] static_string_EXPRESSION
3756
[,[Version =>] Ada_05]]);
3757
 
3758
pragma Obsolescent (
3759
  [Entity  =>] NAME
3760
[,[Message =>] static_string_EXPRESSION
3761
[,[Version =>] Ada_05]] );
3762
@end smallexample
3763
 
3764
@noindent
3765
This pragma can occur immediately following a declaration of an entity,
3766
including the case of a record component. If no Entity argument is present,
3767
then this declaration is the one to which the pragma applies. If an Entity
3768
parameter is present, it must either match the name of the entity in this
3769
declaration, or alternatively, the pragma can immediately follow an enumeration
3770
type declaration, where the Entity argument names one of the enumeration
3771
literals.
3772
 
3773
This pragma is used to indicate that the named entity
3774
is considered obsolescent and should not be used. Typically this is
3775
used when an API must be modified by eventually removing or modifying
3776
existing subprograms or other entities. The pragma can be used at an
3777
intermediate stage when the entity is still present, but will be
3778
removed later.
3779
 
3780
The effect of this pragma is to output a warning message on a reference to
3781
an entity thus marked that the subprogram is obsolescent if the appropriate
3782
warning option in the compiler is activated. If the Message parameter is
3783
present, then a second warning message is given containing this text. In
3784
addition, a reference to the entity is considered to be a violation of pragma
3785
Restrictions (No_Obsolescent_Features).
3786
 
3787
This pragma can also be used as a program unit pragma for a package,
3788
in which case the entity name is the name of the package, and the
3789
pragma indicates that the entire package is considered
3790
obsolescent. In this case a client @code{with}'ing such a package
3791
violates the restriction, and the @code{with} statement is
3792
flagged with warnings if the warning option is set.
3793
 
3794
If the Version parameter is present (which must be exactly
3795
the identifier Ada_05, no other argument is allowed), then the
3796
indication of obsolescence applies only when compiling in Ada 2005
3797
mode. This is primarily intended for dealing with the situations
3798
in the predefined library where subprograms or packages
3799
have become defined as obsolescent in Ada 2005
3800
(e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3801
 
3802
The following examples show typical uses of this pragma:
3803
 
3804
@smallexample @c ada
3805
package p is
3806
   pragma Obsolescent (p, Message => "use pp instead of p");
3807
end p;
3808
 
3809
package q is
3810
   procedure q2;
3811
   pragma Obsolescent ("use q2new instead");
3812
 
3813
   type R is new integer;
3814
   pragma Obsolescent
3815
     (Entity  => R,
3816
      Message => "use RR in Ada 2005",
3817
      Version => Ada_05);
3818
 
3819
   type M is record
3820
      F1 : Integer;
3821
      F2 : Integer;
3822
      pragma Obsolescent;
3823
      F3 : Integer;
3824
   end record;
3825
 
3826
   type E is (a, bc, 'd', quack);
3827
   pragma Obsolescent (Entity => bc)
3828
   pragma Obsolescent (Entity => 'd')
3829
 
3830
   function "+"
3831
     (a, b : character) return character;
3832
   pragma Obsolescent (Entity => "+");
3833
end;
3834
@end smallexample
3835
 
3836
@noindent
3837
Note that, as for all pragmas, if you use a pragma argument identifier,
3838
then all subsequent parameters must also use a pragma argument identifier.
3839
So if you specify "Entity =>" for the Entity argument, and a Message
3840
argument is present, it must be preceded by "Message =>".
3841
 
3842
@node Pragma Optimize_Alignment
3843
@unnumberedsec Pragma Optimize_Alignment
3844
@findex Optimize_Alignment
3845
@cindex Alignment, default settings
3846
@noindent
3847
Syntax:
3848
 
3849
@smallexample @c ada
3850
pragma Optimize_Alignment (TIME | SPACE | OFF);
3851
@end smallexample
3852
 
3853
@noindent
3854
This is a configuration pragma which affects the choice of default alignments
3855
for types where no alignment is explicitly specified. There is a time/space
3856
trade-off in the selection of these values. Large alignments result in more
3857
efficient code, at the expense of larger data space, since sizes have to be
3858
increased to match these alignments. Smaller alignments save space, but the
3859
access code is slower. The normal choice of default alignments (which is what
3860
you get if you do not use this pragma, or if you use an argument of OFF),
3861
tries to balance these two requirements.
3862
 
3863
Specifying SPACE causes smaller default alignments to be chosen in two cases.
3864
First any packed record is given an alignment of 1. Second, if a size is given
3865
for the type, then the alignment is chosen to avoid increasing this size. For
3866
example, consider:
3867
 
3868
@smallexample @c ada
3869
   type R is record
3870
      X : Integer;
3871
      Y : Character;
3872
   end record;
3873
 
3874
   for R'Size use 5*8;
3875
@end smallexample
3876
 
3877
@noindent
3878
In the default mode, this type gets an alignment of 4, so that access to the
3879
Integer field X are efficient. But this means that objects of the type end up
3880
with a size of 8 bytes. This is a valid choice, since sizes of objects are
3881
allowed to be bigger than the size of the type, but it can waste space if for
3882
example fields of type R appear in an enclosing record. If the above type is
3883
compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3884
 
3885
Specifying TIME causes larger default alignments to be chosen in the case of
3886
small types with sizes that are not a power of 2. For example, consider:
3887
 
3888
@smallexample @c ada
3889
   type R is record
3890
      A : Character;
3891
      B : Character;
3892
      C : Boolean;
3893
   end record;
3894
 
3895
   pragma Pack (R);
3896
   for R'Size use 17;
3897
@end smallexample
3898
 
3899
@noindent
3900
The default alignment for this record is normally 1, but if this type is
3901
compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3902
to 4, which wastes space for objects of the type, since they are now 4 bytes
3903
long, but results in more efficient access when the whole record is referenced.
3904
 
3905
As noted above, this is a configuration pragma, and there is a requirement
3906
that all units in a partition be compiled with a consistent setting of the
3907
optimization setting. This would normally be achieved by use of a configuration
3908
pragma file containing the appropriate setting. The exception to this rule is
3909
that units with an explicit configuration pragma in the same file as the source
3910
unit are excluded from the consistency check, as are all predefined units. The
3911
latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3912
pragma appears at the start of the file.
3913
 
3914
@node Pragma Ordered
3915
@unnumberedsec Pragma Ordered
3916
@findex Ordered
3917
@findex pragma @code{Ordered}
3918
@noindent
3919
Syntax:
3920
 
3921
@smallexample @c ada
3922
pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3923
@end smallexample
3924
 
3925
@noindent
3926
Most enumeration types are from a conceptual point of view unordered.
3927
For example, consider:
3928
 
3929
@smallexample @c ada
3930
type Color is (Red, Blue, Green, Yellow);
3931
@end smallexample
3932
 
3933
@noindent
3934
By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3935
but really these relations make no sense; the enumeration type merely
3936
specifies a set of possible colors, and the order is unimportant.
3937
 
3938
For unordered enumeration types, it is generally a good idea if
3939
clients avoid comparisons (other than equality or inequality) and
3940
explicit ranges. (A @emph{client} is a unit where the type is referenced,
3941
other than the unit where the type is declared, its body, and its subunits.)
3942
For example, if code buried in some client says:
3943
 
3944
@smallexample @c ada
3945
if Current_Color < Yellow then ...
3946
if Current_Color in Blue .. Green then ...
3947
@end smallexample
3948
 
3949
@noindent
3950
then the client code is relying on the order, which is undesirable.
3951
It makes the code hard to read and creates maintenance difficulties if
3952
entries have to be added to the enumeration type. Instead,
3953
the code in the client should list the possibilities, or an
3954
appropriate subtype should be declared in the unit that declares
3955
the original enumeration type. E.g., the following subtype could
3956
be declared along with the type @code{Color}:
3957
 
3958
@smallexample @c ada
3959
subtype RBG is Color range Red .. Green;
3960
@end smallexample
3961
 
3962
@noindent
3963
and then the client could write:
3964
 
3965
@smallexample @c ada
3966
if Current_Color in RBG then ...
3967
if Current_Color = Blue or Current_Color = Green then ...
3968
@end smallexample
3969
 
3970
@noindent
3971
However, some enumeration types are legitimately ordered from a conceptual
3972
point of view. For example, if you declare:
3973
 
3974
@smallexample @c ada
3975
type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3976
@end smallexample
3977
 
3978
@noindent
3979
then the ordering imposed by the language is reasonable, and
3980
clients can depend on it, writing for example:
3981
 
3982
@smallexample @c ada
3983
if D in Mon .. Fri then ...
3984
if D < Wed then ...
3985
@end smallexample
3986
 
3987
@noindent
3988
The pragma @option{Ordered} is provided to mark enumeration types that
3989
are conceptually ordered, alerting the reader that clients may depend
3990
on the ordering. GNAT provides a pragma to mark enumerations as ordered
3991
rather than one to mark them as unordered, since in our experience,
3992
the great majority of enumeration types are conceptually unordered.
3993
 
3994
The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3995
and @code{Wide_Wide_Character}
3996
are considered to be ordered types, so each is declared with a
3997
pragma @code{Ordered} in package @code{Standard}.
3998
 
3999
Normally pragma @code{Ordered} serves only as documentation and a guide for
4000
coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4001
requests warnings for inappropriate uses (comparisons and explicit
4002
subranges) for unordered types. If this switch is used, then any
4003
enumeration type not marked with pragma @code{Ordered} will be considered
4004
as unordered, and will generate warnings for inappropriate uses.
4005
 
4006
For additional information please refer to the description of the
4007
@option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4008
 
4009
@node Pragma Passive
4010
@unnumberedsec Pragma Passive
4011
@findex Passive
4012
@noindent
4013
Syntax:
4014
 
4015
@smallexample @c ada
4016
pragma Passive [(Semaphore | No)];
4017
@end smallexample
4018
 
4019
@noindent
4020
Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
4021
compatibility with DEC Ada 83 implementations, where it is used within a
4022
task definition to request that a task be made passive.  If the argument
4023
@code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4024
treats the pragma as an assertion that the containing task is passive
4025
and that optimization of context switch with this task is permitted and
4026
desired.  If the argument @code{No} is present, the task must not be
4027
optimized.  GNAT does not attempt to optimize any tasks in this manner
4028
(since protected objects are available in place of passive tasks).
4029
 
4030
@node Pragma Persistent_BSS
4031
@unnumberedsec Pragma Persistent_BSS
4032
@findex Persistent_BSS
4033
@noindent
4034
Syntax:
4035
 
4036
@smallexample @c ada
4037
pragma Persistent_BSS [(LOCAL_NAME)]
4038
@end smallexample
4039
 
4040
@noindent
4041
This pragma allows selected objects to be placed in the @code{.persistent_bss}
4042
section. On some targets the linker and loader provide for special
4043
treatment of this section, allowing a program to be reloaded without
4044
affecting the contents of this data (hence the name persistent).
4045
 
4046
There are two forms of usage. If an argument is given, it must be the
4047
local name of a library level object, with no explicit initialization
4048
and whose type is potentially persistent. If no argument is given, then
4049
the pragma is a configuration pragma, and applies to all library level
4050
objects with no explicit initialization of potentially persistent types.
4051
 
4052
A potentially persistent type is a scalar type, or a non-tagged,
4053
non-discriminated record, all of whose components have no explicit
4054
initialization and are themselves of a potentially persistent type,
4055
or an array, all of whose constraints are static, and whose component
4056
type is potentially persistent.
4057
 
4058
If this pragma is used on a target where this feature is not supported,
4059
then the pragma will be ignored. See also @code{pragma Linker_Section}.
4060
 
4061
@node Pragma Polling
4062
@unnumberedsec Pragma Polling
4063
@findex Polling
4064
@noindent
4065
Syntax:
4066
 
4067
@smallexample @c ada
4068
pragma Polling (ON | OFF);
4069
@end smallexample
4070
 
4071
@noindent
4072
This pragma controls the generation of polling code.  This is normally off.
4073
If @code{pragma Polling (ON)} is used then periodic calls are generated to
4074
the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
4075
runtime library, and can be found in file @file{a-excpol.adb}.
4076
 
4077
Pragma @code{Polling} can appear as a configuration pragma (for example it
4078
can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4079
can be used in the statement or declaration sequence to control polling
4080
more locally.
4081
 
4082
A call to the polling routine is generated at the start of every loop and
4083
at the start of every subprogram call.  This guarantees that the @code{Poll}
4084
routine is called frequently, and places an upper bound (determined by
4085
the complexity of the code) on the period between two @code{Poll} calls.
4086
 
4087
The primary purpose of the polling interface is to enable asynchronous
4088
aborts on targets that cannot otherwise support it (for example Windows
4089
NT), but it may be used for any other purpose requiring periodic polling.
4090
The standard version is null, and can be replaced by a user program.  This
4091
will require re-compilation of the @code{Ada.Exceptions} package that can
4092
be found in files @file{a-except.ads} and @file{a-except.adb}.
4093
 
4094
A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4095
distribution) is used to enable the asynchronous abort capability on
4096
targets that do not normally support the capability.  The version of
4097
@code{Poll} in this file makes a call to the appropriate runtime routine
4098
to test for an abort condition.
4099
 
4100
Note that polling can also be enabled by use of the @option{-gnatP} switch.
4101
@xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4102
details.
4103
 
4104
@node Pragma Postcondition
4105
@unnumberedsec Pragma Postcondition
4106
@cindex Postconditions
4107
@cindex Checks, postconditions
4108
@findex Postconditions
4109
@noindent
4110
Syntax:
4111
 
4112
@smallexample @c ada
4113
pragma Postcondition (
4114
   [Check   =>] Boolean_Expression
4115
 [,[Message =>] String_Expression]);
4116
@end smallexample
4117
 
4118
@noindent
4119
The @code{Postcondition} pragma allows specification of automatic
4120
postcondition checks for subprograms. These checks are similar to
4121
assertions, but are automatically inserted just prior to the return
4122
statements of the subprogram with which they are associated (including
4123
implicit returns at the end of procedure bodies and associated
4124
exception handlers).
4125
 
4126
In addition, the boolean expression which is the condition which
4127
must be true may contain references to function'Result in the case
4128
of a function to refer to the returned value.
4129
 
4130
@code{Postcondition} pragmas may appear either immediately following the
4131
(separate) declaration of a subprogram, or at the start of the
4132
declarations of a subprogram body. Only other pragmas may intervene
4133
(that is appear between the subprogram declaration and its
4134
postconditions, or appear before the postcondition in the
4135
declaration sequence in a subprogram body). In the case of a
4136
postcondition appearing after a subprogram declaration, the
4137
formal arguments of the subprogram are visible, and can be
4138
referenced in the postcondition expressions.
4139
 
4140
The postconditions are collected and automatically tested just
4141
before any return (implicit or explicit) in the subprogram body.
4142
A postcondition is only recognized if postconditions are active
4143
at the time the pragma is encountered. The compiler switch @option{gnata}
4144
turns on all postconditions by default, and pragma @code{Check_Policy}
4145
with an identifier of @code{Postcondition} can also be used to
4146
control whether postconditions are active.
4147
 
4148
The general approach is that postconditions are placed in the spec
4149
if they represent functional aspects which make sense to the client.
4150
For example we might have:
4151
 
4152
@smallexample @c ada
4153
   function Direction return Integer;
4154
   pragma Postcondition
4155
    (Direction'Result = +1
4156
       or else
4157
     Direction'Result = -1);
4158
@end smallexample
4159
 
4160
@noindent
4161
which serves to document that the result must be +1 or -1, and
4162
will test that this is the case at run time if postcondition
4163
checking is active.
4164
 
4165
Postconditions within the subprogram body can be used to
4166
check that some internal aspect of the implementation,
4167
not visible to the client, is operating as expected.
4168
For instance if a square root routine keeps an internal
4169
counter of the number of times it is called, then we
4170
might have the following postcondition:
4171
 
4172
@smallexample @c ada
4173
   Sqrt_Calls : Natural := 0;
4174
 
4175
   function Sqrt (Arg : Float) return Float is
4176
     pragma Postcondition
4177
       (Sqrt_Calls = Sqrt_Calls'Old + 1);
4178
     ...
4179
   end Sqrt
4180
@end smallexample
4181
 
4182
@noindent
4183
As this example, shows, the use of the @code{Old} attribute
4184
is often useful in postconditions to refer to the state on
4185
entry to the subprogram.
4186
 
4187
Note that postconditions are only checked on normal returns
4188
from the subprogram. If an abnormal return results from
4189
raising an exception, then the postconditions are not checked.
4190
 
4191
If a postcondition fails, then the exception
4192
@code{System.Assertions.Assert_Failure} is raised. If
4193
a message argument was supplied, then the given string
4194
will be used as the exception message. If no message
4195
argument was supplied, then the default message has
4196
the form "Postcondition failed at file:line". The
4197
exception is raised in the context of the subprogram
4198
body, so it is possible to catch postcondition failures
4199
within the subprogram body itself.
4200
 
4201
Within a package spec, normal visibility rules
4202
in Ada would prevent forward references within a
4203
postcondition pragma to functions defined later in
4204
the same package. This would introduce undesirable
4205
ordering constraints. To avoid this problem, all
4206
postcondition pragmas are analyzed at the end of
4207
the package spec, allowing forward references.
4208
 
4209
The following example shows that this even allows
4210
mutually recursive postconditions as in:
4211
 
4212
@smallexample @c ada
4213
package Parity_Functions is
4214
   function Odd  (X : Natural) return Boolean;
4215
   pragma Postcondition
4216
     (Odd'Result =
4217
        (x = 1
4218
          or else
4219
        (x /= 0 and then Even (X - 1))));
4220
 
4221
   function Even (X : Natural) return Boolean;
4222
   pragma Postcondition
4223
     (Even'Result =
4224
        (x = 0
4225
          or else
4226
        (x /= 1 and then Odd (X - 1))));
4227
 
4228
end Parity_Functions;
4229
@end smallexample
4230
 
4231
@noindent
4232
There are no restrictions on the complexity or form of
4233
conditions used within @code{Postcondition} pragmas.
4234
The following example shows that it is even possible
4235
to verify performance behavior.
4236
 
4237
@smallexample @c ada
4238
package Sort is
4239
 
4240
   Performance : constant Float;
4241
   --  Performance constant set by implementation
4242
   --  to match target architecture behavior.
4243
 
4244
   procedure Treesort (Arg : String);
4245
   --  Sorts characters of argument using N*logN sort
4246
   pragma Postcondition
4247
     (Float (Clock - Clock'Old) <=
4248
        Float (Arg'Length) *
4249
        log (Float (Arg'Length)) *
4250
        Performance);
4251
end Sort;
4252
@end smallexample
4253
 
4254
@noindent
4255
Note: postcondition pragmas associated with subprograms that are
4256
marked as Inline_Always, or those marked as Inline with front-end
4257
inlining (-gnatN option set) are accepted and legality-checked
4258
by the compiler, but are ignored at run-time even if postcondition
4259
checking is enabled.
4260
 
4261
@node Pragma Precondition
4262
@unnumberedsec Pragma Precondition
4263
@cindex Preconditions
4264
@cindex Checks, preconditions
4265
@findex Preconditions
4266
@noindent
4267
Syntax:
4268
 
4269
@smallexample @c ada
4270
pragma Precondition (
4271
   [Check   =>] Boolean_Expression
4272
 [,[Message =>] String_Expression]);
4273
@end smallexample
4274
 
4275
@noindent
4276
The @code{Precondition} pragma is similar to @code{Postcondition}
4277
except that the corresponding checks take place immediately upon
4278
entry to the subprogram, and if a precondition fails, the exception
4279
is raised in the context of the caller, and the attribute 'Result
4280
cannot be used within the precondition expression.
4281
 
4282
Otherwise, the placement and visibility rules are identical to those
4283
described for postconditions. The following is an example of use
4284
within a package spec:
4285
 
4286
@smallexample @c ada
4287
package Math_Functions is
4288
   ...
4289
   function Sqrt (Arg : Float) return Float;
4290
   pragma Precondition (Arg >= 0.0)
4291
   ...
4292
end Math_Functions;
4293
@end smallexample
4294
 
4295
@noindent
4296
@code{Precondition} pragmas may appear either immediately following the
4297
(separate) declaration of a subprogram, or at the start of the
4298
declarations of a subprogram body. Only other pragmas may intervene
4299
(that is appear between the subprogram declaration and its
4300
postconditions, or appear before the postcondition in the
4301
declaration sequence in a subprogram body).
4302
 
4303
Note: postcondition pragmas associated with subprograms that are
4304
marked as Inline_Always, or those marked as Inline with front-end
4305
inlining (-gnatN option set) are accepted and legality-checked
4306
by the compiler, but are ignored at run-time even if postcondition
4307
checking is enabled.
4308
 
4309
@node Pragma Profile (Ravenscar)
4310
@unnumberedsec Pragma Profile (Ravenscar)
4311
@findex Ravenscar
4312
@noindent
4313
Syntax:
4314
 
4315
@smallexample @c ada
4316
pragma Profile (Ravenscar);
4317
@end smallexample
4318
 
4319
@noindent
4320
A configuration pragma that establishes the following set of configuration
4321
pragmas:
4322
 
4323
@table @code
4324
@item Task_Dispatching_Policy (FIFO_Within_Priorities)
4325
[RM D.2.2] Tasks are dispatched following a preemptive
4326
priority-ordered scheduling policy.
4327
 
4328
@item Locking_Policy (Ceiling_Locking)
4329
[RM D.3] While tasks and interrupts execute a protected action, they inherit
4330
the ceiling priority of the corresponding protected object.
4331
@c
4332
@c @item Detect_Blocking
4333
@c This pragma forces the detection of potentially blocking operations within a
4334
@c protected operation, and to raise Program_Error if that happens.
4335
@end table
4336
@noindent
4337
 
4338
plus the following set of restrictions:
4339
 
4340
@table @code
4341
@item Max_Entry_Queue_Length => 1
4342
No task can be queued on a protected entry.
4343
@item Max_Protected_Entries => 1
4344
@item Max_Task_Entries => 0
4345
No rendezvous statements are allowed.
4346
@item No_Abort_Statements
4347
@item No_Dynamic_Attachment
4348
@item No_Dynamic_Priorities
4349
@item No_Implicit_Heap_Allocations
4350
@item No_Local_Protected_Objects
4351
@item No_Local_Timing_Events
4352
@item No_Protected_Type_Allocators
4353
@item No_Relative_Delay
4354
@item No_Requeue_Statements
4355
@item No_Select_Statements
4356
@item No_Specific_Termination_Handlers
4357
@item No_Task_Allocators
4358
@item No_Task_Hierarchy
4359
@item No_Task_Termination
4360
@item Simple_Barriers
4361
@end table
4362
@noindent
4363
 
4364
The Ravenscar profile also includes the following restrictions that specify
4365
that there are no semantic dependences on the corresponding predefined
4366
packages:
4367
 
4368
@table @code
4369
@item No_Dependence => Ada.Asynchronous_Task_Control
4370
@item No_Dependence => Ada.Calendar
4371
@item No_Dependence => Ada.Execution_Time.Group_Budget
4372
@item No_Dependence => Ada.Execution_Time.Timers
4373
@item No_Dependence => Ada.Task_Attributes
4374
@item No_Dependence => System.Multiprocessors.Dispatching_Domains
4375
@end table
4376
 
4377
@noindent
4378
 
4379
This set of configuration pragmas and restrictions correspond to the
4380
definition of the ``Ravenscar Profile'' for limited tasking, devised and
4381
published by the @cite{International Real-Time Ada Workshop}, 1997,
4382
and whose most recent description is available at
4383
@url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4384
 
4385
The original definition of the profile was revised at subsequent IRTAW
4386
meetings. It has been included in the ISO
4387
@cite{Guide for the Use of the Ada Programming Language in High
4388
Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4389
the next revision of the standard. The formal definition given by
4390
the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4391
AI-305) available at
4392
@url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4393
@url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4394
 
4395
The above set is a superset of the restrictions provided by pragma
4396
@code{Profile (Restricted)}, it includes six additional restrictions
4397
(@code{Simple_Barriers}, @code{No_Select_Statements},
4398
@code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4399
@code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4400
that pragma @code{Profile (Ravenscar)}, like the pragma
4401
@code{Profile (Restricted)},
4402
automatically causes the use of a simplified,
4403
more efficient version of the tasking run-time system.
4404
 
4405
@node Pragma Profile (Restricted)
4406
@unnumberedsec Pragma Profile (Restricted)
4407
@findex Restricted Run Time
4408
@noindent
4409
Syntax:
4410
 
4411
@smallexample @c ada
4412
pragma Profile (Restricted);
4413
@end smallexample
4414
 
4415
@noindent
4416
A configuration pragma that establishes the following set of restrictions:
4417
 
4418
@itemize @bullet
4419
@item No_Abort_Statements
4420
@item No_Entry_Queue
4421
@item No_Task_Hierarchy
4422
@item No_Task_Allocators
4423
@item No_Dynamic_Priorities
4424
@item No_Terminate_Alternatives
4425
@item No_Dynamic_Attachment
4426
@item No_Protected_Type_Allocators
4427
@item No_Local_Protected_Objects
4428
@item No_Requeue_Statements
4429
@item No_Task_Attributes_Package
4430
@item Max_Asynchronous_Select_Nesting =  0
4431
@item Max_Task_Entries =  0
4432
@item Max_Protected_Entries = 1
4433
@item Max_Select_Alternatives = 0
4434
@end itemize
4435
 
4436
@noindent
4437
This set of restrictions causes the automatic selection of a simplified
4438
version of the run time that provides improved performance for the
4439
limited set of tasking functionality permitted by this set of restrictions.
4440
 
4441
@node Pragma Psect_Object
4442
@unnumberedsec Pragma Psect_Object
4443
@findex Psect_Object
4444
@noindent
4445
Syntax:
4446
 
4447
@smallexample @c ada
4448
pragma Psect_Object (
4449
     [Internal =>] LOCAL_NAME,
4450
  [, [External =>] EXTERNAL_SYMBOL]
4451
  [, [Size     =>] EXTERNAL_SYMBOL]);
4452
 
4453
EXTERNAL_SYMBOL ::=
4454
  IDENTIFIER
4455
| static_string_EXPRESSION
4456
@end smallexample
4457
 
4458
@noindent
4459
This pragma is identical in effect to pragma @code{Common_Object}.
4460
 
4461
@node Pragma Pure_Function
4462
@unnumberedsec Pragma Pure_Function
4463
@findex Pure_Function
4464
@noindent
4465
Syntax:
4466
 
4467
@smallexample @c ada
4468
pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4469
@end smallexample
4470
 
4471
@noindent
4472
This pragma appears in the same declarative part as a function
4473
declaration (or a set of function declarations if more than one
4474
overloaded declaration exists, in which case the pragma applies
4475
to all entities).  It specifies that the function @code{Entity} is
4476
to be considered pure for the purposes of code generation.  This means
4477
that the compiler can assume that there are no side effects, and
4478
in particular that two calls with identical arguments produce the
4479
same result.  It also means that the function can be used in an
4480
address clause.
4481
 
4482
Note that, quite deliberately, there are no static checks to try
4483
to ensure that this promise is met, so @code{Pure_Function} can be used
4484
with functions that are conceptually pure, even if they do modify
4485
global variables.  For example, a square root function that is
4486
instrumented to count the number of times it is called is still
4487
conceptually pure, and can still be optimized, even though it
4488
modifies a global variable (the count).  Memo functions are another
4489
example (where a table of previous calls is kept and consulted to
4490
avoid re-computation).
4491
 
4492
Note also that the normal rules excluding optimization of subprograms
4493
in pure units (when parameter types are descended from System.Address,
4494
or when the full view of a parameter type is limited), do not apply
4495
for the Pure_Function case. If you explicitly specify Pure_Function,
4496
the compiler may optimize away calls with identical arguments, and
4497
if that results in unexpected behavior, the proper action is not to
4498
use the pragma for subprograms that are not (conceptually) pure.
4499
 
4500
@findex Pure
4501
Note: Most functions in a @code{Pure} package are automatically pure, and
4502
there is no need to use pragma @code{Pure_Function} for such functions.  One
4503
exception is any function that has at least one formal of type
4504
@code{System.Address} or a type derived from it.  Such functions are not
4505
considered pure by default, since the compiler assumes that the
4506
@code{Address} parameter may be functioning as a pointer and that the
4507
referenced data may change even if the address value does not.
4508
Similarly, imported functions are not considered to be pure by default,
4509
since there is no way of checking that they are in fact pure.  The use
4510
of pragma @code{Pure_Function} for such a function will override these default
4511
assumption, and cause the compiler to treat a designated subprogram as pure
4512
in these cases.
4513
 
4514
Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4515
applies to the underlying renamed function.  This can be used to
4516
disambiguate cases of overloading where some but not all functions
4517
in a set of overloaded functions are to be designated as pure.
4518
 
4519
If pragma @code{Pure_Function} is applied to a library level function, the
4520
function is also considered pure from an optimization point of view, but the
4521
unit is not a Pure unit in the categorization sense. So for example, a function
4522
thus marked is free to @code{with} non-pure units.
4523
 
4524
@node Pragma Remote_Access_Type
4525
@unnumberedsec Pragma Remote_Access_Type
4526
@findex Remote_Access_Type
4527
@noindent
4528
Syntax:
4529
 
4530
@smallexample @c ada
4531
pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4532
@end smallexample
4533
 
4534
@noindent
4535
This pragma appears in the formal part of a generic declaration.
4536
It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4537
the use of a remote access to class-wide type as actual for a formal
4538
access type.
4539
 
4540
When this pragma applies to a formal access type @code{Entity}, that
4541
type is treated as a remote access to class-wide type in the generic.
4542
It must be a formal general access type, and its designated type must
4543
be the class-wide type of a formal tagged limited private type from the
4544
same generic declaration.
4545
 
4546
In the generic unit, the formal type is subject to all restrictions
4547
pertaining to remote access to class-wide types. At instantiation, the
4548
actual type must be a remote access to class-wide type.
4549
 
4550
@node Pragma Restriction_Warnings
4551
@unnumberedsec Pragma Restriction_Warnings
4552
@findex Restriction_Warnings
4553
@noindent
4554
Syntax:
4555
 
4556
@smallexample @c ada
4557
pragma Restriction_Warnings
4558
  (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4559
@end smallexample
4560
 
4561
@noindent
4562
This pragma allows a series of restriction identifiers to be
4563
specified (the list of allowed identifiers is the same as for
4564
pragma @code{Restrictions}). For each of these identifiers
4565
the compiler checks for violations of the restriction, but
4566
generates a warning message rather than an error message
4567
if the restriction is violated.
4568
 
4569
@node Pragma Shared
4570
@unnumberedsec Pragma Shared
4571
@findex Shared
4572
 
4573
@noindent
4574
This pragma is provided for compatibility with Ada 83. The syntax and
4575
semantics are identical to pragma Atomic.
4576
 
4577
@node Pragma Short_Circuit_And_Or
4578
@unnumberedsec Pragma Short_Circuit_And_Or
4579
@findex Short_Circuit_And_Or
4580
 
4581
@noindent
4582
This configuration pragma causes any occurrence of the AND operator applied to
4583
operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4584
is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4585
may be useful in the context of certification protocols requiring the use of
4586
short-circuited logical operators. If this configuration pragma occurs locally
4587
within the file being compiled, it applies only to the file being compiled.
4588
There is no requirement that all units in a partition use this option.
4589
 
4590
@node Pragma Short_Descriptors
4591
@unnumberedsec Pragma Short_Descriptors
4592
@findex Short_Descriptors
4593
@noindent
4594
Syntax:
4595
 
4596
@smallexample @c ada
4597
pragma Short_Descriptors
4598
@end smallexample
4599
 
4600
@noindent
4601
In VMS versions of the compiler, this configuration pragma causes all
4602
occurrences of the mechanism types Descriptor[_xxx] to be treated as
4603
Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4604
32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4605
versions.
4606
 
4607
@node Pragma Simple_Storage_Pool_Type
4608
@unnumberedsec Pragma Simple_Storage_Pool_Type
4609
@findex Simple_Storage_Pool_Type
4610
@cindex Storage pool, simple
4611
@cindex Simple storage pool
4612
@noindent
4613
Syntax:
4614
 
4615
@smallexample @c ada
4616
pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4617
@end smallexample
4618
 
4619
@noindent
4620
A type can be established as a ``simple storage pool type'' by applying
4621
the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4622
A type named in the pragma must be a library-level immutably limited record
4623
type or limited tagged type declared immediately within a package declaration.
4624
The type can also be a limited private type whose full type is allowed as
4625
a simple storage pool type.
4626
 
4627
For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4628
@code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4629
are subtype conformant with the following subprogram declarations:
4630
 
4631
@smallexample @c ada
4632
procedure Allocate
4633
  (Pool                     : in out SSP;
4634
   Storage_Address          : out System.Address;
4635
   Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4636
   Alignment                : System.Storage_Elements.Storage_Count);
4637
 
4638
procedure Deallocate
4639
  (Pool : in out SSP;
4640
   Storage_Address          : System.Address;
4641
   Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4642
   Alignment                : System.Storage_Elements.Storage_Count);
4643
 
4644
function Storage_Size (Pool : SSP)
4645
  return System.Storage_Elements.Storage_Count;
4646
@end smallexample
4647
 
4648
@noindent
4649
Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4650
@code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4651
applying an unchecked deallocation has no effect other than to set its actual
4652
parameter to null. If @code{Storage_Size} is not declared, then the
4653
@code{Storage_Size} attribute applied to an access type associated with
4654
a pool object of type SSP returns zero. Additional operations can be declared
4655
for a simple storage pool type (such as for supporting a mark/release
4656
storage-management discipline).
4657
 
4658
An object of a simple storage pool type can be associated with an access
4659
type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4660
 
4661
@smallexample @c ada
4662
 
4663
My_Pool : My_Simple_Storage_Pool_Type;
4664
 
4665
type Acc is access My_Data_Type;
4666
 
4667
for Acc'Simple_Storage_Pool use My_Pool;
4668
 
4669
@end smallexample
4670
 
4671
@noindent
4672
See attribute @code{Simple_Storage_Pool} for further details.
4673
 
4674
@node Pragma Source_File_Name
4675
@unnumberedsec Pragma Source_File_Name
4676
@findex Source_File_Name
4677
@noindent
4678
Syntax:
4679
 
4680
@smallexample @c ada
4681
pragma Source_File_Name (
4682
  [Unit_Name   =>] unit_NAME,
4683
  Spec_File_Name =>  STRING_LITERAL,
4684
  [Index => INTEGER_LITERAL]);
4685
 
4686
pragma Source_File_Name (
4687
  [Unit_Name   =>] unit_NAME,
4688
  Body_File_Name =>  STRING_LITERAL,
4689
  [Index => INTEGER_LITERAL]);
4690
@end smallexample
4691
 
4692
@noindent
4693
Use this to override the normal naming convention.  It is a configuration
4694
pragma, and so has the usual applicability of configuration pragmas
4695
(i.e.@: it applies to either an entire partition, or to all units in a
4696
compilation, or to a single unit, depending on how it is used.
4697
@var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4698
the second argument is required, and indicates whether this is the file
4699
name for the spec or for the body.
4700
 
4701
The optional Index argument should be used when a file contains multiple
4702
units, and when you do not want to use @code{gnatchop} to separate then
4703
into multiple files (which is the recommended procedure to limit the
4704
number of recompilations that are needed when some sources change).
4705
For instance, if the source file @file{source.ada} contains
4706
 
4707
@smallexample @c ada
4708
package B is
4709
...
4710
end B;
4711
 
4712
with B;
4713
procedure A is
4714
begin
4715
   ..
4716
end A;
4717
@end smallexample
4718
 
4719
you could use the following configuration pragmas:
4720
 
4721
@smallexample @c ada
4722
pragma Source_File_Name
4723
  (B, Spec_File_Name => "source.ada", Index => 1);
4724
pragma Source_File_Name
4725
  (A, Body_File_Name => "source.ada", Index => 2);
4726
@end smallexample
4727
 
4728
Note that the @code{gnatname} utility can also be used to generate those
4729
configuration pragmas.
4730
 
4731
Another form of the @code{Source_File_Name} pragma allows
4732
the specification of patterns defining alternative file naming schemes
4733
to apply to all files.
4734
 
4735
@smallexample @c ada
4736
pragma Source_File_Name
4737
  (  [Spec_File_Name  =>] STRING_LITERAL
4738
   [,[Casing          =>] CASING_SPEC]
4739
   [,[Dot_Replacement =>] STRING_LITERAL]);
4740
 
4741
pragma Source_File_Name
4742
  (  [Body_File_Name  =>] STRING_LITERAL
4743
   [,[Casing          =>] CASING_SPEC]
4744
   [,[Dot_Replacement =>] STRING_LITERAL]);
4745
 
4746
pragma Source_File_Name
4747
  (  [Subunit_File_Name =>] STRING_LITERAL
4748
   [,[Casing            =>] CASING_SPEC]
4749
   [,[Dot_Replacement   =>] STRING_LITERAL]);
4750
 
4751
CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4752
@end smallexample
4753
 
4754
@noindent
4755
The first argument is a pattern that contains a single asterisk indicating
4756
the point at which the unit name is to be inserted in the pattern string
4757
to form the file name.  The second argument is optional.  If present it
4758
specifies the casing of the unit name in the resulting file name string.
4759
The default is lower case.  Finally the third argument allows for systematic
4760
replacement of any dots in the unit name by the specified string literal.
4761
 
4762
Note that Source_File_Name pragmas should not be used if you are using
4763
project files. The reason for this rule is that the project manager is not
4764
aware of these pragmas, and so other tools that use the projet file would not
4765
be aware of the intended naming conventions. If you are using project files,
4766
file naming is controlled by Source_File_Name_Project pragmas, which are
4767
usually supplied automatically by the project manager. A pragma
4768
Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4769
 
4770
For more details on the use of the @code{Source_File_Name} pragma,
4771
@xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4772
and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4773
User's Guide}.
4774
 
4775
@node Pragma Source_File_Name_Project
4776
@unnumberedsec Pragma Source_File_Name_Project
4777
@findex Source_File_Name_Project
4778
@noindent
4779
 
4780
This pragma has the same syntax and semantics as pragma Source_File_Name.
4781
It is only allowed as a stand alone configuration pragma.
4782
It cannot appear after a @ref{Pragma Source_File_Name}, and
4783
most importantly, once pragma Source_File_Name_Project appears,
4784
no further Source_File_Name pragmas are allowed.
4785
 
4786
The intention is that Source_File_Name_Project pragmas are always
4787
generated by the Project Manager in a manner consistent with the naming
4788
specified in a project file, and when naming is controlled in this manner,
4789
it is not permissible to attempt to modify this naming scheme using
4790
Source_File_Name or Source_File_Name_Project pragmas (which would not be
4791
known to the project manager).
4792
 
4793
@node Pragma Source_Reference
4794
@unnumberedsec Pragma Source_Reference
4795
@findex Source_Reference
4796
@noindent
4797
Syntax:
4798
 
4799
@smallexample @c ada
4800
pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4801
@end smallexample
4802
 
4803
@noindent
4804
This pragma must appear as the first line of a source file.
4805
@var{integer_literal} is the logical line number of the line following
4806
the pragma line (for use in error messages and debugging
4807
information).  @var{string_literal} is a static string constant that
4808
specifies the file name to be used in error messages and debugging
4809
information.  This is most notably used for the output of @code{gnatchop}
4810
with the @option{-r} switch, to make sure that the original unchopped
4811
source file is the one referred to.
4812
 
4813
The second argument must be a string literal, it cannot be a static
4814
string expression other than a string literal.  This is because its value
4815
is needed for error messages issued by all phases of the compiler.
4816
 
4817
@node Pragma Static_Elaboration_Desired
4818
@unnumberedsec Pragma Static_Elaboration_Desired
4819
@findex Static_Elaboration_Desired
4820
@noindent
4821
Syntax:
4822
 
4823
@smallexample @c ada
4824
pragma Static_Elaboration_Desired;
4825
@end smallexample
4826
 
4827
@noindent
4828
This pragma is used to indicate that the compiler should attempt to initialize
4829
statically the objects declared in the library unit to which the pragma applies,
4830
when these objects are initialized (explicitly or implicitly) by an aggregate.
4831
In the absence of this pragma, aggregates in object declarations are expanded
4832
into assignments and loops, even when the aggregate components are static
4833
constants. When the aggregate is present the compiler builds a static expression
4834
that requires no run-time code, so that the initialized object can be placed in
4835
read-only data space. If the components are not static, or the aggregate has
4836
more that 100 components, the compiler emits a warning that the pragma cannot
4837
be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4838
construction of larger aggregates with static components that include an others
4839
choice.)
4840
 
4841
@node Pragma Stream_Convert
4842
@unnumberedsec Pragma Stream_Convert
4843
@findex Stream_Convert
4844
@noindent
4845
Syntax:
4846
 
4847
@smallexample @c ada
4848
pragma Stream_Convert (
4849
  [Entity =>] type_LOCAL_NAME,
4850
  [Read   =>] function_NAME,
4851
  [Write  =>] function_NAME);
4852
@end smallexample
4853
 
4854
@noindent
4855
This pragma provides an efficient way of providing stream functions for
4856
types defined in packages.  Not only is it simpler to use than declaring
4857
the necessary functions with attribute representation clauses, but more
4858
significantly, it allows the declaration to made in such a way that the
4859
stream packages are not loaded unless they are needed.  The use of
4860
the Stream_Convert pragma adds no overhead at all, unless the stream
4861
attributes are actually used on the designated type.
4862
 
4863
The first argument specifies the type for which stream functions are
4864
provided.  The second parameter provides a function used to read values
4865
of this type.  It must name a function whose argument type may be any
4866
subtype, and whose returned type must be the type given as the first
4867
argument to the pragma.
4868
 
4869
The meaning of the @var{Read}
4870
parameter is that if a stream attribute directly
4871
or indirectly specifies reading of the type given as the first parameter,
4872
then a value of the type given as the argument to the Read function is
4873
read from the stream, and then the Read function is used to convert this
4874
to the required target type.
4875
 
4876
Similarly the @var{Write} parameter specifies how to treat write attributes
4877
that directly or indirectly apply to the type given as the first parameter.
4878
It must have an input parameter of the type specified by the first parameter,
4879
and the return type must be the same as the input type of the Read function.
4880
The effect is to first call the Write function to convert to the given stream
4881
type, and then write the result type to the stream.
4882
 
4883
The Read and Write functions must not be overloaded subprograms.  If necessary
4884
renamings can be supplied to meet this requirement.
4885
The usage of this attribute is best illustrated by a simple example, taken
4886
from the GNAT implementation of package Ada.Strings.Unbounded:
4887
 
4888
@smallexample @c ada
4889
function To_Unbounded (S : String)
4890
           return Unbounded_String
4891
  renames To_Unbounded_String;
4892
 
4893
pragma Stream_Convert
4894
  (Unbounded_String, To_Unbounded, To_String);
4895
@end smallexample
4896
 
4897
@noindent
4898
The specifications of the referenced functions, as given in the Ada
4899
Reference Manual are:
4900
 
4901
@smallexample @c ada
4902
function To_Unbounded_String (Source : String)
4903
  return Unbounded_String;
4904
 
4905
function To_String (Source : Unbounded_String)
4906
  return String;
4907
@end smallexample
4908
 
4909
@noindent
4910
The effect is that if the value of an unbounded string is written to a stream,
4911
then the representation of the item in the stream is in the same format that
4912
would be used for @code{Standard.String'Output}, and this same representation
4913
is expected when a value of this type is read from the stream. Note that the
4914
value written always includes the bounds, even for Unbounded_String'Write,
4915
since Unbounded_String is not an array type.
4916
 
4917
@node Pragma Style_Checks
4918
@unnumberedsec Pragma Style_Checks
4919
@findex Style_Checks
4920
@noindent
4921
Syntax:
4922
 
4923
@smallexample @c ada
4924
pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4925
                     On | Off [, LOCAL_NAME]);
4926
@end smallexample
4927
 
4928
@noindent
4929
This pragma is used in conjunction with compiler switches to control the
4930
built in style checking provided by GNAT@.  The compiler switches, if set,
4931
provide an initial setting for the switches, and this pragma may be used
4932
to modify these settings, or the settings may be provided entirely by
4933
the use of the pragma.  This pragma can be used anywhere that a pragma
4934
is legal, including use as a configuration pragma (including use in
4935
the @file{gnat.adc} file).
4936
 
4937
The form with a string literal specifies which style options are to be
4938
activated.  These are additive, so they apply in addition to any previously
4939
set style check options.  The codes for the options are the same as those
4940
used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4941
For example the following two methods can be used to enable
4942
layout checking:
4943
 
4944
@itemize @bullet
4945
@item
4946
@smallexample @c ada
4947
pragma Style_Checks ("l");
4948
@end smallexample
4949
 
4950
@item
4951
@smallexample
4952
gcc -c -gnatyl @dots{}
4953
@end smallexample
4954
@end itemize
4955
 
4956
@noindent
4957
The form ALL_CHECKS activates all standard checks (its use is equivalent
4958
to the use of the @code{gnaty} switch with no options.  @xref{Top,
4959
@value{EDITION} User's Guide, About This Guide, gnat_ugn,
4960
@value{EDITION} User's Guide}, for details.)
4961
 
4962
Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4963
In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4964
options (i.e. equivalent to -gnatyg).
4965
 
4966
The forms with @code{Off} and @code{On}
4967
can be used to temporarily disable style checks
4968
as shown in the following example:
4969
 
4970
@smallexample @c ada
4971
@iftex
4972
@leftskip=0cm
4973
@end iftex
4974
pragma Style_Checks ("k"); -- requires keywords in lower case
4975
pragma Style_Checks (Off); -- turn off style checks
4976
NULL;                      -- this will not generate an error message
4977
pragma Style_Checks (On);  -- turn style checks back on
4978
NULL;                      -- this will generate an error message
4979
@end smallexample
4980
 
4981
@noindent
4982
Finally the two argument form is allowed only if the first argument is
4983
@code{On} or @code{Off}.  The effect is to turn of semantic style checks
4984
for the specified entity, as shown in the following example:
4985
 
4986
@smallexample @c ada
4987
@iftex
4988
@leftskip=0cm
4989
@end iftex
4990
pragma Style_Checks ("r"); -- require consistency of identifier casing
4991
Arg : Integer;
4992
Rf1 : Integer := ARG;      -- incorrect, wrong case
4993
pragma Style_Checks (Off, Arg);
4994
Rf2 : Integer := ARG;      -- OK, no error
4995
@end smallexample
4996
 
4997
@node Pragma Subtitle
4998
@unnumberedsec Pragma Subtitle
4999
@findex Subtitle
5000
@noindent
5001
Syntax:
5002
 
5003
@smallexample @c ada
5004
pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5005
@end smallexample
5006
 
5007
@noindent
5008
This pragma is recognized for compatibility with other Ada compilers
5009
but is ignored by GNAT@.
5010
 
5011
@node Pragma Suppress
5012
@unnumberedsec Pragma Suppress
5013
@findex Suppress
5014
@noindent
5015
Syntax:
5016
 
5017
@smallexample @c ada
5018
pragma Suppress (Identifier [, [On =>] Name]);
5019
@end smallexample
5020
 
5021
@noindent
5022
This is a standard pragma, and supports all the check names required in
5023
the RM. It is included here because GNAT recognizes one additional check
5024
name: @code{Alignment_Check} which can be used to suppress alignment checks
5025
on addresses used in address clauses. Such checks can also be suppressed
5026
by suppressing range checks, but the specific use of @code{Alignment_Check}
5027
allows suppression of alignment checks without suppressing other range checks.
5028
 
5029
Note that pragma Suppress gives the compiler permission to omit
5030
checks, but does not require the compiler to omit checks. The compiler
5031
will generate checks if they are essentially free, even when they are
5032
suppressed. In particular, if the compiler can prove that a certain
5033
check will necessarily fail, it will generate code to do an
5034
unconditional ``raise'', even if checks are suppressed. The compiler
5035
warns in this case.
5036
 
5037
Of course, run-time checks are omitted whenever the compiler can prove
5038
that they will not fail, whether or not checks are suppressed.
5039
 
5040
@node Pragma Suppress_All
5041
@unnumberedsec Pragma Suppress_All
5042
@findex Suppress_All
5043
@noindent
5044
Syntax:
5045
 
5046
@smallexample @c ada
5047
pragma Suppress_All;
5048
@end smallexample
5049
 
5050
@noindent
5051
This pragma can appear anywhere within a unit.
5052
The effect is to apply @code{Suppress (All_Checks)} to the unit
5053
in which it appears.  This pragma is implemented for compatibility with DEC
5054
Ada 83 usage where it appears at the end of a unit, and for compatibility
5055
with Rational Ada, where it appears as a program unit pragma.
5056
The use of the standard Ada pragma @code{Suppress (All_Checks)}
5057
as a normal configuration pragma is the preferred usage in GNAT@.
5058
 
5059
@node Pragma Suppress_Exception_Locations
5060
@unnumberedsec Pragma Suppress_Exception_Locations
5061
@findex Suppress_Exception_Locations
5062
@noindent
5063
Syntax:
5064
 
5065
@smallexample @c ada
5066
pragma Suppress_Exception_Locations;
5067
@end smallexample
5068
 
5069
@noindent
5070
In normal mode, a raise statement for an exception by default generates
5071
an exception message giving the file name and line number for the location
5072
of the raise. This is useful for debugging and logging purposes, but this
5073
entails extra space for the strings for the messages. The configuration
5074
pragma @code{Suppress_Exception_Locations} can be used to suppress the
5075
generation of these strings, with the result that space is saved, but the
5076
exception message for such raises is null. This configuration pragma may
5077
appear in a global configuration pragma file, or in a specific unit as
5078
usual. It is not required that this pragma be used consistently within
5079
a partition, so it is fine to have some units within a partition compiled
5080
with this pragma and others compiled in normal mode without it.
5081
 
5082
@node Pragma Suppress_Initialization
5083
@unnumberedsec Pragma Suppress_Initialization
5084
@findex Suppress_Initialization
5085
@cindex Suppressing initialization
5086
@cindex Initialization, suppression of
5087
@noindent
5088
Syntax:
5089
 
5090
@smallexample @c ada
5091
pragma Suppress_Initialization ([Entity =>] subtype_Name);
5092
@end smallexample
5093
 
5094
@noindent
5095
Here subtype_Name is the name introduced by a type declaration
5096
or subtype declaration.
5097
This pragma suppresses any implicit or explicit initialization
5098
for all variables of the given type or subtype,
5099
including initialization resulting from the use of pragmas
5100
Normalize_Scalars or Initialize_Scalars.
5101
 
5102
This is considered a representation item, so it cannot be given after
5103
the type is frozen. It applies to all subsequent object declarations,
5104
and also any allocator that creates objects of the type.
5105
 
5106
If the pragma is given for the first subtype, then it is considered
5107
to apply to the base type and all its subtypes. If the pragma is given
5108
for other than a first subtype, then it applies only to the given subtype.
5109
The pragma may not be given after the type is frozen.
5110
 
5111
@node Pragma Task_Info
5112
@unnumberedsec Pragma Task_Info
5113
@findex Task_Info
5114
@noindent
5115
Syntax
5116
 
5117
@smallexample @c ada
5118
pragma Task_Info (EXPRESSION);
5119
@end smallexample
5120
 
5121
@noindent
5122
This pragma appears within a task definition (like pragma
5123
@code{Priority}) and applies to the task in which it appears.  The
5124
argument must be of type @code{System.Task_Info.Task_Info_Type}.
5125
The @code{Task_Info} pragma provides system dependent control over
5126
aspects of tasking implementation, for example, the ability to map
5127
tasks to specific processors.  For details on the facilities available
5128
for the version of GNAT that you are using, see the documentation
5129
in the spec of package System.Task_Info in the runtime
5130
library.
5131
 
5132
@node Pragma Task_Name
5133
@unnumberedsec Pragma Task_Name
5134
@findex Task_Name
5135
@noindent
5136
Syntax
5137
 
5138
@smallexample @c ada
5139
pragma Task_Name (string_EXPRESSION);
5140
@end smallexample
5141
 
5142
@noindent
5143
This pragma appears within a task definition (like pragma
5144
@code{Priority}) and applies to the task in which it appears.  The
5145
argument must be of type String, and provides a name to be used for
5146
the task instance when the task is created.  Note that this expression
5147
is not required to be static, and in particular, it can contain
5148
references to task discriminants.  This facility can be used to
5149
provide different names for different tasks as they are created,
5150
as illustrated in the example below.
5151
 
5152
The task name is recorded internally in the run-time structures
5153
and is accessible to tools like the debugger.  In addition the
5154
routine @code{Ada.Task_Identification.Image} will return this
5155
string, with a unique task address appended.
5156
 
5157
@smallexample @c ada
5158
--  Example of the use of pragma Task_Name
5159
 
5160
with Ada.Task_Identification;
5161
use Ada.Task_Identification;
5162
with Text_IO; use Text_IO;
5163
procedure t3 is
5164
 
5165
   type Astring is access String;
5166
 
5167
   task type Task_Typ (Name : access String) is
5168
      pragma Task_Name (Name.all);
5169
   end Task_Typ;
5170
 
5171
   task body Task_Typ is
5172
      Nam : constant String := Image (Current_Task);
5173
   begin
5174
      Put_Line ("-->" & Nam (1 .. 14) & "<--");
5175
   end Task_Typ;
5176
 
5177
   type Ptr_Task is access Task_Typ;
5178
   Task_Var : Ptr_Task;
5179
 
5180
begin
5181
   Task_Var :=
5182
     new Task_Typ (new String'("This is task 1"));
5183
   Task_Var :=
5184
     new Task_Typ (new String'("This is task 2"));
5185
end;
5186
@end smallexample
5187
 
5188
@node Pragma Task_Storage
5189
@unnumberedsec Pragma Task_Storage
5190
@findex Task_Storage
5191
Syntax:
5192
 
5193
@smallexample @c ada
5194
pragma Task_Storage (
5195
  [Task_Type =>] LOCAL_NAME,
5196
  [Top_Guard =>] static_integer_EXPRESSION);
5197
@end smallexample
5198
 
5199
@noindent
5200
This pragma specifies the length of the guard area for tasks.  The guard
5201
area is an additional storage area allocated to a task.  A value of zero
5202
means that either no guard area is created or a minimal guard area is
5203
created, depending on the target.  This pragma can appear anywhere a
5204
@code{Storage_Size} attribute definition clause is allowed for a task
5205
type.
5206
 
5207
@node Pragma Test_Case
5208
@unnumberedsec Pragma Test_Case
5209
@cindex Test cases
5210
@findex Test_Case
5211
@noindent
5212
Syntax:
5213
 
5214
@smallexample @c ada
5215
pragma Test_Case (
5216
   [Name     =>] static_string_Expression
5217
  ,[Mode     =>] (Nominal | Robustness)
5218
 [, Requires =>  Boolean_Expression]
5219
 [, Ensures  =>  Boolean_Expression]);
5220
@end smallexample
5221
 
5222
@noindent
5223
The @code{Test_Case} pragma allows defining fine-grain specifications
5224
for use by testing and verification tools. The compiler checks its
5225
validity but the presence of pragma @code{Test_Case} does not lead to
5226
any modification of the code generated by the compiler.
5227
 
5228
@code{Test_Case} pragmas may only appear immediately following the
5229
(separate) declaration of a subprogram in a package declaration, inside
5230
a package spec unit. Only other pragmas may intervene (that is appear
5231
between the subprogram declaration and a test case).
5232
 
5233
The compiler checks that boolean expressions given in @code{Requires} and
5234
@code{Ensures} are valid, where the rules for @code{Requires} are the
5235
same as the rule for an expression in @code{Precondition} and the rules
5236
for @code{Ensures} are the same as the rule for an expression in
5237
@code{Postcondition}. In particular, attributes @code{'Old} and
5238
@code{'Result} can only be used within the @code{Ensures}
5239
expression. The following is an example of use within a package spec:
5240
 
5241
@smallexample @c ada
5242
package Math_Functions is
5243
   ...
5244
   function Sqrt (Arg : Float) return Float;
5245
   pragma Test_Case (Name     => "Test 1",
5246
                     Mode     => Nominal,
5247
                     Requires => Arg < 100,
5248
                     Ensures  => Sqrt'Result < 10);
5249
   ...
5250
end Math_Functions;
5251
@end smallexample
5252
 
5253
@noindent
5254
The meaning of a test case is that, if the associated subprogram is
5255
executed in a context where @code{Requires} holds, then @code{Ensures}
5256
should hold when the subprogram returns. Mode @code{Nominal} indicates
5257
that the input context should satisfy the precondition of the
5258
subprogram, and the output context should then satisfy its
5259
postcondition. More @code{Robustness} indicates that the pre- and
5260
postcondition of the subprogram should be ignored for this test case.
5261
 
5262
@node Pragma Thread_Local_Storage
5263
@unnumberedsec Pragma Thread_Local_Storage
5264
@findex Thread_Local_Storage
5265
@cindex Task specific storage
5266
@cindex TLS (Thread Local Storage)
5267
Syntax:
5268
 
5269
@smallexample @c ada
5270
pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5271
@end smallexample
5272
 
5273
@noindent
5274
This pragma specifies that the specified entity, which must be
5275
a variable declared in a library level package, is to be marked as
5276
"Thread Local Storage" (@code{TLS}). On systems supporting this (which
5277
include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5278
(and hence each Ada task) to see a distinct copy of the variable.
5279
 
5280
The variable may not have default initialization, and if there is
5281
an explicit initialization, it must be either @code{null} for an
5282
access variable, or a static expression for a scalar variable.
5283
This provides a low level mechanism similar to that provided by
5284
the @code{Ada.Task_Attributes} package, but much more efficient
5285
and is also useful in writing interface code that will interact
5286
with foreign threads.
5287
 
5288
If this pragma is used on a system where @code{TLS} is not supported,
5289
then an error message will be generated and the program will be rejected.
5290
 
5291
@node Pragma Time_Slice
5292
@unnumberedsec Pragma Time_Slice
5293
@findex Time_Slice
5294
@noindent
5295
Syntax:
5296
 
5297
@smallexample @c ada
5298
pragma Time_Slice (static_duration_EXPRESSION);
5299
@end smallexample
5300
 
5301
@noindent
5302
For implementations of GNAT on operating systems where it is possible
5303
to supply a time slice value, this pragma may be used for this purpose.
5304
It is ignored if it is used in a system that does not allow this control,
5305
or if it appears in other than the main program unit.
5306
@cindex OpenVMS
5307
Note that the effect of this pragma is identical to the effect of the
5308
DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5309
 
5310
@node Pragma Title
5311
@unnumberedsec Pragma Title
5312
@findex Title
5313
@noindent
5314
Syntax:
5315
 
5316
@smallexample @c ada
5317
pragma Title (TITLING_OPTION [, TITLING OPTION]);
5318
 
5319
TITLING_OPTION ::=
5320
  [Title    =>] STRING_LITERAL,
5321
| [Subtitle =>] STRING_LITERAL
5322
@end smallexample
5323
 
5324
@noindent
5325
Syntax checked but otherwise ignored by GNAT@.  This is a listing control
5326
pragma used in DEC Ada 83 implementations to provide a title and/or
5327
subtitle for the program listing.  The program listing generated by GNAT
5328
does not have titles or subtitles.
5329
 
5330
Unlike other pragmas, the full flexibility of named notation is allowed
5331
for this pragma, i.e.@: the parameters may be given in any order if named
5332
notation is used, and named and positional notation can be mixed
5333
following the normal rules for procedure calls in Ada.
5334
 
5335
@node Pragma Unchecked_Union
5336
@unnumberedsec Pragma Unchecked_Union
5337
@cindex Unions in C
5338
@findex Unchecked_Union
5339
@noindent
5340
Syntax:
5341
 
5342
@smallexample @c ada
5343
pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5344
@end smallexample
5345
 
5346
@noindent
5347
This pragma is used to specify a representation of a record type that is
5348
equivalent to a C union. It was introduced as a GNAT implementation defined
5349
pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5350
pragma, making it language defined, and GNAT fully implements this extended
5351
version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5352
details, consult the Ada 2005 Reference Manual, section B.3.3.
5353
 
5354
@node Pragma Unimplemented_Unit
5355
@unnumberedsec Pragma Unimplemented_Unit
5356
@findex Unimplemented_Unit
5357
@noindent
5358
Syntax:
5359
 
5360
@smallexample @c ada
5361
pragma Unimplemented_Unit;
5362
@end smallexample
5363
 
5364
@noindent
5365
If this pragma occurs in a unit that is processed by the compiler, GNAT
5366
aborts with the message @samp{@var{xxx} not implemented}, where
5367
@var{xxx} is the name of the current compilation unit.  This pragma is
5368
intended to allow the compiler to handle unimplemented library units in
5369
a clean manner.
5370
 
5371
The abort only happens if code is being generated.  Thus you can use
5372
specs of unimplemented packages in syntax or semantic checking mode.
5373
 
5374
@node Pragma Universal_Aliasing
5375
@unnumberedsec Pragma Universal_Aliasing
5376
@findex Universal_Aliasing
5377
@noindent
5378
Syntax:
5379
 
5380
@smallexample @c ada
5381
pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5382
@end smallexample
5383
 
5384
@noindent
5385
@var{type_LOCAL_NAME} must refer to a type declaration in the current
5386
declarative part.  The effect is to inhibit strict type-based aliasing
5387
optimization for the given type.  In other words, the effect is as though
5388
access types designating this type were subject to pragma No_Strict_Aliasing.
5389
For a detailed description of the strict aliasing optimization, and the
5390
situations in which it must be suppressed, @xref{Optimization and Strict
5391
Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5392
 
5393
@node Pragma Universal_Data
5394
@unnumberedsec Pragma Universal_Data
5395
@findex Universal_Data
5396
@noindent
5397
Syntax:
5398
 
5399
@smallexample @c ada
5400
pragma Universal_Data [(library_unit_Name)];
5401
@end smallexample
5402
 
5403
@noindent
5404
This pragma is supported only for the AAMP target and is ignored for
5405
other targets. The pragma specifies that all library-level objects
5406
(Counter 0 data) associated with the library unit are to be accessed
5407
and updated using universal addressing (24-bit addresses for AAMP5)
5408
rather than the default of 16-bit Data Environment (DENV) addressing.
5409
Use of this pragma will generally result in less efficient code for
5410
references to global data associated with the library unit, but
5411
allows such data to be located anywhere in memory. This pragma is
5412
a library unit pragma, but can also be used as a configuration pragma
5413
(including use in the @file{gnat.adc} file). The functionality
5414
of this pragma is also available by applying the -univ switch on the
5415
compilations of units where universal addressing of the data is desired.
5416
 
5417
@node Pragma Unmodified
5418
@unnumberedsec Pragma Unmodified
5419
@findex Unmodified
5420
@cindex Warnings, unmodified
5421
@noindent
5422
Syntax:
5423
 
5424
@smallexample @c ada
5425
pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5426
@end smallexample
5427
 
5428
@noindent
5429
This pragma signals that the assignable entities (variables,
5430
@code{out} parameters, @code{in out} parameters) whose names are listed are
5431
deliberately not assigned in the current source unit. This
5432
suppresses warnings about the
5433
entities being referenced but not assigned, and in addition a warning will be
5434
generated if one of these entities is in fact assigned in the
5435
same unit as the pragma (or in the corresponding body, or one
5436
of its subunits).
5437
 
5438
This is particularly useful for clearly signaling that a particular
5439
parameter is not modified, even though the spec suggests that it might
5440
be.
5441
 
5442
@node Pragma Unreferenced
5443
@unnumberedsec Pragma Unreferenced
5444
@findex Unreferenced
5445
@cindex Warnings, unreferenced
5446
@noindent
5447
Syntax:
5448
 
5449
@smallexample @c ada
5450
pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5451
pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5452
@end smallexample
5453
 
5454
@noindent
5455
This pragma signals that the entities whose names are listed are
5456
deliberately not referenced in the current source unit. This
5457
suppresses warnings about the
5458
entities being unreferenced, and in addition a warning will be
5459
generated if one of these entities is in fact subsequently referenced in the
5460
same unit as the pragma (or in the corresponding body, or one
5461
of its subunits).
5462
 
5463
This is particularly useful for clearly signaling that a particular
5464
parameter is not referenced in some particular subprogram implementation
5465
and that this is deliberate. It can also be useful in the case of
5466
objects declared only for their initialization or finalization side
5467
effects.
5468
 
5469
If @code{LOCAL_NAME} identifies more than one matching homonym in the
5470
current scope, then the entity most recently declared is the one to which
5471
the pragma applies. Note that in the case of accept formals, the pragma
5472
Unreferenced may appear immediately after the keyword @code{do} which
5473
allows the indication of whether or not accept formals are referenced
5474
or not to be given individually for each accept statement.
5475
 
5476
The left hand side of an assignment does not count as a reference for the
5477
purpose of this pragma. Thus it is fine to assign to an entity for which
5478
pragma Unreferenced is given.
5479
 
5480
Note that if a warning is desired for all calls to a given subprogram,
5481
regardless of whether they occur in the same unit as the subprogram
5482
declaration, then this pragma should not be used (calls from another
5483
unit would not be flagged); pragma Obsolescent can be used instead
5484
for this purpose, see @xref{Pragma Obsolescent}.
5485
 
5486
The second form of pragma @code{Unreferenced} is used within a context
5487
clause. In this case the arguments must be unit names of units previously
5488
mentioned in @code{with} clauses (similar to the usage of pragma
5489
@code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5490
units and unreferenced entities within these units.
5491
 
5492
@node Pragma Unreferenced_Objects
5493
@unnumberedsec Pragma Unreferenced_Objects
5494
@findex Unreferenced_Objects
5495
@cindex Warnings, unreferenced
5496
@noindent
5497
Syntax:
5498
 
5499
@smallexample @c ada
5500
pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5501
@end smallexample
5502
 
5503
@noindent
5504
This pragma signals that for the types or subtypes whose names are
5505
listed, objects which are declared with one of these types or subtypes may
5506
not be referenced, and if no references appear, no warnings are given.
5507
 
5508
This is particularly useful for objects which are declared solely for their
5509
initialization and finalization effect. Such variables are sometimes referred
5510
to as RAII variables (Resource Acquisition Is Initialization). Using this
5511
pragma on the relevant type (most typically a limited controlled type), the
5512
compiler will automatically suppress unwanted warnings about these variables
5513
not being referenced.
5514
 
5515
@node Pragma Unreserve_All_Interrupts
5516
@unnumberedsec Pragma Unreserve_All_Interrupts
5517
@findex Unreserve_All_Interrupts
5518
@noindent
5519
Syntax:
5520
 
5521
@smallexample @c ada
5522
pragma Unreserve_All_Interrupts;
5523
@end smallexample
5524
 
5525
@noindent
5526
Normally certain interrupts are reserved to the implementation.  Any attempt
5527
to attach an interrupt causes Program_Error to be raised, as described in
5528
RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5529
many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5530
reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5531
interrupt execution.
5532
 
5533
If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5534
a program, then all such interrupts are unreserved.  This allows the
5535
program to handle these interrupts, but disables their standard
5536
functions.  For example, if this pragma is used, then pressing
5537
@kbd{Ctrl-C} will not automatically interrupt execution.  However,
5538
a program can then handle the @code{SIGINT} interrupt as it chooses.
5539
 
5540
For a full list of the interrupts handled in a specific implementation,
5541
see the source code for the spec of @code{Ada.Interrupts.Names} in
5542
file @file{a-intnam.ads}.  This is a target dependent file that contains the
5543
list of interrupts recognized for a given target.  The documentation in
5544
this file also specifies what interrupts are affected by the use of
5545
the @code{Unreserve_All_Interrupts} pragma.
5546
 
5547
For a more general facility for controlling what interrupts can be
5548
handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5549
of the @code{Unreserve_All_Interrupts} pragma.
5550
 
5551
@node Pragma Unsuppress
5552
@unnumberedsec Pragma Unsuppress
5553
@findex Unsuppress
5554
@noindent
5555
Syntax:
5556
 
5557
@smallexample @c ada
5558
pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5559
@end smallexample
5560
 
5561
@noindent
5562
This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5563
there is no corresponding pragma @code{Suppress} in effect, it has no
5564
effect.  The range of the effect is the same as for pragma
5565
@code{Suppress}.  The meaning of the arguments is identical to that used
5566
in pragma @code{Suppress}.
5567
 
5568
One important application is to ensure that checks are on in cases where
5569
code depends on the checks for its correct functioning, so that the code
5570
will compile correctly even if the compiler switches are set to suppress
5571
checks.
5572
 
5573
@node Pragma Use_VADS_Size
5574
@unnumberedsec Pragma Use_VADS_Size
5575
@cindex @code{Size}, VADS compatibility
5576
@findex Use_VADS_Size
5577
@noindent
5578
Syntax:
5579
 
5580
@smallexample @c ada
5581
pragma Use_VADS_Size;
5582
@end smallexample
5583
 
5584
@noindent
5585
This is a configuration pragma.  In a unit to which it applies, any use
5586
of the 'Size attribute is automatically interpreted as a use of the
5587
'VADS_Size attribute.  Note that this may result in incorrect semantic
5588
processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5589
the handling of existing code which depends on the interpretation of Size
5590
as implemented in the VADS compiler.  See description of the VADS_Size
5591
attribute for further details.
5592
 
5593
@node Pragma Validity_Checks
5594
@unnumberedsec Pragma Validity_Checks
5595
@findex Validity_Checks
5596
@noindent
5597
Syntax:
5598
 
5599
@smallexample @c ada
5600
pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5601
@end smallexample
5602
 
5603
@noindent
5604
This pragma is used in conjunction with compiler switches to control the
5605
built-in validity checking provided by GNAT@.  The compiler switches, if set
5606
provide an initial setting for the switches, and this pragma may be used
5607
to modify these settings, or the settings may be provided entirely by
5608
the use of the pragma.  This pragma can be used anywhere that a pragma
5609
is legal, including use as a configuration pragma (including use in
5610
the @file{gnat.adc} file).
5611
 
5612
The form with a string literal specifies which validity options are to be
5613
activated.  The validity checks are first set to include only the default
5614
reference manual settings, and then a string of letters in the string
5615
specifies the exact set of options required.  The form of this string
5616
is exactly as described for the @option{-gnatVx} compiler switch (see the
5617
GNAT users guide for details).  For example the following two methods
5618
can be used to enable validity checking for mode @code{in} and
5619
@code{in out} subprogram parameters:
5620
 
5621
@itemize @bullet
5622
@item
5623
@smallexample @c ada
5624
pragma Validity_Checks ("im");
5625
@end smallexample
5626
 
5627
@item
5628
@smallexample
5629
gcc -c -gnatVim @dots{}
5630
@end smallexample
5631
@end itemize
5632
 
5633
@noindent
5634
The form ALL_CHECKS activates all standard checks (its use is equivalent
5635
to the use of the @code{gnatva} switch.
5636
 
5637
The forms with @code{Off} and @code{On}
5638
can be used to temporarily disable validity checks
5639
as shown in the following example:
5640
 
5641
@smallexample @c ada
5642
@iftex
5643
@leftskip=0cm
5644
@end iftex
5645
pragma Validity_Checks ("c"); -- validity checks for copies
5646
pragma Validity_Checks (Off); -- turn off validity checks
5647
A := B;                       -- B will not be validity checked
5648
pragma Validity_Checks (On);  -- turn validity checks back on
5649
A := C;                       -- C will be validity checked
5650
@end smallexample
5651
 
5652
@node Pragma Volatile
5653
@unnumberedsec Pragma Volatile
5654
@findex Volatile
5655
@noindent
5656
Syntax:
5657
 
5658
@smallexample @c ada
5659
pragma Volatile (LOCAL_NAME);
5660
@end smallexample
5661
 
5662
@noindent
5663
This pragma is defined by the Ada Reference Manual, and the GNAT
5664
implementation is fully conformant with this definition.  The reason it
5665
is mentioned in this section is that a pragma of the same name was supplied
5666
in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5667
implementation of pragma Volatile is upwards compatible with the
5668
implementation in DEC Ada 83.
5669
 
5670
@node Pragma Warnings
5671
@unnumberedsec Pragma Warnings
5672
@findex Warnings
5673
@noindent
5674
Syntax:
5675
 
5676
@smallexample @c ada
5677
pragma Warnings (On | Off);
5678
pragma Warnings (On | Off, LOCAL_NAME);
5679
pragma Warnings (static_string_EXPRESSION);
5680
pragma Warnings (On | Off, static_string_EXPRESSION);
5681
@end smallexample
5682
 
5683
@noindent
5684
Normally warnings are enabled, with the output being controlled by
5685
the command line switch.  Warnings (@code{Off}) turns off generation of
5686
warnings until a Warnings (@code{On}) is encountered or the end of the
5687
current unit.  If generation of warnings is turned off using this
5688
pragma, then no warning messages are output, regardless of the
5689
setting of the command line switches.
5690
 
5691
The form with a single argument may be used as a configuration pragma.
5692
 
5693
If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5694
the specified entity.  This suppression is effective from the point where
5695
it occurs till the end of the extended scope of the variable (similar to
5696
the scope of @code{Suppress}).
5697
 
5698
The form with a single static_string_EXPRESSION argument provides more precise
5699
control over which warnings are active. The string is a list of letters
5700
specifying which warnings are to be activated and which deactivated. The
5701
code for these letters is the same as the string used in the command
5702
line switch controlling warnings. For a brief summary, use the gnatmake
5703
command with no arguments, which will generate usage information containing
5704
the list of warnings switches supported. For
5705
full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5706
User's Guide}.
5707
 
5708
@noindent
5709
The specified warnings will be in effect until the end of the program
5710
or another pragma Warnings is encountered. The effect of the pragma is
5711
cumulative. Initially the set of warnings is the standard default set
5712
as possibly modified by compiler switches. Then each pragma Warning
5713
modifies this set of warnings as specified. This form of the pragma may
5714
also be used as a configuration pragma.
5715
 
5716
The fourth form, with an @code{On|Off} parameter and a string, is used to
5717
control individual messages, based on their text. The string argument
5718
is a pattern that is used to match against the text of individual
5719
warning messages (not including the initial "warning: " tag).
5720
 
5721
The pattern may contain asterisks, which match zero or more characters in
5722
the message. For example, you can use
5723
@code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5724
message @code{warning: 960 bits of "a" unused}. No other regular
5725
expression notations are permitted. All characters other than asterisk in
5726
these three specific cases are treated as literal characters in the match.
5727
 
5728
There are two ways to use the pragma in this form. The OFF form can be used as a
5729
configuration pragma. The effect is to suppress all warnings (if any)
5730
that match the pattern string throughout the compilation.
5731
 
5732
The second usage is to suppress a warning locally, and in this case, two
5733
pragmas must appear in sequence:
5734
 
5735
@smallexample @c ada
5736
pragma Warnings (Off, Pattern);
5737
@dots{} code where given warning is to be suppressed
5738
pragma Warnings (On, Pattern);
5739
@end smallexample
5740
 
5741
@noindent
5742
In this usage, the pattern string must match in the Off and On pragmas,
5743
and at least one matching warning must be suppressed.
5744
 
5745
Note: to write a string that will match any warning, use the string
5746
@code{"***"}. It will not work to use a single asterisk or two asterisks
5747
since this looks like an operator name. This form with three asterisks
5748
is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5749
matching @code{pragma Warnings (On, "***")} will be required. This can be
5750
helpful in avoiding forgetting to turn warnings back on.
5751
 
5752
Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5753
used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5754
be useful in checking whether obsolete pragmas in existing programs are hiding
5755
real problems.
5756
 
5757
Note: pragma Warnings does not affect the processing of style messages. See
5758
separate entry for pragma Style_Checks for control of style messages.
5759
 
5760
@node Pragma Weak_External
5761
@unnumberedsec Pragma Weak_External
5762
@findex Weak_External
5763
@noindent
5764
Syntax:
5765
 
5766
@smallexample @c ada
5767
pragma Weak_External ([Entity =>] LOCAL_NAME);
5768
@end smallexample
5769
 
5770
@noindent
5771
@var{LOCAL_NAME} must refer to an object that is declared at the library
5772
level. This pragma specifies that the given entity should be marked as a
5773
weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5774
in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5775
of a regular symbol, that is to say a symbol that does not have to be
5776
resolved by the linker if used in conjunction with a pragma Import.
5777
 
5778
When a weak symbol is not resolved by the linker, its address is set to
5779
zero. This is useful in writing interfaces to external modules that may
5780
or may not be linked in the final executable, for example depending on
5781
configuration settings.
5782
 
5783
If a program references at run time an entity to which this pragma has been
5784
applied, and the corresponding symbol was not resolved at link time, then
5785
the execution of the program is erroneous. It is not erroneous to take the
5786
Address of such an entity, for example to guard potential references,
5787
as shown in the example below.
5788
 
5789
Some file formats do not support weak symbols so not all target machines
5790
support this pragma.
5791
 
5792
@smallexample @c ada
5793
--  Example of the use of pragma Weak_External
5794
 
5795
package External_Module is
5796
  key : Integer;
5797
  pragma Import (C, key);
5798
  pragma Weak_External (key);
5799
  function Present return boolean;
5800
end External_Module;
5801
 
5802
with System; use System;
5803
package body External_Module is
5804
  function Present return boolean is
5805
  begin
5806
    return key'Address /= System.Null_Address;
5807
  end Present;
5808
end External_Module;
5809
@end smallexample
5810
 
5811
@node Pragma Wide_Character_Encoding
5812
@unnumberedsec Pragma Wide_Character_Encoding
5813
@findex Wide_Character_Encoding
5814
@noindent
5815
Syntax:
5816
 
5817
@smallexample @c ada
5818
pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5819
@end smallexample
5820
 
5821
@noindent
5822
This pragma specifies the wide character encoding to be used in program
5823
source text appearing subsequently. It is a configuration pragma, but may
5824
also be used at any point that a pragma is allowed, and it is permissible
5825
to have more than one such pragma in a file, allowing multiple encodings
5826
to appear within the same file.
5827
 
5828
The argument can be an identifier or a character literal. In the identifier
5829
case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5830
@code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5831
case it is correspondingly one of the characters @samp{h}, @samp{u},
5832
@samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5833
 
5834
Note that when the pragma is used within a file, it affects only the
5835
encoding within that file, and does not affect withed units, specs,
5836
or subunits.
5837
 
5838
@node Implementation Defined Attributes
5839
@chapter Implementation Defined Attributes
5840
Ada defines (throughout the Ada reference manual,
5841
summarized in Annex K),
5842
a set of attributes that provide useful additional functionality in all
5843
areas of the language.  These language defined attributes are implemented
5844
in GNAT and work as described in the Ada Reference Manual.
5845
 
5846
In addition, Ada allows implementations to define additional
5847
attributes whose meaning is defined by the implementation.  GNAT provides
5848
a number of these implementation-dependent attributes which can be used
5849
to extend and enhance the functionality of the compiler.  This section of
5850
the GNAT reference manual describes these additional attributes.
5851
 
5852
Note that any program using these attributes may not be portable to
5853
other compilers (although GNAT implements this set of attributes on all
5854
platforms).  Therefore if portability to other compilers is an important
5855
consideration, you should minimize the use of these attributes.
5856
 
5857
@menu
5858
* Abort_Signal::
5859
* Address_Size::
5860
* Asm_Input::
5861
* Asm_Output::
5862
* AST_Entry::
5863
* Bit::
5864
* Bit_Position::
5865
* Compiler_Version::
5866
* Code_Address::
5867
* Default_Bit_Order::
5868
* Descriptor_Size::
5869
* Elaborated::
5870
* Elab_Body::
5871
* Elab_Spec::
5872
* Elab_Subp_Body::
5873
* Emax::
5874
* Enabled::
5875
* Enum_Rep::
5876
* Enum_Val::
5877
* Epsilon::
5878
* Fixed_Value::
5879
* Has_Access_Values::
5880
* Has_Discriminants::
5881
* Img::
5882
* Integer_Value::
5883
* Invalid_Value::
5884
* Large::
5885
* Machine_Size::
5886
* Mantissa::
5887
* Max_Interrupt_Priority::
5888
* Max_Priority::
5889
* Maximum_Alignment::
5890
* Mechanism_Code::
5891
* Null_Parameter::
5892
* Object_Size::
5893
* Old::
5894
* Passed_By_Reference::
5895
* Pool_Address::
5896
* Range_Length::
5897
* Ref::
5898
* Result::
5899
* Safe_Emax::
5900
* Safe_Large::
5901
* Simple_Storage_Pool::
5902
* Small::
5903
* Storage_Unit::
5904
* Stub_Type::
5905
* System_Allocator_Alignment::
5906
* Target_Name::
5907
* Tick::
5908
* To_Address::
5909
* Type_Class::
5910
* UET_Address::
5911
* Unconstrained_Array::
5912
* Universal_Literal_String::
5913
* Unrestricted_Access::
5914
* VADS_Size::
5915
* Value_Size::
5916
* Wchar_T_Size::
5917
* Word_Size::
5918
@end menu
5919
 
5920
@node Abort_Signal
5921
@unnumberedsec Abort_Signal
5922
@findex Abort_Signal
5923
@noindent
5924
@code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5925
prefix) provides the entity for the special exception used to signal
5926
task abort or asynchronous transfer of control.  Normally this attribute
5927
should only be used in the tasking runtime (it is highly peculiar, and
5928
completely outside the normal semantics of Ada, for a user program to
5929
intercept the abort exception).
5930
 
5931
@node Address_Size
5932
@unnumberedsec Address_Size
5933
@cindex Size of @code{Address}
5934
@findex Address_Size
5935
@noindent
5936
@code{Standard'Address_Size} (@code{Standard} is the only allowed
5937
prefix) is a static constant giving the number of bits in an
5938
@code{Address}. It is the same value as System.Address'Size,
5939
but has the advantage of being static, while a direct
5940
reference to System.Address'Size is non-static because Address
5941
is a private type.
5942
 
5943
@node Asm_Input
5944
@unnumberedsec Asm_Input
5945
@findex Asm_Input
5946
@noindent
5947
The @code{Asm_Input} attribute denotes a function that takes two
5948
parameters.  The first is a string, the second is an expression of the
5949
type designated by the prefix.  The first (string) argument is required
5950
to be a static expression, and is the constraint for the parameter,
5951
(e.g.@: what kind of register is required).  The second argument is the
5952
value to be used as the input argument.  The possible values for the
5953
constant are the same as those used in the RTL, and are dependent on
5954
the configuration file used to built the GCC back end.
5955
@ref{Machine Code Insertions}
5956
 
5957
@node Asm_Output
5958
@unnumberedsec Asm_Output
5959
@findex Asm_Output
5960
@noindent
5961
The @code{Asm_Output} attribute denotes a function that takes two
5962
parameters.  The first is a string, the second is the name of a variable
5963
of the type designated by the attribute prefix.  The first (string)
5964
argument is required to be a static expression and designates the
5965
constraint for the parameter (e.g.@: what kind of register is
5966
required).  The second argument is the variable to be updated with the
5967
result.  The possible values for constraint are the same as those used in
5968
the RTL, and are dependent on the configuration file used to build the
5969
GCC back end.  If there are no output operands, then this argument may
5970
either be omitted, or explicitly given as @code{No_Output_Operands}.
5971
@ref{Machine Code Insertions}
5972
 
5973
@node AST_Entry
5974
@unnumberedsec AST_Entry
5975
@cindex OpenVMS
5976
@findex AST_Entry
5977
@noindent
5978
This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5979
the name of an entry, it yields a value of the predefined type AST_Handler
5980
(declared in the predefined package System, as extended by the use of
5981
pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5982
be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5983
Language Reference Manual}, section 9.12a.
5984
 
5985
@node Bit
5986
@unnumberedsec Bit
5987
@findex Bit
5988
@code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5989
offset within the storage unit (byte) that contains the first bit of
5990
storage allocated for the object.  The value of this attribute is of the
5991
type @code{Universal_Integer}, and is always a non-negative number not
5992
exceeding the value of @code{System.Storage_Unit}.
5993
 
5994
For an object that is a variable or a constant allocated in a register,
5995
the value is zero.  (The use of this attribute does not force the
5996
allocation of a variable to memory).
5997
 
5998
For an object that is a formal parameter, this attribute applies
5999
to either the matching actual parameter or to a copy of the
6000
matching actual parameter.
6001
 
6002
For an access object the value is zero.  Note that
6003
@code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6004
designated object.  Similarly for a record component
6005
@code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6006
@code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6007
are subject to index checks.
6008
 
6009
This attribute is designed to be compatible with the DEC Ada 83 definition
6010
and implementation of the @code{Bit} attribute.
6011
 
6012
@node Bit_Position
6013
@unnumberedsec Bit_Position
6014
@findex Bit_Position
6015
@noindent
6016
@code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6017
of the fields of the record type, yields the bit
6018
offset within the record contains the first bit of
6019
storage allocated for the object.  The value of this attribute is of the
6020
type @code{Universal_Integer}.  The value depends only on the field
6021
@var{C} and is independent of the alignment of
6022
the containing record @var{R}.
6023
 
6024
@node Compiler_Version
6025
@unnumberedsec Compiler_Version
6026
@findex Compiler_Version
6027
@noindent
6028
@code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6029
prefix) yields a static string identifying the version of the compiler
6030
being used to compile the unit containing the attribute reference. A
6031
typical result would be something like "@value{EDITION} @i{version} (20090221)".
6032
 
6033
@node Code_Address
6034
@unnumberedsec Code_Address
6035
@findex Code_Address
6036
@cindex Subprogram address
6037
@cindex Address of subprogram code
6038
@noindent
6039
The @code{'Address}
6040
attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6041
intended effect seems to be to provide
6042
an address value which can be used to call the subprogram by means of
6043
an address clause as in the following example:
6044
 
6045
@smallexample @c ada
6046
procedure K is @dots{}
6047
 
6048
procedure L;
6049
for L'Address use K'Address;
6050
pragma Import (Ada, L);
6051
@end smallexample
6052
 
6053
@noindent
6054
A call to @code{L} is then expected to result in a call to @code{K}@.
6055
In Ada 83, where there were no access-to-subprogram values, this was
6056
a common work-around for getting the effect of an indirect call.
6057
GNAT implements the above use of @code{Address} and the technique
6058
illustrated by the example code works correctly.
6059
 
6060
However, for some purposes, it is useful to have the address of the start
6061
of the generated code for the subprogram.  On some architectures, this is
6062
not necessarily the same as the @code{Address} value described above.
6063
For example, the @code{Address} value may reference a subprogram
6064
descriptor rather than the subprogram itself.
6065
 
6066
The @code{'Code_Address} attribute, which can only be applied to
6067
subprogram entities, always returns the address of the start of the
6068
generated code of the specified subprogram, which may or may not be
6069
the same value as is returned by the corresponding @code{'Address}
6070
attribute.
6071
 
6072
@node Default_Bit_Order
6073
@unnumberedsec Default_Bit_Order
6074
@cindex Big endian
6075
@cindex Little endian
6076
@findex Default_Bit_Order
6077
@noindent
6078
@code{Standard'Default_Bit_Order} (@code{Standard} is the only
6079
permissible prefix), provides the value @code{System.Default_Bit_Order}
6080
as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6081
@code{Low_Order_First}).  This is used to construct the definition of
6082
@code{Default_Bit_Order} in package @code{System}.
6083
 
6084
@node Descriptor_Size
6085
@unnumberedsec Descriptor_Size
6086
@cindex Descriptor
6087
@cindex Dope vector
6088
@findex Descriptor_Size
6089
@noindent
6090
Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6091
descriptor allocated for a type.  The result is non-zero only for unconstrained
6092
array types and the returned value is of type universal integer.  In GNAT, an
6093
array descriptor contains bounds information and is located immediately before
6094
the first element of the array.
6095
 
6096
@smallexample @c ada
6097
type Unconstr_Array is array (Positive range <>) of Boolean;
6098
Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6099
@end smallexample
6100
 
6101
@noindent
6102
The attribute takes into account any additional padding due to type alignment.
6103
In the example above, the descriptor contains two values of type
6104
@code{Positive} representing the low and high bound.  Since @code{Positive} has
6105
a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6106
Positive'Size + 2} or 64 bits.
6107
 
6108
@node Elaborated
6109
@unnumberedsec Elaborated
6110
@findex Elaborated
6111
@noindent
6112
The prefix of the @code{'Elaborated} attribute must be a unit name.  The
6113
value is a Boolean which indicates whether or not the given unit has been
6114
elaborated.  This attribute is primarily intended for internal use by the
6115
generated code for dynamic elaboration checking, but it can also be used
6116
in user programs.  The value will always be True once elaboration of all
6117
units has been completed.  An exception is for units which need no
6118
elaboration, the value is always False for such units.
6119
 
6120
@node Elab_Body
6121
@unnumberedsec Elab_Body
6122
@findex Elab_Body
6123
@noindent
6124
This attribute can only be applied to a program unit name.  It returns
6125
the entity for the corresponding elaboration procedure for elaborating
6126
the body of the referenced unit.  This is used in the main generated
6127
elaboration procedure by the binder and is not normally used in any
6128
other context.  However, there may be specialized situations in which it
6129
is useful to be able to call this elaboration procedure from Ada code,
6130
e.g.@: if it is necessary to do selective re-elaboration to fix some
6131
error.
6132
 
6133
@node Elab_Spec
6134
@unnumberedsec Elab_Spec
6135
@findex Elab_Spec
6136
@noindent
6137
This attribute can only be applied to a program unit name.  It returns
6138
the entity for the corresponding elaboration procedure for elaborating
6139
the spec of the referenced unit.  This is used in the main
6140
generated elaboration procedure by the binder and is not normally used
6141
in any other context.  However, there may be specialized situations in
6142
which it is useful to be able to call this elaboration procedure from
6143
Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6144
some error.
6145
 
6146
@node Elab_Subp_Body
6147
@unnumberedsec Elab_Subp_Body
6148
@findex Elab_Subp_Body
6149
@noindent
6150
This attribute can only be applied to a library level subprogram
6151
name and is only allowed in CodePeer mode. It returns the entity
6152
for the corresponding elaboration procedure for elaborating the body
6153
of the referenced subprogram unit. This is used in the main generated
6154
elaboration procedure by the binder in CodePeer mode only and is unrecognized
6155
otherwise.
6156
 
6157
@node Emax
6158
@unnumberedsec Emax
6159
@cindex Ada 83 attributes
6160
@findex Emax
6161
@noindent
6162
The @code{Emax} attribute is provided for compatibility with Ada 83.  See
6163
the Ada 83 reference manual for an exact description of the semantics of
6164
this attribute.
6165
 
6166
@node Enabled
6167
@unnumberedsec Enabled
6168
@findex Enabled
6169
@noindent
6170
The @code{Enabled} attribute allows an application program to check at compile
6171
time to see if the designated check is currently enabled. The prefix is a
6172
simple identifier, referencing any predefined check name (other than
6173
@code{All_Checks}) or a check name introduced by pragma Check_Name. If
6174
no argument is given for the attribute, the check is for the general state
6175
of the check, if an argument is given, then it is an entity name, and the
6176
check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6177
given naming the entity (if not, then the argument is ignored).
6178
 
6179
Note that instantiations inherit the check status at the point of the
6180
instantiation, so a useful idiom is to have a library package that
6181
introduces a check name with @code{pragma Check_Name}, and then contains
6182
generic packages or subprograms which use the @code{Enabled} attribute
6183
to see if the check is enabled. A user of this package can then issue
6184
a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6185
the package or subprogram, controlling whether the check will be present.
6186
 
6187
@node Enum_Rep
6188
@unnumberedsec Enum_Rep
6189
@cindex Representation of enums
6190
@findex Enum_Rep
6191
@noindent
6192
For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6193
function with the following spec:
6194
 
6195
@smallexample @c ada
6196
function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6197
  return @i{Universal_Integer};
6198
@end smallexample
6199
 
6200
@noindent
6201
It is also allowable to apply @code{Enum_Rep} directly to an object of an
6202
enumeration type or to a non-overloaded enumeration
6203
literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
6204
@code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6205
enumeration literal or object.
6206
 
6207
The function returns the representation value for the given enumeration
6208
value.  This will be equal to value of the @code{Pos} attribute in the
6209
absence of an enumeration representation clause.  This is a static
6210
attribute (i.e.@: the result is static if the argument is static).
6211
 
6212
@code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6213
in which case it simply returns the integer value.  The reason for this
6214
is to allow it to be used for @code{(<>)} discrete formal arguments in
6215
a generic unit that can be instantiated with either enumeration types
6216
or integer types.  Note that if @code{Enum_Rep} is used on a modular
6217
type whose upper bound exceeds the upper bound of the largest signed
6218
integer type, and the argument is a variable, so that the universal
6219
integer calculation is done at run time, then the call to @code{Enum_Rep}
6220
may raise @code{Constraint_Error}.
6221
 
6222
@node Enum_Val
6223
@unnumberedsec Enum_Val
6224
@cindex Representation of enums
6225
@findex Enum_Val
6226
@noindent
6227
For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6228
function with the following spec:
6229
 
6230
@smallexample @c ada
6231
function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6232
  return @var{S}'Base};
6233
@end smallexample
6234
 
6235
@noindent
6236
The function returns the enumeration value whose representation matches the
6237
argument, or raises Constraint_Error if no enumeration literal of the type
6238
has the matching value.
6239
This will be equal to value of the @code{Val} attribute in the
6240
absence of an enumeration representation clause.  This is a static
6241
attribute (i.e.@: the result is static if the argument is static).
6242
 
6243
@node Epsilon
6244
@unnumberedsec Epsilon
6245
@cindex Ada 83 attributes
6246
@findex Epsilon
6247
@noindent
6248
The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
6249
the Ada 83 reference manual for an exact description of the semantics of
6250
this attribute.
6251
 
6252
@node Fixed_Value
6253
@unnumberedsec Fixed_Value
6254
@findex Fixed_Value
6255
@noindent
6256
For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6257
function with the following specification:
6258
 
6259
@smallexample @c ada
6260
function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6261
  return @var{S};
6262
@end smallexample
6263
 
6264
@noindent
6265
The value returned is the fixed-point value @var{V} such that
6266
 
6267
@smallexample @c ada
6268
@var{V} = Arg * @var{S}'Small
6269
@end smallexample
6270
 
6271
@noindent
6272
The effect is thus similar to first converting the argument to the
6273
integer type used to represent @var{S}, and then doing an unchecked
6274
conversion to the fixed-point type.  The difference is
6275
that there are full range checks, to ensure that the result is in range.
6276
This attribute is primarily intended for use in implementation of the
6277
input-output functions for fixed-point values.
6278
 
6279
@node Has_Access_Values
6280
@unnumberedsec Has_Access_Values
6281
@cindex Access values, testing for
6282
@findex Has_Access_Values
6283
@noindent
6284
The prefix of the @code{Has_Access_Values} attribute is a type.  The result
6285
is a Boolean value which is True if the is an access type, or is a composite
6286
type with a component (at any nesting depth) that is an access type, and is
6287
False otherwise.
6288
The intended use of this attribute is in conjunction with generic
6289
definitions.  If the attribute is applied to a generic private type, it
6290
indicates whether or not the corresponding actual type has access values.
6291
 
6292
@node Has_Discriminants
6293
@unnumberedsec Has_Discriminants
6294
@cindex Discriminants, testing for
6295
@findex Has_Discriminants
6296
@noindent
6297
The prefix of the @code{Has_Discriminants} attribute is a type.  The result
6298
is a Boolean value which is True if the type has discriminants, and False
6299
otherwise.  The intended use of this attribute is in conjunction with generic
6300
definitions.  If the attribute is applied to a generic private type, it
6301
indicates whether or not the corresponding actual type has discriminants.
6302
 
6303
@node Img
6304
@unnumberedsec Img
6305
@findex Img
6306
@noindent
6307
The @code{Img} attribute differs from @code{Image} in that it may be
6308
applied to objects as well as types, in which case it gives the
6309
@code{Image} for the subtype of the object.  This is convenient for
6310
debugging:
6311
 
6312
@smallexample @c ada
6313
Put_Line ("X = " & X'Img);
6314
@end smallexample
6315
 
6316
@noindent
6317
has the same meaning as the more verbose:
6318
 
6319
@smallexample @c ada
6320
Put_Line ("X = " & @var{T}'Image (X));
6321
@end smallexample
6322
 
6323
@noindent
6324
where @var{T} is the (sub)type of the object @code{X}.
6325
 
6326
@node Integer_Value
6327
@unnumberedsec Integer_Value
6328
@findex Integer_Value
6329
@noindent
6330
For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6331
function with the following spec:
6332
 
6333
@smallexample @c ada
6334
function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6335
  return @var{S};
6336
@end smallexample
6337
 
6338
@noindent
6339
The value returned is the integer value @var{V}, such that
6340
 
6341
@smallexample @c ada
6342
Arg = @var{V} * @var{T}'Small
6343
@end smallexample
6344
 
6345
@noindent
6346
where @var{T} is the type of @code{Arg}.
6347
The effect is thus similar to first doing an unchecked conversion from
6348
the fixed-point type to its corresponding implementation type, and then
6349
converting the result to the target integer type.  The difference is
6350
that there are full range checks, to ensure that the result is in range.
6351
This attribute is primarily intended for use in implementation of the
6352
standard input-output functions for fixed-point values.
6353
 
6354
@node Invalid_Value
6355
@unnumberedsec Invalid_Value
6356
@findex Invalid_Value
6357
@noindent
6358
For every scalar type S, S'Invalid_Value returns an undefined value of the
6359
type. If possible this value is an invalid representation for the type. The
6360
value returned is identical to the value used to initialize an otherwise
6361
uninitialized value of the type if pragma Initialize_Scalars is used,
6362
including the ability to modify the value with the binder -Sxx flag and
6363
relevant environment variables at run time.
6364
 
6365
@node Large
6366
@unnumberedsec Large
6367
@cindex Ada 83 attributes
6368
@findex Large
6369
@noindent
6370
The @code{Large} attribute is provided for compatibility with Ada 83.  See
6371
the Ada 83 reference manual for an exact description of the semantics of
6372
this attribute.
6373
 
6374
@node Machine_Size
6375
@unnumberedsec Machine_Size
6376
@findex Machine_Size
6377
@noindent
6378
This attribute is identical to the @code{Object_Size} attribute.  It is
6379
provided for compatibility with the DEC Ada 83 attribute of this name.
6380
 
6381
@node Mantissa
6382
@unnumberedsec Mantissa
6383
@cindex Ada 83 attributes
6384
@findex Mantissa
6385
@noindent
6386
The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
6387
the Ada 83 reference manual for an exact description of the semantics of
6388
this attribute.
6389
 
6390
@node Max_Interrupt_Priority
6391
@unnumberedsec Max_Interrupt_Priority
6392
@cindex Interrupt priority, maximum
6393
@findex Max_Interrupt_Priority
6394
@noindent
6395
@code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6396
permissible prefix), provides the same value as
6397
@code{System.Max_Interrupt_Priority}.
6398
 
6399
@node Max_Priority
6400
@unnumberedsec Max_Priority
6401
@cindex Priority, maximum
6402
@findex Max_Priority
6403
@noindent
6404
@code{Standard'Max_Priority} (@code{Standard} is the only permissible
6405
prefix) provides the same value as @code{System.Max_Priority}.
6406
 
6407
@node Maximum_Alignment
6408
@unnumberedsec Maximum_Alignment
6409
@cindex Alignment, maximum
6410
@findex Maximum_Alignment
6411
@noindent
6412
@code{Standard'Maximum_Alignment} (@code{Standard} is the only
6413
permissible prefix) provides the maximum useful alignment value for the
6414
target.  This is a static value that can be used to specify the alignment
6415
for an object, guaranteeing that it is properly aligned in all
6416
cases.
6417
 
6418
@node Mechanism_Code
6419
@unnumberedsec Mechanism_Code
6420
@cindex Return values, passing mechanism
6421
@cindex Parameters, passing mechanism
6422
@findex Mechanism_Code
6423
@noindent
6424
@code{@var{function}'Mechanism_Code} yields an integer code for the
6425
mechanism used for the result of function, and
6426
@code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6427
used for formal parameter number @var{n} (a static integer value with 1
6428
meaning the first parameter) of @var{subprogram}.  The code returned is:
6429
 
6430
@table @asis
6431
@item 1
6432
by copy (value)
6433
@item 2
6434
by reference
6435
@item 3
6436
by descriptor (default descriptor class)
6437
@item 4
6438
by descriptor (UBS: unaligned bit string)
6439
@item 5
6440
by descriptor (UBSB: aligned bit string with arbitrary bounds)
6441
@item 6
6442
by descriptor (UBA: unaligned bit array)
6443
@item 7
6444
by descriptor (S: string, also scalar access type parameter)
6445
@item 8
6446
by descriptor (SB: string with arbitrary bounds)
6447
@item 9
6448
by descriptor (A: contiguous array)
6449
@item 10
6450
by descriptor (NCA: non-contiguous array)
6451
@end table
6452
 
6453
@noindent
6454
Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6455
@cindex OpenVMS
6456
 
6457
@node Null_Parameter
6458
@unnumberedsec Null_Parameter
6459
@cindex Zero address, passing
6460
@findex Null_Parameter
6461
@noindent
6462
A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6463
type or subtype @var{T} allocated at machine address zero.  The attribute
6464
is allowed only as the default expression of a formal parameter, or as
6465
an actual expression of a subprogram call.  In either case, the
6466
subprogram must be imported.
6467
 
6468
The identity of the object is represented by the address zero in the
6469
argument list, independent of the passing mechanism (explicit or
6470
default).
6471
 
6472
This capability is needed to specify that a zero address should be
6473
passed for a record or other composite object passed by reference.
6474
There is no way of indicating this without the @code{Null_Parameter}
6475
attribute.
6476
 
6477
@node Object_Size
6478
@unnumberedsec Object_Size
6479
@cindex Size, used for objects
6480
@findex Object_Size
6481
@noindent
6482
The size of an object is not necessarily the same as the size of the type
6483
of an object.  This is because by default object sizes are increased to be
6484
a multiple of the alignment of the object.  For example,
6485
@code{Natural'Size} is
6486
31, but by default objects of type @code{Natural} will have a size of 32 bits.
6487
Similarly, a record containing an integer and a character:
6488
 
6489
@smallexample @c ada
6490
type Rec is record
6491
   I : Integer;
6492
   C : Character;
6493
end record;
6494
@end smallexample
6495
 
6496
@noindent
6497
will have a size of 40 (that is @code{Rec'Size} will be 40).  The
6498
alignment will be 4, because of the
6499
integer field, and so the default size of record objects for this type
6500
will be 64 (8 bytes).
6501
 
6502
@node Old
6503
@unnumberedsec Old
6504
@cindex Capturing Old values
6505
@cindex Postconditions
6506
@noindent
6507
The attribute Prefix'Old can be used within a
6508
subprogram body or within a precondition or
6509
postcondition pragma. The effect is to
6510
refer to the value of the prefix on entry. So for
6511
example if you have an argument of a record type X called Arg1,
6512
you can refer to Arg1.Field'Old which yields the value of
6513
Arg1.Field on entry. The implementation simply involves generating
6514
an object declaration which captures the value on entry.
6515
The prefix must denote an object of a nonlimited type (since limited types
6516
cannot be copied to capture their values) and it must not reference a local
6517
variable (since local variables do not exist at subprogram entry time). Note
6518
that the variable introduced by a quantified expression is a local variable.
6519
The following example shows the use of 'Old to implement
6520
a test of a postcondition:
6521
 
6522
@smallexample @c ada
6523
with Old_Pkg;
6524
procedure Old is
6525
begin
6526
   Old_Pkg.Incr;
6527
end Old;
6528
 
6529
package Old_Pkg is
6530
   procedure Incr;
6531
end Old_Pkg;
6532
 
6533
package body Old_Pkg is
6534
   Count : Natural := 0;
6535
 
6536
   procedure Incr is
6537
   begin
6538
      ... code manipulating the value of Count
6539
 
6540
      pragma Assert (Count = Count'Old + 1);
6541
   end Incr;
6542
end Old_Pkg;
6543
@end smallexample
6544
 
6545
@noindent
6546
Note that it is allowed to apply 'Old to a constant entity, but this will
6547
result in a warning, since the old and new values will always be the same.
6548
 
6549
@node Passed_By_Reference
6550
@unnumberedsec Passed_By_Reference
6551
@cindex Parameters, when passed by reference
6552
@findex Passed_By_Reference
6553
@noindent
6554
@code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6555
a value of type @code{Boolean} value that is @code{True} if the type is
6556
normally passed by reference and @code{False} if the type is normally
6557
passed by copy in calls.  For scalar types, the result is always @code{False}
6558
and is static.  For non-scalar types, the result is non-static.
6559
 
6560
@node Pool_Address
6561
@unnumberedsec Pool_Address
6562
@cindex Parameters, when passed by reference
6563
@findex Pool_Address
6564
@noindent
6565
@code{@var{X}'Pool_Address} for any object @var{X} returns the address
6566
of X within its storage pool. This is the same as
6567
@code{@var{X}'Address}, except that for an unconstrained array whose
6568
bounds are allocated just before the first component,
6569
@code{@var{X}'Pool_Address} returns the address of those bounds,
6570
whereas @code{@var{X}'Address} returns the address of the first
6571
component.
6572
 
6573
Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6574
the object is allocated'', which could be a user-defined storage pool,
6575
the global heap, on the stack, or in a static memory area. For an
6576
object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6577
what is passed to @code{Allocate} and returned from @code{Deallocate}.
6578
 
6579
@node Range_Length
6580
@unnumberedsec Range_Length
6581
@findex Range_Length
6582
@noindent
6583
@code{@var{type}'Range_Length} for any discrete type @var{type} yields
6584
the number of values represented by the subtype (zero for a null
6585
range).  The result is static for static subtypes.  @code{Range_Length}
6586
applied to the index subtype of a one dimensional array always gives the
6587
same result as @code{Range} applied to the array itself.
6588
 
6589
@node Ref
6590
@unnumberedsec Ref
6591
@findex Ref
6592
@noindent
6593
The @code{System.Address'Ref}
6594
(@code{System.Address} is the only permissible prefix)
6595
denotes a function identical to
6596
@code{System.Storage_Elements.To_Address} except that
6597
it is a static attribute.  See @ref{To_Address} for more details.
6598
 
6599
@node Result
6600
@unnumberedsec Result
6601
@findex Result
6602
@noindent
6603
@code{@var{function}'Result} can only be used with in a Postcondition pragma
6604
for a function. The prefix must be the name of the corresponding function. This
6605
is used to refer to the result of the function in the postcondition expression.
6606
For a further discussion of the use of this attribute and examples of its use,
6607
see the description of pragma Postcondition.
6608
 
6609
@node Safe_Emax
6610
@unnumberedsec Safe_Emax
6611
@cindex Ada 83 attributes
6612
@findex Safe_Emax
6613
@noindent
6614
The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6615
the Ada 83 reference manual for an exact description of the semantics of
6616
this attribute.
6617
 
6618
@node Safe_Large
6619
@unnumberedsec Safe_Large
6620
@cindex Ada 83 attributes
6621
@findex Safe_Large
6622
@noindent
6623
The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6624
the Ada 83 reference manual for an exact description of the semantics of
6625
this attribute.
6626
 
6627
@node Simple_Storage_Pool
6628
@unnumberedsec Simple_Storage_Pool
6629
@cindex Storage pool, simple
6630
@cindex Simple storage pool
6631
@findex Simple_Storage_Pool
6632
@noindent
6633
For every nonformal, nonderived access-to-object type @var{Acc}, the
6634
representation attribute @code{Simple_Storage_Pool} may be specified
6635
via an attribute_definition_clause (or by specifying the equivalent aspect):
6636
 
6637
@smallexample @c ada
6638
 
6639
My_Pool : My_Simple_Storage_Pool_Type;
6640
 
6641
type Acc is access My_Data_Type;
6642
 
6643
for Acc'Simple_Storage_Pool use My_Pool;
6644
 
6645
@end smallexample
6646
 
6647
@noindent
6648
The name given in an attribute_definition_clause for the
6649
@code{Simple_Storage_Pool} attribute shall denote a variable of
6650
a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6651
 
6652
The use of this attribute is only allowed for a prefix denoting a type
6653
for which it has been specified. The type of the attribute is the type
6654
of the variable specified as the simple storage pool of the access type,
6655
and the attribute denotes that variable.
6656
 
6657
It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6658
for the same access type.
6659
 
6660
If the @code{Simple_Storage_Pool} attribute has been specified for an access
6661
type, then applying the @code{Storage_Pool} attribute to the type is flagged
6662
with a warning and its evaluation raises the exception @code{Program_Error}.
6663
 
6664
If the Simple_Storage_Pool attribute has been specified for an access
6665
type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6666
returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6667
which is intended to indicate the number of storage elements reserved for
6668
the simple storage pool. If the Storage_Size function has not been defined
6669
for the simple storage pool type, then this attribute returns zero.
6670
 
6671
If an access type @var{S} has a specified simple storage pool of type
6672
@var{SSP}, then the evaluation of an allocator for that access type calls
6673
the primitive @code{Allocate} procedure for type @var{SSP}, passing
6674
@code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6675
semantics of such allocators is the same as those defined for allocators
6676
in section 13.11 of the Ada Reference Manual, with the term
6677
``simple storage pool'' substituted for ``storage pool''.
6678
 
6679
If an access type @var{S} has a specified simple storage pool of type
6680
@var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6681
for that access type invokes the primitive @code{Deallocate} procedure
6682
for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6683
parameter. The detailed semantics of such unchecked deallocations is the same
6684
as defined in section 13.11.2 of the Ada Reference Manual, except that the
6685
term ``simple storage pool'' is substituted for ``storage pool''.
6686
 
6687
@node Small
6688
@unnumberedsec Small
6689
@cindex Ada 83 attributes
6690
@findex Small
6691
@noindent
6692
The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6693
fixed-point types.
6694
GNAT also allows this attribute to be applied to floating-point types
6695
for compatibility with Ada 83.  See
6696
the Ada 83 reference manual for an exact description of the semantics of
6697
this attribute when applied to floating-point types.
6698
 
6699
@node Storage_Unit
6700
@unnumberedsec Storage_Unit
6701
@findex Storage_Unit
6702
@noindent
6703
@code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6704
prefix) provides the same value as @code{System.Storage_Unit}.
6705
 
6706
@node Stub_Type
6707
@unnumberedsec Stub_Type
6708
@findex Stub_Type
6709
@noindent
6710
The GNAT implementation of remote access-to-classwide types is
6711
organized as described in AARM section E.4 (20.t): a value of an RACW type
6712
(designating a remote object) is represented as a normal access
6713
value, pointing to a "stub" object which in turn contains the
6714
necessary information to contact the designated remote object. A
6715
call on any dispatching operation of such a stub object does the
6716
remote call, if necessary, using the information in the stub object
6717
to locate the target partition, etc.
6718
 
6719
For a prefix @code{T} that denotes a remote access-to-classwide type,
6720
@code{T'Stub_Type} denotes the type of the corresponding stub objects.
6721
 
6722
By construction, the layout of @code{T'Stub_Type} is identical to that of
6723
type @code{RACW_Stub_Type} declared in the internal implementation-defined
6724
unit @code{System.Partition_Interface}. Use of this attribute will create
6725
an implicit dependency on this unit.
6726
 
6727
@node System_Allocator_Alignment
6728
@unnumberedsec System_Allocator_Alignment
6729
@cindex Alignment, allocator
6730
@findex System_Allocator_Alignment
6731
@noindent
6732
@code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6733
permissible prefix) provides the observable guaranted to be honored by
6734
the system allocator (malloc). This is a static value that can be used
6735
in user storage pools based on malloc either to reject allocation
6736
with alignment too large or to enable a realignment circuitry if the
6737
alignment request is larger than this value.
6738
 
6739
@node Target_Name
6740
@unnumberedsec Target_Name
6741
@findex Target_Name
6742
@noindent
6743
@code{Standard'Target_Name} (@code{Standard} is the only permissible
6744
prefix) provides a static string value that identifies the target
6745
for the current compilation. For GCC implementations, this is the
6746
standard gcc target name without the terminating slash (for
6747
example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6748
 
6749
@node Tick
6750
@unnumberedsec Tick
6751
@findex Tick
6752
@noindent
6753
@code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6754
provides the same value as @code{System.Tick},
6755
 
6756
@node To_Address
6757
@unnumberedsec To_Address
6758
@findex To_Address
6759
@noindent
6760
The @code{System'To_Address}
6761
(@code{System} is the only permissible prefix)
6762
denotes a function identical to
6763
@code{System.Storage_Elements.To_Address} except that
6764
it is a static attribute.  This means that if its argument is
6765
a static expression, then the result of the attribute is a
6766
static expression.  The result is that such an expression can be
6767
used in contexts (e.g.@: preelaborable packages) which require a
6768
static expression and where the function call could not be used
6769
(since the function call is always non-static, even if its
6770
argument is static).
6771
 
6772
@node Type_Class
6773
@unnumberedsec Type_Class
6774
@findex Type_Class
6775
@noindent
6776
@code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6777
the value of the type class for the full type of @var{type}.  If
6778
@var{type} is a generic formal type, the value is the value for the
6779
corresponding actual subtype.  The value of this attribute is of type
6780
@code{System.Aux_DEC.Type_Class}, which has the following definition:
6781
 
6782
@smallexample @c ada
6783
  type Type_Class is
6784
    (Type_Class_Enumeration,
6785
     Type_Class_Integer,
6786
     Type_Class_Fixed_Point,
6787
     Type_Class_Floating_Point,
6788
     Type_Class_Array,
6789
     Type_Class_Record,
6790
     Type_Class_Access,
6791
     Type_Class_Task,
6792
     Type_Class_Address);
6793
@end smallexample
6794
 
6795
@noindent
6796
Protected types yield the value @code{Type_Class_Task}, which thus
6797
applies to all concurrent types.  This attribute is designed to
6798
be compatible with the DEC Ada 83 attribute of the same name.
6799
 
6800
@node UET_Address
6801
@unnumberedsec UET_Address
6802
@findex UET_Address
6803
@noindent
6804
The @code{UET_Address} attribute can only be used for a prefix which
6805
denotes a library package.  It yields the address of the unit exception
6806
table when zero cost exception handling is used.  This attribute is
6807
intended only for use within the GNAT implementation.  See the unit
6808
@code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6809
for details on how this attribute is used in the implementation.
6810
 
6811
@node Unconstrained_Array
6812
@unnumberedsec Unconstrained_Array
6813
@findex Unconstrained_Array
6814
@noindent
6815
The @code{Unconstrained_Array} attribute can be used with a prefix that
6816
denotes any type or subtype. It is a static attribute that yields
6817
@code{True} if the prefix designates an unconstrained array,
6818
and @code{False} otherwise. In a generic instance, the result is
6819
still static, and yields the result of applying this test to the
6820
generic actual.
6821
 
6822
@node Universal_Literal_String
6823
@unnumberedsec Universal_Literal_String
6824
@cindex Named numbers, representation of
6825
@findex Universal_Literal_String
6826
@noindent
6827
The prefix of @code{Universal_Literal_String} must be a named
6828
number.  The static result is the string consisting of the characters of
6829
the number as defined in the original source.  This allows the user
6830
program to access the actual text of named numbers without intermediate
6831
conversions and without the need to enclose the strings in quotes (which
6832
would preclude their use as numbers).
6833
 
6834
For example, the following program prints the first 50 digits of pi:
6835
 
6836
@smallexample @c ada
6837
with Text_IO; use Text_IO;
6838
with Ada.Numerics;
6839
procedure Pi is
6840
begin
6841
   Put (Ada.Numerics.Pi'Universal_Literal_String);
6842
end;
6843
@end smallexample
6844
 
6845
@node Unrestricted_Access
6846
@unnumberedsec Unrestricted_Access
6847
@cindex @code{Access}, unrestricted
6848
@findex Unrestricted_Access
6849
@noindent
6850
The @code{Unrestricted_Access} attribute is similar to @code{Access}
6851
except that all accessibility and aliased view checks are omitted.  This
6852
is a user-beware attribute.  It is similar to
6853
@code{Address}, for which it is a desirable replacement where the value
6854
desired is an access type.  In other words, its effect is identical to
6855
first applying the @code{Address} attribute and then doing an unchecked
6856
conversion to a desired access type.  In GNAT, but not necessarily in
6857
other implementations, the use of static chains for inner level
6858
subprograms means that @code{Unrestricted_Access} applied to a
6859
subprogram yields a value that can be called as long as the subprogram
6860
is in scope (normal Ada accessibility rules restrict this usage).
6861
 
6862
It is possible to use @code{Unrestricted_Access} for any type, but care
6863
must be exercised if it is used to create pointers to unconstrained
6864
objects. In this case, the resulting pointer has the same scope as the
6865
context of the attribute, and may not be returned to some enclosing
6866
scope. For instance, a function cannot use @code{Unrestricted_Access}
6867
to create a unconstrained pointer and then return that value to the
6868
caller.
6869
 
6870
@node VADS_Size
6871
@unnumberedsec VADS_Size
6872
@cindex @code{Size}, VADS compatibility
6873
@findex VADS_Size
6874
@noindent
6875
The @code{'VADS_Size} attribute is intended to make it easier to port
6876
legacy code which relies on the semantics of @code{'Size} as implemented
6877
by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6878
same semantic interpretation.  In particular, @code{'VADS_Size} applied
6879
to a predefined or other primitive type with no Size clause yields the
6880
Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6881
typical machines).  In addition @code{'VADS_Size} applied to an object
6882
gives the result that would be obtained by applying the attribute to
6883
the corresponding type.
6884
 
6885
@node Value_Size
6886
@unnumberedsec Value_Size
6887
@cindex @code{Size}, setting for not-first subtype
6888
@findex Value_Size
6889
@code{@var{type}'Value_Size} is the number of bits required to represent
6890
a value of the given subtype.  It is the same as @code{@var{type}'Size},
6891
but, unlike @code{Size}, may be set for non-first subtypes.
6892
 
6893
@node Wchar_T_Size
6894
@unnumberedsec Wchar_T_Size
6895
@findex Wchar_T_Size
6896
@code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6897
prefix) provides the size in bits of the C @code{wchar_t} type
6898
primarily for constructing the definition of this type in
6899
package @code{Interfaces.C}.
6900
 
6901
@node Word_Size
6902
@unnumberedsec Word_Size
6903
@findex Word_Size
6904
@code{Standard'Word_Size} (@code{Standard} is the only permissible
6905
prefix) provides the value @code{System.Word_Size}.
6906
 
6907
@node Implementation Defined Restrictions
6908
@chapter Implementation Defined Restrictions
6909
 
6910
@noindent
6911
All RM defined Restriction identifiers are implemented:
6912
 
6913
@itemize @bullet
6914
@item language-defined restrictions (see 13.12.1)
6915
@item tasking restrictions (see D.7)
6916
@item high integrity restrictions (see H.4)
6917
@end itemize
6918
 
6919
@noindent
6920
GNAT implements additional restriction identifiers. All restrictions, whether
6921
language defined or GNAT-specific, are listed in the following.
6922
 
6923
@menu
6924
* Partition-Wide Restrictions::
6925
* Program Unit Level Restrictions::
6926
@end menu
6927
 
6928
@node Partition-Wide Restrictions
6929
@section Partition-Wide Restrictions
6930
 
6931
There are two separate lists of restriction identifiers. The first
6932
set requires consistency throughout a partition (in other words, if the
6933
restriction identifier is used for any compilation unit in the partition,
6934
then all compilation units in the partition must obey the restriction).
6935
 
6936
@menu
6937
* Immediate_Reclamation::
6938
* Max_Asynchronous_Select_Nesting::
6939
* Max_Entry_Queue_Length::
6940
* Max_Protected_Entries::
6941
* Max_Select_Alternatives::
6942
* Max_Storage_At_Blocking::
6943
* Max_Task_Entries::
6944
* Max_Tasks::
6945
* No_Abort_Statements::
6946
* No_Access_Parameter_Allocators::
6947
* No_Access_Subprograms::
6948
* No_Allocators::
6949
* No_Anonymous_Allocators::
6950
* No_Calendar::
6951
* No_Coextensions::
6952
* No_Default_Initialization::
6953
* No_Delay::
6954
* No_Dependence::
6955
* No_Direct_Boolean_Operators::
6956
* No_Dispatch::
6957
* No_Dispatching_Calls::
6958
* No_Dynamic_Attachment::
6959
* No_Dynamic_Priorities::
6960
* No_Entry_Calls_In_Elaboration_Code::
6961
* No_Enumeration_Maps::
6962
* No_Exception_Handlers::
6963
* No_Exception_Propagation::
6964
* No_Exception_Registration::
6965
* No_Exceptions::
6966
* No_Finalization::
6967
* No_Fixed_Point::
6968
* No_Floating_Point::
6969
* No_Implicit_Conditionals::
6970
* No_Implicit_Dynamic_Code::
6971
* No_Implicit_Heap_Allocations::
6972
* No_Implicit_Loops::
6973
* No_Initialize_Scalars::
6974
* No_IO::
6975
* No_Local_Allocators::
6976
* No_Local_Protected_Objects::
6977
* No_Local_Timing_Events::
6978
* No_Nested_Finalization::
6979
* No_Protected_Type_Allocators::
6980
* No_Protected_Types::
6981
* No_Recursion::
6982
* No_Reentrancy::
6983
* No_Relative_Delay::
6984
* No_Requeue_Statements::
6985
* No_Secondary_Stack::
6986
* No_Select_Statements::
6987
* No_Specific_Termination_Handlers::
6988
* No_Specification_of_Aspect::
6989
* No_Standard_Allocators_After_Elaboration::
6990
* No_Standard_Storage_Pools::
6991
* No_Stream_Optimizations::
6992
* No_Streams::
6993
* No_Task_Allocators::
6994
* No_Task_Attributes_Package::
6995
* No_Task_Hierarchy::
6996
* No_Task_Termination::
6997
* No_Tasking::
6998
* No_Terminate_Alternatives::
6999
* No_Unchecked_Access::
7000
* Simple_Barriers::
7001
* Static_Priorities::
7002
* Static_Storage_Size::
7003
@end menu
7004
 
7005
@node Immediate_Reclamation
7006
@unnumberedsubsec Immediate_Reclamation
7007
@findex Immediate_Reclamation
7008
[RM H.4] This restriction ensures that, except for storage occupied by
7009
objects created by allocators and not deallocated via unchecked
7010
deallocation, any storage reserved at run time for an object is
7011
immediately reclaimed when the object no longer exists.
7012
 
7013
@node Max_Asynchronous_Select_Nesting
7014
@unnumberedsubsec Max_Asynchronous_Select_Nesting
7015
@findex Max_Asynchronous_Select_Nesting
7016
[RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7017
selects. Violations of this restriction with a value of zero are
7018
detected at compile time. Violations of this restriction with values
7019
other than zero cause Storage_Error to be raised.
7020
 
7021
@node Max_Entry_Queue_Length
7022
@unnumberedsubsec Max_Entry_Queue_Length
7023
@findex Max_Entry_Queue_Length
7024
[RM D.7] This restriction is a declaration that any protected entry compiled in
7025
the scope of the restriction has at most the specified number of
7026
tasks waiting on the entry at any one time, and so no queue is required.
7027
Note that this restriction is checked at run time. Violation of this
7028
restriction results in the raising of Program_Error exception at the point of
7029
the call.
7030
 
7031
@node Max_Protected_Entries
7032
@unnumberedsubsec Max_Protected_Entries
7033
@findex Max_Protected_Entries
7034
[RM D.7] Specifies the maximum number of entries per protected type. The
7035
bounds of every entry family of a protected unit shall be static, or shall be
7036
defined by a discriminant of a subtype whose corresponding bound is static.
7037
 
7038
@node Max_Select_Alternatives
7039
@unnumberedsubsec Max_Select_Alternatives
7040
@findex Max_Select_Alternatives
7041
[RM D.7] Specifies the maximum number of alternatives in a selective accept.
7042
 
7043
@node Max_Storage_At_Blocking
7044
@unnumberedsubsec Max_Storage_At_Blocking
7045
@findex Max_Storage_At_Blocking
7046
[RM D.7] Specifies the maximum portion (in storage elements) of a task's
7047
Storage_Size that can be retained by a blocked task. A violation of this
7048
restriction causes Storage_Error to be raised.
7049
 
7050
@node Max_Task_Entries
7051
@unnumberedsubsec Max_Task_Entries
7052
@findex Max_Task_Entries
7053
[RM D.7] Specifies the maximum number of entries
7054
per task.  The bounds of every entry family
7055
of a task unit shall be static, or shall be
7056
defined by a discriminant of a subtype whose
7057
corresponding bound is static.
7058
 
7059
@node Max_Tasks
7060
@unnumberedsubsec Max_Tasks
7061
@findex Max_Tasks
7062
[RM D.7] Specifies the maximum number of task that may be created, not
7063
counting the creation of the environment task.  Violations of this
7064
restriction with a value of zero are detected at compile
7065
time. Violations of this restriction with values other than zero cause
7066
Storage_Error to be raised.
7067
 
7068
@node No_Abort_Statements
7069
@unnumberedsubsec No_Abort_Statements
7070
@findex No_Abort_Statements
7071
[RM D.7] There are no abort_statements, and there are
7072
no calls to Task_Identification.Abort_Task.
7073
 
7074
@node No_Access_Parameter_Allocators
7075
@unnumberedsubsec No_Access_Parameter_Allocators
7076
@findex No_Access_Parameter_Allocators
7077
[RM H.4] This restriction ensures at compile time that there are no
7078
occurrences of an allocator as the actual parameter to an access
7079
parameter.
7080
 
7081
@node No_Access_Subprograms
7082
@unnumberedsubsec No_Access_Subprograms
7083
@findex No_Access_Subprograms
7084
[RM H.4] This restriction ensures at compile time that there are no
7085
declarations of access-to-subprogram types.
7086
 
7087
@node No_Allocators
7088
@unnumberedsubsec No_Allocators
7089
@findex No_Allocators
7090
[RM H.4] This restriction ensures at compile time that there are no
7091
occurrences of an allocator.
7092
 
7093
@node No_Anonymous_Allocators
7094
@unnumberedsubsec No_Anonymous_Allocators
7095
@findex No_Anonymous_Allocators
7096
[RM H.4] This restriction ensures at compile time that there are no
7097
occurrences of an allocator of anonymous access type.
7098
 
7099
@node No_Calendar
7100
@unnumberedsubsec No_Calendar
7101
@findex No_Calendar
7102
[GNAT] This restriction ensures at compile time that there is no implicit or
7103
explicit dependence on the package @code{Ada.Calendar}.
7104
 
7105
@node No_Coextensions
7106
@unnumberedsubsec No_Coextensions
7107
@findex No_Coextensions
7108
[RM H.4] This restriction ensures at compile time that there are no
7109
coextensions. See 3.10.2.
7110
 
7111
@node No_Default_Initialization
7112
@unnumberedsubsec No_Default_Initialization
7113
@findex No_Default_Initialization
7114
 
7115
[GNAT] This restriction prohibits any instance of default initialization
7116
of variables.  The binder implements a consistency rule which prevents
7117
any unit compiled without the restriction from with'ing a unit with the
7118
restriction (this allows the generation of initialization procedures to
7119
be skipped, since you can be sure that no call is ever generated to an
7120
initialization procedure in a unit with the restriction active). If used
7121
in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7122
is to prohibit all cases of variables declared without a specific
7123
initializer (including the case of OUT scalar parameters).
7124
 
7125
@node No_Delay
7126
@unnumberedsubsec No_Delay
7127
@findex No_Delay
7128
[RM H.4] This restriction ensures at compile time that there are no
7129
delay statements and no dependences on package Calendar.
7130
 
7131
@node No_Dependence
7132
@unnumberedsubsec No_Dependence
7133
@findex No_Dependence
7134
[RM 13.12.1] This restriction checks at compile time that there are no
7135
dependence on a library unit.
7136
 
7137
@node No_Direct_Boolean_Operators
7138
@unnumberedsubsec No_Direct_Boolean_Operators
7139
@findex No_Direct_Boolean_Operators
7140
[GNAT] This restriction ensures that no logical (and/or/xor) are used on
7141
operands of type Boolean (or any type derived
7142
from Boolean). This is intended for use in safety critical programs
7143
where the certification protocol requires the use of short-circuit
7144
(and then, or else) forms for all composite boolean operations.
7145
 
7146
@node No_Dispatch
7147
@unnumberedsubsec No_Dispatch
7148
@findex No_Dispatch
7149
[RM H.4] This restriction ensures at compile time that there are no
7150
occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7151
 
7152
@node No_Dispatching_Calls
7153
@unnumberedsubsec No_Dispatching_Calls
7154
@findex No_Dispatching_Calls
7155
[GNAT] This restriction ensures at compile time that the code generated by the
7156
compiler involves no dispatching calls. The use of this restriction allows the
7157
safe use of record extensions, classwide membership tests and other classwide
7158
features not involving implicit dispatching. This restriction ensures that
7159
the code contains no indirect calls through a dispatching mechanism. Note that
7160
this includes internally-generated calls created by the compiler, for example
7161
in the implementation of class-wide objects assignments. The
7162
membership test is allowed in the presence of this restriction, because its
7163
implementation requires no dispatching.
7164
This restriction is comparable to the official Ada restriction
7165
@code{No_Dispatch} except that it is a bit less restrictive in that it allows
7166
all classwide constructs that do not imply dispatching.
7167
The following example indicates constructs that violate this restriction.
7168
 
7169
@smallexample
7170
package Pkg is
7171
  type T is tagged record
7172
    Data : Natural;
7173
  end record;
7174
  procedure P (X : T);
7175
 
7176
  type DT is new T with record
7177
    More_Data : Natural;
7178
  end record;
7179
  procedure Q (X : DT);
7180
end Pkg;
7181
 
7182
with Pkg; use Pkg;
7183
procedure Example is
7184
  procedure Test (O : T'Class) is
7185
    N : Natural  := O'Size;--  Error: Dispatching call
7186
    C : T'Class := O;      --  Error: implicit Dispatching Call
7187
  begin
7188
    if O in DT'Class then  --  OK   : Membership test
7189
       Q (DT (O));         --  OK   : Type conversion plus direct call
7190
    else
7191
       P (O);              --  Error: Dispatching call
7192
    end if;
7193
  end Test;
7194
 
7195
  Obj : DT;
7196
begin
7197
  P (Obj);                 --  OK   : Direct call
7198
  P (T (Obj));             --  OK   : Type conversion plus direct call
7199
  P (T'Class (Obj));       --  Error: Dispatching call
7200
 
7201
  Test (Obj);              --  OK   : Type conversion
7202
 
7203
  if Obj in T'Class then   --  OK   : Membership test
7204
     null;
7205
  end if;
7206
end Example;
7207
@end smallexample
7208
 
7209
@node No_Dynamic_Attachment
7210
@unnumberedsubsec No_Dynamic_Attachment
7211
@findex No_Dynamic_Attachment
7212
[RM D.7] This restriction ensures that there is no call to any of the
7213
operations defined in package Ada.Interrupts
7214
(Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7215
Detach_Handler, and Reference).
7216
 
7217
@node No_Dynamic_Priorities
7218
@unnumberedsubsec No_Dynamic_Priorities
7219
@findex No_Dynamic_Priorities
7220
[RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7221
 
7222
@node No_Entry_Calls_In_Elaboration_Code
7223
@unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7224
@findex No_Entry_Calls_In_Elaboration_Code
7225
[GNAT] This restriction ensures at compile time that no task or protected entry
7226
calls are made during elaboration code.  As a result of the use of this
7227
restriction, the compiler can assume that no code past an accept statement
7228
in a task can be executed at elaboration time.
7229
 
7230
@node No_Enumeration_Maps
7231
@unnumberedsubsec No_Enumeration_Maps
7232
@findex No_Enumeration_Maps
7233
[GNAT] This restriction ensures at compile time that no operations requiring
7234
enumeration maps are used (that is Image and Value attributes applied
7235
to enumeration types).
7236
 
7237
@node No_Exception_Handlers
7238
@unnumberedsubsec No_Exception_Handlers
7239
@findex No_Exception_Handlers
7240
[GNAT] This restriction ensures at compile time that there are no explicit
7241
exception handlers. It also indicates that no exception propagation will
7242
be provided. In this mode, exceptions may be raised but will result in
7243
an immediate call to the last chance handler, a routine that the user
7244
must define with the following profile:
7245
 
7246
@smallexample @c ada
7247
procedure Last_Chance_Handler
7248
  (Source_Location : System.Address; Line : Integer);
7249
pragma Export (C, Last_Chance_Handler,
7250
               "__gnat_last_chance_handler");
7251
@end smallexample
7252
 
7253
The parameter is a C null-terminated string representing a message to be
7254
associated with the exception (typically the source location of the raise
7255
statement generated by the compiler). The Line parameter when nonzero
7256
represents the line number in the source program where the raise occurs.
7257
 
7258
@node No_Exception_Propagation
7259
@unnumberedsubsec No_Exception_Propagation
7260
@findex No_Exception_Propagation
7261
[GNAT] This restriction guarantees that exceptions are never propagated
7262
to an outer subprogram scope. The only case in which an exception may
7263
be raised is when the handler is statically in the same subprogram, so
7264
that the effect of a raise is essentially like a goto statement. Any
7265
other raise statement (implicit or explicit) will be considered
7266
unhandled. Exception handlers are allowed, but may not contain an
7267
exception occurrence identifier (exception choice). In addition, use of
7268
the package GNAT.Current_Exception is not permitted, and reraise
7269
statements (raise with no operand) are not permitted.
7270
 
7271
@node No_Exception_Registration
7272
@unnumberedsubsec No_Exception_Registration
7273
@findex No_Exception_Registration
7274
[GNAT] This restriction ensures at compile time that no stream operations for
7275
types Exception_Id or Exception_Occurrence are used. This also makes it
7276
impossible to pass exceptions to or from a partition with this restriction
7277
in a distributed environment. If this exception is active, then the generated
7278
code is simplified by omitting the otherwise-required global registration
7279
of exceptions when they are declared.
7280
 
7281
@node No_Exceptions
7282
@unnumberedsubsec No_Exceptions
7283
@findex No_Exceptions
7284
[RM H.4] This restriction ensures at compile time that there are no
7285
raise statements and no exception handlers.
7286
 
7287
@node No_Finalization
7288
@unnumberedsubsec No_Finalization
7289
@findex No_Finalization
7290
[GNAT] This restriction disables the language features described in
7291
chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7292
performed by the compiler to support these features. The following types
7293
are no longer considered controlled when this restriction is in effect:
7294
@itemize @bullet
7295
@item
7296
@code{Ada.Finalization.Controlled}
7297
@item
7298
@code{Ada.Finalization.Limited_Controlled}
7299
@item
7300
Derivations from @code{Controlled} or @code{Limited_Controlled}
7301
@item
7302
Class-wide types
7303
@item
7304
Protected types
7305
@item
7306
Task types
7307
@item
7308
Array and record types with controlled components
7309
@end itemize
7310
The compiler no longer generates code to initialize, finalize or adjust an
7311
object or a nested component, either declared on the stack or on the heap. The
7312
deallocation of a controlled object no longer finalizes its contents.
7313
 
7314
@node No_Fixed_Point
7315
@unnumberedsubsec No_Fixed_Point
7316
@findex No_Fixed_Point
7317
[RM H.4] This restriction ensures at compile time that there are no
7318
occurrences of fixed point types and operations.
7319
 
7320
@node No_Floating_Point
7321
@unnumberedsubsec No_Floating_Point
7322
@findex No_Floating_Point
7323
[RM H.4] This restriction ensures at compile time that there are no
7324
occurrences of floating point types and operations.
7325
 
7326
@node No_Implicit_Conditionals
7327
@unnumberedsubsec No_Implicit_Conditionals
7328
@findex No_Implicit_Conditionals
7329
[GNAT] This restriction ensures that the generated code does not contain any
7330
implicit conditionals, either by modifying the generated code where possible,
7331
or by rejecting any construct that would otherwise generate an implicit
7332
conditional. Note that this check does not include run time constraint
7333
checks, which on some targets may generate implicit conditionals as
7334
well. To control the latter, constraint checks can be suppressed in the
7335
normal manner. Constructs generating implicit conditionals include comparisons
7336
of composite objects and the Max/Min attributes.
7337
 
7338
@node No_Implicit_Dynamic_Code
7339
@unnumberedsubsec No_Implicit_Dynamic_Code
7340
@findex No_Implicit_Dynamic_Code
7341
@cindex trampoline
7342
[GNAT] This restriction prevents the compiler from building ``trampolines''.
7343
This is a structure that is built on the stack and contains dynamic
7344
code to be executed at run time. On some targets, a trampoline is
7345
built for the following features: @code{Access},
7346
@code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7347
nested task bodies; primitive operations of nested tagged types.
7348
Trampolines do not work on machines that prevent execution of stack
7349
data. For example, on windows systems, enabling DEP (data execution
7350
protection) will cause trampolines to raise an exception.
7351
Trampolines are also quite slow at run time.
7352
 
7353
On many targets, trampolines have been largely eliminated. Look at the
7354
version of system.ads for your target --- if it has
7355
Always_Compatible_Rep equal to False, then trampolines are largely
7356
eliminated. In particular, a trampoline is built for the following
7357
features: @code{Address} of a nested subprogram;
7358
@code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7359
but only if pragma Favor_Top_Level applies, or the access type has a
7360
foreign-language convention; primitive operations of nested tagged
7361
types.
7362
 
7363
@node No_Implicit_Heap_Allocations
7364
@unnumberedsubsec No_Implicit_Heap_Allocations
7365
@findex No_Implicit_Heap_Allocations
7366
[RM D.7] No constructs are allowed to cause implicit heap allocation.
7367
 
7368
@node No_Implicit_Loops
7369
@unnumberedsubsec No_Implicit_Loops
7370
@findex No_Implicit_Loops
7371
[GNAT] This restriction ensures that the generated code does not contain any
7372
implicit @code{for} loops, either by modifying
7373
the generated code where possible,
7374
or by rejecting any construct that would otherwise generate an implicit
7375
@code{for} loop. If this restriction is active, it is possible to build
7376
large array aggregates with all static components without generating an
7377
intermediate temporary, and without generating a loop to initialize individual
7378
components. Otherwise, a loop is created for arrays larger than about 5000
7379
scalar components.
7380
 
7381
@node No_Initialize_Scalars
7382
@unnumberedsubsec No_Initialize_Scalars
7383
@findex No_Initialize_Scalars
7384
[GNAT] This restriction ensures that no unit in the partition is compiled with
7385
pragma Initialize_Scalars. This allows the generation of more efficient
7386
code, and in particular eliminates dummy null initialization routines that
7387
are otherwise generated for some record and array types.
7388
 
7389
@node No_IO
7390
@unnumberedsubsec No_IO
7391
@findex No_IO
7392
[RM H.4] This restriction ensures at compile time that there are no
7393
dependences on any of the library units Sequential_IO, Direct_IO,
7394
Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7395
 
7396
@node No_Local_Allocators
7397
@unnumberedsubsec No_Local_Allocators
7398
@findex No_Local_Allocators
7399
[RM H.4] This restriction ensures at compile time that there are no
7400
occurrences of an allocator in subprograms, generic subprograms, tasks,
7401
and entry bodies.
7402
 
7403
@node No_Local_Protected_Objects
7404
@unnumberedsubsec No_Local_Protected_Objects
7405
@findex No_Local_Protected_Objects
7406
[RM D.7] This restriction ensures at compile time that protected objects are
7407
only declared at the library level.
7408
 
7409
@node No_Local_Timing_Events
7410
@unnumberedsubsec No_Local_Timing_Events
7411
@findex No_Local_Timing_Events
7412
[RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7413
declared at the library level.
7414
 
7415
@node No_Nested_Finalization
7416
@unnumberedsubsec No_Nested_Finalization
7417
@findex No_Nested_Finalization
7418
[RM D.7] All objects requiring finalization are declared at the library level.
7419
 
7420
@node No_Protected_Type_Allocators
7421
@unnumberedsubsec No_Protected_Type_Allocators
7422
@findex No_Protected_Type_Allocators
7423
[RM D.7] This restriction ensures at compile time that there are no allocator
7424
expressions that attempt to allocate protected objects.
7425
 
7426
@node No_Protected_Types
7427
@unnumberedsubsec No_Protected_Types
7428
@findex No_Protected_Types
7429
[RM H.4] This restriction ensures at compile time that there are no
7430
declarations of protected types or protected objects.
7431
 
7432
@node No_Recursion
7433
@unnumberedsubsec No_Recursion
7434
@findex No_Recursion
7435
[RM H.4] A program execution is erroneous if a subprogram is invoked as
7436
part of its execution.
7437
 
7438
@node No_Reentrancy
7439
@unnumberedsubsec No_Reentrancy
7440
@findex No_Reentrancy
7441
[RM H.4] A program execution is erroneous if a subprogram is executed by
7442
two tasks at the same time.
7443
 
7444
@node No_Relative_Delay
7445
@unnumberedsubsec No_Relative_Delay
7446
@findex No_Relative_Delay
7447
[RM D.7] This restriction ensures at compile time that there are no delay
7448
relative statements and prevents expressions such as @code{delay 1.23;} from
7449
appearing in source code.
7450
 
7451
@node No_Requeue_Statements
7452
@unnumberedsubsec No_Requeue_Statements
7453
@findex No_Requeue_Statements
7454
[RM D.7] This restriction ensures at compile time that no requeue statements
7455
are permitted and prevents keyword @code{requeue} from being used in source
7456
code.
7457
 
7458
@node No_Secondary_Stack
7459
@unnumberedsubsec No_Secondary_Stack
7460
@findex No_Secondary_Stack
7461
[GNAT] This restriction ensures at compile time that the generated code
7462
does not contain any reference to the secondary stack.  The secondary
7463
stack is used to implement functions returning unconstrained objects
7464
(arrays or records) on some targets.
7465
 
7466
@node No_Select_Statements
7467
@unnumberedsubsec No_Select_Statements
7468
@findex No_Select_Statements
7469
[RM D.7] This restriction ensures at compile time no select statements of any
7470
kind are permitted, that is the keyword @code{select} may not appear.
7471
 
7472
@node No_Specific_Termination_Handlers
7473
@unnumberedsubsec No_Specific_Termination_Handlers
7474
@findex No_Specific_Termination_Handlers
7475
[RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7476
or to Ada.Task_Termination.Specific_Handler.
7477
 
7478
@node No_Specification_of_Aspect
7479
@unnumberedsubsec No_Specification_of_Aspect
7480
@findex No_Specification_of_Aspect
7481
[RM 13.12.1] This restriction checks at compile time that no aspect
7482
specification, attribute definition clause, or pragma is given for a
7483
given aspect.
7484
 
7485
@node No_Standard_Allocators_After_Elaboration
7486
@unnumberedsubsec No_Standard_Allocators_After_Elaboration
7487
@findex No_Standard_Allocators_After_Elaboration
7488
[RM D.7] Specifies that an allocator using a standard storage pool
7489
should never be evaluated at run time after the elaboration of the
7490
library items of the partition has completed. Otherwise, Storage_Error
7491
is raised.
7492
 
7493
@node No_Standard_Storage_Pools
7494
@unnumberedsubsec No_Standard_Storage_Pools
7495
@findex No_Standard_Storage_Pools
7496
[GNAT] This restriction ensures at compile time that no access types
7497
use the standard default storage pool.  Any access type declared must
7498
have an explicit Storage_Pool attribute defined specifying a
7499
user-defined storage pool.
7500
 
7501
@node No_Stream_Optimizations
7502
@unnumberedsubsec No_Stream_Optimizations
7503
@findex No_Stream_Optimizations
7504
[GNAT] This restriction affects the performance of stream operations on types
7505
@code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7506
compiler uses block reads and writes when manipulating @code{String} objects
7507
due to their supperior performance. When this restriction is in effect, the
7508
compiler performs all IO operations on a per-character basis.
7509
 
7510
@node No_Streams
7511
@unnumberedsubsec No_Streams
7512
@findex No_Streams
7513
[GNAT] This restriction ensures at compile/bind time that there are no
7514
stream objects created and no use of stream attributes.
7515
This restriction does not forbid dependences on the package
7516
@code{Ada.Streams}. So it is permissible to with
7517
@code{Ada.Streams} (or another package that does so itself)
7518
as long as no actual stream objects are created and no
7519
stream attributes are used.
7520
 
7521
Note that the use of restriction allows optimization of tagged types,
7522
since they do not need to worry about dispatching stream operations.
7523
To take maximum advantage of this space-saving optimization, any
7524
unit declaring a tagged type should be compiled with the restriction,
7525
though this is not required.
7526
 
7527
@node No_Task_Allocators
7528
@unnumberedsubsec No_Task_Allocators
7529
@findex No_Task_Allocators
7530
[RM D.7] There are no allocators for task types
7531
or types containing task subcomponents.
7532
 
7533
@node No_Task_Attributes_Package
7534
@unnumberedsubsec No_Task_Attributes_Package
7535
@findex No_Task_Attributes_Package
7536
[GNAT] This restriction ensures at compile time that there are no implicit or
7537
explicit dependencies on the package @code{Ada.Task_Attributes}.
7538
 
7539
@node No_Task_Hierarchy
7540
@unnumberedsubsec No_Task_Hierarchy
7541
@findex No_Task_Hierarchy
7542
[RM D.7] All (non-environment) tasks depend
7543
directly on the environment task of the partition.
7544
 
7545
@node No_Task_Termination
7546
@unnumberedsubsec No_Task_Termination
7547
@findex No_Task_Termination
7548
[RM D.7] Tasks which terminate are erroneous.
7549
 
7550
@node No_Tasking
7551
@unnumberedsubsec No_Tasking
7552
@findex No_Tasking
7553
[GNAT] This restriction prevents the declaration of tasks or task types
7554
throughout the partition.  It is similar in effect to the use of
7555
@code{Max_Tasks => 0} except that violations are caught at compile time
7556
and cause an error message to be output either by the compiler or
7557
binder.
7558
 
7559
@node No_Terminate_Alternatives
7560
@unnumberedsubsec No_Terminate_Alternatives
7561
@findex No_Terminate_Alternatives
7562
[RM D.7] There are no selective accepts with terminate alternatives.
7563
 
7564
@node No_Unchecked_Access
7565
@unnumberedsubsec No_Unchecked_Access
7566
@findex No_Unchecked_Access
7567
[RM H.4] This restriction ensures at compile time that there are no
7568
occurrences of the Unchecked_Access attribute.
7569
 
7570
@node Simple_Barriers
7571
@unnumberedsubsec Simple_Barriers
7572
@findex Simple_Barriers
7573
[RM D.7] This restriction ensures at compile time that barriers in entry
7574
declarations for protected types are restricted to either static boolean
7575
expressions or references to simple boolean variables defined in the private
7576
part of the protected type.  No other form of entry barriers is permitted.
7577
 
7578
@node Static_Priorities
7579
@unnumberedsubsec Static_Priorities
7580
@findex Static_Priorities
7581
[GNAT] This restriction ensures at compile time that all priority expressions
7582
are static, and that there are no dependences on the package
7583
@code{Ada.Dynamic_Priorities}.
7584
 
7585
@node Static_Storage_Size
7586
@unnumberedsubsec Static_Storage_Size
7587
@findex Static_Storage_Size
7588
[GNAT] This restriction ensures at compile time that any expression appearing
7589
in a Storage_Size pragma or attribute definition clause is static.
7590
 
7591
@node Program Unit Level Restrictions
7592
@section Program Unit Level Restrictions
7593
 
7594
@noindent
7595
The second set of restriction identifiers
7596
does not require partition-wide consistency.
7597
The restriction may be enforced for a single
7598
compilation unit without any effect on any of the
7599
other compilation units in the partition.
7600
 
7601
@menu
7602
* No_Elaboration_Code::
7603
* No_Entry_Queue::
7604
* No_Implementation_Aspect_Specifications::
7605
* No_Implementation_Attributes::
7606
* No_Implementation_Identifiers::
7607
* No_Implementation_Pragmas::
7608
* No_Implementation_Restrictions::
7609
* No_Implementation_Units::
7610
* No_Implicit_Aliasing::
7611
* No_Obsolescent_Features::
7612
* No_Wide_Characters::
7613
* SPARK::
7614
@end menu
7615
 
7616
@node No_Elaboration_Code
7617
@unnumberedsubsec No_Elaboration_Code
7618
@findex No_Elaboration_Code
7619
[GNAT] This restriction ensures at compile time that no elaboration code is
7620
generated.  Note that this is not the same condition as is enforced
7621
by pragma @code{Preelaborate}.  There are cases in which pragma
7622
@code{Preelaborate} still permits code to be generated (e.g.@: code
7623
to initialize a large array to all zeroes), and there are cases of units
7624
which do not meet the requirements for pragma @code{Preelaborate},
7625
but for which no elaboration code is generated.  Generally, it is
7626
the case that preelaborable units will meet the restrictions, with
7627
the exception of large aggregates initialized with an others_clause,
7628
and exception declarations (which generate calls to a run-time
7629
registry procedure).  This restriction is enforced on
7630
a unit by unit basis, it need not be obeyed consistently
7631
throughout a partition.
7632
 
7633
In the case of aggregates with others, if the aggregate has a dynamic
7634
size, there is no way to eliminate the elaboration code (such dynamic
7635
bounds would be incompatible with @code{Preelaborate} in any case). If
7636
the bounds are static, then use of this restriction actually modifies
7637
the code choice of the compiler to avoid generating a loop, and instead
7638
generate the aggregate statically if possible, no matter how many times
7639
the data for the others clause must be repeatedly generated.
7640
 
7641
It is not possible to precisely document
7642
the constructs which are compatible with this restriction, since,
7643
unlike most other restrictions, this is not a restriction on the
7644
source code, but a restriction on the generated object code. For
7645
example, if the source contains a declaration:
7646
 
7647
@smallexample
7648
   Val : constant Integer := X;
7649
@end smallexample
7650
 
7651
@noindent
7652
where X is not a static constant, it may be possible, depending
7653
on complex optimization circuitry, for the compiler to figure
7654
out the value of X at compile time, in which case this initialization
7655
can be done by the loader, and requires no initialization code. It
7656
is not possible to document the precise conditions under which the
7657
optimizer can figure this out.
7658
 
7659
Note that this the implementation of this restriction requires full
7660
code generation. If it is used in conjunction with "semantics only"
7661
checking, then some cases of violations may be missed.
7662
 
7663
@node No_Entry_Queue
7664
@unnumberedsubsec No_Entry_Queue
7665
@findex No_Entry_Queue
7666
[GNAT] This restriction is a declaration that any protected entry compiled in
7667
the scope of the restriction has at most one task waiting on the entry
7668
at any one time, and so no queue is required.  This restriction is not
7669
checked at compile time.  A program execution is erroneous if an attempt
7670
is made to queue a second task on such an entry.
7671
 
7672
@node No_Implementation_Aspect_Specifications
7673
@unnumberedsubsec No_Implementation_Aspect_Specifications
7674
@findex No_Implementation_Aspect_Specifications
7675
[RM 13.12.1] This restriction checks at compile time that no
7676
GNAT-defined aspects are present.  With this restriction, the only
7677
aspects that can be used are those defined in the Ada Reference Manual.
7678
 
7679
@node No_Implementation_Attributes
7680
@unnumberedsubsec No_Implementation_Attributes
7681
@findex No_Implementation_Attributes
7682
[RM 13.12.1] This restriction checks at compile time that no
7683
GNAT-defined attributes are present.  With this restriction, the only
7684
attributes that can be used are those defined in the Ada Reference
7685
Manual.
7686
 
7687
@node No_Implementation_Identifiers
7688
@unnumberedsubsec No_Implementation_Identifiers
7689
@findex No_Implementation_Identifiers
7690
[RM 13.12.1] This restriction checks at compile time that no
7691
implementation-defined identifiers occur within language-defined
7692
packages.
7693
 
7694
@node No_Implementation_Pragmas
7695
@unnumberedsubsec No_Implementation_Pragmas
7696
@findex No_Implementation_Pragmas
7697
[RM 13.12.1] This restriction checks at compile time that no
7698
GNAT-defined pragmas are present.  With this restriction, the only
7699
pragmas that can be used are those defined in the Ada Reference Manual.
7700
 
7701
@node No_Implementation_Restrictions
7702
@unnumberedsubsec No_Implementation_Restrictions
7703
@findex No_Implementation_Restrictions
7704
[GNAT] This restriction checks at compile time that no GNAT-defined restriction
7705
identifiers (other than @code{No_Implementation_Restrictions} itself)
7706
are present.  With this restriction, the only other restriction identifiers
7707
that can be used are those defined in the Ada Reference Manual.
7708
 
7709
@node No_Implementation_Units
7710
@unnumberedsubsec No_Implementation_Units
7711
@findex No_Implementation_Units
7712
[RM 13.12.1] This restriction checks at compile time that there is no
7713
mention in the context clause of any implementation-defined descendants
7714
of packages Ada, Interfaces, or System.
7715
 
7716
@node No_Implicit_Aliasing
7717
@unnumberedsubsec No_Implicit_Aliasing
7718
@findex No_Implicit_Aliasing
7719
[GNAT] This restriction, which is not required to be partition-wide consistent,
7720
requires an explicit aliased keyword for an object to which 'Access,
7721
'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7722
the 'Unrestricted_Access attribute for objects. Note: the reason that
7723
Unrestricted_Access is forbidden is that it would require the prefix
7724
to be aliased, and in such cases, it can always be replaced by
7725
the standard attribute Unchecked_Access which is preferable.
7726
 
7727
@node No_Obsolescent_Features
7728
@unnumberedsubsec No_Obsolescent_Features
7729
@findex No_Obsolescent_Features
7730
[RM 13.12.1] This restriction checks at compile time that no obsolescent
7731
features are used, as defined in Annex J of the Ada Reference Manual.
7732
 
7733
@node No_Wide_Characters
7734
@unnumberedsubsec No_Wide_Characters
7735
@findex No_Wide_Characters
7736
[GNAT] This restriction ensures at compile time that no uses of the types
7737
@code{Wide_Character} or @code{Wide_String} or corresponding wide
7738
wide types
7739
appear, and that no wide or wide wide string or character literals
7740
appear in the program (that is literals representing characters not in
7741
type @code{Character}.
7742
 
7743
@node SPARK
7744
@unnumberedsubsec SPARK
7745
@findex SPARK
7746
[GNAT] This restriction checks at compile time that some constructs
7747
forbidden in SPARK are not present. The SPARK version used as a
7748
reference is the same as the Ada mode for the unit, so a unit compiled
7749
in Ada 95 mode with SPARK restrictions will be checked for constructs
7750
forbidden in SPARK 95.  Error messages related to SPARK restriction have
7751
the form:
7752
 
7753
@smallexample
7754
violation of restriction "SPARK" at <file>
7755
 <error message>
7756
@end smallexample
7757
 
7758
This is not a replacement for the semantic checks performed by the
7759
SPARK Examiner tool, as the compiler only deals currently with code,
7760
not at all with SPARK annotations and does not guarantee catching all
7761
cases of constructs forbidden by SPARK.
7762
 
7763
Thus it may well be the case that code which
7764
passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7765
e.g. due to the different visibility rules of the Examiner based on
7766
SPARK @code{inherit} annotations.
7767
 
7768
This restriction can be useful in providing an initial filter for
7769
code developed using SPARK, or in examining legacy code to see how far
7770
it is from meeting SPARK restrictions.
7771
 
7772
@c ------------------------
7773
@node Implementation Advice
7774
@chapter Implementation Advice
7775
@noindent
7776
The main text of the Ada Reference Manual describes the required
7777
behavior of all Ada compilers, and the GNAT compiler conforms to
7778
these requirements.
7779
 
7780
In addition, there are sections throughout the Ada Reference Manual headed
7781
by the phrase ``Implementation advice''.  These sections are not normative,
7782
i.e., they do not specify requirements that all compilers must
7783
follow.  Rather they provide advice on generally desirable behavior.  You
7784
may wonder why they are not requirements.  The most typical answer is
7785
that they describe behavior that seems generally desirable, but cannot
7786
be provided on all systems, or which may be undesirable on some systems.
7787
 
7788
As far as practical, GNAT follows the implementation advice sections in
7789
the Ada Reference Manual.  This chapter contains a table giving the
7790
reference manual section number, paragraph number and several keywords
7791
for each advice.  Each entry consists of the text of the advice followed
7792
by the GNAT interpretation of this advice.  Most often, this simply says
7793
``followed'', which means that GNAT follows the advice.  However, in a
7794
number of cases, GNAT deliberately deviates from this advice, in which
7795
case the text describes what GNAT does and why.
7796
 
7797
@cindex Error detection
7798
@unnumberedsec 1.1.3(20): Error Detection
7799
@sp 1
7800
@cartouche
7801
If an implementation detects the use of an unsupported Specialized Needs
7802
Annex feature at run time, it should raise @code{Program_Error} if
7803
feasible.
7804
@end cartouche
7805
Not relevant.  All specialized needs annex features are either supported,
7806
or diagnosed at compile time.
7807
 
7808
@cindex Child Units
7809
@unnumberedsec 1.1.3(31): Child Units
7810
@sp 1
7811
@cartouche
7812
If an implementation wishes to provide implementation-defined
7813
extensions to the functionality of a language-defined library unit, it
7814
should normally do so by adding children to the library unit.
7815
@end cartouche
7816
Followed.
7817
 
7818
@cindex Bounded errors
7819
@unnumberedsec 1.1.5(12): Bounded Errors
7820
@sp 1
7821
@cartouche
7822
If an implementation detects a bounded error or erroneous
7823
execution, it should raise @code{Program_Error}.
7824
@end cartouche
7825
Followed in all cases in which the implementation detects a bounded
7826
error or erroneous execution.  Not all such situations are detected at
7827
runtime.
7828
 
7829
@cindex Pragmas
7830
@unnumberedsec 2.8(16): Pragmas
7831
@sp 1
7832
@cartouche
7833
Normally, implementation-defined pragmas should have no semantic effect
7834
for error-free programs; that is, if the implementation-defined pragmas
7835
are removed from a working program, the program should still be legal,
7836
and should still have the same semantics.
7837
@end cartouche
7838
The following implementation defined pragmas are exceptions to this
7839
rule:
7840
 
7841
@table @code
7842
@item Abort_Defer
7843
Affects semantics
7844
@item Ada_83
7845
Affects legality
7846
@item Assert
7847
Affects semantics
7848
@item CPP_Class
7849
Affects semantics
7850
@item CPP_Constructor
7851
Affects semantics
7852
@item Debug
7853
Affects semantics
7854
@item Interface_Name
7855
Affects semantics
7856
@item Machine_Attribute
7857
Affects semantics
7858
@item Unimplemented_Unit
7859
Affects legality
7860
@item Unchecked_Union
7861
Affects semantics
7862
@end table
7863
 
7864
@noindent
7865
In each of the above cases, it is essential to the purpose of the pragma
7866
that this advice not be followed.  For details see the separate section
7867
on implementation defined pragmas.
7868
 
7869
@unnumberedsec 2.8(17-19): Pragmas
7870
@sp 1
7871
@cartouche
7872
Normally, an implementation should not define pragmas that can
7873
make an illegal program legal, except as follows:
7874
@end cartouche
7875
@sp 1
7876
@cartouche
7877
A pragma used to complete a declaration, such as a pragma @code{Import};
7878
@end cartouche
7879
@sp 1
7880
@cartouche
7881
A pragma used to configure the environment by adding, removing, or
7882
replacing @code{library_items}.
7883
@end cartouche
7884
See response to paragraph 16 of this same section.
7885
 
7886
@cindex Character Sets
7887
@cindex Alternative Character Sets
7888
@unnumberedsec 3.5.2(5): Alternative Character Sets
7889
@sp 1
7890
@cartouche
7891
If an implementation supports a mode with alternative interpretations
7892
for @code{Character} and @code{Wide_Character}, the set of graphic
7893
characters of @code{Character} should nevertheless remain a proper
7894
subset of the set of graphic characters of @code{Wide_Character}.  Any
7895
character set ``localizations'' should be reflected in the results of
7896
the subprograms defined in the language-defined package
7897
@code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
7898
an alternative interpretation of @code{Character}, the implementation should
7899
also support a corresponding change in what is a legal
7900
@code{identifier_letter}.
7901
@end cartouche
7902
Not all wide character modes follow this advice, in particular the JIS
7903
and IEC modes reflect standard usage in Japan, and in these encoding,
7904
the upper half of the Latin-1 set is not part of the wide-character
7905
subset, since the most significant bit is used for wide character
7906
encoding.  However, this only applies to the external forms.  Internally
7907
there is no such restriction.
7908
 
7909
@cindex Integer types
7910
@unnumberedsec 3.5.4(28): Integer Types
7911
 
7912
@sp 1
7913
@cartouche
7914
An implementation should support @code{Long_Integer} in addition to
7915
@code{Integer} if the target machine supports 32-bit (or longer)
7916
arithmetic.  No other named integer subtypes are recommended for package
7917
@code{Standard}.  Instead, appropriate named integer subtypes should be
7918
provided in the library package @code{Interfaces} (see B.2).
7919
@end cartouche
7920
@code{Long_Integer} is supported.  Other standard integer types are supported
7921
so this advice is not fully followed.  These types
7922
are supported for convenient interface to C, and so that all hardware
7923
types of the machine are easily available.
7924
@unnumberedsec 3.5.4(29): Integer Types
7925
 
7926
@sp 1
7927
@cartouche
7928
An implementation for a two's complement machine should support
7929
modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
7930
implementation should support a non-binary modules up to @code{Integer'Last}.
7931
@end cartouche
7932
Followed.
7933
 
7934
@cindex Enumeration values
7935
@unnumberedsec 3.5.5(8): Enumeration Values
7936
@sp 1
7937
@cartouche
7938
For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
7939
subtype, if the value of the operand does not correspond to the internal
7940
code for any enumeration literal of its type (perhaps due to an
7941
un-initialized variable), then the implementation should raise
7942
@code{Program_Error}.  This is particularly important for enumeration
7943
types with noncontiguous internal codes specified by an
7944
enumeration_representation_clause.
7945
@end cartouche
7946
Followed.
7947
 
7948
@cindex Float types
7949
@unnumberedsec 3.5.7(17): Float Types
7950
@sp 1
7951
@cartouche
7952
An implementation should support @code{Long_Float} in addition to
7953
@code{Float} if the target machine supports 11 or more digits of
7954
precision.  No other named floating point subtypes are recommended for
7955
package @code{Standard}.  Instead, appropriate named floating point subtypes
7956
should be provided in the library package @code{Interfaces} (see B.2).
7957
@end cartouche
7958
@code{Short_Float} and @code{Long_Long_Float} are also provided.  The
7959
former provides improved compatibility with other implementations
7960
supporting this type.  The latter corresponds to the highest precision
7961
floating-point type supported by the hardware.  On most machines, this
7962
will be the same as @code{Long_Float}, but on some machines, it will
7963
correspond to the IEEE extended form.  The notable case is all ia32
7964
(x86) implementations, where @code{Long_Long_Float} corresponds to
7965
the 80-bit extended precision format supported in hardware on this
7966
processor.  Note that the 128-bit format on SPARC is not supported,
7967
since this is a software rather than a hardware format.
7968
 
7969
@cindex Multidimensional arrays
7970
@cindex Arrays, multidimensional
7971
@unnumberedsec 3.6.2(11): Multidimensional Arrays
7972
@sp 1
7973
@cartouche
7974
An implementation should normally represent multidimensional arrays in
7975
row-major order, consistent with the notation used for multidimensional
7976
array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
7977
(@code{Fortran}, @dots{}) applies to a multidimensional array type, then
7978
column-major order should be used instead (see B.5, ``Interfacing with
7979
Fortran'').
7980
@end cartouche
7981
Followed.
7982
 
7983
@findex Duration'Small
7984
@unnumberedsec 9.6(30-31): Duration'Small
7985
@sp 1
7986
@cartouche
7987
Whenever possible in an implementation, the value of @code{Duration'Small}
7988
should be no greater than 100 microseconds.
7989
@end cartouche
7990
Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
7991
 
7992
@sp 1
7993
@cartouche
7994
The time base for @code{delay_relative_statements} should be monotonic;
7995
it need not be the same time base as used for @code{Calendar.Clock}.
7996
@end cartouche
7997
Followed.
7998
 
7999
@unnumberedsec 10.2.1(12): Consistent Representation
8000
@sp 1
8001
@cartouche
8002
In an implementation, a type declared in a pre-elaborated package should
8003
have the same representation in every elaboration of a given version of
8004
the package, whether the elaborations occur in distinct executions of
8005
the same program, or in executions of distinct programs or partitions
8006
that include the given version.
8007
@end cartouche
8008
Followed, except in the case of tagged types.  Tagged types involve
8009
implicit pointers to a local copy of a dispatch table, and these pointers
8010
have representations which thus depend on a particular elaboration of the
8011
package.  It is not easy to see how it would be possible to follow this
8012
advice without severely impacting efficiency of execution.
8013
 
8014
@cindex Exception information
8015
@unnumberedsec 11.4.1(19): Exception Information
8016
@sp 1
8017
@cartouche
8018
@code{Exception_Message} by default and @code{Exception_Information}
8019
should produce information useful for
8020
debugging.  @code{Exception_Message} should be short, about one
8021
line.  @code{Exception_Information} can be long.  @code{Exception_Message}
8022
should not include the
8023
@code{Exception_Name}.  @code{Exception_Information} should include both
8024
the @code{Exception_Name} and the @code{Exception_Message}.
8025
@end cartouche
8026
Followed.  For each exception that doesn't have a specified
8027
@code{Exception_Message}, the compiler generates one containing the location
8028
of the raise statement.  This location has the form ``file:line'', where
8029
file is the short file name (without path information) and line is the line
8030
number in the file.  Note that in the case of the Zero Cost Exception
8031
mechanism, these messages become redundant with the Exception_Information that
8032
contains a full backtrace of the calling sequence, so they are disabled.
8033
To disable explicitly the generation of the source location message, use the
8034
Pragma @code{Discard_Names}.
8035
 
8036
@cindex Suppression of checks
8037
@cindex Checks, suppression of
8038
@unnumberedsec 11.5(28): Suppression of Checks
8039
@sp 1
8040
@cartouche
8041
The implementation should minimize the code executed for checks that
8042
have been suppressed.
8043
@end cartouche
8044
Followed.
8045
 
8046
@cindex Representation clauses
8047
@unnumberedsec 13.1 (21-24): Representation Clauses
8048
@sp 1
8049
@cartouche
8050
The recommended level of support for all representation items is
8051
qualified as follows:
8052
@end cartouche
8053
@sp 1
8054
@cartouche
8055
An implementation need not support representation items containing
8056
non-static expressions, except that an implementation should support a
8057
representation item for a given entity if each non-static expression in
8058
the representation item is a name that statically denotes a constant
8059
declared before the entity.
8060
@end cartouche
8061
Followed.  In fact, GNAT goes beyond the recommended level of support
8062
by allowing nonstatic expressions in some representation clauses even
8063
without the need to declare constants initialized with the values of
8064
such expressions.
8065
For example:
8066
 
8067
@smallexample @c ada
8068
  X : Integer;
8069
  Y : Float;
8070
  for Y'Address use X'Address;>>
8071
@end smallexample
8072
 
8073
@sp 1
8074
@cartouche
8075
An implementation need not support a specification for the @code{Size}
8076
for a given composite subtype, nor the size or storage place for an
8077
object (including a component) of a given composite subtype, unless the
8078
constraints on the subtype and its composite subcomponents (if any) are
8079
all static constraints.
8080
@end cartouche
8081
Followed.  Size Clauses are not permitted on non-static components, as
8082
described above.
8083
 
8084
@sp 1
8085
@cartouche
8086
An aliased component, or a component whose type is by-reference, should
8087
always be allocated at an addressable location.
8088
@end cartouche
8089
Followed.
8090
 
8091
@cindex Packed types
8092
@unnumberedsec 13.2(6-8): Packed Types
8093
@sp 1
8094
@cartouche
8095
If a type is packed, then the implementation should try to minimize
8096
storage allocated to objects of the type, possibly at the expense of
8097
speed of accessing components, subject to reasonable complexity in
8098
addressing calculations.
8099
@end cartouche
8100
@sp 1
8101
@cartouche
8102
The recommended level of support pragma @code{Pack} is:
8103
 
8104
For a packed record type, the components should be packed as tightly as
8105
possible subject to the Sizes of the component subtypes, and subject to
8106
any @code{record_representation_clause} that applies to the type; the
8107
implementation may, but need not, reorder components or cross aligned
8108
word boundaries to improve the packing.  A component whose @code{Size} is
8109
greater than the word size may be allocated an integral number of words.
8110
@end cartouche
8111
Followed.  Tight packing of arrays is supported for all component sizes
8112
up to 64-bits. If the array component size is 1 (that is to say, if
8113
the component is a boolean type or an enumeration type with two values)
8114
then values of the type are implicitly initialized to zero. This
8115
happens both for objects of the packed type, and for objects that have a
8116
subcomponent of the packed type.
8117
 
8118
@sp 1
8119
@cartouche
8120
An implementation should support Address clauses for imported
8121
subprograms.
8122
@end cartouche
8123
Followed.
8124
@cindex @code{Address} clauses
8125
@unnumberedsec 13.3(14-19): Address Clauses
8126
 
8127
@sp 1
8128
@cartouche
8129
For an array @var{X}, @code{@var{X}'Address} should point at the first
8130
component of the array, and not at the array bounds.
8131
@end cartouche
8132
Followed.
8133
 
8134
@sp 1
8135
@cartouche
8136
The recommended level of support for the @code{Address} attribute is:
8137
 
8138
@code{@var{X}'Address} should produce a useful result if @var{X} is an
8139
object that is aliased or of a by-reference type, or is an entity whose
8140
@code{Address} has been specified.
8141
@end cartouche
8142
Followed.  A valid address will be produced even if none of those
8143
conditions have been met.  If necessary, the object is forced into
8144
memory to ensure the address is valid.
8145
 
8146
@sp 1
8147
@cartouche
8148
An implementation should support @code{Address} clauses for imported
8149
subprograms.
8150
@end cartouche
8151
Followed.
8152
 
8153
@sp 1
8154
@cartouche
8155
Objects (including subcomponents) that are aliased or of a by-reference
8156
type should be allocated on storage element boundaries.
8157
@end cartouche
8158
Followed.
8159
 
8160
@sp 1
8161
@cartouche
8162
If the @code{Address} of an object is specified, or it is imported or exported,
8163
then the implementation should not perform optimizations based on
8164
assumptions of no aliases.
8165
@end cartouche
8166
Followed.
8167
 
8168
@cindex @code{Alignment} clauses
8169
@unnumberedsec 13.3(29-35): Alignment Clauses
8170
@sp 1
8171
@cartouche
8172
The recommended level of support for the @code{Alignment} attribute for
8173
subtypes is:
8174
 
8175
An implementation should support specified Alignments that are factors
8176
and multiples of the number of storage elements per word, subject to the
8177
following:
8178
@end cartouche
8179
Followed.
8180
 
8181
@sp 1
8182
@cartouche
8183
An implementation need not support specified @code{Alignment}s for
8184
combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8185
loaded and stored by available machine instructions.
8186
@end cartouche
8187
Followed.
8188
 
8189
@sp 1
8190
@cartouche
8191
An implementation need not support specified @code{Alignment}s that are
8192
greater than the maximum @code{Alignment} the implementation ever returns by
8193
default.
8194
@end cartouche
8195
Followed.
8196
 
8197
@sp 1
8198
@cartouche
8199
The recommended level of support for the @code{Alignment} attribute for
8200
objects is:
8201
 
8202
Same as above, for subtypes, but in addition:
8203
@end cartouche
8204
Followed.
8205
 
8206
@sp 1
8207
@cartouche
8208
For stand-alone library-level objects of statically constrained
8209
subtypes, the implementation should support all @code{Alignment}s
8210
supported by the target linker.  For example, page alignment is likely to
8211
be supported for such objects, but not for subtypes.
8212
@end cartouche
8213
Followed.
8214
 
8215
@cindex @code{Size} clauses
8216
@unnumberedsec 13.3(42-43): Size Clauses
8217
@sp 1
8218
@cartouche
8219
The recommended level of support for the @code{Size} attribute of
8220
objects is:
8221
 
8222
A @code{Size} clause should be supported for an object if the specified
8223
@code{Size} is at least as large as its subtype's @code{Size}, and
8224
corresponds to a size in storage elements that is a multiple of the
8225
object's @code{Alignment} (if the @code{Alignment} is nonzero).
8226
@end cartouche
8227
Followed.
8228
 
8229
@unnumberedsec 13.3(50-56): Size Clauses
8230
@sp 1
8231
@cartouche
8232
If the @code{Size} of a subtype is specified, and allows for efficient
8233
independent addressability (see 9.10) on the target architecture, then
8234
the @code{Size} of the following objects of the subtype should equal the
8235
@code{Size} of the subtype:
8236
 
8237
Aliased objects (including components).
8238
@end cartouche
8239
Followed.
8240
 
8241
@sp 1
8242
@cartouche
8243
@code{Size} clause on a composite subtype should not affect the
8244
internal layout of components.
8245
@end cartouche
8246
Followed. But note that this can be overridden by use of the implementation
8247
pragma Implicit_Packing in the case of packed arrays.
8248
 
8249
@sp 1
8250
@cartouche
8251
The recommended level of support for the @code{Size} attribute of subtypes is:
8252
@end cartouche
8253
@sp 1
8254
@cartouche
8255
The @code{Size} (if not specified) of a static discrete or fixed point
8256
subtype should be the number of bits needed to represent each value
8257
belonging to the subtype using an unbiased representation, leaving space
8258
for a sign bit only if the subtype contains negative values.  If such a
8259
subtype is a first subtype, then an implementation should support a
8260
specified @code{Size} for it that reflects this representation.
8261
@end cartouche
8262
Followed.
8263
 
8264
@sp 1
8265
@cartouche
8266
For a subtype implemented with levels of indirection, the @code{Size}
8267
should include the size of the pointers, but not the size of what they
8268
point at.
8269
@end cartouche
8270
Followed.
8271
 
8272
@cindex @code{Component_Size} clauses
8273
@unnumberedsec 13.3(71-73): Component Size Clauses
8274
@sp 1
8275
@cartouche
8276
The recommended level of support for the @code{Component_Size}
8277
attribute is:
8278
@end cartouche
8279
@sp 1
8280
@cartouche
8281
An implementation need not support specified @code{Component_Sizes} that are
8282
less than the @code{Size} of the component subtype.
8283
@end cartouche
8284
Followed.
8285
 
8286
@sp 1
8287
@cartouche
8288
An implementation should support specified @code{Component_Size}s that
8289
are factors and multiples of the word size.  For such
8290
@code{Component_Size}s, the array should contain no gaps between
8291
components.  For other @code{Component_Size}s (if supported), the array
8292
should contain no gaps between components when packing is also
8293
specified; the implementation should forbid this combination in cases
8294
where it cannot support a no-gaps representation.
8295
@end cartouche
8296
Followed.
8297
 
8298
@cindex Enumeration representation clauses
8299
@cindex Representation clauses, enumeration
8300
@unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8301
@sp 1
8302
@cartouche
8303
The recommended level of support for enumeration representation clauses
8304
is:
8305
 
8306
An implementation need not support enumeration representation clauses
8307
for boolean types, but should at minimum support the internal codes in
8308
the range @code{System.Min_Int.System.Max_Int}.
8309
@end cartouche
8310
Followed.
8311
 
8312
@cindex Record representation clauses
8313
@cindex Representation clauses, records
8314
@unnumberedsec 13.5.1(17-22): Record Representation Clauses
8315
@sp 1
8316
@cartouche
8317
The recommended level of support for
8318
@*@code{record_representation_clauses} is:
8319
 
8320
An implementation should support storage places that can be extracted
8321
with a load, mask, shift sequence of machine code, and set with a load,
8322
shift, mask, store sequence, given the available machine instructions
8323
and run-time model.
8324
@end cartouche
8325
Followed.
8326
 
8327
@sp 1
8328
@cartouche
8329
A storage place should be supported if its size is equal to the
8330
@code{Size} of the component subtype, and it starts and ends on a
8331
boundary that obeys the @code{Alignment} of the component subtype.
8332
@end cartouche
8333
Followed.
8334
 
8335
@sp 1
8336
@cartouche
8337
If the default bit ordering applies to the declaration of a given type,
8338
then for a component whose subtype's @code{Size} is less than the word
8339
size, any storage place that does not cross an aligned word boundary
8340
should be supported.
8341
@end cartouche
8342
Followed.
8343
 
8344
@sp 1
8345
@cartouche
8346
An implementation may reserve a storage place for the tag field of a
8347
tagged type, and disallow other components from overlapping that place.
8348
@end cartouche
8349
Followed.  The storage place for the tag field is the beginning of the tagged
8350
record, and its size is Address'Size.  GNAT will reject an explicit component
8351
clause for the tag field.
8352
 
8353
@sp 1
8354
@cartouche
8355
An implementation need not support a @code{component_clause} for a
8356
component of an extension part if the storage place is not after the
8357
storage places of all components of the parent type, whether or not
8358
those storage places had been specified.
8359
@end cartouche
8360
Followed.  The above advice on record representation clauses is followed,
8361
and all mentioned features are implemented.
8362
 
8363
@cindex Storage place attributes
8364
@unnumberedsec 13.5.2(5): Storage Place Attributes
8365
@sp 1
8366
@cartouche
8367
If a component is represented using some form of pointer (such as an
8368
offset) to the actual data of the component, and this data is contiguous
8369
with the rest of the object, then the storage place attributes should
8370
reflect the place of the actual data, not the pointer.  If a component is
8371
allocated discontinuously from the rest of the object, then a warning
8372
should be generated upon reference to one of its storage place
8373
attributes.
8374
@end cartouche
8375
Followed.  There are no such components in GNAT@.
8376
 
8377
@cindex Bit ordering
8378
@unnumberedsec 13.5.3(7-8): Bit Ordering
8379
@sp 1
8380
@cartouche
8381
The recommended level of support for the non-default bit ordering is:
8382
@end cartouche
8383
@sp 1
8384
@cartouche
8385
If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8386
should support the non-default bit ordering in addition to the default
8387
bit ordering.
8388
@end cartouche
8389
Followed.  Word size does not equal storage size in this implementation.
8390
Thus non-default bit ordering is not supported.
8391
 
8392
@cindex @code{Address}, as private type
8393
@unnumberedsec 13.7(37): Address as Private
8394
@sp 1
8395
@cartouche
8396
@code{Address} should be of a private type.
8397
@end cartouche
8398
Followed.
8399
 
8400
@cindex Operations, on @code{Address}
8401
@cindex @code{Address}, operations of
8402
@unnumberedsec 13.7.1(16): Address Operations
8403
@sp 1
8404
@cartouche
8405
Operations in @code{System} and its children should reflect the target
8406
environment semantics as closely as is reasonable.  For example, on most
8407
machines, it makes sense for address arithmetic to ``wrap around''.
8408
Operations that do not make sense should raise @code{Program_Error}.
8409
@end cartouche
8410
Followed.  Address arithmetic is modular arithmetic that wraps around.  No
8411
operation raises @code{Program_Error}, since all operations make sense.
8412
 
8413
@cindex Unchecked conversion
8414
@unnumberedsec 13.9(14-17): Unchecked Conversion
8415
@sp 1
8416
@cartouche
8417
The @code{Size} of an array object should not include its bounds; hence,
8418
the bounds should not be part of the converted data.
8419
@end cartouche
8420
Followed.
8421
 
8422
@sp 1
8423
@cartouche
8424
The implementation should not generate unnecessary run-time checks to
8425
ensure that the representation of @var{S} is a representation of the
8426
target type.  It should take advantage of the permission to return by
8427
reference when possible.  Restrictions on unchecked conversions should be
8428
avoided unless required by the target environment.
8429
@end cartouche
8430
Followed.  There are no restrictions on unchecked conversion.  A warning is
8431
generated if the source and target types do not have the same size since
8432
the semantics in this case may be target dependent.
8433
 
8434
@sp 1
8435
@cartouche
8436
The recommended level of support for unchecked conversions is:
8437
@end cartouche
8438
@sp 1
8439
@cartouche
8440
Unchecked conversions should be supported and should be reversible in
8441
the cases where this clause defines the result.  To enable meaningful use
8442
of unchecked conversion, a contiguous representation should be used for
8443
elementary subtypes, for statically constrained array subtypes whose
8444
component subtype is one of the subtypes described in this paragraph,
8445
and for record subtypes without discriminants whose component subtypes
8446
are described in this paragraph.
8447
@end cartouche
8448
Followed.
8449
 
8450
@cindex Heap usage, implicit
8451
@unnumberedsec 13.11(23-25): Implicit Heap Usage
8452
@sp 1
8453
@cartouche
8454
An implementation should document any cases in which it dynamically
8455
allocates heap storage for a purpose other than the evaluation of an
8456
allocator.
8457
@end cartouche
8458
Followed, the only other points at which heap storage is dynamically
8459
allocated are as follows:
8460
 
8461
@itemize @bullet
8462
@item
8463
At initial elaboration time, to allocate dynamically sized global
8464
objects.
8465
 
8466
@item
8467
To allocate space for a task when a task is created.
8468
 
8469
@item
8470
To extend the secondary stack dynamically when needed.  The secondary
8471
stack is used for returning variable length results.
8472
@end itemize
8473
 
8474
@sp 1
8475
@cartouche
8476
A default (implementation-provided) storage pool for an
8477
access-to-constant type should not have overhead to support deallocation of
8478
individual objects.
8479
@end cartouche
8480
Followed.
8481
 
8482
@sp 1
8483
@cartouche
8484
A storage pool for an anonymous access type should be created at the
8485
point of an allocator for the type, and be reclaimed when the designated
8486
object becomes inaccessible.
8487
@end cartouche
8488
Followed.
8489
 
8490
@cindex Unchecked deallocation
8491
@unnumberedsec 13.11.2(17): Unchecked De-allocation
8492
@sp 1
8493
@cartouche
8494
For a standard storage pool, @code{Free} should actually reclaim the
8495
storage.
8496
@end cartouche
8497
Followed.
8498
 
8499
@cindex Stream oriented attributes
8500
@unnumberedsec 13.13.2(17): Stream Oriented Attributes
8501
@sp 1
8502
@cartouche
8503
If a stream element is the same size as a storage element, then the
8504
normal in-memory representation should be used by @code{Read} and
8505
@code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
8506
should use the smallest number of stream elements needed to represent
8507
all values in the base range of the scalar type.
8508
@end cartouche
8509
 
8510
Followed.  By default, GNAT uses the interpretation suggested by AI-195,
8511
which specifies using the size of the first subtype.
8512
However, such an implementation is based on direct binary
8513
representations and is therefore target- and endianness-dependent.
8514
To address this issue, GNAT also supplies an alternate implementation
8515
of the stream attributes @code{Read} and @code{Write},
8516
which uses the target-independent XDR standard representation
8517
for scalar types.
8518
@cindex XDR representation
8519
@cindex @code{Read} attribute
8520
@cindex @code{Write} attribute
8521
@cindex Stream oriented attributes
8522
The XDR implementation is provided as an alternative body of the
8523
@code{System.Stream_Attributes} package, in the file
8524
@file{s-stratt-xdr.adb} in the GNAT library.
8525
There is no @file{s-stratt-xdr.ads} file.
8526
In order to install the XDR implementation, do the following:
8527
@enumerate
8528
@item Replace the default implementation of the
8529
@code{System.Stream_Attributes} package with the XDR implementation.
8530
For example on a Unix platform issue the commands:
8531
@smallexample
8532
$ mv s-stratt.adb s-stratt-default.adb
8533
$ mv s-stratt-xdr.adb s-stratt.adb
8534
@end smallexample
8535
 
8536
@item
8537
Rebuild the GNAT run-time library as documented in
8538
@ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8539
@end enumerate
8540
 
8541
@unnumberedsec A.1(52): Names of Predefined Numeric Types
8542
@sp 1
8543
@cartouche
8544
If an implementation provides additional named predefined integer types,
8545
then the names should end with @samp{Integer} as in
8546
@samp{Long_Integer}.  If an implementation provides additional named
8547
predefined floating point types, then the names should end with
8548
@samp{Float} as in @samp{Long_Float}.
8549
@end cartouche
8550
Followed.
8551
 
8552
@findex Ada.Characters.Handling
8553
@unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8554
@sp 1
8555
@cartouche
8556
If an implementation provides a localized definition of @code{Character}
8557
or @code{Wide_Character}, then the effects of the subprograms in
8558
@code{Characters.Handling} should reflect the localizations.  See also
8559
3.5.2.
8560
@end cartouche
8561
Followed.  GNAT provides no such localized definitions.
8562
 
8563
@cindex Bounded-length strings
8564
@unnumberedsec A.4.4(106): Bounded-Length String Handling
8565
@sp 1
8566
@cartouche
8567
Bounded string objects should not be implemented by implicit pointers
8568
and dynamic allocation.
8569
@end cartouche
8570
Followed.  No implicit pointers or dynamic allocation are used.
8571
 
8572
@cindex Random number generation
8573
@unnumberedsec A.5.2(46-47): Random Number Generation
8574
@sp 1
8575
@cartouche
8576
Any storage associated with an object of type @code{Generator} should be
8577
reclaimed on exit from the scope of the object.
8578
@end cartouche
8579
Followed.
8580
 
8581
@sp 1
8582
@cartouche
8583
If the generator period is sufficiently long in relation to the number
8584
of distinct initiator values, then each possible value of
8585
@code{Initiator} passed to @code{Reset} should initiate a sequence of
8586
random numbers that does not, in a practical sense, overlap the sequence
8587
initiated by any other value.  If this is not possible, then the mapping
8588
between initiator values and generator states should be a rapidly
8589
varying function of the initiator value.
8590
@end cartouche
8591
Followed.  The generator period is sufficiently long for the first
8592
condition here to hold true.
8593
 
8594
@findex Get_Immediate
8595
@unnumberedsec A.10.7(23): @code{Get_Immediate}
8596
@sp 1
8597
@cartouche
8598
The @code{Get_Immediate} procedures should be implemented with
8599
unbuffered input.  For a device such as a keyboard, input should be
8600
@dfn{available} if a key has already been typed, whereas for a disk
8601
file, input should always be available except at end of file.  For a file
8602
associated with a keyboard-like device, any line-editing features of the
8603
underlying operating system should be disabled during the execution of
8604
@code{Get_Immediate}.
8605
@end cartouche
8606
Followed on all targets except VxWorks. For VxWorks, there is no way to
8607
provide this functionality that does not result in the input buffer being
8608
flushed before the @code{Get_Immediate} call. A special unit
8609
@code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8610
this functionality.
8611
 
8612
@findex Export
8613
@unnumberedsec B.1(39-41): Pragma @code{Export}
8614
@sp 1
8615
@cartouche
8616
If an implementation supports pragma @code{Export} to a given language,
8617
then it should also allow the main subprogram to be written in that
8618
language.  It should support some mechanism for invoking the elaboration
8619
of the Ada library units included in the system, and for invoking the
8620
finalization of the environment task.  On typical systems, the
8621
recommended mechanism is to provide two subprograms whose link names are
8622
@code{adainit} and @code{adafinal}.  @code{adainit} should contain the
8623
elaboration code for library units.  @code{adafinal} should contain the
8624
finalization code.  These subprograms should have no effect the second
8625
and subsequent time they are called.
8626
@end cartouche
8627
Followed.
8628
 
8629
@sp 1
8630
@cartouche
8631
Automatic elaboration of pre-elaborated packages should be
8632
provided when pragma @code{Export} is supported.
8633
@end cartouche
8634
Followed when the main program is in Ada.  If the main program is in a
8635
foreign language, then
8636
@code{adainit} must be called to elaborate pre-elaborated
8637
packages.
8638
 
8639
@sp 1
8640
@cartouche
8641
For each supported convention @var{L} other than @code{Intrinsic}, an
8642
implementation should support @code{Import} and @code{Export} pragmas
8643
for objects of @var{L}-compatible types and for subprograms, and pragma
8644
@code{Convention} for @var{L}-eligible types and for subprograms,
8645
presuming the other language has corresponding features.  Pragma
8646
@code{Convention} need not be supported for scalar types.
8647
@end cartouche
8648
Followed.
8649
 
8650
@cindex Package @code{Interfaces}
8651
@findex Interfaces
8652
@unnumberedsec B.2(12-13): Package @code{Interfaces}
8653
@sp 1
8654
@cartouche
8655
For each implementation-defined convention identifier, there should be a
8656
child package of package Interfaces with the corresponding name.  This
8657
package should contain any declarations that would be useful for
8658
interfacing to the language (implementation) represented by the
8659
convention.  Any declarations useful for interfacing to any language on
8660
the given hardware architecture should be provided directly in
8661
@code{Interfaces}.
8662
@end cartouche
8663
Followed. An additional package not defined
8664
in the Ada Reference Manual is @code{Interfaces.CPP}, used
8665
for interfacing to C++.
8666
 
8667
@sp 1
8668
@cartouche
8669
An implementation supporting an interface to C, COBOL, or Fortran should
8670
provide the corresponding package or packages described in the following
8671
clauses.
8672
@end cartouche
8673
Followed.  GNAT provides all the packages described in this section.
8674
 
8675
@cindex C, interfacing with
8676
@unnumberedsec B.3(63-71): Interfacing with C
8677
@sp 1
8678
@cartouche
8679
An implementation should support the following interface correspondences
8680
between Ada and C@.
8681
@end cartouche
8682
Followed.
8683
 
8684
@sp 1
8685
@cartouche
8686
An Ada procedure corresponds to a void-returning C function.
8687
@end cartouche
8688
Followed.
8689
 
8690
@sp 1
8691
@cartouche
8692
An Ada function corresponds to a non-void C function.
8693
@end cartouche
8694
Followed.
8695
 
8696
@sp 1
8697
@cartouche
8698
An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8699
function.
8700
@end cartouche
8701
Followed.
8702
 
8703
@sp 1
8704
@cartouche
8705
An Ada @code{in} parameter of an access-to-object type with designated
8706
type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8707
where @var{t} is the C type corresponding to the Ada type @var{T}.
8708
@end cartouche
8709
Followed.
8710
 
8711
@sp 1
8712
@cartouche
8713
An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8714
parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8715
argument to a C function, where @var{t} is the C type corresponding to
8716
the Ada type @var{T}.  In the case of an elementary @code{out} or
8717
@code{in out} parameter, a pointer to a temporary copy is used to
8718
preserve by-copy semantics.
8719
@end cartouche
8720
Followed.
8721
 
8722
@sp 1
8723
@cartouche
8724
An Ada parameter of a record type @var{T}, of any mode, is passed as a
8725
@code{@var{t}*} argument to a C function, where @var{t} is the C
8726
structure corresponding to the Ada type @var{T}.
8727
@end cartouche
8728
Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
8729
pragma, or Convention, or by explicitly specifying the mechanism for a given
8730
call using an extended import or export pragma.
8731
 
8732
@sp 1
8733
@cartouche
8734
An Ada parameter of an array type with component type @var{T}, of any
8735
mode, is passed as a @code{@var{t}*} argument to a C function, where
8736
@var{t} is the C type corresponding to the Ada type @var{T}.
8737
@end cartouche
8738
Followed.
8739
 
8740
@sp 1
8741
@cartouche
8742
An Ada parameter of an access-to-subprogram type is passed as a pointer
8743
to a C function whose prototype corresponds to the designated
8744
subprogram's specification.
8745
@end cartouche
8746
Followed.
8747
 
8748
@cindex COBOL, interfacing with
8749
@unnumberedsec B.4(95-98): Interfacing with COBOL
8750
@sp 1
8751
@cartouche
8752
An Ada implementation should support the following interface
8753
correspondences between Ada and COBOL@.
8754
@end cartouche
8755
Followed.
8756
 
8757
@sp 1
8758
@cartouche
8759
An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8760
the COBOL type corresponding to @var{T}.
8761
@end cartouche
8762
Followed.
8763
 
8764
@sp 1
8765
@cartouche
8766
An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8767
the corresponding COBOL type.
8768
@end cartouche
8769
Followed.
8770
 
8771
@sp 1
8772
@cartouche
8773
Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8774
COBOL type corresponding to the Ada parameter type; for scalars, a local
8775
copy is used if necessary to ensure by-copy semantics.
8776
@end cartouche
8777
Followed.
8778
 
8779
@cindex Fortran, interfacing with
8780
@unnumberedsec B.5(22-26): Interfacing with Fortran
8781
@sp 1
8782
@cartouche
8783
An Ada implementation should support the following interface
8784
correspondences between Ada and Fortran:
8785
@end cartouche
8786
Followed.
8787
 
8788
@sp 1
8789
@cartouche
8790
An Ada procedure corresponds to a Fortran subroutine.
8791
@end cartouche
8792
Followed.
8793
 
8794
@sp 1
8795
@cartouche
8796
An Ada function corresponds to a Fortran function.
8797
@end cartouche
8798
Followed.
8799
 
8800
@sp 1
8801
@cartouche
8802
An Ada parameter of an elementary, array, or record type @var{T} is
8803
passed as a @var{T} argument to a Fortran procedure, where @var{T} is
8804
the Fortran type corresponding to the Ada type @var{T}, and where the
8805
INTENT attribute of the corresponding dummy argument matches the Ada
8806
formal parameter mode; the Fortran implementation's parameter passing
8807
conventions are used.  For elementary types, a local copy is used if
8808
necessary to ensure by-copy semantics.
8809
@end cartouche
8810
Followed.
8811
 
8812
@sp 1
8813
@cartouche
8814
An Ada parameter of an access-to-subprogram type is passed as a
8815
reference to a Fortran procedure whose interface corresponds to the
8816
designated subprogram's specification.
8817
@end cartouche
8818
Followed.
8819
 
8820
@cindex Machine operations
8821
@unnumberedsec C.1(3-5): Access to Machine Operations
8822
@sp 1
8823
@cartouche
8824
The machine code or intrinsic support should allow access to all
8825
operations normally available to assembly language programmers for the
8826
target environment, including privileged instructions, if any.
8827
@end cartouche
8828
Followed.
8829
 
8830
@sp 1
8831
@cartouche
8832
The interfacing pragmas (see Annex B) should support interface to
8833
assembler; the default assembler should be associated with the
8834
convention identifier @code{Assembler}.
8835
@end cartouche
8836
Followed.
8837
 
8838
@sp 1
8839
@cartouche
8840
If an entity is exported to assembly language, then the implementation
8841
should allocate it at an addressable location, and should ensure that it
8842
is retained by the linking process, even if not otherwise referenced
8843
from the Ada code.  The implementation should assume that any call to a
8844
machine code or assembler subprogram is allowed to read or update every
8845
object that is specified as exported.
8846
@end cartouche
8847
Followed.
8848
 
8849
@unnumberedsec C.1(10-16): Access to Machine Operations
8850
@sp 1
8851
@cartouche
8852
The implementation should ensure that little or no overhead is
8853
associated with calling intrinsic and machine-code subprograms.
8854
@end cartouche
8855
Followed for both intrinsics and machine-code subprograms.
8856
 
8857
@sp 1
8858
@cartouche
8859
It is recommended that intrinsic subprograms be provided for convenient
8860
access to any machine operations that provide special capabilities or
8861
efficiency and that are not otherwise available through the language
8862
constructs.
8863
@end cartouche
8864
Followed.  A full set of machine operation intrinsic subprograms is provided.
8865
 
8866
@sp 1
8867
@cartouche
8868
Atomic read-modify-write operations---e.g.@:, test and set, compare and
8869
swap, decrement and test, enqueue/dequeue.
8870
@end cartouche
8871
Followed on any target supporting such operations.
8872
 
8873
@sp 1
8874
@cartouche
8875
Standard numeric functions---e.g.@:, sin, log.
8876
@end cartouche
8877
Followed on any target supporting such operations.
8878
 
8879
@sp 1
8880
@cartouche
8881
String manipulation operations---e.g.@:, translate and test.
8882
@end cartouche
8883
Followed on any target supporting such operations.
8884
 
8885
@sp 1
8886
@cartouche
8887
Vector operations---e.g.@:, compare vector against thresholds.
8888
@end cartouche
8889
Followed on any target supporting such operations.
8890
 
8891
@sp 1
8892
@cartouche
8893
Direct operations on I/O ports.
8894
@end cartouche
8895
Followed on any target supporting such operations.
8896
 
8897
@cindex Interrupt support
8898
@unnumberedsec C.3(28): Interrupt Support
8899
@sp 1
8900
@cartouche
8901
If the @code{Ceiling_Locking} policy is not in effect, the
8902
implementation should provide means for the application to specify which
8903
interrupts are to be blocked during protected actions, if the underlying
8904
system allows for a finer-grain control of interrupt blocking.
8905
@end cartouche
8906
Followed.  The underlying system does not allow for finer-grain control
8907
of interrupt blocking.
8908
 
8909
@cindex Protected procedure handlers
8910
@unnumberedsec C.3.1(20-21): Protected Procedure Handlers
8911
@sp 1
8912
@cartouche
8913
Whenever possible, the implementation should allow interrupt handlers to
8914
be called directly by the hardware.
8915
@end cartouche
8916
@c SGI info:
8917
@ignore
8918
This is never possible under IRIX, so this is followed by default.
8919
@end ignore
8920
Followed on any target where the underlying operating system permits
8921
such direct calls.
8922
 
8923
@sp 1
8924
@cartouche
8925
Whenever practical, violations of any
8926
implementation-defined restrictions should be detected before run time.
8927
@end cartouche
8928
Followed.  Compile time warnings are given when possible.
8929
 
8930
@cindex Package @code{Interrupts}
8931
@findex Interrupts
8932
@unnumberedsec C.3.2(25): Package @code{Interrupts}
8933
 
8934
@sp 1
8935
@cartouche
8936
If implementation-defined forms of interrupt handler procedures are
8937
supported, such as protected procedures with parameters, then for each
8938
such form of a handler, a type analogous to @code{Parameterless_Handler}
8939
should be specified in a child package of @code{Interrupts}, with the
8940
same operations as in the predefined package Interrupts.
8941
@end cartouche
8942
Followed.
8943
 
8944
@cindex Pre-elaboration requirements
8945
@unnumberedsec C.4(14): Pre-elaboration Requirements
8946
@sp 1
8947
@cartouche
8948
It is recommended that pre-elaborated packages be implemented in such a
8949
way that there should be little or no code executed at run time for the
8950
elaboration of entities not already covered by the Implementation
8951
Requirements.
8952
@end cartouche
8953
Followed.  Executable code is generated in some cases, e.g.@: loops
8954
to initialize large arrays.
8955
 
8956
@unnumberedsec C.5(8): Pragma @code{Discard_Names}
8957
@sp 1
8958
@cartouche
8959
If the pragma applies to an entity, then the implementation should
8960
reduce the amount of storage used for storing names associated with that
8961
entity.
8962
@end cartouche
8963
Followed.
8964
 
8965
@cindex Package @code{Task_Attributes}
8966
@findex Task_Attributes
8967
@unnumberedsec C.7.2(30): The Package Task_Attributes
8968
@sp 1
8969
@cartouche
8970
Some implementations are targeted to domains in which memory use at run
8971
time must be completely deterministic.  For such implementations, it is
8972
recommended that the storage for task attributes will be pre-allocated
8973
statically and not from the heap.  This can be accomplished by either
8974
placing restrictions on the number and the size of the task's
8975
attributes, or by using the pre-allocated storage for the first @var{N}
8976
attribute objects, and the heap for the others.  In the latter case,
8977
@var{N} should be documented.
8978
@end cartouche
8979
Not followed.  This implementation is not targeted to such a domain.
8980
 
8981
@cindex Locking Policies
8982
@unnumberedsec D.3(17): Locking Policies
8983
 
8984
@sp 1
8985
@cartouche
8986
The implementation should use names that end with @samp{_Locking} for
8987
locking policies defined by the implementation.
8988
@end cartouche
8989
Followed.  Two implementation-defined locking policies are defined,
8990
whose names (@code{Inheritance_Locking} and
8991
@code{Concurrent_Readers_Locking}) follow this suggestion.
8992
 
8993
@cindex Entry queuing policies
8994
@unnumberedsec D.4(16): Entry Queuing Policies
8995
@sp 1
8996
@cartouche
8997
Names that end with @samp{_Queuing} should be used
8998
for all implementation-defined queuing policies.
8999
@end cartouche
9000
Followed.  No such implementation-defined queuing policies exist.
9001
 
9002
@cindex Preemptive abort
9003
@unnumberedsec D.6(9-10): Preemptive Abort
9004
@sp 1
9005
@cartouche
9006
Even though the @code{abort_statement} is included in the list of
9007
potentially blocking operations (see 9.5.1), it is recommended that this
9008
statement be implemented in a way that never requires the task executing
9009
the @code{abort_statement} to block.
9010
@end cartouche
9011
Followed.
9012
 
9013
@sp 1
9014
@cartouche
9015
On a multi-processor, the delay associated with aborting a task on
9016
another processor should be bounded; the implementation should use
9017
periodic polling, if necessary, to achieve this.
9018
@end cartouche
9019
Followed.
9020
 
9021
@cindex Tasking restrictions
9022
@unnumberedsec D.7(21): Tasking Restrictions
9023
@sp 1
9024
@cartouche
9025
When feasible, the implementation should take advantage of the specified
9026
restrictions to produce a more efficient implementation.
9027
@end cartouche
9028
GNAT currently takes advantage of these restrictions by providing an optimized
9029
run time when the Ravenscar profile and the GNAT restricted run time set
9030
of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
9031
pragma @code{Profile (Restricted)} for more details.
9032
 
9033
@cindex Time, monotonic
9034
@unnumberedsec D.8(47-49): Monotonic Time
9035
@sp 1
9036
@cartouche
9037
When appropriate, implementations should provide configuration
9038
mechanisms to change the value of @code{Tick}.
9039
@end cartouche
9040
Such configuration mechanisms are not appropriate to this implementation
9041
and are thus not supported.
9042
 
9043
@sp 1
9044
@cartouche
9045
It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9046
be implemented as transformations of the same time base.
9047
@end cartouche
9048
Followed.
9049
 
9050
@sp 1
9051
@cartouche
9052
It is recommended that the @dfn{best} time base which exists in
9053
the underlying system be available to the application through
9054
@code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
9055
@end cartouche
9056
Followed.
9057
 
9058
@cindex Partition communication subsystem
9059
@cindex PCS
9060
@unnumberedsec E.5(28-29): Partition Communication Subsystem
9061
@sp 1
9062
@cartouche
9063
Whenever possible, the PCS on the called partition should allow for
9064
multiple tasks to call the RPC-receiver with different messages and
9065
should allow them to block until the corresponding subprogram body
9066
returns.
9067
@end cartouche
9068
Followed by GLADE, a separately supplied PCS that can be used with
9069
GNAT.
9070
 
9071
@sp 1
9072
@cartouche
9073
The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9074
should raise @code{Storage_Error} if it runs out of space trying to
9075
write the @code{Item} into the stream.
9076
@end cartouche
9077
Followed by GLADE, a separately supplied PCS that can be used with
9078
GNAT@.
9079
 
9080
@cindex COBOL support
9081
@unnumberedsec F(7): COBOL Support
9082
@sp 1
9083
@cartouche
9084
If COBOL (respectively, C) is widely supported in the target
9085
environment, implementations supporting the Information Systems Annex
9086
should provide the child package @code{Interfaces.COBOL} (respectively,
9087
@code{Interfaces.C}) specified in Annex B and should support a
9088
@code{convention_identifier} of COBOL (respectively, C) in the interfacing
9089
pragmas (see Annex B), thus allowing Ada programs to interface with
9090
programs written in that language.
9091
@end cartouche
9092
Followed.
9093
 
9094
@cindex Decimal radix support
9095
@unnumberedsec F.1(2): Decimal Radix Support
9096
@sp 1
9097
@cartouche
9098
Packed decimal should be used as the internal representation for objects
9099
of subtype @var{S} when @var{S}'Machine_Radix = 10.
9100
@end cartouche
9101
Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
9102
representations.
9103
 
9104
@cindex Numerics
9105
@unnumberedsec G: Numerics
9106
@sp 2
9107
@cartouche
9108
If Fortran (respectively, C) is widely supported in the target
9109
environment, implementations supporting the Numerics Annex
9110
should provide the child package @code{Interfaces.Fortran} (respectively,
9111
@code{Interfaces.C}) specified in Annex B and should support a
9112
@code{convention_identifier} of Fortran (respectively, C) in the interfacing
9113
pragmas (see Annex B), thus allowing Ada programs to interface with
9114
programs written in that language.
9115
@end cartouche
9116
Followed.
9117
 
9118
@cindex Complex types
9119
@unnumberedsec G.1.1(56-58): Complex Types
9120
@sp 2
9121
@cartouche
9122
Because the usual mathematical meaning of multiplication of a complex
9123
operand and a real operand is that of the scaling of both components of
9124
the former by the latter, an implementation should not perform this
9125
operation by first promoting the real operand to complex type and then
9126
performing a full complex multiplication.  In systems that, in the
9127
future, support an Ada binding to IEC 559:1989, the latter technique
9128
will not generate the required result when one of the components of the
9129
complex operand is infinite.  (Explicit multiplication of the infinite
9130
component by the zero component obtained during promotion yields a NaN
9131
that propagates into the final result.) Analogous advice applies in the
9132
case of multiplication of a complex operand and a pure-imaginary
9133
operand, and in the case of division of a complex operand by a real or
9134
pure-imaginary operand.
9135
@end cartouche
9136
Not followed.
9137
 
9138
@sp 1
9139
@cartouche
9140
Similarly, because the usual mathematical meaning of addition of a
9141
complex operand and a real operand is that the imaginary operand remains
9142
unchanged, an implementation should not perform this operation by first
9143
promoting the real operand to complex type and then performing a full
9144
complex addition.  In implementations in which the @code{Signed_Zeros}
9145
attribute of the component type is @code{True} (and which therefore
9146
conform to IEC 559:1989 in regard to the handling of the sign of zero in
9147
predefined arithmetic operations), the latter technique will not
9148
generate the required result when the imaginary component of the complex
9149
operand is a negatively signed zero.  (Explicit addition of the negative
9150
zero to the zero obtained during promotion yields a positive zero.)
9151
Analogous advice applies in the case of addition of a complex operand
9152
and a pure-imaginary operand, and in the case of subtraction of a
9153
complex operand and a real or pure-imaginary operand.
9154
@end cartouche
9155
Not followed.
9156
 
9157
@sp 1
9158
@cartouche
9159
Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9160
attempt to provide a rational treatment of the signs of zero results and
9161
result components.  As one example, the result of the @code{Argument}
9162
function should have the sign of the imaginary component of the
9163
parameter @code{X} when the point represented by that parameter lies on
9164
the positive real axis; as another, the sign of the imaginary component
9165
of the @code{Compose_From_Polar} function should be the same as
9166
(respectively, the opposite of) that of the @code{Argument} parameter when that
9167
parameter has a value of zero and the @code{Modulus} parameter has a
9168
nonnegative (respectively, negative) value.
9169
@end cartouche
9170
Followed.
9171
 
9172
@cindex Complex elementary functions
9173
@unnumberedsec G.1.2(49): Complex Elementary Functions
9174
@sp 1
9175
@cartouche
9176
Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9177
@code{True} should attempt to provide a rational treatment of the signs
9178
of zero results and result components.  For example, many of the complex
9179
elementary functions have components that are odd functions of one of
9180
the parameter components; in these cases, the result component should
9181
have the sign of the parameter component at the origin.  Other complex
9182
elementary functions have zero components whose sign is opposite that of
9183
a parameter component at the origin, or is always positive or always
9184
negative.
9185
@end cartouche
9186
Followed.
9187
 
9188
@cindex Accuracy requirements
9189
@unnumberedsec G.2.4(19): Accuracy Requirements
9190
@sp 1
9191
@cartouche
9192
The versions of the forward trigonometric functions without a
9193
@code{Cycle} parameter should not be implemented by calling the
9194
corresponding version with a @code{Cycle} parameter of
9195
@code{2.0*Numerics.Pi}, since this will not provide the required
9196
accuracy in some portions of the domain.  For the same reason, the
9197
version of @code{Log} without a @code{Base} parameter should not be
9198
implemented by calling the corresponding version with a @code{Base}
9199
parameter of @code{Numerics.e}.
9200
@end cartouche
9201
Followed.
9202
 
9203
@cindex Complex arithmetic accuracy
9204
@cindex Accuracy, complex arithmetic
9205
@unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9206
 
9207
@sp 1
9208
@cartouche
9209
The version of the @code{Compose_From_Polar} function without a
9210
@code{Cycle} parameter should not be implemented by calling the
9211
corresponding version with a @code{Cycle} parameter of
9212
@code{2.0*Numerics.Pi}, since this will not provide the required
9213
accuracy in some portions of the domain.
9214
@end cartouche
9215
Followed.
9216
 
9217
@c -----------------------------------------
9218
@node Implementation Defined Characteristics
9219
@chapter Implementation Defined Characteristics
9220
 
9221
@noindent
9222
In addition to the implementation dependent pragmas and attributes, and the
9223
implementation advice, there are a number of other Ada features that are
9224
potentially implementation dependent and are designated as
9225
implementation-defined. These are mentioned throughout the Ada Reference
9226
Manual, and are summarized in Annex M@.
9227
 
9228
A requirement for conforming Ada compilers is that they provide
9229
documentation describing how the implementation deals with each of these
9230
issues.  In this chapter, you will find each point in Annex M listed
9231
followed by a description in italic font of how GNAT
9232
@c SGI info:
9233
@ignore
9234
in the ProDev Ada
9235
implementation on IRIX 5.3 operating system or greater
9236
@end ignore
9237
handles the implementation dependence.
9238
 
9239
You can use this chapter as a guide to minimizing implementation
9240
dependent features in your programs if portability to other compilers
9241
and other operating systems is an important consideration.  The numbers
9242
in each section below correspond to the paragraph number in the Ada
9243
Reference Manual.
9244
 
9245
@sp 1
9246
@cartouche
9247
@noindent
9248
@strong{2}.  Whether or not each recommendation given in Implementation
9249
Advice is followed.  See 1.1.2(37).
9250
@end cartouche
9251
@noindent
9252
@xref{Implementation Advice}.
9253
 
9254
@sp 1
9255
@cartouche
9256
@noindent
9257
@strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
9258
@end cartouche
9259
@noindent
9260
The complexity of programs that can be processed is limited only by the
9261
total amount of available virtual memory, and disk space for the
9262
generated object files.
9263
 
9264
@sp 1
9265
@cartouche
9266
@noindent
9267
@strong{4}.  Variations from the standard that are impractical to avoid
9268
given the implementation's execution environment.  See 1.1.3(6).
9269
@end cartouche
9270
@noindent
9271
There are no variations from the standard.
9272
 
9273
@sp 1
9274
@cartouche
9275
@noindent
9276
@strong{5}.  Which @code{code_statement}s cause external
9277
interactions.  See 1.1.3(10).
9278
@end cartouche
9279
@noindent
9280
Any @code{code_statement} can potentially cause external interactions.
9281
 
9282
@sp 1
9283
@cartouche
9284
@noindent
9285
@strong{6}.  The coded representation for the text of an Ada
9286
program.  See 2.1(4).
9287
@end cartouche
9288
@noindent
9289
See separate section on source representation.
9290
 
9291
@sp 1
9292
@cartouche
9293
@noindent
9294
@strong{7}.  The control functions allowed in comments.  See 2.1(14).
9295
@end cartouche
9296
@noindent
9297
See separate section on source representation.
9298
 
9299
@sp 1
9300
@cartouche
9301
@noindent
9302
@strong{8}.  The representation for an end of line.  See 2.2(2).
9303
@end cartouche
9304
@noindent
9305
See separate section on source representation.
9306
 
9307
@sp 1
9308
@cartouche
9309
@noindent
9310
@strong{9}.  Maximum supported line length and lexical element
9311
length.  See 2.2(15).
9312
@end cartouche
9313
@noindent
9314
The maximum line length is 255 characters and the maximum length of a
9315
lexical element is also 255 characters.
9316
 
9317
@sp 1
9318
@cartouche
9319
@noindent
9320
@strong{10}.  Implementation defined pragmas.  See 2.8(14).
9321
@end cartouche
9322
@noindent
9323
 
9324
@xref{Implementation Defined Pragmas}.
9325
 
9326
@sp 1
9327
@cartouche
9328
@noindent
9329
@strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
9330
@end cartouche
9331
@noindent
9332
Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9333
parameter, checks that the optimization flag is set, and aborts if it is
9334
not.
9335
 
9336
@sp 1
9337
@cartouche
9338
@noindent
9339
@strong{12}.  The sequence of characters of the value returned by
9340
@code{@var{S}'Image} when some of the graphic characters of
9341
@code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
9342
3.5(37).
9343
@end cartouche
9344
@noindent
9345
The sequence of characters is as defined by the wide character encoding
9346
method used for the source.  See section on source representation for
9347
further details.
9348
 
9349
@sp 1
9350
@cartouche
9351
@noindent
9352
@strong{13}.  The predefined integer types declared in
9353
@code{Standard}.  See 3.5.4(25).
9354
@end cartouche
9355
@noindent
9356
@table @code
9357
@item Short_Short_Integer
9358
8 bit signed
9359
@item Short_Integer
9360
(Short) 16 bit signed
9361
@item Integer
9362
32 bit signed
9363
@item Long_Integer
9364
64 bit signed (on most 64 bit targets, depending on the C definition of long).
9365
32 bit signed (all other targets)
9366
@item Long_Long_Integer
9367
64 bit signed
9368
@end table
9369
 
9370
@sp 1
9371
@cartouche
9372
@noindent
9373
@strong{14}.  Any nonstandard integer types and the operators defined
9374
for them.  See 3.5.4(26).
9375
@end cartouche
9376
@noindent
9377
There are no nonstandard integer types.
9378
 
9379
@sp 1
9380
@cartouche
9381
@noindent
9382
@strong{15}.  Any nonstandard real types and the operators defined for
9383
them.  See 3.5.6(8).
9384
@end cartouche
9385
@noindent
9386
There are no nonstandard real types.
9387
 
9388
@sp 1
9389
@cartouche
9390
@noindent
9391
@strong{16}.  What combinations of requested decimal precision and range
9392
are supported for floating point types.  See 3.5.7(7).
9393
@end cartouche
9394
@noindent
9395
The precision and range is as defined by the IEEE standard.
9396
 
9397
@sp 1
9398
@cartouche
9399
@noindent
9400
@strong{17}.  The predefined floating point types declared in
9401
@code{Standard}.  See 3.5.7(16).
9402
@end cartouche
9403
@noindent
9404
@table @code
9405
@item Short_Float
9406
32 bit IEEE short
9407
@item Float
9408
(Short) 32 bit IEEE short
9409
@item Long_Float
9410
64 bit IEEE long
9411
@item Long_Long_Float
9412
64 bit IEEE long (80 bit IEEE long on x86 processors)
9413
@end table
9414
 
9415
@sp 1
9416
@cartouche
9417
@noindent
9418
@strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
9419
@end cartouche
9420
@noindent
9421
@code{Fine_Delta} is 2**(@minus{}63)
9422
 
9423
@sp 1
9424
@cartouche
9425
@noindent
9426
@strong{19}.  What combinations of small, range, and digits are
9427
supported for fixed point types.  See 3.5.9(10).
9428
@end cartouche
9429
@noindent
9430
Any combinations are permitted that do not result in a small less than
9431
@code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9432
If the mantissa is larger than 53 bits on machines where Long_Long_Float
9433
is 64 bits (true of all architectures except ia32), then the output from
9434
Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
9435
is because floating-point conversions are used to convert fixed point.
9436
 
9437
@sp 1
9438
@cartouche
9439
@noindent
9440
@strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
9441
within an unnamed @code{block_statement}.  See 3.9(10).
9442
@end cartouche
9443
@noindent
9444
Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9445
decimal integer are allocated.
9446
 
9447
@sp 1
9448
@cartouche
9449
@noindent
9450
@strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
9451
@end cartouche
9452
@noindent
9453
@xref{Implementation Defined Attributes}.
9454
 
9455
@sp 1
9456
@cartouche
9457
@noindent
9458
@strong{22}.  Any implementation-defined time types.  See 9.6(6).
9459
@end cartouche
9460
@noindent
9461
There are no implementation-defined time types.
9462
 
9463
@sp 1
9464
@cartouche
9465
@noindent
9466
@strong{23}.  The time base associated with relative delays.
9467
@end cartouche
9468
@noindent
9469
See 9.6(20).  The time base used is that provided by the C library
9470
function @code{gettimeofday}.
9471
 
9472
@sp 1
9473
@cartouche
9474
@noindent
9475
@strong{24}.  The time base of the type @code{Calendar.Time}.  See
9476
9.6(23).
9477
@end cartouche
9478
@noindent
9479
The time base used is that provided by the C library function
9480
@code{gettimeofday}.
9481
 
9482
@sp 1
9483
@cartouche
9484
@noindent
9485
@strong{25}.  The time zone used for package @code{Calendar}
9486
operations.  See 9.6(24).
9487
@end cartouche
9488
@noindent
9489
The time zone used by package @code{Calendar} is the current system time zone
9490
setting for local time, as accessed by the C library function
9491
@code{localtime}.
9492
 
9493
@sp 1
9494
@cartouche
9495
@noindent
9496
@strong{26}.  Any limit on @code{delay_until_statements} of
9497
@code{select_statements}.  See 9.6(29).
9498
@end cartouche
9499
@noindent
9500
There are no such limits.
9501
 
9502
@sp 1
9503
@cartouche
9504
@noindent
9505
@strong{27}.  Whether or not two non-overlapping parts of a composite
9506
object are independently addressable, in the case where packing, record
9507
layout, or @code{Component_Size} is specified for the object.  See
9508
9.10(1).
9509
@end cartouche
9510
@noindent
9511
Separate components are independently addressable if they do not share
9512
overlapping storage units.
9513
 
9514
@sp 1
9515
@cartouche
9516
@noindent
9517
@strong{28}.  The representation for a compilation.  See 10.1(2).
9518
@end cartouche
9519
@noindent
9520
A compilation is represented by a sequence of files presented to the
9521
compiler in a single invocation of the @command{gcc} command.
9522
 
9523
@sp 1
9524
@cartouche
9525
@noindent
9526
@strong{29}.  Any restrictions on compilations that contain multiple
9527
compilation_units.  See 10.1(4).
9528
@end cartouche
9529
@noindent
9530
No single file can contain more than one compilation unit, but any
9531
sequence of files can be presented to the compiler as a single
9532
compilation.
9533
 
9534
@sp 1
9535
@cartouche
9536
@noindent
9537
@strong{30}.  The mechanisms for creating an environment and for adding
9538
and replacing compilation units.  See 10.1.4(3).
9539
@end cartouche
9540
@noindent
9541
See separate section on compilation model.
9542
 
9543
@sp 1
9544
@cartouche
9545
@noindent
9546
@strong{31}.  The manner of explicitly assigning library units to a
9547
partition.  See 10.2(2).
9548
@end cartouche
9549
@noindent
9550
If a unit contains an Ada main program, then the Ada units for the partition
9551
are determined by recursive application of the rules in the Ada Reference
9552
Manual section 10.2(2-6).  In other words, the Ada units will be those that
9553
are needed by the main program, and then this definition of need is applied
9554
recursively to those units, and the partition contains the transitive
9555
closure determined by this relationship.  In short, all the necessary units
9556
are included, with no need to explicitly specify the list.  If additional
9557
units are required, e.g.@: by foreign language units, then all units must be
9558
mentioned in the context clause of one of the needed Ada units.
9559
 
9560
If the partition contains no main program, or if the main program is in
9561
a language other than Ada, then GNAT
9562
provides the binder options @option{-z} and @option{-n} respectively, and in
9563
this case a list of units can be explicitly supplied to the binder for
9564
inclusion in the partition (all units needed by these units will also
9565
be included automatically).  For full details on the use of these
9566
options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9567
@value{EDITION} User's Guide}.
9568
 
9569
@sp 1
9570
@cartouche
9571
@noindent
9572
@strong{32}.  The implementation-defined means, if any, of specifying
9573
which compilation units are needed by a given compilation unit.  See
9574
10.2(2).
9575
@end cartouche
9576
@noindent
9577
The units needed by a given compilation unit are as defined in
9578
the Ada Reference Manual section 10.2(2-6).  There are no
9579
implementation-defined pragmas or other implementation-defined
9580
means for specifying needed units.
9581
 
9582
@sp 1
9583
@cartouche
9584
@noindent
9585
@strong{33}.  The manner of designating the main subprogram of a
9586
partition.  See 10.2(7).
9587
@end cartouche
9588
@noindent
9589
The main program is designated by providing the name of the
9590
corresponding @file{ALI} file as the input parameter to the binder.
9591
 
9592
@sp 1
9593
@cartouche
9594
@noindent
9595
@strong{34}.  The order of elaboration of @code{library_items}.  See
9596
10.2(18).
9597
@end cartouche
9598
@noindent
9599
The first constraint on ordering is that it meets the requirements of
9600
Chapter 10 of the Ada Reference Manual.  This still leaves some
9601
implementation dependent choices, which are resolved by first
9602
elaborating bodies as early as possible (i.e., in preference to specs
9603
where there is a choice), and second by evaluating the immediate with
9604
clauses of a unit to determine the probably best choice, and
9605
third by elaborating in alphabetical order of unit names
9606
where a choice still remains.
9607
 
9608
@sp 1
9609
@cartouche
9610
@noindent
9611
@strong{35}.  Parameter passing and function return for the main
9612
subprogram.  See 10.2(21).
9613
@end cartouche
9614
@noindent
9615
The main program has no parameters.  It may be a procedure, or a function
9616
returning an integer type.  In the latter case, the returned integer
9617
value is the return code of the program (overriding any value that
9618
may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9619
 
9620
@sp 1
9621
@cartouche
9622
@noindent
9623
@strong{36}.  The mechanisms for building and running partitions.  See
9624
10.2(24).
9625
@end cartouche
9626
@noindent
9627
GNAT itself supports programs with only a single partition.  The GNATDIST
9628
tool provided with the GLADE package (which also includes an implementation
9629
of the PCS) provides a completely flexible method for building and running
9630
programs consisting of multiple partitions.  See the separate GLADE manual
9631
for details.
9632
 
9633
@sp 1
9634
@cartouche
9635
@noindent
9636
@strong{37}.  The details of program execution, including program
9637
termination.  See 10.2(25).
9638
@end cartouche
9639
@noindent
9640
See separate section on compilation model.
9641
 
9642
@sp 1
9643
@cartouche
9644
@noindent
9645
@strong{38}.  The semantics of any non-active partitions supported by the
9646
implementation.  See 10.2(28).
9647
@end cartouche
9648
@noindent
9649
Passive partitions are supported on targets where shared memory is
9650
provided by the operating system.  See the GLADE reference manual for
9651
further details.
9652
 
9653
@sp 1
9654
@cartouche
9655
@noindent
9656
@strong{39}.  The information returned by @code{Exception_Message}.  See
9657
11.4.1(10).
9658
@end cartouche
9659
@noindent
9660
Exception message returns the null string unless a specific message has
9661
been passed by the program.
9662
 
9663
@sp 1
9664
@cartouche
9665
@noindent
9666
@strong{40}.  The result of @code{Exceptions.Exception_Name} for types
9667
declared within an unnamed @code{block_statement}.  See 11.4.1(12).
9668
@end cartouche
9669
@noindent
9670
Blocks have implementation defined names of the form @code{B@var{nnn}}
9671
where @var{nnn} is an integer.
9672
 
9673
@sp 1
9674
@cartouche
9675
@noindent
9676
@strong{41}.  The information returned by
9677
@code{Exception_Information}.  See 11.4.1(13).
9678
@end cartouche
9679
@noindent
9680
@code{Exception_Information} returns a string in the following format:
9681
 
9682
@smallexample
9683
@emph{Exception_Name:} nnnnn
9684
@emph{Message:} mmmmm
9685
@emph{PID:} ppp
9686
@emph{Call stack traceback locations:}
9687
0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9688
@end smallexample
9689
 
9690
@noindent
9691
where
9692
 
9693
@itemize @bullet
9694
@item
9695
@code{nnnn} is the fully qualified name of the exception in all upper
9696
case letters. This line is always present.
9697
 
9698
@item
9699
@code{mmmm} is the message (this line present only if message is non-null)
9700
 
9701
@item
9702
@code{ppp} is the Process Id value as a decimal integer (this line is
9703
present only if the Process Id is nonzero). Currently we are
9704
not making use of this field.
9705
 
9706
@item
9707
The Call stack traceback locations line and the following values
9708
are present only if at least one traceback location was recorded.
9709
The values are given in C style format, with lower case letters
9710
for a-f, and only as many digits present as are necessary.
9711
@end itemize
9712
 
9713
@noindent
9714
The line terminator sequence at the end of each line, including
9715
the last line is a single @code{LF} character (@code{16#0A#}).
9716
 
9717
@sp 1
9718
@cartouche
9719
@noindent
9720
@strong{42}.  Implementation-defined check names.  See 11.5(27).
9721
@end cartouche
9722
@noindent
9723
The implementation defined check name Alignment_Check controls checking of
9724
address clause values for proper alignment (that is, the address supplied
9725
must be consistent with the alignment of the type).
9726
 
9727
In addition, a user program can add implementation-defined check names
9728
by means of the pragma Check_Name.
9729
 
9730
@sp 1
9731
@cartouche
9732
@noindent
9733
@strong{43}.  The interpretation of each aspect of representation.  See
9734
13.1(20).
9735
@end cartouche
9736
@noindent
9737
See separate section on data representations.
9738
 
9739
@sp 1
9740
@cartouche
9741
@noindent
9742
@strong{44}.  Any restrictions placed upon representation items.  See
9743
13.1(20).
9744
@end cartouche
9745
@noindent
9746
See separate section on data representations.
9747
 
9748
@sp 1
9749
@cartouche
9750
@noindent
9751
@strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
9752
13.3(48).
9753
@end cartouche
9754
@noindent
9755
Size for an indefinite subtype is the maximum possible size, except that
9756
for the case of a subprogram parameter, the size of the parameter object
9757
is the actual size.
9758
 
9759
@sp 1
9760
@cartouche
9761
@noindent
9762
@strong{46}.  The default external representation for a type tag.  See
9763
13.3(75).
9764
@end cartouche
9765
@noindent
9766
The default external representation for a type tag is the fully expanded
9767
name of the type in upper case letters.
9768
 
9769
@sp 1
9770
@cartouche
9771
@noindent
9772
@strong{47}.  What determines whether a compilation unit is the same in
9773
two different partitions.  See 13.3(76).
9774
@end cartouche
9775
@noindent
9776
A compilation unit is the same in two different partitions if and only
9777
if it derives from the same source file.
9778
 
9779
@sp 1
9780
@cartouche
9781
@noindent
9782
@strong{48}.  Implementation-defined components.  See 13.5.1(15).
9783
@end cartouche
9784
@noindent
9785
The only implementation defined component is the tag for a tagged type,
9786
which contains a pointer to the dispatching table.
9787
 
9788
@sp 1
9789
@cartouche
9790
@noindent
9791
@strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
9792
ordering.  See 13.5.3(5).
9793
@end cartouche
9794
@noindent
9795
@code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
9796
implementation, so no non-default bit ordering is supported.  The default
9797
bit ordering corresponds to the natural endianness of the target architecture.
9798
 
9799
@sp 1
9800
@cartouche
9801
@noindent
9802
@strong{50}.  The contents of the visible part of package @code{System}
9803
and its language-defined children.  See 13.7(2).
9804
@end cartouche
9805
@noindent
9806
See the definition of these packages in files @file{system.ads} and
9807
@file{s-stoele.ads}.
9808
 
9809
@sp 1
9810
@cartouche
9811
@noindent
9812
@strong{51}.  The contents of the visible part of package
9813
@code{System.Machine_Code}, and the meaning of
9814
@code{code_statements}.  See 13.8(7).
9815
@end cartouche
9816
@noindent
9817
See the definition and documentation in file @file{s-maccod.ads}.
9818
 
9819
@sp 1
9820
@cartouche
9821
@noindent
9822
@strong{52}.  The effect of unchecked conversion.  See 13.9(11).
9823
@end cartouche
9824
@noindent
9825
Unchecked conversion between types of the same size
9826
results in an uninterpreted transmission of the bits from one type
9827
to the other.  If the types are of unequal sizes, then in the case of
9828
discrete types, a shorter source is first zero or sign extended as
9829
necessary, and a shorter target is simply truncated on the left.
9830
For all non-discrete types, the source is first copied if necessary
9831
to ensure that the alignment requirements of the target are met, then
9832
a pointer is constructed to the source value, and the result is obtained
9833
by dereferencing this pointer after converting it to be a pointer to the
9834
target type. Unchecked conversions where the target subtype is an
9835
unconstrained array are not permitted. If the target alignment is
9836
greater than the source alignment, then a copy of the result is
9837
made with appropriate alignment
9838
 
9839
@sp 1
9840
@cartouche
9841
@noindent
9842
@strong{53}. The semantics of operations on invalid representations.
9843
See 13.9.2(10-11).
9844
@end cartouche
9845
@noindent
9846
For assignments and other operations where the use of invalid values cannot
9847
result in erroneous behavior, the compiler ignores the possibility of invalid
9848
values. An exception is raised at the point where an invalid value would
9849
result in erroneous behavior. For example executing:
9850
 
9851
@smallexample @c ada
9852
procedure invalidvals is
9853
   X : Integer := -1;
9854
   Y : Natural range 1 .. 10;
9855
   for Y'Address use X'Address;
9856
   Z : Natural range 1 .. 10;
9857
   A : array (Natural range 1 .. 10) of Integer;
9858
begin
9859
   Z := Y;     -- no exception
9860
   A (Z) := 3; -- exception raised;
9861
end;
9862
@end smallexample
9863
 
9864
@noindent
9865
As indicated, an exception is raised on the array assignment, but not
9866
on the simple assignment of the invalid negative value from Y to Z.
9867
 
9868
@sp 1
9869
@cartouche
9870
@noindent
9871
@strong{53}.  The manner of choosing a storage pool for an access type
9872
when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
9873
@end cartouche
9874
@noindent
9875
There are 3 different standard pools used by the compiler when
9876
@code{Storage_Pool} is not specified depending whether the type is local
9877
to a subprogram or defined at the library level and whether
9878
@code{Storage_Size}is specified or not.  See documentation in the runtime
9879
library units @code{System.Pool_Global}, @code{System.Pool_Size} and
9880
@code{System.Pool_Local} in files @file{s-poosiz.ads},
9881
@file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
9882
default pools used.
9883
 
9884
@sp 1
9885
@cartouche
9886
@noindent
9887
@strong{54}.  Whether or not the implementation provides user-accessible
9888
names for the standard pool type(s).  See 13.11(17).
9889
@end cartouche
9890
@noindent
9891
 
9892
See documentation in the sources of the run time mentioned in paragraph
9893
@strong{53} .  All these pools are accessible by means of @code{with}'ing
9894
these units.
9895
 
9896
@sp 1
9897
@cartouche
9898
@noindent
9899
@strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
9900
@end cartouche
9901
@noindent
9902
@code{Storage_Size} is measured in storage units, and refers to the
9903
total space available for an access type collection, or to the primary
9904
stack space for a task.
9905
 
9906
@sp 1
9907
@cartouche
9908
@noindent
9909
@strong{56}.  Implementation-defined aspects of storage pools.  See
9910
13.11(22).
9911
@end cartouche
9912
@noindent
9913
See documentation in the sources of the run time mentioned in paragraph
9914
@strong{53} for details on GNAT-defined aspects of storage pools.
9915
 
9916
@sp 1
9917
@cartouche
9918
@noindent
9919
@strong{57}.  The set of restrictions allowed in a pragma
9920
@code{Restrictions}.  See 13.12(7).
9921
@end cartouche
9922
@noindent
9923
@xref{Implementation Defined Restrictions}.
9924
 
9925
@sp 1
9926
@cartouche
9927
@noindent
9928
@strong{58}.  The consequences of violating limitations on
9929
@code{Restrictions} pragmas.  See 13.12(9).
9930
@end cartouche
9931
@noindent
9932
Restrictions that can be checked at compile time result in illegalities
9933
if violated.  Currently there are no other consequences of violating
9934
restrictions.
9935
 
9936
@sp 1
9937
@cartouche
9938
@noindent
9939
@strong{59}.  The representation used by the @code{Read} and
9940
@code{Write} attributes of elementary types in terms of stream
9941
elements.  See 13.13.2(9).
9942
@end cartouche
9943
@noindent
9944
The representation is the in-memory representation of the base type of
9945
the type, using the number of bits corresponding to the
9946
@code{@var{type}'Size} value, and the natural ordering of the machine.
9947
 
9948
@sp 1
9949
@cartouche
9950
@noindent
9951
@strong{60}.  The names and characteristics of the numeric subtypes
9952
declared in the visible part of package @code{Standard}.  See A.1(3).
9953
@end cartouche
9954
@noindent
9955
See items describing the integer and floating-point types supported.
9956
 
9957
@sp 1
9958
@cartouche
9959
@noindent
9960
@strong{61}.  The accuracy actually achieved by the elementary
9961
functions.  See A.5.1(1).
9962
@end cartouche
9963
@noindent
9964
The elementary functions correspond to the functions available in the C
9965
library.  Only fast math mode is implemented.
9966
 
9967
@sp 1
9968
@cartouche
9969
@noindent
9970
@strong{62}.  The sign of a zero result from some of the operators or
9971
functions in @code{Numerics.Generic_Elementary_Functions}, when
9972
@code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
9973
@end cartouche
9974
@noindent
9975
The sign of zeroes follows the requirements of the IEEE 754 standard on
9976
floating-point.
9977
 
9978
@sp 1
9979
@cartouche
9980
@noindent
9981
@strong{63}.  The value of
9982
@code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
9983
@end cartouche
9984
@noindent
9985
Maximum image width is 6864, see library file @file{s-rannum.ads}.
9986
 
9987
@sp 1
9988
@cartouche
9989
@noindent
9990
@strong{64}.  The value of
9991
@code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
9992
@end cartouche
9993
@noindent
9994
Maximum image width is 6864, see library file @file{s-rannum.ads}.
9995
 
9996
@sp 1
9997
@cartouche
9998
@noindent
9999
@strong{65}.  The algorithms for random number generation.  See
10000
A.5.2(32).
10001
@end cartouche
10002
@noindent
10003
The algorithm is the Mersenne Twister, as documented in the source file
10004
@file{s-rannum.adb}. This version of the algorithm has a period of
10005
2**19937-1.
10006
 
10007
@sp 1
10008
@cartouche
10009
@noindent
10010
@strong{66}.  The string representation of a random number generator's
10011
state.  See A.5.2(38).
10012
@end cartouche
10013
@noindent
10014
The value returned by the Image function is the concatenation of
10015
the fixed-width decimal representations of the 624 32-bit integers
10016
of the state vector.
10017
 
10018
@sp 1
10019
@cartouche
10020
@noindent
10021
@strong{67}.  The minimum time interval between calls to the
10022
time-dependent Reset procedure that are guaranteed to initiate different
10023
random number sequences.  See A.5.2(45).
10024
@end cartouche
10025
@noindent
10026
The minimum period between reset calls to guarantee distinct series of
10027
random numbers is one microsecond.
10028
 
10029
@sp 1
10030
@cartouche
10031
@noindent
10032
@strong{68}.  The values of the @code{Model_Mantissa},
10033
@code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10034
@code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10035
Annex is not supported.  See A.5.3(72).
10036
@end cartouche
10037
@noindent
10038
Run the compiler with @option{-gnatS} to produce a listing of package
10039
@code{Standard}, has the values of all numeric attributes.
10040
 
10041
@sp 1
10042
@cartouche
10043
@noindent
10044
@strong{69}.  Any implementation-defined characteristics of the
10045
input-output packages.  See A.7(14).
10046
@end cartouche
10047
@noindent
10048
There are no special implementation defined characteristics for these
10049
packages.
10050
 
10051
@sp 1
10052
@cartouche
10053
@noindent
10054
@strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
10055
A.9(10).
10056
@end cartouche
10057
@noindent
10058
All type representations are contiguous, and the @code{Buffer_Size} is
10059
the value of @code{@var{type}'Size} rounded up to the next storage unit
10060
boundary.
10061
 
10062
@sp 1
10063
@cartouche
10064
@noindent
10065
@strong{71}.  External files for standard input, standard output, and
10066
standard error See A.10(5).
10067
@end cartouche
10068
@noindent
10069
These files are mapped onto the files provided by the C streams
10070
libraries.  See source file @file{i-cstrea.ads} for further details.
10071
 
10072
@sp 1
10073
@cartouche
10074
@noindent
10075
@strong{72}.  The accuracy of the value produced by @code{Put}.  See
10076
A.10.9(36).
10077
@end cartouche
10078
@noindent
10079
If more digits are requested in the output than are represented by the
10080
precision of the value, zeroes are output in the corresponding least
10081
significant digit positions.
10082
 
10083
@sp 1
10084
@cartouche
10085
@noindent
10086
@strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
10087
@code{Command_Name}.  See A.15(1).
10088
@end cartouche
10089
@noindent
10090
These are mapped onto the @code{argv} and @code{argc} parameters of the
10091
main program in the natural manner.
10092
 
10093
@sp 1
10094
@cartouche
10095
@noindent
10096
@strong{74}.  The interpretation of the @code{Form} parameter in procedure
10097
@code{Create_Directory}.  See A.16(56).
10098
@end cartouche
10099
@noindent
10100
The @code{Form} parameter is not used.
10101
 
10102
@sp 1
10103
@cartouche
10104
@noindent
10105
@strong{75}.  The interpretation of the @code{Form} parameter in procedure
10106
@code{Create_Path}.  See A.16(60).
10107
@end cartouche
10108
@noindent
10109
The @code{Form} parameter is not used.
10110
 
10111
@sp 1
10112
@cartouche
10113
@noindent
10114
@strong{76}.  The interpretation of the @code{Form} parameter in procedure
10115
@code{Copy_File}.  See A.16(68).
10116
@end cartouche
10117
@noindent
10118
The @code{Form} parameter is case-insensitive.
10119
 
10120
Two fields are recognized in the @code{Form} parameter:
10121
 
10122
@table @code
10123
 
10124
@item preserve=<value>
10125
 
10126
@item mode=<value>
10127
 
10128
@end table
10129
 
10130
@noindent
10131
<value> starts immediately after the character '=' and ends with the
10132
character immediately preceding the next comma (',') or with the last
10133
character of the parameter.
10134
 
10135
The only possible values for preserve= are:
10136
 
10137
@table @code
10138
 
10139
@item no_attributes
10140
Do not try to preserve any file attributes. This is the default if no
10141
preserve= is found in Form.
10142
 
10143
@item all_attributes
10144
Try to preserve all file attributes (timestamps, access rights).
10145
 
10146
@item timestamps
10147
Preserve the timestamp of the copied file, but not the other file attributes.
10148
 
10149
@end table
10150
 
10151
@noindent
10152
The only possible values for mode= are:
10153
 
10154
@table @code
10155
 
10156
@item copy
10157
Only do the copy if the destination file does not already exist. If it already
10158
exists, Copy_File fails.
10159
 
10160
@item overwrite
10161
Copy the file in all cases. Overwrite an already existing destination file.
10162
 
10163
@item append
10164
Append the original file to the destination file. If the destination file does
10165
not exist, the destination file is a copy of the source file. When mode=append,
10166
the field preserve=, if it exists, is not taken into account.
10167
 
10168
@end table
10169
 
10170
@noindent
10171
If the Form parameter includes one or both of the fields and the value or
10172
values are incorrect, Copy_file fails with Use_Error.
10173
 
10174
Examples of correct Forms:
10175
 
10176
@smallexample
10177
Form => "preserve=no_attributes,mode=overwrite" (the default)
10178
Form => "mode=append"
10179
Form => "mode=copy, preserve=all_attributes"
10180
@end smallexample
10181
 
10182
@noindent
10183
Examples of incorrect Forms
10184
 
10185
@smallexample
10186
Form => "preserve=junk"
10187
Form => "mode=internal, preserve=timestamps"
10188
@end smallexample
10189
 
10190
@sp 1
10191
@cartouche
10192
@noindent
10193
@strong{77}.  Implementation-defined convention names.  See B.1(11).
10194
@end cartouche
10195
@noindent
10196
The following convention names are supported
10197
 
10198
@table @code
10199
@item  Ada
10200
Ada
10201
@item Ada_Pass_By_Copy
10202
Allowed for any types except by-reference types such as limited
10203
records. Compatible with convention Ada, but causes any parameters
10204
with this convention to be passed by copy.
10205
@item Ada_Pass_By_Reference
10206
Allowed for any types except by-copy types such as scalars.
10207
Compatible with convention Ada, but causes any parameters
10208
with this convention to be passed by reference.
10209
@item Assembler
10210
Assembly language
10211
@item Asm
10212
Synonym for Assembler
10213
@item Assembly
10214
Synonym for Assembler
10215
@item C
10216
C
10217
@item C_Pass_By_Copy
10218
Allowed only for record types, like C, but also notes that record
10219
is to be passed by copy rather than reference.
10220
@item COBOL
10221
COBOL
10222
@item C_Plus_Plus (or CPP)
10223
C++
10224
@item Default
10225
Treated the same as C
10226
@item External
10227
Treated the same as C
10228
@item Fortran
10229
Fortran
10230
@item Intrinsic
10231
For support of pragma @code{Import} with convention Intrinsic, see
10232
separate section on Intrinsic Subprograms.
10233
@item Stdcall
10234
Stdcall (used for Windows implementations only).  This convention correspond
10235
to the WINAPI (previously called Pascal convention) C/C++ convention under
10236
Windows.  A routine with this convention cleans the stack before
10237
exit. This pragma cannot be applied to a dispatching call.
10238
@item DLL
10239
Synonym for Stdcall
10240
@item Win32
10241
Synonym for Stdcall
10242
@item Stubbed
10243
Stubbed is a special convention used to indicate that the body of the
10244
subprogram will be entirely ignored.  Any call to the subprogram
10245
is converted into a raise of the @code{Program_Error} exception.  If a
10246
pragma @code{Import} specifies convention @code{stubbed} then no body need
10247
be present at all.  This convention is useful during development for the
10248
inclusion of subprograms whose body has not yet been written.
10249
 
10250
@end table
10251
@noindent
10252
In addition, all otherwise unrecognized convention names are also
10253
treated as being synonymous with convention C@.  In all implementations
10254
except for VMS, use of such other names results in a warning.  In VMS
10255
implementations, these names are accepted silently.
10256
 
10257
@sp 1
10258
@cartouche
10259
@noindent
10260
@strong{78}.  The meaning of link names.  See B.1(36).
10261
@end cartouche
10262
@noindent
10263
Link names are the actual names used by the linker.
10264
 
10265
@sp 1
10266
@cartouche
10267
@noindent
10268
@strong{79}.  The manner of choosing link names when neither the link
10269
name nor the address of an imported or exported entity is specified.  See
10270
B.1(36).
10271
@end cartouche
10272
@noindent
10273
The default linker name is that which would be assigned by the relevant
10274
external language, interpreting the Ada name as being in all lower case
10275
letters.
10276
 
10277
@sp 1
10278
@cartouche
10279
@noindent
10280
@strong{80}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
10281
@end cartouche
10282
@noindent
10283
The string passed to @code{Linker_Options} is presented uninterpreted as
10284
an argument to the link command, unless it contains ASCII.NUL characters.
10285
NUL characters if they appear act as argument separators, so for example
10286
 
10287
@smallexample @c ada
10288
pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10289
@end smallexample
10290
 
10291
@noindent
10292
causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10293
linker. The order of linker options is preserved for a given unit. The final
10294
list of options passed to the linker is in reverse order of the elaboration
10295
order. For example, linker options for a body always appear before the options
10296
from the corresponding package spec.
10297
 
10298
@sp 1
10299
@cartouche
10300
@noindent
10301
@strong{81}.  The contents of the visible part of package
10302
@code{Interfaces} and its language-defined descendants.  See B.2(1).
10303
@end cartouche
10304
@noindent
10305
See files with prefix @file{i-} in the distributed library.
10306
 
10307
@sp 1
10308
@cartouche
10309
@noindent
10310
@strong{82}.  Implementation-defined children of package
10311
@code{Interfaces}.  The contents of the visible part of package
10312
@code{Interfaces}.  See B.2(11).
10313
@end cartouche
10314
@noindent
10315
See files with prefix @file{i-} in the distributed library.
10316
 
10317
@sp 1
10318
@cartouche
10319
@noindent
10320
@strong{83}.  The types @code{Floating}, @code{Long_Floating},
10321
@code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10322
@code{COBOL_Character}; and the initialization of the variables
10323
@code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10324
@code{Interfaces.COBOL}.  See B.4(50).
10325
@end cartouche
10326
@noindent
10327
@table @code
10328
@item Floating
10329
Float
10330
@item Long_Floating
10331
(Floating) Long_Float
10332
@item Binary
10333
Integer
10334
@item Long_Binary
10335
Long_Long_Integer
10336
@item Decimal_Element
10337
Character
10338
@item COBOL_Character
10339
Character
10340
@end table
10341
 
10342
@noindent
10343
For initialization, see the file @file{i-cobol.ads} in the distributed library.
10344
 
10345
@sp 1
10346
@cartouche
10347
@noindent
10348
@strong{84}.  Support for access to machine instructions.  See C.1(1).
10349
@end cartouche
10350
@noindent
10351
See documentation in file @file{s-maccod.ads} in the distributed library.
10352
 
10353
@sp 1
10354
@cartouche
10355
@noindent
10356
@strong{85}.  Implementation-defined aspects of access to machine
10357
operations.  See C.1(9).
10358
@end cartouche
10359
@noindent
10360
See documentation in file @file{s-maccod.ads} in the distributed library.
10361
 
10362
@sp 1
10363
@cartouche
10364
@noindent
10365
@strong{86}.  Implementation-defined aspects of interrupts.  See C.3(2).
10366
@end cartouche
10367
@noindent
10368
Interrupts are mapped to signals or conditions as appropriate.  See
10369
definition of unit
10370
@code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10371
on the interrupts supported on a particular target.
10372
 
10373
@sp 1
10374
@cartouche
10375
@noindent
10376
@strong{87}.  Implementation-defined aspects of pre-elaboration.  See
10377
C.4(13).
10378
@end cartouche
10379
@noindent
10380
GNAT does not permit a partition to be restarted without reloading,
10381
except under control of the debugger.
10382
 
10383
@sp 1
10384
@cartouche
10385
@noindent
10386
@strong{88}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
10387
@end cartouche
10388
@noindent
10389
Pragma @code{Discard_Names} causes names of enumeration literals to
10390
be suppressed.  In the presence of this pragma, the Image attribute
10391
provides the image of the Pos of the literal, and Value accepts
10392
Pos values.
10393
 
10394
@sp 1
10395
@cartouche
10396
@noindent
10397
@strong{89}.  The result of the @code{Task_Identification.Image}
10398
attribute.  See C.7.1(7).
10399
@end cartouche
10400
@noindent
10401
The result of this attribute is a string that identifies
10402
the object or component that denotes a given task. If a variable @code{Var}
10403
has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10404
where the suffix
10405
is the hexadecimal representation of the virtual address of the corresponding
10406
task control block. If the variable is an array of tasks, the image of each
10407
task will have the form of an indexed component indicating the position of a
10408
given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10409
component of a record, the image of the task will have the form of a selected
10410
component. These rules are fully recursive, so that the image of a task that
10411
is a subcomponent of a composite object corresponds to the expression that
10412
designates this task.
10413
@noindent
10414
If a task is created by an allocator, its image depends on the context. If the
10415
allocator is part of an object declaration, the rules described above are used
10416
to construct its image, and this image is not affected by subsequent
10417
assignments. If the allocator appears within an expression, the image
10418
includes only the name of the task type.
10419
@noindent
10420
If the configuration pragma Discard_Names is present, or if the restriction
10421
No_Implicit_Heap_Allocation is in effect,  the image reduces to
10422
the numeric suffix, that is to say the hexadecimal representation of the
10423
virtual address of the control block of the task.
10424
@sp 1
10425
@cartouche
10426
@noindent
10427
@strong{90}.  The value of @code{Current_Task} when in a protected entry
10428
or interrupt handler.  See C.7.1(17).
10429
@end cartouche
10430
@noindent
10431
Protected entries or interrupt handlers can be executed by any
10432
convenient thread, so the value of @code{Current_Task} is undefined.
10433
 
10434
@sp 1
10435
@cartouche
10436
@noindent
10437
@strong{91}.  The effect of calling @code{Current_Task} from an entry
10438
body or interrupt handler.  See C.7.1(19).
10439
@end cartouche
10440
@noindent
10441
The effect of calling @code{Current_Task} from an entry body or
10442
interrupt handler is to return the identification of the task currently
10443
executing the code.
10444
 
10445
@sp 1
10446
@cartouche
10447
@noindent
10448
@strong{92}.  Implementation-defined aspects of
10449
@code{Task_Attributes}.  See C.7.2(19).
10450
@end cartouche
10451
@noindent
10452
There are no implementation-defined aspects of @code{Task_Attributes}.
10453
 
10454
@sp 1
10455
@cartouche
10456
@noindent
10457
@strong{93}.  Values of all @code{Metrics}.  See D(2).
10458
@end cartouche
10459
@noindent
10460
The metrics information for GNAT depends on the performance of the
10461
underlying operating system.  The sources of the run-time for tasking
10462
implementation, together with the output from @option{-gnatG} can be
10463
used to determine the exact sequence of operating systems calls made
10464
to implement various tasking constructs.  Together with appropriate
10465
information on the performance of the underlying operating system,
10466
on the exact target in use, this information can be used to determine
10467
the required metrics.
10468
 
10469
@sp 1
10470
@cartouche
10471
@noindent
10472
@strong{94}.  The declarations of @code{Any_Priority} and
10473
@code{Priority}.  See D.1(11).
10474
@end cartouche
10475
@noindent
10476
See declarations in file @file{system.ads}.
10477
 
10478
@sp 1
10479
@cartouche
10480
@noindent
10481
@strong{95}.  Implementation-defined execution resources.  See D.1(15).
10482
@end cartouche
10483
@noindent
10484
There are no implementation-defined execution resources.
10485
 
10486
@sp 1
10487
@cartouche
10488
@noindent
10489
@strong{96}.  Whether, on a multiprocessor, a task that is waiting for
10490
access to a protected object keeps its processor busy.  See D.2.1(3).
10491
@end cartouche
10492
@noindent
10493
On a multi-processor, a task that is waiting for access to a protected
10494
object does not keep its processor busy.
10495
 
10496
@sp 1
10497
@cartouche
10498
@noindent
10499
@strong{97}.  The affect of implementation defined execution resources
10500
on task dispatching.  See D.2.1(9).
10501
@end cartouche
10502
@noindent
10503
@c SGI info
10504
@ignore
10505
Tasks map to IRIX threads, and the dispatching policy is as defined by
10506
the IRIX implementation of threads.
10507
@end ignore
10508
Tasks map to threads in the threads package used by GNAT@.  Where possible
10509
and appropriate, these threads correspond to native threads of the
10510
underlying operating system.
10511
 
10512
@sp 1
10513
@cartouche
10514
@noindent
10515
@strong{98}.  Implementation-defined @code{policy_identifiers} allowed
10516
in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
10517
@end cartouche
10518
@noindent
10519
There are no implementation-defined policy-identifiers allowed in this
10520
pragma.
10521
 
10522
@sp 1
10523
@cartouche
10524
@noindent
10525
@strong{99}.  Implementation-defined aspects of priority inversion.  See
10526
D.2.2(16).
10527
@end cartouche
10528
@noindent
10529
Execution of a task cannot be preempted by the implementation processing
10530
of delay expirations for lower priority tasks.
10531
 
10532
@sp 1
10533
@cartouche
10534
@noindent
10535
@strong{100}.  Implementation-defined task dispatching.  See D.2.2(18).
10536
@end cartouche
10537
@noindent
10538
@c SGI info:
10539
@ignore
10540
Tasks map to IRIX threads, and the dispatching policy is as defined by
10541
the IRIX implementation of threads.
10542
@end ignore
10543
The policy is the same as that of the underlying threads implementation.
10544
 
10545
@sp 1
10546
@cartouche
10547
@noindent
10548
@strong{101}.  Implementation-defined @code{policy_identifiers} allowed
10549
in a pragma @code{Locking_Policy}.  See D.3(4).
10550
@end cartouche
10551
@noindent
10552
The two implementation defined policies permitted in GNAT are
10553
@code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
10554
targets that support the @code{Inheritance_Locking} policy, locking is
10555
implemented by inheritance, i.e.@: the task owning the lock operates
10556
at a priority equal to the highest priority of any task currently
10557
requesting the lock.  On targets that support the
10558
@code{Conccurent_Readers_Locking} policy, locking is implemented with a
10559
read/write lock allowing multiple propected object functions to enter
10560
concurrently.
10561
 
10562
@sp 1
10563
@cartouche
10564
@noindent
10565
@strong{102}.  Default ceiling priorities.  See D.3(10).
10566
@end cartouche
10567
@noindent
10568
The ceiling priority of protected objects of the type
10569
@code{System.Interrupt_Priority'Last} as described in the Ada
10570
Reference Manual D.3(10),
10571
 
10572
@sp 1
10573
@cartouche
10574
@noindent
10575
@strong{103}.  The ceiling of any protected object used internally by
10576
the implementation.  See D.3(16).
10577
@end cartouche
10578
@noindent
10579
The ceiling priority of internal protected objects is
10580
@code{System.Priority'Last}.
10581
 
10582
@sp 1
10583
@cartouche
10584
@noindent
10585
@strong{104}.  Implementation-defined queuing policies.  See D.4(1).
10586
@end cartouche
10587
@noindent
10588
There are no implementation-defined queuing policies.
10589
 
10590
@sp 1
10591
@cartouche
10592
@noindent
10593
@strong{105}.  On a multiprocessor, any conditions that cause the
10594
completion of an aborted construct to be delayed later than what is
10595
specified for a single processor.  See D.6(3).
10596
@end cartouche
10597
@noindent
10598
The semantics for abort on a multi-processor is the same as on a single
10599
processor, there are no further delays.
10600
 
10601
@sp 1
10602
@cartouche
10603
@noindent
10604
@strong{106}.  Any operations that implicitly require heap storage
10605
allocation.  See D.7(8).
10606
@end cartouche
10607
@noindent
10608
The only operation that implicitly requires heap storage allocation is
10609
task creation.
10610
 
10611
@sp 1
10612
@cartouche
10613
@noindent
10614
@strong{107}.  Implementation-defined aspects of pragma
10615
@code{Restrictions}.  See D.7(20).
10616
@end cartouche
10617
@noindent
10618
There are no such implementation-defined aspects.
10619
 
10620
@sp 1
10621
@cartouche
10622
@noindent
10623
@strong{108}.  Implementation-defined aspects of package
10624
@code{Real_Time}.  See D.8(17).
10625
@end cartouche
10626
@noindent
10627
There are no implementation defined aspects of package @code{Real_Time}.
10628
 
10629
@sp 1
10630
@cartouche
10631
@noindent
10632
@strong{109}.  Implementation-defined aspects of
10633
@code{delay_statements}.  See D.9(8).
10634
@end cartouche
10635
@noindent
10636
Any difference greater than one microsecond will cause the task to be
10637
delayed (see D.9(7)).
10638
 
10639
@sp 1
10640
@cartouche
10641
@noindent
10642
@strong{110}.  The upper bound on the duration of interrupt blocking
10643
caused by the implementation.  See D.12(5).
10644
@end cartouche
10645
@noindent
10646
The upper bound is determined by the underlying operating system.  In
10647
no cases is it more than 10 milliseconds.
10648
 
10649
@sp 1
10650
@cartouche
10651
@noindent
10652
@strong{111}.  The means for creating and executing distributed
10653
programs.  See E(5).
10654
@end cartouche
10655
@noindent
10656
The GLADE package provides a utility GNATDIST for creating and executing
10657
distributed programs.  See the GLADE reference manual for further details.
10658
 
10659
@sp 1
10660
@cartouche
10661
@noindent
10662
@strong{112}.  Any events that can result in a partition becoming
10663
inaccessible.  See E.1(7).
10664
@end cartouche
10665
@noindent
10666
See the GLADE reference manual for full details on such events.
10667
 
10668
@sp 1
10669
@cartouche
10670
@noindent
10671
@strong{113}.  The scheduling policies, treatment of priorities, and
10672
management of shared resources between partitions in certain cases.  See
10673
E.1(11).
10674
@end cartouche
10675
@noindent
10676
See the GLADE reference manual for full details on these aspects of
10677
multi-partition execution.
10678
 
10679
@sp 1
10680
@cartouche
10681
@noindent
10682
@strong{114}.  Events that cause the version of a compilation unit to
10683
change.  See E.3(5).
10684
@end cartouche
10685
@noindent
10686
Editing the source file of a compilation unit, or the source files of
10687
any units on which it is dependent in a significant way cause the version
10688
to change.  No other actions cause the version number to change.  All changes
10689
are significant except those which affect only layout, capitalization or
10690
comments.
10691
 
10692
@sp 1
10693
@cartouche
10694
@noindent
10695
@strong{115}.  Whether the execution of the remote subprogram is
10696
immediately aborted as a result of cancellation.  See E.4(13).
10697
@end cartouche
10698
@noindent
10699
See the GLADE reference manual for details on the effect of abort in
10700
a distributed application.
10701
 
10702
@sp 1
10703
@cartouche
10704
@noindent
10705
@strong{116}.  Implementation-defined aspects of the PCS@.  See E.5(25).
10706
@end cartouche
10707
@noindent
10708
See the GLADE reference manual for a full description of all implementation
10709
defined aspects of the PCS@.
10710
 
10711
@sp 1
10712
@cartouche
10713
@noindent
10714
@strong{117}.  Implementation-defined interfaces in the PCS@.  See
10715
E.5(26).
10716
@end cartouche
10717
@noindent
10718
See the GLADE reference manual for a full description of all
10719
implementation defined interfaces.
10720
 
10721
@sp 1
10722
@cartouche
10723
@noindent
10724
@strong{118}.  The values of named numbers in the package
10725
@code{Decimal}.  See F.2(7).
10726
@end cartouche
10727
@noindent
10728
@table @code
10729
@item Max_Scale
10730
+18
10731
@item Min_Scale
10732
-18
10733
@item Min_Delta
10734
1.0E-18
10735
@item Max_Delta
10736
1.0E+18
10737
@item Max_Decimal_Digits
10738
18
10739
@end table
10740
 
10741
@sp 1
10742
@cartouche
10743
@noindent
10744
@strong{119}.  The value of @code{Max_Picture_Length} in the package
10745
@code{Text_IO.Editing}.  See F.3.3(16).
10746
@end cartouche
10747
@noindent
10748
64
10749
 
10750
@sp 1
10751
@cartouche
10752
@noindent
10753
@strong{120}.  The value of @code{Max_Picture_Length} in the package
10754
@code{Wide_Text_IO.Editing}.  See F.3.4(5).
10755
@end cartouche
10756
@noindent
10757
64
10758
 
10759
@sp 1
10760
@cartouche
10761
@noindent
10762
@strong{121}.  The accuracy actually achieved by the complex elementary
10763
functions and by other complex arithmetic operations.  See G.1(1).
10764
@end cartouche
10765
@noindent
10766
Standard library functions are used for the complex arithmetic
10767
operations.  Only fast math mode is currently supported.
10768
 
10769
@sp 1
10770
@cartouche
10771
@noindent
10772
@strong{122}.  The sign of a zero result (or a component thereof) from
10773
any operator or function in @code{Numerics.Generic_Complex_Types}, when
10774
@code{Real'Signed_Zeros} is True.  See G.1.1(53).
10775
@end cartouche
10776
@noindent
10777
The signs of zero values are as recommended by the relevant
10778
implementation advice.
10779
 
10780
@sp 1
10781
@cartouche
10782
@noindent
10783
@strong{123}.  The sign of a zero result (or a component thereof) from
10784
any operator or function in
10785
@code{Numerics.Generic_Complex_Elementary_Functions}, when
10786
@code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
10787
@end cartouche
10788
@noindent
10789
The signs of zero values are as recommended by the relevant
10790
implementation advice.
10791
 
10792
@sp 1
10793
@cartouche
10794
@noindent
10795
@strong{124}.  Whether the strict mode or the relaxed mode is the
10796
default.  See G.2(2).
10797
@end cartouche
10798
@noindent
10799
The strict mode is the default.  There is no separate relaxed mode.  GNAT
10800
provides a highly efficient implementation of strict mode.
10801
 
10802
@sp 1
10803
@cartouche
10804
@noindent
10805
@strong{125}.  The result interval in certain cases of fixed-to-float
10806
conversion.  See G.2.1(10).
10807
@end cartouche
10808
@noindent
10809
For cases where the result interval is implementation dependent, the
10810
accuracy is that provided by performing all operations in 64-bit IEEE
10811
floating-point format.
10812
 
10813
@sp 1
10814
@cartouche
10815
@noindent
10816
@strong{126}.  The result of a floating point arithmetic operation in
10817
overflow situations, when the @code{Machine_Overflows} attribute of the
10818
result type is @code{False}.  See G.2.1(13).
10819
@end cartouche
10820
@noindent
10821
Infinite and NaN values are produced as dictated by the IEEE
10822
floating-point standard.
10823
 
10824
Note that on machines that are not fully compliant with the IEEE
10825
floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10826
must be used for achieving IEEE conforming behavior (although at the cost
10827
of a significant performance penalty), so infinite and NaN values are
10828
properly generated.
10829
 
10830
@sp 1
10831
@cartouche
10832
@noindent
10833
@strong{127}.  The result interval for division (or exponentiation by a
10834
negative exponent), when the floating point hardware implements division
10835
as multiplication by a reciprocal.  See G.2.1(16).
10836
@end cartouche
10837
@noindent
10838
Not relevant, division is IEEE exact.
10839
 
10840
@sp 1
10841
@cartouche
10842
@noindent
10843
@strong{128}.  The definition of close result set, which determines the
10844
accuracy of certain fixed point multiplications and divisions.  See
10845
G.2.3(5).
10846
@end cartouche
10847
@noindent
10848
Operations in the close result set are performed using IEEE long format
10849
floating-point arithmetic.  The input operands are converted to
10850
floating-point, the operation is done in floating-point, and the result
10851
is converted to the target type.
10852
 
10853
@sp 1
10854
@cartouche
10855
@noindent
10856
@strong{129}.  Conditions on a @code{universal_real} operand of a fixed
10857
point multiplication or division for which the result shall be in the
10858
perfect result set.  See G.2.3(22).
10859
@end cartouche
10860
@noindent
10861
The result is only defined to be in the perfect result set if the result
10862
can be computed by a single scaling operation involving a scale factor
10863
representable in 64-bits.
10864
 
10865
@sp 1
10866
@cartouche
10867
@noindent
10868
@strong{130}.  The result of a fixed point arithmetic operation in
10869
overflow situations, when the @code{Machine_Overflows} attribute of the
10870
result type is @code{False}.  See G.2.3(27).
10871
@end cartouche
10872
@noindent
10873
Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10874
types.
10875
 
10876
@sp 1
10877
@cartouche
10878
@noindent
10879
@strong{131}.  The result of an elementary function reference in
10880
overflow situations, when the @code{Machine_Overflows} attribute of the
10881
result type is @code{False}.  See G.2.4(4).
10882
@end cartouche
10883
@noindent
10884
IEEE infinite and Nan values are produced as appropriate.
10885
 
10886
@sp 1
10887
@cartouche
10888
@noindent
10889
@strong{132}.  The value of the angle threshold, within which certain
10890
elementary functions, complex arithmetic operations, and complex
10891
elementary functions yield results conforming to a maximum relative
10892
error bound.  See G.2.4(10).
10893
@end cartouche
10894
@noindent
10895
Information on this subject is not yet available.
10896
 
10897
@sp 1
10898
@cartouche
10899
@noindent
10900
@strong{133}.  The accuracy of certain elementary functions for
10901
parameters beyond the angle threshold.  See G.2.4(10).
10902
@end cartouche
10903
@noindent
10904
Information on this subject is not yet available.
10905
 
10906
@sp 1
10907
@cartouche
10908
@noindent
10909
@strong{134}.  The result of a complex arithmetic operation or complex
10910
elementary function reference in overflow situations, when the
10911
@code{Machine_Overflows} attribute of the corresponding real type is
10912
@code{False}.  See G.2.6(5).
10913
@end cartouche
10914
@noindent
10915
IEEE infinite and Nan values are produced as appropriate.
10916
 
10917
@sp 1
10918
@cartouche
10919
@noindent
10920
@strong{135}.  The accuracy of certain complex arithmetic operations and
10921
certain complex elementary functions for parameters (or components
10922
thereof) beyond the angle threshold.  See G.2.6(8).
10923
@end cartouche
10924
@noindent
10925
Information on those subjects is not yet available.
10926
 
10927
@sp 1
10928
@cartouche
10929
@noindent
10930
@strong{136}.  Information regarding bounded errors and erroneous
10931
execution.  See H.2(1).
10932
@end cartouche
10933
@noindent
10934
Information on this subject is not yet available.
10935
 
10936
@sp 1
10937
@cartouche
10938
@noindent
10939
@strong{137}.  Implementation-defined aspects of pragma
10940
@code{Inspection_Point}.  See H.3.2(8).
10941
@end cartouche
10942
@noindent
10943
Pragma @code{Inspection_Point} ensures that the variable is live and can
10944
be examined by the debugger at the inspection point.
10945
 
10946
@sp 1
10947
@cartouche
10948
@noindent
10949
@strong{138}.  Implementation-defined aspects of pragma
10950
@code{Restrictions}.  See H.4(25).
10951
@end cartouche
10952
@noindent
10953
There are no implementation-defined aspects of pragma @code{Restrictions}.  The
10954
use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10955
generated code.  Checks must suppressed by use of pragma @code{Suppress}.
10956
 
10957
@sp 1
10958
@cartouche
10959
@noindent
10960
@strong{139}.  Any restrictions on pragma @code{Restrictions}.  See
10961
H.4(27).
10962
@end cartouche
10963
@noindent
10964
There are no restrictions on pragma @code{Restrictions}.
10965
 
10966
@node Intrinsic Subprograms
10967
@chapter Intrinsic Subprograms
10968
@cindex Intrinsic Subprograms
10969
 
10970
@menu
10971
* Intrinsic Operators::
10972
* Enclosing_Entity::
10973
* Exception_Information::
10974
* Exception_Message::
10975
* Exception_Name::
10976
* File::
10977
* Line::
10978
* Shifts and Rotates::
10979
* Source_Location::
10980
@end menu
10981
 
10982
@noindent
10983
GNAT allows a user application program to write the declaration:
10984
 
10985
@smallexample @c ada
10986
   pragma Import (Intrinsic, name);
10987
@end smallexample
10988
 
10989
@noindent
10990
providing that the name corresponds to one of the implemented intrinsic
10991
subprograms in GNAT, and that the parameter profile of the referenced
10992
subprogram meets the requirements.  This chapter describes the set of
10993
implemented intrinsic subprograms, and the requirements on parameter profiles.
10994
Note that no body is supplied; as with other uses of pragma Import, the
10995
body is supplied elsewhere (in this case by the compiler itself).  Note
10996
that any use of this feature is potentially non-portable, since the
10997
Ada standard does not require Ada compilers to implement this feature.
10998
 
10999
@node Intrinsic Operators
11000
@section Intrinsic Operators
11001
@cindex Intrinsic operator
11002
 
11003
@noindent
11004
All the predefined numeric operators in package Standard
11005
in @code{pragma Import (Intrinsic,..)}
11006
declarations.  In the binary operator case, the operands must have the same
11007
size.  The operand or operands must also be appropriate for
11008
the operator.  For example, for addition, the operands must
11009
both be floating-point or both be fixed-point, and the
11010
right operand for @code{"**"} must have a root type of
11011
@code{Standard.Integer'Base}.
11012
You can use an intrinsic operator declaration as in the following example:
11013
 
11014
@smallexample @c ada
11015
   type Int1 is new Integer;
11016
   type Int2 is new Integer;
11017
 
11018
   function "+" (X1 : Int1; X2 : Int2) return Int1;
11019
   function "+" (X1 : Int1; X2 : Int2) return Int2;
11020
   pragma Import (Intrinsic, "+");
11021
@end smallexample
11022
 
11023
@noindent
11024
This declaration would permit ``mixed mode'' arithmetic on items
11025
of the differing types @code{Int1} and @code{Int2}.
11026
It is also possible to specify such operators for private types, if the
11027
full views are appropriate arithmetic types.
11028
 
11029
@node Enclosing_Entity
11030
@section Enclosing_Entity
11031
@cindex Enclosing_Entity
11032
@noindent
11033
This intrinsic subprogram is used in the implementation of the
11034
library routine @code{GNAT.Source_Info}.  The only useful use of the
11035
intrinsic import in this case is the one in this unit, so an
11036
application program should simply call the function
11037
@code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11038
the current subprogram, package, task, entry, or protected subprogram.
11039
 
11040
@node Exception_Information
11041
@section Exception_Information
11042
@cindex Exception_Information'
11043
@noindent
11044
This intrinsic subprogram is used in the implementation of the
11045
library routine @code{GNAT.Current_Exception}.  The only useful
11046
use of the intrinsic import in this case is the one in this unit,
11047
so an application program should simply call the function
11048
@code{GNAT.Current_Exception.Exception_Information} to obtain
11049
the exception information associated with the current exception.
11050
 
11051
@node Exception_Message
11052
@section Exception_Message
11053
@cindex Exception_Message
11054
@noindent
11055
This intrinsic subprogram is used in the implementation of the
11056
library routine @code{GNAT.Current_Exception}.  The only useful
11057
use of the intrinsic import in this case is the one in this unit,
11058
so an application program should simply call the function
11059
@code{GNAT.Current_Exception.Exception_Message} to obtain
11060
the message associated with the current exception.
11061
 
11062
@node Exception_Name
11063
@section Exception_Name
11064
@cindex Exception_Name
11065
@noindent
11066
This intrinsic subprogram is used in the implementation of the
11067
library routine @code{GNAT.Current_Exception}.  The only useful
11068
use of the intrinsic import in this case is the one in this unit,
11069
so an application program should simply call the function
11070
@code{GNAT.Current_Exception.Exception_Name} to obtain
11071
the name of the current exception.
11072
 
11073
@node File
11074
@section File
11075
@cindex File
11076
@noindent
11077
This intrinsic subprogram is used in the implementation of the
11078
library routine @code{GNAT.Source_Info}.  The only useful use of the
11079
intrinsic import in this case is the one in this unit, so an
11080
application program should simply call the function
11081
@code{GNAT.Source_Info.File} to obtain the name of the current
11082
file.
11083
 
11084
@node Line
11085
@section Line
11086
@cindex Line
11087
@noindent
11088
This intrinsic subprogram is used in the implementation of the
11089
library routine @code{GNAT.Source_Info}.  The only useful use of the
11090
intrinsic import in this case is the one in this unit, so an
11091
application program should simply call the function
11092
@code{GNAT.Source_Info.Line} to obtain the number of the current
11093
source line.
11094
 
11095
@node Shifts and Rotates
11096
@section Shifts and Rotates
11097
@cindex Shift_Left
11098
@cindex Shift_Right
11099
@cindex Shift_Right_Arithmetic
11100
@cindex Rotate_Left
11101
@cindex Rotate_Right
11102
@noindent
11103
In standard Ada, the shift and rotate functions are available only
11104
for the predefined modular types in package @code{Interfaces}.  However, in
11105
GNAT it is possible to define these functions for any integer
11106
type (signed or modular), as in this example:
11107
 
11108
@smallexample @c ada
11109
   function Shift_Left
11110
     (Value  : T;
11111
      Amount : Natural)
11112
      return   T;
11113
@end smallexample
11114
 
11115
@noindent
11116
The function name must be one of
11117
Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11118
Rotate_Right. T must be an integer type. T'Size must be
11119
8, 16, 32 or 64 bits; if T is modular, the modulus
11120
must be 2**8, 2**16, 2**32 or 2**64.
11121
The result type must be the same as the type of @code{Value}.
11122
The shift amount must be Natural.
11123
The formal parameter names can be anything.
11124
 
11125
@node Source_Location
11126
@section Source_Location
11127
@cindex Source_Location
11128
@noindent
11129
This intrinsic subprogram is used in the implementation of the
11130
library routine @code{GNAT.Source_Info}.  The only useful use of the
11131
intrinsic import in this case is the one in this unit, so an
11132
application program should simply call the function
11133
@code{GNAT.Source_Info.Source_Location} to obtain the current
11134
source file location.
11135
 
11136
@node Representation Clauses and Pragmas
11137
@chapter Representation Clauses and Pragmas
11138
@cindex Representation Clauses
11139
 
11140
@menu
11141
* Alignment Clauses::
11142
* Size Clauses::
11143
* Storage_Size Clauses::
11144
* Size of Variant Record Objects::
11145
* Biased Representation ::
11146
* Value_Size and Object_Size Clauses::
11147
* Component_Size Clauses::
11148
* Bit_Order Clauses::
11149
* Effect of Bit_Order on Byte Ordering::
11150
* Pragma Pack for Arrays::
11151
* Pragma Pack for Records::
11152
* Record Representation Clauses::
11153
* Enumeration Clauses::
11154
* Address Clauses::
11155
* Effect of Convention on Representation::
11156
* Determining the Representations chosen by GNAT::
11157
@end menu
11158
 
11159
@noindent
11160
@cindex Representation Clause
11161
@cindex Representation Pragma
11162
@cindex Pragma, representation
11163
This section describes the representation clauses accepted by GNAT, and
11164
their effect on the representation of corresponding data objects.
11165
 
11166
GNAT fully implements Annex C (Systems Programming).  This means that all
11167
the implementation advice sections in chapter 13 are fully implemented.
11168
However, these sections only require a minimal level of support for
11169
representation clauses.  GNAT provides much more extensive capabilities,
11170
and this section describes the additional capabilities provided.
11171
 
11172
@node Alignment Clauses
11173
@section Alignment Clauses
11174
@cindex Alignment Clause
11175
 
11176
@noindent
11177
GNAT requires that all alignment clauses specify a power of 2, and all
11178
default alignments are always a power of 2.  The default alignment
11179
values are as follows:
11180
 
11181
@itemize @bullet
11182
@item @emph{Primitive Types}.
11183
For primitive types, the alignment is the minimum of the actual size of
11184
objects of the type divided by @code{Storage_Unit},
11185
and the maximum alignment supported by the target.
11186
(This maximum alignment is given by the GNAT-specific attribute
11187
@code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11188
@cindex @code{Maximum_Alignment} attribute
11189
For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11190
default alignment will be 8 on any target that supports alignments
11191
this large, but on some targets, the maximum alignment may be smaller
11192
than 8, in which case objects of type @code{Long_Float} will be maximally
11193
aligned.
11194
 
11195
@item @emph{Arrays}.
11196
For arrays, the alignment is equal to the alignment of the component type
11197
for the normal case where no packing or component size is given.  If the
11198
array is packed, and the packing is effective (see separate section on
11199
packed arrays), then the alignment will be one for long packed arrays,
11200
or arrays whose length is not known at compile time.  For short packed
11201
arrays, which are handled internally as modular types, the alignment
11202
will be as described for primitive types, e.g.@: a packed array of length
11203
31 bits will have an object size of four bytes, and an alignment of 4.
11204
 
11205
@item @emph{Records}.
11206
For the normal non-packed case, the alignment of a record is equal to
11207
the maximum alignment of any of its components.  For tagged records, this
11208
includes the implicit access type used for the tag.  If a pragma @code{Pack}
11209
is used and all components are packable (see separate section on pragma
11210
@code{Pack}), then the resulting alignment is 1, unless the layout of the
11211
record makes it profitable to increase it.
11212
 
11213
A special case is when:
11214
@itemize @bullet
11215
@item
11216
the size of the record is given explicitly, or a
11217
full record representation clause is given, and
11218
@item
11219
the size of the record is 2, 4, or 8 bytes.
11220
@end itemize
11221
@noindent
11222
In this case, an alignment is chosen to match the
11223
size of the record. For example, if we have:
11224
 
11225
@smallexample @c ada
11226
   type Small is record
11227
      A, B : Character;
11228
   end record;
11229
   for Small'Size use 16;
11230
@end smallexample
11231
 
11232
@noindent
11233
then the default alignment of the record type @code{Small} is 2, not 1. This
11234
leads to more efficient code when the record is treated as a unit, and also
11235
allows the type to specified as @code{Atomic} on architectures requiring
11236
strict alignment.
11237
 
11238
@end itemize
11239
 
11240
@noindent
11241
An alignment clause may specify a larger alignment than the default value
11242
up to some maximum value dependent on the target (obtainable by using the
11243
attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11244
a smaller alignment than the default value for enumeration, integer and
11245
fixed point types, as well as for record types, for example
11246
 
11247
@smallexample @c ada
11248
  type V is record
11249
     A : Integer;
11250
  end record;
11251
 
11252
  for V'alignment use 1;
11253
@end smallexample
11254
 
11255
@noindent
11256
@cindex Alignment, default
11257
The default alignment for the type @code{V} is 4, as a result of the
11258
Integer field in the record, but it is permissible, as shown, to
11259
override the default alignment of the record with a smaller value.
11260
 
11261
@node Size Clauses
11262
@section Size Clauses
11263
@cindex Size Clause
11264
 
11265
@noindent
11266
The default size for a type @code{T} is obtainable through the
11267
language-defined attribute @code{T'Size} and also through the
11268
equivalent GNAT-defined attribute @code{T'Value_Size}.
11269
For objects of type @code{T}, GNAT will generally increase the type size
11270
so that the object size (obtainable through the GNAT-defined attribute
11271
@code{T'Object_Size})
11272
is a multiple of @code{T'Alignment * Storage_Unit}.
11273
For example
11274
 
11275
@smallexample @c ada
11276
   type Smallint is range 1 .. 6;
11277
 
11278
   type Rec is record
11279
      Y1 : integer;
11280
      Y2 : boolean;
11281
   end record;
11282
@end smallexample
11283
 
11284
@noindent
11285
In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11286
as specified by the RM rules,
11287
but objects of this type will have a size of 8
11288
(@code{Smallint'Object_Size} = 8),
11289
since objects by default occupy an integral number
11290
of storage units.  On some targets, notably older
11291
versions of the Digital Alpha, the size of stand
11292
alone objects of this type may be 32, reflecting
11293
the inability of the hardware to do byte load/stores.
11294
 
11295
Similarly, the size of type @code{Rec} is 40 bits
11296
(@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11297
the alignment is 4, so objects of this type will have
11298
their size increased to 64 bits so that it is a multiple
11299
of the alignment (in bits).  This decision is
11300
in accordance with the specific Implementation Advice in RM 13.3(43):
11301
 
11302
@quotation
11303
A @code{Size} clause should be supported for an object if the specified
11304
@code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11305
to a size in storage elements that is a multiple of the object's
11306
@code{Alignment} (if the @code{Alignment} is nonzero).
11307
@end quotation
11308
 
11309
@noindent
11310
An explicit size clause may be used to override the default size by
11311
increasing it.  For example, if we have:
11312
 
11313
@smallexample @c ada
11314
   type My_Boolean is new Boolean;
11315
   for My_Boolean'Size use 32;
11316
@end smallexample
11317
 
11318
@noindent
11319
then values of this type will always be 32 bits long.  In the case of
11320
discrete types, the size can be increased up to 64 bits, with the effect
11321
that the entire specified field is used to hold the value, sign- or
11322
zero-extended as appropriate.  If more than 64 bits is specified, then
11323
padding space is allocated after the value, and a warning is issued that
11324
there are unused bits.
11325
 
11326
Similarly the size of records and arrays may be increased, and the effect
11327
is to add padding bits after the value.  This also causes a warning message
11328
to be generated.
11329
 
11330
The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
11331
Size in bits, this corresponds to an object of size 256 megabytes (minus
11332
one).  This limitation is true on all targets.  The reason for this
11333
limitation is that it improves the quality of the code in many cases
11334
if it is known that a Size value can be accommodated in an object of
11335
type Integer.
11336
 
11337
@node Storage_Size Clauses
11338
@section Storage_Size Clauses
11339
@cindex Storage_Size Clause
11340
 
11341
@noindent
11342
For tasks, the @code{Storage_Size} clause specifies the amount of space
11343
to be allocated for the task stack.  This cannot be extended, and if the
11344
stack is exhausted, then @code{Storage_Error} will be raised (if stack
11345
checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
11346
or a @code{Storage_Size} pragma in the task definition to set the
11347
appropriate required size.  A useful technique is to include in every
11348
task definition a pragma of the form:
11349
 
11350
@smallexample @c ada
11351
   pragma Storage_Size (Default_Stack_Size);
11352
@end smallexample
11353
 
11354
@noindent
11355
Then @code{Default_Stack_Size} can be defined in a global package, and
11356
modified as required. Any tasks requiring stack sizes different from the
11357
default can have an appropriate alternative reference in the pragma.
11358
 
11359
You can also use the @option{-d} binder switch to modify the default stack
11360
size.
11361
 
11362
For access types, the @code{Storage_Size} clause specifies the maximum
11363
space available for allocation of objects of the type.  If this space is
11364
exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11365
In the case where the access type is declared local to a subprogram, the
11366
use of a @code{Storage_Size} clause triggers automatic use of a special
11367
predefined storage pool (@code{System.Pool_Size}) that ensures that all
11368
space for the pool is automatically reclaimed on exit from the scope in
11369
which the type is declared.
11370
 
11371
A special case recognized by the compiler is the specification of a
11372
@code{Storage_Size} of zero for an access type.  This means that no
11373
items can be allocated from the pool, and this is recognized at compile
11374
time, and all the overhead normally associated with maintaining a fixed
11375
size storage pool is eliminated.  Consider the following example:
11376
 
11377
@smallexample @c ada
11378
   procedure p is
11379
      type R is array (Natural) of Character;
11380
      type P is access all R;
11381
      for P'Storage_Size use 0;
11382
      --  Above access type intended only for interfacing purposes
11383
 
11384
      y : P;
11385
 
11386
      procedure g (m : P);
11387
      pragma Import (C, g);
11388
 
11389
      --  @dots{}
11390
 
11391
   begin
11392
      --  @dots{}
11393
      y := new R;
11394
   end;
11395
@end smallexample
11396
 
11397
@noindent
11398
As indicated in this example, these dummy storage pools are often useful in
11399
connection with interfacing where no object will ever be allocated.  If you
11400
compile the above example, you get the warning:
11401
 
11402
@smallexample
11403
   p.adb:16:09: warning: allocation from empty storage pool
11404
   p.adb:16:09: warning: Storage_Error will be raised at run time
11405
@end smallexample
11406
 
11407
@noindent
11408
Of course in practice, there will not be any explicit allocators in the
11409
case of such an access declaration.
11410
 
11411
@node Size of Variant Record Objects
11412
@section Size of Variant Record Objects
11413
@cindex Size, variant record objects
11414
@cindex Variant record objects, size
11415
 
11416
@noindent
11417
In the case of variant record objects, there is a question whether Size gives
11418
information about a particular variant, or the maximum size required
11419
for any variant.  Consider the following program
11420
 
11421
@smallexample @c ada
11422
with Text_IO; use Text_IO;
11423
procedure q is
11424
   type R1 (A : Boolean := False) is record
11425
     case A is
11426
       when True  => X : Character;
11427
       when False => null;
11428
     end case;
11429
   end record;
11430
 
11431
   V1 : R1 (False);
11432
   V2 : R1;
11433
 
11434
begin
11435
   Put_Line (Integer'Image (V1'Size));
11436
   Put_Line (Integer'Image (V2'Size));
11437
end q;
11438
@end smallexample
11439
 
11440
@noindent
11441
Here we are dealing with a variant record, where the True variant
11442
requires 16 bits, and the False variant requires 8 bits.
11443
In the above example, both V1 and V2 contain the False variant,
11444
which is only 8 bits long.  However, the result of running the
11445
program is:
11446
 
11447
@smallexample
11448
8
11449
16
11450
@end smallexample
11451
 
11452
@noindent
11453
The reason for the difference here is that the discriminant value of
11454
V1 is fixed, and will always be False.  It is not possible to assign
11455
a True variant value to V1, therefore 8 bits is sufficient.  On the
11456
other hand, in the case of V2, the initial discriminant value is
11457
False (from the default), but it is possible to assign a True
11458
variant value to V2, therefore 16 bits must be allocated for V2
11459
in the general case, even fewer bits may be needed at any particular
11460
point during the program execution.
11461
 
11462
As can be seen from the output of this program, the @code{'Size}
11463
attribute applied to such an object in GNAT gives the actual allocated
11464
size of the variable, which is the largest size of any of the variants.
11465
The Ada Reference Manual is not completely clear on what choice should
11466
be made here, but the GNAT behavior seems most consistent with the
11467
language in the RM@.
11468
 
11469
In some cases, it may be desirable to obtain the size of the current
11470
variant, rather than the size of the largest variant.  This can be
11471
achieved in GNAT by making use of the fact that in the case of a
11472
subprogram parameter, GNAT does indeed return the size of the current
11473
variant (because a subprogram has no way of knowing how much space
11474
is actually allocated for the actual).
11475
 
11476
Consider the following modified version of the above program:
11477
 
11478
@smallexample @c ada
11479
with Text_IO; use Text_IO;
11480
procedure q is
11481
   type R1 (A : Boolean := False) is record
11482
     case A is
11483
       when True  => X : Character;
11484
       when False => null;
11485
     end case;
11486
   end record;
11487
 
11488
   V2 : R1;
11489
 
11490
   function Size (V : R1) return Integer is
11491
   begin
11492
      return V'Size;
11493
   end Size;
11494
 
11495
begin
11496
   Put_Line (Integer'Image (V2'Size));
11497
   Put_Line (Integer'IMage (Size (V2)));
11498
   V2 := (True, 'x');
11499
   Put_Line (Integer'Image (V2'Size));
11500
   Put_Line (Integer'IMage (Size (V2)));
11501
end q;
11502
@end smallexample
11503
 
11504
@noindent
11505
The output from this program is
11506
 
11507
@smallexample
11508
16
11509
8
11510
16
11511
16
11512
@end smallexample
11513
 
11514
@noindent
11515
Here we see that while the @code{'Size} attribute always returns
11516
the maximum size, regardless of the current variant value, the
11517
@code{Size} function does indeed return the size of the current
11518
variant value.
11519
 
11520
@node Biased Representation
11521
@section Biased Representation
11522
@cindex Size for biased representation
11523
@cindex Biased representation
11524
 
11525
@noindent
11526
In the case of scalars with a range starting at other than zero, it is
11527
possible in some cases to specify a size smaller than the default minimum
11528
value, and in such cases, GNAT uses an unsigned biased representation,
11529
in which zero is used to represent the lower bound, and successive values
11530
represent successive values of the type.
11531
 
11532
For example, suppose we have the declaration:
11533
 
11534
@smallexample @c ada
11535
   type Small is range -7 .. -4;
11536
   for Small'Size use 2;
11537
@end smallexample
11538
 
11539
@noindent
11540
Although the default size of type @code{Small} is 4, the @code{Size}
11541
clause is accepted by GNAT and results in the following representation
11542
scheme:
11543
 
11544
@smallexample
11545
  -7 is represented as 2#00#
11546
  -6 is represented as 2#01#
11547
  -5 is represented as 2#10#
11548
  -4 is represented as 2#11#
11549
@end smallexample
11550
 
11551
@noindent
11552
Biased representation is only used if the specified @code{Size} clause
11553
cannot be accepted in any other manner.  These reduced sizes that force
11554
biased representation can be used for all discrete types except for
11555
enumeration types for which a representation clause is given.
11556
 
11557
@node Value_Size and Object_Size Clauses
11558
@section Value_Size and Object_Size Clauses
11559
@findex Value_Size
11560
@findex Object_Size
11561
@cindex Size, of objects
11562
 
11563
@noindent
11564
In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11565
number of bits required to hold values of type @code{T}.
11566
Although this interpretation was allowed in Ada 83, it was not required,
11567
and this requirement in practice can cause some significant difficulties.
11568
For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11569
However, in Ada 95 and Ada 2005,
11570
@code{Natural'Size} is
11571
typically 31.  This means that code may change in behavior when moving
11572
from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
11573
 
11574
@smallexample @c ada
11575
   type Rec is record;
11576
      A : Natural;
11577
      B : Natural;
11578
   end record;
11579
 
11580
   for Rec use record
11581
      at 0  range 0 .. Natural'Size - 1;
11582
      at 0  range Natural'Size .. 2 * Natural'Size - 1;
11583
   end record;
11584
@end smallexample
11585
 
11586
@noindent
11587
In the above code, since the typical size of @code{Natural} objects
11588
is 32 bits and @code{Natural'Size} is 31, the above code can cause
11589
unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11590
there are cases where the fact that the object size can exceed the
11591
size of the type causes surprises.
11592
 
11593
To help get around this problem GNAT provides two implementation
11594
defined attributes, @code{Value_Size} and @code{Object_Size}.  When
11595
applied to a type, these attributes yield the size of the type
11596
(corresponding to the RM defined size attribute), and the size of
11597
objects of the type respectively.
11598
 
11599
The @code{Object_Size} is used for determining the default size of
11600
objects and components.  This size value can be referred to using the
11601
@code{Object_Size} attribute.  The phrase ``is used'' here means that it is
11602
the basis of the determination of the size.  The backend is free to
11603
pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11604
character might be stored in 32 bits on a machine with no efficient
11605
byte access instructions such as the Alpha.
11606
 
11607
The default rules for the value of @code{Object_Size} for
11608
discrete types are as follows:
11609
 
11610
@itemize @bullet
11611
@item
11612
The @code{Object_Size} for base subtypes reflect the natural hardware
11613
size in bits (run the compiler with @option{-gnatS} to find those values
11614
for numeric types). Enumeration types and fixed-point base subtypes have
11615
8, 16, 32 or 64 bits for this size, depending on the range of values
11616
to be stored.
11617
 
11618
@item
11619
The @code{Object_Size} of a subtype is the same as the
11620
@code{Object_Size} of
11621
the type from which it is obtained.
11622
 
11623
@item
11624
The @code{Object_Size} of a derived base type is copied from the parent
11625
base type, and the @code{Object_Size} of a derived first subtype is copied
11626
from the parent first subtype.
11627
@end itemize
11628
 
11629
@noindent
11630
The @code{Value_Size} attribute
11631
is the (minimum) number of bits required to store a value
11632
of the type.
11633
This value is used to determine how tightly to pack
11634
records or arrays with components of this type, and also affects
11635
the semantics of unchecked conversion (unchecked conversions where
11636
the @code{Value_Size} values differ generate a warning, and are potentially
11637
target dependent).
11638
 
11639
The default rules for the value of @code{Value_Size} are as follows:
11640
 
11641
@itemize @bullet
11642
@item
11643
The @code{Value_Size} for a base subtype is the minimum number of bits
11644
required to store all values of the type (including the sign bit
11645
only if negative values are possible).
11646
 
11647
@item
11648
If a subtype statically matches the first subtype of a given type, then it has
11649
by default the same @code{Value_Size} as the first subtype.  This is a
11650
consequence of RM 13.1(14) (``if two subtypes statically match,
11651
then their subtype-specific aspects are the same''.)
11652
 
11653
@item
11654
All other subtypes have a @code{Value_Size} corresponding to the minimum
11655
number of bits required to store all values of the subtype.  For
11656
dynamic bounds, it is assumed that the value can range down or up
11657
to the corresponding bound of the ancestor
11658
@end itemize
11659
 
11660
@noindent
11661
The RM defined attribute @code{Size} corresponds to the
11662
@code{Value_Size} attribute.
11663
 
11664
The @code{Size} attribute may be defined for a first-named subtype.  This sets
11665
the @code{Value_Size} of
11666
the first-named subtype to the given value, and the
11667
@code{Object_Size} of this first-named subtype to the given value padded up
11668
to an appropriate boundary.  It is a consequence of the default rules
11669
above that this @code{Object_Size} will apply to all further subtypes.  On the
11670
other hand, @code{Value_Size} is affected only for the first subtype, any
11671
dynamic subtypes obtained from it directly, and any statically matching
11672
subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
11673
 
11674
@code{Value_Size} and
11675
@code{Object_Size} may be explicitly set for any subtype using
11676
an attribute definition clause.  Note that the use of these attributes
11677
can cause the RM 13.1(14) rule to be violated.  If two access types
11678
reference aliased objects whose subtypes have differing @code{Object_Size}
11679
values as a result of explicit attribute definition clauses, then it
11680
is erroneous to convert from one access subtype to the other.
11681
 
11682
At the implementation level, Esize stores the Object_Size and the
11683
RM_Size field stores the @code{Value_Size} (and hence the value of the
11684
@code{Size} attribute,
11685
which, as noted above, is equivalent to @code{Value_Size}).
11686
 
11687
To get a feel for the difference, consider the following examples (note
11688
that in each case the base is @code{Short_Short_Integer} with a size of 8):
11689
 
11690
@smallexample
11691
                                       Object_Size     Value_Size
11692
 
11693
type x1 is range 0 .. 5;                    8               3
11694
 
11695
type x2 is range 0 .. 5;
11696
for x2'size use 12;                        16              12
11697
 
11698
subtype x3 is x2 range 0 .. 3;             16               2
11699
 
11700
subtype x4 is x2'base range 0 .. 10;        8               4
11701
 
11702
subtype x5 is x2 range 0 .. dynamic;       16               3*
11703
 
11704
subtype x6 is x2'base range 0 .. dynamic;   8               3*
11705
 
11706
@end smallexample
11707
 
11708
@noindent
11709
Note: the entries marked ``3*'' are not actually specified by the Ada
11710
Reference Manual, but it seems in the spirit of the RM rules to allocate
11711
the minimum number of bits (here 3, given the range for @code{x2})
11712
known to be large enough to hold the given range of values.
11713
 
11714
So far, so good, but GNAT has to obey the RM rules, so the question is
11715
under what conditions must the RM @code{Size} be used.
11716
The following is a list
11717
of the occasions on which the RM @code{Size} must be used:
11718
 
11719
@itemize @bullet
11720
@item
11721
Component size for packed arrays or records
11722
 
11723
@item
11724
Value of the attribute @code{Size} for a type
11725
 
11726
@item
11727
Warning about sizes not matching for unchecked conversion
11728
@end itemize
11729
 
11730
@noindent
11731
For record types, the @code{Object_Size} is always a multiple of the
11732
alignment of the type (this is true for all types). In some cases the
11733
@code{Value_Size} can be smaller. Consider:
11734
 
11735
@smallexample
11736
   type R is record
11737
     X : Integer;
11738
     Y : Character;
11739
   end record;
11740
@end smallexample
11741
 
11742
@noindent
11743
On a typical 32-bit architecture, the X component will be four bytes, and
11744
require four-byte alignment, and the Y component will be one byte. In this
11745
case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11746
required to store a value of this type, and for example, it is permissible
11747
to have a component of type R in an outer array whose component size is
11748
specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11749
since it must be rounded up so that this value is a multiple of the
11750
alignment (4 bytes = 32 bits).
11751
 
11752
@noindent
11753
For all other types, the @code{Object_Size}
11754
and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11755
Only @code{Size} may be specified for such types.
11756
 
11757
@node Component_Size Clauses
11758
@section Component_Size Clauses
11759
@cindex Component_Size Clause
11760
 
11761
@noindent
11762
Normally, the value specified in a component size clause must be consistent
11763
with the subtype of the array component with regard to size and alignment.
11764
In other words, the value specified must be at least equal to the size
11765
of this subtype, and must be a multiple of the alignment value.
11766
 
11767
In addition, component size clauses are allowed which cause the array
11768
to be packed, by specifying a smaller value.  A first case is for
11769
component size values in the range 1 through 63.  The value specified
11770
must not be smaller than the Size of the subtype.  GNAT will accurately
11771
honor all packing requests in this range.  For example, if we have:
11772
 
11773
@smallexample @c ada
11774
type r is array (1 .. 8) of Natural;
11775
for r'Component_Size use 31;
11776
@end smallexample
11777
 
11778
@noindent
11779
then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11780
Of course access to the components of such an array is considerably
11781
less efficient than if the natural component size of 32 is used.
11782
A second case is when the subtype of the component is a record type
11783
padded because of its default alignment.  For example, if we have:
11784
 
11785
@smallexample @c ada
11786
type r is record
11787
  i : Integer;
11788
  j : Integer;
11789
  b : Boolean;
11790
end record;
11791
 
11792
type a is array (1 .. 8) of r;
11793
for a'Component_Size use 72;
11794
@end smallexample
11795
 
11796
@noindent
11797
then the resulting array has a length of 72 bytes, instead of 96 bytes
11798
if the alignment of the record (4) was obeyed.
11799
 
11800
Note that there is no point in giving both a component size clause
11801
and a pragma Pack for the same array type. if such duplicate
11802
clauses are given, the pragma Pack will be ignored.
11803
 
11804
@node Bit_Order Clauses
11805
@section Bit_Order Clauses
11806
@cindex Bit_Order Clause
11807
@cindex bit ordering
11808
@cindex ordering, of bits
11809
 
11810
@noindent
11811
For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11812
attribute.  The specification may either correspond to the default bit
11813
order for the target, in which case the specification has no effect and
11814
places no additional restrictions, or it may be for the non-standard
11815
setting (that is the opposite of the default).
11816
 
11817
In the case where the non-standard value is specified, the effect is
11818
to renumber bits within each byte, but the ordering of bytes is not
11819
affected.  There are certain
11820
restrictions placed on component clauses as follows:
11821
 
11822
@itemize @bullet
11823
 
11824
@item Components fitting within a single storage unit.
11825
@noindent
11826
These are unrestricted, and the effect is merely to renumber bits.  For
11827
example if we are on a little-endian machine with @code{Low_Order_First}
11828
being the default, then the following two declarations have exactly
11829
the same effect:
11830
 
11831
@smallexample @c ada
11832
   type R1 is record
11833
      A : Boolean;
11834
      B : Integer range 1 .. 120;
11835
   end record;
11836
 
11837
   for R1 use record
11838
      A at 0 range 0 .. 0;
11839
      B at 0 range 1 .. 7;
11840
   end record;
11841
 
11842
   type R2 is record
11843
      A : Boolean;
11844
      B : Integer range 1 .. 120;
11845
   end record;
11846
 
11847
   for R2'Bit_Order use High_Order_First;
11848
 
11849
   for R2 use record
11850
      A at 0 range 7 .. 7;
11851
      B at 0 range 0 .. 6;
11852
   end record;
11853
@end smallexample
11854
 
11855
@noindent
11856
The useful application here is to write the second declaration with the
11857
@code{Bit_Order} attribute definition clause, and know that it will be treated
11858
the same, regardless of whether the target is little-endian or big-endian.
11859
 
11860
@item Components occupying an integral number of bytes.
11861
@noindent
11862
These are components that exactly fit in two or more bytes.  Such component
11863
declarations are allowed, but have no effect, since it is important to realize
11864
that the @code{Bit_Order} specification does not affect the ordering of bytes.
11865
In particular, the following attempt at getting an endian-independent integer
11866
does not work:
11867
 
11868
@smallexample @c ada
11869
   type R2 is record
11870
      A : Integer;
11871
   end record;
11872
 
11873
   for R2'Bit_Order use High_Order_First;
11874
 
11875
   for R2 use record
11876
      A at 0 range 0 .. 31;
11877
   end record;
11878
@end smallexample
11879
 
11880
@noindent
11881
This declaration will result in a little-endian integer on a
11882
little-endian machine, and a big-endian integer on a big-endian machine.
11883
If byte flipping is required for interoperability between big- and
11884
little-endian machines, this must be explicitly programmed.  This capability
11885
is not provided by @code{Bit_Order}.
11886
 
11887
@item Components that are positioned across byte boundaries
11888
@noindent
11889
but do not occupy an integral number of bytes.  Given that bytes are not
11890
reordered, such fields would occupy a non-contiguous sequence of bits
11891
in memory, requiring non-trivial code to reassemble.  They are for this
11892
reason not permitted, and any component clause specifying such a layout
11893
will be flagged as illegal by GNAT@.
11894
 
11895
@end itemize
11896
 
11897
@noindent
11898
Since the misconception that Bit_Order automatically deals with all
11899
endian-related incompatibilities is a common one, the specification of
11900
a component field that is an integral number of bytes will always
11901
generate a warning.  This warning may be suppressed using @code{pragma
11902
Warnings (Off)} if desired.  The following section contains additional
11903
details regarding the issue of byte ordering.
11904
 
11905
@node Effect of Bit_Order on Byte Ordering
11906
@section Effect of Bit_Order on Byte Ordering
11907
@cindex byte ordering
11908
@cindex ordering, of bytes
11909
 
11910
@noindent
11911
In this section we will review the effect of the @code{Bit_Order} attribute
11912
definition clause on byte ordering.  Briefly, it has no effect at all, but
11913
a detailed example will be helpful.  Before giving this
11914
example, let us review the precise
11915
definition of the effect of defining @code{Bit_Order}.  The effect of a
11916
non-standard bit order is described in section 15.5.3 of the Ada
11917
Reference Manual:
11918
 
11919
@quotation
11920
2   A bit ordering is a method of interpreting the meaning of
11921
the storage place attributes.
11922
@end quotation
11923
 
11924
@noindent
11925
To understand the precise definition of storage place attributes in
11926
this context, we visit section 13.5.1 of the manual:
11927
 
11928
@quotation
11929
13   A record_representation_clause (without the mod_clause)
11930
specifies the layout.  The storage place attributes (see 13.5.2)
11931
are taken from the values of the position, first_bit, and last_bit
11932
expressions after normalizing those values so that first_bit is
11933
less than Storage_Unit.
11934
@end quotation
11935
 
11936
@noindent
11937
The critical point here is that storage places are taken from
11938
the values after normalization, not before.  So the @code{Bit_Order}
11939
interpretation applies to normalized values.  The interpretation
11940
is described in the later part of the 15.5.3 paragraph:
11941
 
11942
@quotation
11943
2   A bit ordering is a method of interpreting the meaning of
11944
the storage place attributes.  High_Order_First (known in the
11945
vernacular as ``big endian'') means that the first bit of a
11946
storage element (bit 0) is the most significant bit (interpreting
11947
the sequence of bits that represent a component as an unsigned
11948
integer value).  Low_Order_First (known in the vernacular as
11949
``little endian'') means the opposite: the first bit is the
11950
least significant.
11951
@end quotation
11952
 
11953
@noindent
11954
Note that the numbering is with respect to the bits of a storage
11955
unit.  In other words, the specification affects only the numbering
11956
of bits within a single storage unit.
11957
 
11958
We can make the effect clearer by giving an example.
11959
 
11960
Suppose that we have an external device which presents two bytes, the first
11961
byte presented, which is the first (low addressed byte) of the two byte
11962
record is called Master, and the second byte is called Slave.
11963
 
11964
The left most (most significant bit is called Control for each byte, and
11965
the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11966
(least significant) bit.
11967
 
11968
On a big-endian machine, we can write the following representation clause
11969
 
11970
@smallexample @c ada
11971
   type Data is record
11972
      Master_Control : Bit;
11973
      Master_V1      : Bit;
11974
      Master_V2      : Bit;
11975
      Master_V3      : Bit;
11976
      Master_V4      : Bit;
11977
      Master_V5      : Bit;
11978
      Master_V6      : Bit;
11979
      Master_V7      : Bit;
11980
      Slave_Control  : Bit;
11981
      Slave_V1       : Bit;
11982
      Slave_V2       : Bit;
11983
      Slave_V3       : Bit;
11984
      Slave_V4       : Bit;
11985
      Slave_V5       : Bit;
11986
      Slave_V6       : Bit;
11987
      Slave_V7       : Bit;
11988
   end record;
11989
 
11990
   for Data use record
11991
      Master_Control at 0 range 0 .. 0;
11992
      Master_V1      at 0 range 1 .. 1;
11993
      Master_V2      at 0 range 2 .. 2;
11994
      Master_V3      at 0 range 3 .. 3;
11995
      Master_V4      at 0 range 4 .. 4;
11996
      Master_V5      at 0 range 5 .. 5;
11997
      Master_V6      at 0 range 6 .. 6;
11998
      Master_V7      at 0 range 7 .. 7;
11999
      Slave_Control  at 1 range 0 .. 0;
12000
      Slave_V1       at 1 range 1 .. 1;
12001
      Slave_V2       at 1 range 2 .. 2;
12002
      Slave_V3       at 1 range 3 .. 3;
12003
      Slave_V4       at 1 range 4 .. 4;
12004
      Slave_V5       at 1 range 5 .. 5;
12005
      Slave_V6       at 1 range 6 .. 6;
12006
      Slave_V7       at 1 range 7 .. 7;
12007
   end record;
12008
@end smallexample
12009
 
12010
@noindent
12011
Now if we move this to a little endian machine, then the bit ordering within
12012
the byte is backwards, so we have to rewrite the record rep clause as:
12013
 
12014
@smallexample @c ada
12015
   for Data use record
12016
      Master_Control at 0 range 7 .. 7;
12017
      Master_V1      at 0 range 6 .. 6;
12018
      Master_V2      at 0 range 5 .. 5;
12019
      Master_V3      at 0 range 4 .. 4;
12020
      Master_V4      at 0 range 3 .. 3;
12021
      Master_V5      at 0 range 2 .. 2;
12022
      Master_V6      at 0 range 1 .. 1;
12023
      Master_V7      at 0 range 0 .. 0;
12024
      Slave_Control  at 1 range 7 .. 7;
12025
      Slave_V1       at 1 range 6 .. 6;
12026
      Slave_V2       at 1 range 5 .. 5;
12027
      Slave_V3       at 1 range 4 .. 4;
12028
      Slave_V4       at 1 range 3 .. 3;
12029
      Slave_V5       at 1 range 2 .. 2;
12030
      Slave_V6       at 1 range 1 .. 1;
12031
      Slave_V7       at 1 range 0 .. 0;
12032
   end record;
12033
@end smallexample
12034
 
12035
@noindent
12036
It is a nuisance to have to rewrite the clause, especially if
12037
the code has to be maintained on both machines.  However,
12038
this is a case that we can handle with the
12039
@code{Bit_Order} attribute if it is implemented.
12040
Note that the implementation is not required on byte addressed
12041
machines, but it is indeed implemented in GNAT.
12042
This means that we can simply use the
12043
first record clause, together with the declaration
12044
 
12045
@smallexample @c ada
12046
   for Data'Bit_Order use High_Order_First;
12047
@end smallexample
12048
 
12049
@noindent
12050
and the effect is what is desired, namely the layout is exactly the same,
12051
independent of whether the code is compiled on a big-endian or little-endian
12052
machine.
12053
 
12054
The important point to understand is that byte ordering is not affected.
12055
A @code{Bit_Order} attribute definition never affects which byte a field
12056
ends up in, only where it ends up in that byte.
12057
To make this clear, let us rewrite the record rep clause of the previous
12058
example as:
12059
 
12060
@smallexample @c ada
12061
   for Data'Bit_Order use High_Order_First;
12062
   for Data use record
12063
      Master_Control at 0 range  0 .. 0;
12064
      Master_V1      at 0 range  1 .. 1;
12065
      Master_V2      at 0 range  2 .. 2;
12066
      Master_V3      at 0 range  3 .. 3;
12067
      Master_V4      at 0 range  4 .. 4;
12068
      Master_V5      at 0 range  5 .. 5;
12069
      Master_V6      at 0 range  6 .. 6;
12070
      Master_V7      at 0 range  7 .. 7;
12071
      Slave_Control  at 0 range  8 .. 8;
12072
      Slave_V1       at 0 range  9 .. 9;
12073
      Slave_V2       at 0 range 10 .. 10;
12074
      Slave_V3       at 0 range 11 .. 11;
12075
      Slave_V4       at 0 range 12 .. 12;
12076
      Slave_V5       at 0 range 13 .. 13;
12077
      Slave_V6       at 0 range 14 .. 14;
12078
      Slave_V7       at 0 range 15 .. 15;
12079
   end record;
12080
@end smallexample
12081
 
12082
@noindent
12083
This is exactly equivalent to saying (a repeat of the first example):
12084
 
12085
@smallexample @c ada
12086
   for Data'Bit_Order use High_Order_First;
12087
   for Data use record
12088
      Master_Control at 0 range 0 .. 0;
12089
      Master_V1      at 0 range 1 .. 1;
12090
      Master_V2      at 0 range 2 .. 2;
12091
      Master_V3      at 0 range 3 .. 3;
12092
      Master_V4      at 0 range 4 .. 4;
12093
      Master_V5      at 0 range 5 .. 5;
12094
      Master_V6      at 0 range 6 .. 6;
12095
      Master_V7      at 0 range 7 .. 7;
12096
      Slave_Control  at 1 range 0 .. 0;
12097
      Slave_V1       at 1 range 1 .. 1;
12098
      Slave_V2       at 1 range 2 .. 2;
12099
      Slave_V3       at 1 range 3 .. 3;
12100
      Slave_V4       at 1 range 4 .. 4;
12101
      Slave_V5       at 1 range 5 .. 5;
12102
      Slave_V6       at 1 range 6 .. 6;
12103
      Slave_V7       at 1 range 7 .. 7;
12104
   end record;
12105
@end smallexample
12106
 
12107
@noindent
12108
Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12109
field.  The storage place attributes are obtained by normalizing the
12110
values given so that the @code{First_Bit} value is less than 8.  After
12111
normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12112
we specified in the other case.
12113
 
12114
Now one might expect that the @code{Bit_Order} attribute might affect
12115
bit numbering within the entire record component (two bytes in this
12116
case, thus affecting which byte fields end up in), but that is not
12117
the way this feature is defined, it only affects numbering of bits,
12118
not which byte they end up in.
12119
 
12120
Consequently it never makes sense to specify a starting bit number
12121
greater than 7 (for a byte addressable field) if an attribute
12122
definition for @code{Bit_Order} has been given, and indeed it
12123
may be actively confusing to specify such a value, so the compiler
12124
generates a warning for such usage.
12125
 
12126
If you do need to control byte ordering then appropriate conditional
12127
values must be used.  If in our example, the slave byte came first on
12128
some machines we might write:
12129
 
12130
@smallexample @c ada
12131
   Master_Byte_First constant Boolean := @dots{};
12132
 
12133
   Master_Byte : constant Natural :=
12134
                   1 - Boolean'Pos (Master_Byte_First);
12135
   Slave_Byte  : constant Natural :=
12136
                   Boolean'Pos (Master_Byte_First);
12137
 
12138
   for Data'Bit_Order use High_Order_First;
12139
   for Data use record
12140
      Master_Control at Master_Byte range 0 .. 0;
12141
      Master_V1      at Master_Byte range 1 .. 1;
12142
      Master_V2      at Master_Byte range 2 .. 2;
12143
      Master_V3      at Master_Byte range 3 .. 3;
12144
      Master_V4      at Master_Byte range 4 .. 4;
12145
      Master_V5      at Master_Byte range 5 .. 5;
12146
      Master_V6      at Master_Byte range 6 .. 6;
12147
      Master_V7      at Master_Byte range 7 .. 7;
12148
      Slave_Control  at Slave_Byte  range 0 .. 0;
12149
      Slave_V1       at Slave_Byte  range 1 .. 1;
12150
      Slave_V2       at Slave_Byte  range 2 .. 2;
12151
      Slave_V3       at Slave_Byte  range 3 .. 3;
12152
      Slave_V4       at Slave_Byte  range 4 .. 4;
12153
      Slave_V5       at Slave_Byte  range 5 .. 5;
12154
      Slave_V6       at Slave_Byte  range 6 .. 6;
12155
      Slave_V7       at Slave_Byte  range 7 .. 7;
12156
   end record;
12157
@end smallexample
12158
 
12159
@noindent
12160
Now to switch between machines, all that is necessary is
12161
to set the boolean constant @code{Master_Byte_First} in
12162
an appropriate manner.
12163
 
12164
@node Pragma Pack for Arrays
12165
@section Pragma Pack for Arrays
12166
@cindex Pragma Pack (for arrays)
12167
 
12168
@noindent
12169
Pragma @code{Pack} applied to an array has no effect unless the component type
12170
is packable.  For a component type to be packable, it must be one of the
12171
following cases:
12172
 
12173
@itemize @bullet
12174
@item
12175
Any scalar type
12176
@item
12177
Any type whose size is specified with a size clause
12178
@item
12179
Any packed array type with a static size
12180
@item
12181
Any record type padded because of its default alignment
12182
@end itemize
12183
 
12184
@noindent
12185
For all these cases, if the component subtype size is in the range
12186
1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12187
component size were specified giving the component subtype size.
12188
For example if we have:
12189
 
12190
@smallexample @c ada
12191
   type r is range 0 .. 17;
12192
 
12193
   type ar is array (1 .. 8) of r;
12194
   pragma Pack (ar);
12195
@end smallexample
12196
 
12197
@noindent
12198
Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12199
and the size of the array @code{ar} will be exactly 40 bits.
12200
 
12201
Note that in some cases this rather fierce approach to packing can produce
12202
unexpected effects.  For example, in Ada 95 and Ada 2005,
12203
subtype @code{Natural} typically has a size of 31, meaning that if you
12204
pack an array of @code{Natural}, you get 31-bit
12205
close packing, which saves a few bits, but results in far less efficient
12206
access.  Since many other Ada compilers will ignore such a packing request,
12207
GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12208
might not be what is intended.  You can easily remove this warning by
12209
using an explicit @code{Component_Size} setting instead, which never generates
12210
a warning, since the intention of the programmer is clear in this case.
12211
 
12212
GNAT treats packed arrays in one of two ways.  If the size of the array is
12213
known at compile time and is less than 64 bits, then internally the array
12214
is represented as a single modular type, of exactly the appropriate number
12215
of bits.  If the length is greater than 63 bits, or is not known at compile
12216
time, then the packed array is represented as an array of bytes, and the
12217
length is always a multiple of 8 bits.
12218
 
12219
Note that to represent a packed array as a modular type, the alignment must
12220
be suitable for the modular type involved. For example, on typical machines
12221
a 32-bit packed array will be represented by a 32-bit modular integer with
12222
an alignment of four bytes. If you explicitly override the default alignment
12223
with an alignment clause that is too small, the modular representation
12224
cannot be used. For example, consider the following set of declarations:
12225
 
12226
@smallexample @c ada
12227
   type R is range 1 .. 3;
12228
   type S is array (1 .. 31) of R;
12229
   for S'Component_Size use 2;
12230
   for S'Size use 62;
12231
   for S'Alignment use 1;
12232
@end smallexample
12233
 
12234
@noindent
12235
If the alignment clause were not present, then a 62-bit modular
12236
representation would be chosen (typically with an alignment of 4 or 8
12237
bytes depending on the target). But the default alignment is overridden
12238
with the explicit alignment clause. This means that the modular
12239
representation cannot be used, and instead the array of bytes
12240
representation must be used, meaning that the length must be a multiple
12241
of 8. Thus the above set of declarations will result in a diagnostic
12242
rejecting the size clause and noting that the minimum size allowed is 64.
12243
 
12244
@cindex Pragma Pack (for type Natural)
12245
@cindex Pragma Pack warning
12246
 
12247
One special case that is worth noting occurs when the base type of the
12248
component size is 8/16/32 and the subtype is one bit less. Notably this
12249
occurs with subtype @code{Natural}. Consider:
12250
 
12251
@smallexample @c ada
12252
   type Arr is array (1 .. 32) of Natural;
12253
   pragma Pack (Arr);
12254
@end smallexample
12255
 
12256
@noindent
12257
In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12258
since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12259
Ada 83 compilers did not attempt 31 bit packing.
12260
 
12261
In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12262
GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12263
substantial unintended performance penalty when porting legacy Ada 83 code.
12264
To help prevent this, GNAT generates a warning in such cases. If you really
12265
want 31 bit packing in a case like this, you can set the component size
12266
explicitly:
12267
 
12268
@smallexample @c ada
12269
   type Arr is array (1 .. 32) of Natural;
12270
   for Arr'Component_Size use 31;
12271
@end smallexample
12272
 
12273
@noindent
12274
Here 31-bit packing is achieved as required, and no warning is generated,
12275
since in this case the programmer intention is clear.
12276
 
12277
@node Pragma Pack for Records
12278
@section Pragma Pack for Records
12279
@cindex Pragma Pack (for records)
12280
 
12281
@noindent
12282
Pragma @code{Pack} applied to a record will pack the components to reduce
12283
wasted space from alignment gaps and by reducing the amount of space
12284
taken by components.  We distinguish between @emph{packable} components and
12285
@emph{non-packable} components.
12286
Components of the following types are considered packable:
12287
@itemize @bullet
12288
@item
12289
All primitive types are packable.
12290
 
12291
@item
12292
Small packed arrays, whose size does not exceed 64 bits, and where the
12293
size is statically known at compile time, are represented internally
12294
as modular integers, and so they are also packable.
12295
 
12296
@end itemize
12297
 
12298
@noindent
12299
All packable components occupy the exact number of bits corresponding to
12300
their @code{Size} value, and are packed with no padding bits, i.e.@: they
12301
can start on an arbitrary bit boundary.
12302
 
12303
All other types are non-packable, they occupy an integral number of
12304
storage units, and
12305
are placed at a boundary corresponding to their alignment requirements.
12306
 
12307
For example, consider the record
12308
 
12309
@smallexample @c ada
12310
   type Rb1 is array (1 .. 13) of Boolean;
12311
   pragma Pack (rb1);
12312
 
12313
   type Rb2 is array (1 .. 65) of Boolean;
12314
   pragma Pack (rb2);
12315
 
12316
   type x2 is record
12317
      l1 : Boolean;
12318
      l2 : Duration;
12319
      l3 : Float;
12320
      l4 : Boolean;
12321
      l5 : Rb1;
12322
      l6 : Rb2;
12323
   end record;
12324
   pragma Pack (x2);
12325
@end smallexample
12326
 
12327
@noindent
12328
The representation for the record x2 is as follows:
12329
 
12330
@smallexample @c ada
12331
for x2'Size use 224;
12332
for x2 use record
12333
   l1 at  0 range  0 .. 0;
12334
   l2 at  0 range  1 .. 64;
12335
   l3 at 12 range  0 .. 31;
12336
   l4 at 16 range  0 .. 0;
12337
   l5 at 16 range  1 .. 13;
12338
   l6 at 18 range  0 .. 71;
12339
end record;
12340
@end smallexample
12341
 
12342
@noindent
12343
Studying this example, we see that the packable fields @code{l1}
12344
and @code{l2} are
12345
of length equal to their sizes, and placed at specific bit boundaries (and
12346
not byte boundaries) to
12347
eliminate padding.  But @code{l3} is of a non-packable float type, so
12348
it is on the next appropriate alignment boundary.
12349
 
12350
The next two fields are fully packable, so @code{l4} and @code{l5} are
12351
minimally packed with no gaps.  However, type @code{Rb2} is a packed
12352
array that is longer than 64 bits, so it is itself non-packable.  Thus
12353
the @code{l6} field is aligned to the next byte boundary, and takes an
12354
integral number of bytes, i.e.@: 72 bits.
12355
 
12356
@node Record Representation Clauses
12357
@section Record Representation Clauses
12358
@cindex Record Representation Clause
12359
 
12360
@noindent
12361
Record representation clauses may be given for all record types, including
12362
types obtained by record extension.  Component clauses are allowed for any
12363
static component.  The restrictions on component clauses depend on the type
12364
of the component.
12365
 
12366
@cindex Component Clause
12367
For all components of an elementary type, the only restriction on component
12368
clauses is that the size must be at least the 'Size value of the type
12369
(actually the Value_Size).  There are no restrictions due to alignment,
12370
and such components may freely cross storage boundaries.
12371
 
12372
Packed arrays with a size up to and including 64 bits are represented
12373
internally using a modular type with the appropriate number of bits, and
12374
thus the same lack of restriction applies.  For example, if you declare:
12375
 
12376
@smallexample @c ada
12377
   type R is array (1 .. 49) of Boolean;
12378
   pragma Pack (R);
12379
   for R'Size use 49;
12380
@end smallexample
12381
 
12382
@noindent
12383
then a component clause for a component of type R may start on any
12384
specified bit boundary, and may specify a value of 49 bits or greater.
12385
 
12386
For packed bit arrays that are longer than 64 bits, there are two
12387
cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12388
including the important case of single bits or boolean values, then
12389
there are no limitations on placement of such components, and they
12390
may start and end at arbitrary bit boundaries.
12391
 
12392
If the component size is not a power of 2 (e.g.@: 3 or 5), then
12393
an array of this type longer than 64 bits must always be placed on
12394
on a storage unit (byte) boundary and occupy an integral number
12395
of storage units (bytes). Any component clause that does not
12396
meet this requirement will be rejected.
12397
 
12398
Any aliased component, or component of an aliased type, must
12399
have its normal alignment and size. A component clause that
12400
does not meet this requirement will be rejected.
12401
 
12402
The tag field of a tagged type always occupies an address sized field at
12403
the start of the record.  No component clause may attempt to overlay this
12404
tag. When a tagged type appears as a component, the tag field must have
12405
proper alignment
12406
 
12407
In the case of a record extension T1, of a type T, no component clause applied
12408
to the type T1 can specify a storage location that would overlap the first
12409
T'Size bytes of the record.
12410
 
12411
For all other component types, including non-bit-packed arrays,
12412
the component can be placed at an arbitrary bit boundary,
12413
so for example, the following is permitted:
12414
 
12415
@smallexample @c ada
12416
   type R is array (1 .. 10) of Boolean;
12417
   for R'Size use 80;
12418
 
12419
   type Q is record
12420
      G, H : Boolean;
12421
      L, M : R;
12422
   end record;
12423
 
12424
   for Q use record
12425
      G at 0 range  0 ..   0;
12426
      H at 0 range  1 ..   1;
12427
      L at 0 range  2 ..  81;
12428
      R at 0 range 82 .. 161;
12429
   end record;
12430
@end smallexample
12431
 
12432
@noindent
12433
Note: the above rules apply to recent releases of GNAT 5.
12434
In GNAT 3, there are more severe restrictions on larger components.
12435
For non-primitive types, including packed arrays with a size greater than
12436
64 bits, component clauses must respect the alignment requirement of the
12437
type, in particular, always starting on a byte boundary, and the length
12438
must be a multiple of the storage unit.
12439
 
12440
@node Enumeration Clauses
12441
@section Enumeration Clauses
12442
 
12443
The only restriction on enumeration clauses is that the range of values
12444
must be representable.  For the signed case, if one or more of the
12445
representation values are negative, all values must be in the range:
12446
 
12447
@smallexample @c ada
12448
   System.Min_Int .. System.Max_Int
12449
@end smallexample
12450
 
12451
@noindent
12452
For the unsigned case, where all values are nonnegative, the values must
12453
be in the range:
12454
 
12455
@smallexample @c ada
12456
 
12457
@end smallexample
12458
 
12459
@noindent
12460
A @emph{confirming} representation clause is one in which the values range
12461
from 0 in sequence, i.e.@: a clause that confirms the default representation
12462
for an enumeration type.
12463
Such a confirming representation
12464
is permitted by these rules, and is specially recognized by the compiler so
12465
that no extra overhead results from the use of such a clause.
12466
 
12467
If an array has an index type which is an enumeration type to which an
12468
enumeration clause has been applied, then the array is stored in a compact
12469
manner.  Consider the declarations:
12470
 
12471
@smallexample @c ada
12472
   type r is (A, B, C);
12473
   for r use (A => 1, B => 5, C => 10);
12474
   type t is array (r) of Character;
12475
@end smallexample
12476
 
12477
@noindent
12478
The array type t corresponds to a vector with exactly three elements and
12479
has a default size equal to @code{3*Character'Size}.  This ensures efficient
12480
use of space, but means that accesses to elements of the array will incur
12481
the overhead of converting representation values to the corresponding
12482
positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12483
 
12484
@node Address Clauses
12485
@section Address Clauses
12486
@cindex Address Clause
12487
 
12488
The reference manual allows a general restriction on representation clauses,
12489
as found in RM 13.1(22):
12490
 
12491
@quotation
12492
An implementation need not support representation
12493
items containing nonstatic expressions, except that
12494
an implementation should support a representation item
12495
for a given entity if each nonstatic expression in the
12496
representation item is a name that statically denotes
12497
a constant declared before the entity.
12498
@end quotation
12499
 
12500
@noindent
12501
In practice this is applicable only to address clauses, since this is the
12502
only case in which a non-static expression is permitted by the syntax.  As
12503
the AARM notes in sections 13.1 (22.a-22.h):
12504
 
12505
@display
12506
  22.a   Reason: This is to avoid the following sort of thing:
12507
 
12508
  22.b        X : Integer := F(@dots{});
12509
              Y : Address := G(@dots{});
12510
              for X'Address use Y;
12511
 
12512
  22.c   In the above, we have to evaluate the
12513
         initialization expression for X before we
12514
         know where to put the result.  This seems
12515
         like an unreasonable implementation burden.
12516
 
12517
  22.d   The above code should instead be written
12518
         like this:
12519
 
12520
  22.e        Y : constant Address := G(@dots{});
12521
              X : Integer := F(@dots{});
12522
              for X'Address use Y;
12523
 
12524
  22.f   This allows the expression ``Y'' to be safely
12525
         evaluated before X is created.
12526
 
12527
  22.g   The constant could be a formal parameter of mode in.
12528
 
12529
  22.h   An implementation can support other nonstatic
12530
         expressions if it wants to.  Expressions of type
12531
         Address are hardly ever static, but their value
12532
         might be known at compile time anyway in many
12533
         cases.
12534
@end display
12535
 
12536
@noindent
12537
GNAT does indeed permit many additional cases of non-static expressions.  In
12538
particular, if the type involved is elementary there are no restrictions
12539
(since in this case, holding a temporary copy of the initialization value,
12540
if one is present, is inexpensive).  In addition, if there is no implicit or
12541
explicit initialization, then there are no restrictions.  GNAT will reject
12542
only the case where all three of these conditions hold:
12543
 
12544
@itemize @bullet
12545
 
12546
@item
12547
The type of the item is non-elementary (e.g.@: a record or array).
12548
 
12549
@item
12550
There is explicit or implicit initialization required for the object.
12551
Note that access values are always implicitly initialized.
12552
 
12553
@item
12554
The address value is non-static.  Here GNAT is more permissive than the
12555
RM, and allows the address value to be the address of a previously declared
12556
stand-alone variable, as long as it does not itself have an address clause.
12557
 
12558
@smallexample @c ada
12559
           Anchor  : Some_Initialized_Type;
12560
           Overlay : Some_Initialized_Type;
12561
           for Overlay'Address use Anchor'Address;
12562
@end smallexample
12563
 
12564
@noindent
12565
However, the prefix of the address clause cannot be an array component, or
12566
a component of a discriminated record.
12567
 
12568
@end itemize
12569
 
12570
@noindent
12571
As noted above in section 22.h, address values are typically non-static.  In
12572
particular the To_Address function, even if applied to a literal value, is
12573
a non-static function call.  To avoid this minor annoyance, GNAT provides
12574
the implementation defined attribute 'To_Address.  The following two
12575
expressions have identical values:
12576
 
12577
@findex Attribute
12578
@findex To_Address
12579
@smallexample @c ada
12580
   To_Address (16#1234_0000#)
12581
   System'To_Address (16#1234_0000#);
12582
@end smallexample
12583
 
12584
@noindent
12585
except that the second form is considered to be a static expression, and
12586
thus when used as an address clause value is always permitted.
12587
 
12588
@noindent
12589
Additionally, GNAT treats as static an address clause that is an
12590
unchecked_conversion of a static integer value.  This simplifies the porting
12591
of legacy code, and provides a portable equivalent to the GNAT attribute
12592
@code{To_Address}.
12593
 
12594
Another issue with address clauses is the interaction with alignment
12595
requirements.  When an address clause is given for an object, the address
12596
value must be consistent with the alignment of the object (which is usually
12597
the same as the alignment of the type of the object).  If an address clause
12598
is given that specifies an inappropriately aligned address value, then the
12599
program execution is erroneous.
12600
 
12601
Since this source of erroneous behavior can have unfortunate effects, GNAT
12602
checks (at compile time if possible, generating a warning, or at execution
12603
time with a run-time check) that the alignment is appropriate.  If the
12604
run-time check fails, then @code{Program_Error} is raised.  This run-time
12605
check is suppressed if range checks are suppressed, or if the special GNAT
12606
check Alignment_Check is suppressed, or if
12607
@code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12608
 
12609
Finally, GNAT does not permit overlaying of objects of controlled types or
12610
composite types containing a controlled component. In most cases, the compiler
12611
can detect an attempt at such overlays and will generate a warning at compile
12612
time and a Program_Error exception at run time.
12613
 
12614
@findex Export
12615
An address clause cannot be given for an exported object.  More
12616
understandably the real restriction is that objects with an address
12617
clause cannot be exported.  This is because such variables are not
12618
defined by the Ada program, so there is no external object to export.
12619
 
12620
@findex Import
12621
It is permissible to give an address clause and a pragma Import for the
12622
same object.  In this case, the variable is not really defined by the
12623
Ada program, so there is no external symbol to be linked.  The link name
12624
and the external name are ignored in this case.  The reason that we allow this
12625
combination is that it provides a useful idiom to avoid unwanted
12626
initializations on objects with address clauses.
12627
 
12628
When an address clause is given for an object that has implicit or
12629
explicit initialization, then by default initialization takes place.  This
12630
means that the effect of the object declaration is to overwrite the
12631
memory at the specified address.  This is almost always not what the
12632
programmer wants, so GNAT will output a warning:
12633
 
12634
@smallexample
12635
  with System;
12636
  package G is
12637
     type R is record
12638
        M : Integer := 0;
12639
     end record;
12640
 
12641
     Ext : R;
12642
     for Ext'Address use System'To_Address (16#1234_1234#);
12643
         |
12644
  >>> warning: implicit initialization of "Ext" may
12645
      modify overlaid storage
12646
  >>> warning: use pragma Import for "Ext" to suppress
12647
      initialization (RM B(24))
12648
 
12649
  end G;
12650
@end smallexample
12651
 
12652
@noindent
12653
As indicated by the warning message, the solution is to use a (dummy) pragma
12654
Import to suppress this initialization.  The pragma tell the compiler that the
12655
object is declared and initialized elsewhere.  The following package compiles
12656
without warnings (and the initialization is suppressed):
12657
 
12658
@smallexample @c ada
12659
   with System;
12660
   package G is
12661
      type R is record
12662
         M : Integer := 0;
12663
      end record;
12664
 
12665
      Ext : R;
12666
      for Ext'Address use System'To_Address (16#1234_1234#);
12667
      pragma Import (Ada, Ext);
12668
   end G;
12669
@end smallexample
12670
 
12671
@noindent
12672
A final issue with address clauses involves their use for overlaying
12673
variables, as in the following example:
12674
@cindex Overlaying of objects
12675
 
12676
@smallexample @c ada
12677
  A : Integer;
12678
  B : Integer;
12679
  for B'Address use A'Address;
12680
@end smallexample
12681
 
12682
@noindent
12683
or alternatively, using the form recommended by the RM:
12684
 
12685
@smallexample @c ada
12686
  A    : Integer;
12687
  Addr : constant Address := A'Address;
12688
  B    : Integer;
12689
  for B'Address use Addr;
12690
@end smallexample
12691
 
12692
@noindent
12693
In both of these cases, @code{A}
12694
and @code{B} become aliased to one another via the
12695
address clause. This use of address clauses to overlay
12696
variables, achieving an effect similar to unchecked
12697
conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12698
the effect is implementation defined. Furthermore, the
12699
Ada RM specifically recommends that in a situation
12700
like this, @code{B} should be subject to the following
12701
implementation advice (RM 13.3(19)):
12702
 
12703
@quotation
12704
19  If the Address of an object is specified, or it is imported
12705
    or exported, then the implementation should not perform
12706
    optimizations based on assumptions of no aliases.
12707
@end quotation
12708
 
12709
@noindent
12710
GNAT follows this recommendation, and goes further by also applying
12711
this recommendation to the overlaid variable (@code{A}
12712
in the above example) in this case. This means that the overlay
12713
works "as expected", in that a modification to one of the variables
12714
will affect the value of the other.
12715
 
12716
@node Effect of Convention on Representation
12717
@section Effect of Convention on Representation
12718
@cindex Convention, effect on representation
12719
 
12720
@noindent
12721
Normally the specification of a foreign language convention for a type or
12722
an object has no effect on the chosen representation.  In particular, the
12723
representation chosen for data in GNAT generally meets the standard system
12724
conventions, and for example records are laid out in a manner that is
12725
consistent with C@.  This means that specifying convention C (for example)
12726
has no effect.
12727
 
12728
There are four exceptions to this general rule:
12729
 
12730
@itemize @bullet
12731
 
12732
@item Convention Fortran and array subtypes
12733
If pragma Convention Fortran is specified for an array subtype, then in
12734
accordance with the implementation advice in section 3.6.2(11) of the
12735
Ada Reference Manual, the array will be stored in a Fortran-compatible
12736
column-major manner, instead of the normal default row-major order.
12737
 
12738
@item Convention C and enumeration types
12739
GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12740
to accommodate all values of the type.  For example, for the enumeration
12741
type declared by:
12742
 
12743
@smallexample @c ada
12744
   type Color is (Red, Green, Blue);
12745
@end smallexample
12746
 
12747
@noindent
12748
8 bits is sufficient to store all values of the type, so by default, objects
12749
of type @code{Color} will be represented using 8 bits.  However, normal C
12750
convention is to use 32 bits for all enum values in C, since enum values
12751
are essentially of type int.  If pragma @code{Convention C} is specified for an
12752
Ada enumeration type, then the size is modified as necessary (usually to
12753
32 bits) to be consistent with the C convention for enum values.
12754
 
12755
Note that this treatment applies only to types. If Convention C is given for
12756
an enumeration object, where the enumeration type is not Convention C, then
12757
Object_Size bits are allocated. For example, for a normal enumeration type,
12758
with less than 256 elements, only 8 bits will be allocated for the object.
12759
Since this may be a surprise in terms of what C expects, GNAT will issue a
12760
warning in this situation. The warning can be suppressed by giving an explicit
12761
size clause specifying the desired size.
12762
 
12763
@item Convention C/Fortran and Boolean types
12764
In C, the usual convention for boolean values, that is values used for
12765
conditions, is that zero represents false, and nonzero values represent
12766
true.  In Ada, the normal convention is that two specific values, typically
12767
0/1, are used to represent false/true respectively.
12768
 
12769
Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12770
value represents true).
12771
 
12772
To accommodate the Fortran and C conventions, if a pragma Convention specifies
12773
C or Fortran convention for a derived Boolean, as in the following example:
12774
 
12775
@smallexample @c ada
12776
   type C_Switch is new Boolean;
12777
   pragma Convention (C, C_Switch);
12778
@end smallexample
12779
 
12780
@noindent
12781
then the GNAT generated code will treat any nonzero value as true.  For truth
12782
values generated by GNAT, the conventional value 1 will be used for True, but
12783
when one of these values is read, any nonzero value is treated as True.
12784
 
12785
@item Access types on OpenVMS
12786
For 64-bit OpenVMS systems, access types (other than those for unconstrained
12787
arrays) are 64-bits long. An exception to this rule is for the case of
12788
C-convention access types where there is no explicit size clause present (or
12789
inherited for derived types). In this case, GNAT chooses to make these
12790
pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12791
code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12792
 
12793
@end itemize
12794
 
12795
@node Determining the Representations chosen by GNAT
12796
@section Determining the Representations chosen by GNAT
12797
@cindex Representation, determination of
12798
@cindex @option{-gnatR} switch
12799
 
12800
@noindent
12801
Although the descriptions in this section are intended to be complete, it is
12802
often easier to simply experiment to see what GNAT accepts and what the
12803
effect is on the layout of types and objects.
12804
 
12805
As required by the Ada RM, if a representation clause is not accepted, then
12806
it must be rejected as illegal by the compiler.  However, when a
12807
representation clause or pragma is accepted, there can still be questions
12808
of what the compiler actually does.  For example, if a partial record
12809
representation clause specifies the location of some components and not
12810
others, then where are the non-specified components placed? Or if pragma
12811
@code{Pack} is used on a record, then exactly where are the resulting
12812
fields placed? The section on pragma @code{Pack} in this chapter can be
12813
used to answer the second question, but it is often easier to just see
12814
what the compiler does.
12815
 
12816
For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
12817
with this option, then the compiler will output information on the actual
12818
representations chosen, in a format similar to source representation
12819
clauses.  For example, if we compile the package:
12820
 
12821
@smallexample @c ada
12822
package q is
12823
   type r (x : boolean) is tagged record
12824
      case x is
12825
         when True => S : String (1 .. 100);
12826
         when False => null;
12827
      end case;
12828
   end record;
12829
 
12830
   type r2 is new r (false) with record
12831
      y2 : integer;
12832
   end record;
12833
 
12834
   for r2 use record
12835
      y2 at 16 range 0 .. 31;
12836
   end record;
12837
 
12838
   type x is record
12839
      y : character;
12840
   end record;
12841
 
12842
   type x1 is array (1 .. 10) of x;
12843
   for x1'component_size use 11;
12844
 
12845
   type ia is access integer;
12846
 
12847
   type Rb1 is array (1 .. 13) of Boolean;
12848
   pragma Pack (rb1);
12849
 
12850
   type Rb2 is array (1 .. 65) of Boolean;
12851
   pragma Pack (rb2);
12852
 
12853
   type x2 is record
12854
      l1 : Boolean;
12855
      l2 : Duration;
12856
      l3 : Float;
12857
      l4 : Boolean;
12858
      l5 : Rb1;
12859
      l6 : Rb2;
12860
   end record;
12861
   pragma Pack (x2);
12862
end q;
12863
@end smallexample
12864
 
12865
@noindent
12866
using the switch @option{-gnatR} we obtain the following output:
12867
 
12868
@smallexample
12869
Representation information for unit q
12870
-------------------------------------
12871
 
12872
for r'Size use ??;
12873
for r'Alignment use 4;
12874
for r use record
12875
   x    at 4 range  0 .. 7;
12876
   _tag at 0 range  0 .. 31;
12877
   s    at 5 range  0 .. 799;
12878
end record;
12879
 
12880
for r2'Size use 160;
12881
for r2'Alignment use 4;
12882
for r2 use record
12883
   x       at  4 range  0 .. 7;
12884
   _tag    at  0 range  0 .. 31;
12885
   _parent at  0 range  0 .. 63;
12886
   y2      at 16 range  0 .. 31;
12887
end record;
12888
 
12889
for x'Size use 8;
12890
for x'Alignment use 1;
12891
for x use record
12892
   y at 0 range  0 .. 7;
12893
end record;
12894
 
12895
for x1'Size use 112;
12896
for x1'Alignment use 1;
12897
for x1'Component_Size use 11;
12898
 
12899
for rb1'Size use 13;
12900
for rb1'Alignment use 2;
12901
for rb1'Component_Size use 1;
12902
 
12903
for rb2'Size use 72;
12904
for rb2'Alignment use 1;
12905
for rb2'Component_Size use 1;
12906
 
12907
for x2'Size use 224;
12908
for x2'Alignment use 4;
12909
for x2 use record
12910
   l1 at  0 range  0 .. 0;
12911
   l2 at  0 range  1 .. 64;
12912
   l3 at 12 range  0 .. 31;
12913
   l4 at 16 range  0 .. 0;
12914
   l5 at 16 range  1 .. 13;
12915
   l6 at 18 range  0 .. 71;
12916
end record;
12917
@end smallexample
12918
 
12919
@noindent
12920
The Size values are actually the Object_Size, i.e.@: the default size that
12921
will be allocated for objects of the type.
12922
The ?? size for type r indicates that we have a variant record, and the
12923
actual size of objects will depend on the discriminant value.
12924
 
12925
The Alignment values show the actual alignment chosen by the compiler
12926
for each record or array type.
12927
 
12928
The record representation clause for type r shows where all fields
12929
are placed, including the compiler generated tag field (whose location
12930
cannot be controlled by the programmer).
12931
 
12932
The record representation clause for the type extension r2 shows all the
12933
fields present, including the parent field, which is a copy of the fields
12934
of the parent type of r2, i.e.@: r1.
12935
 
12936
The component size and size clauses for types rb1 and rb2 show
12937
the exact effect of pragma @code{Pack} on these arrays, and the record
12938
representation clause for type x2 shows how pragma @code{Pack} affects
12939
this record type.
12940
 
12941
In some cases, it may be useful to cut and paste the representation clauses
12942
generated by the compiler into the original source to fix and guarantee
12943
the actual representation to be used.
12944
 
12945
@node Standard Library Routines
12946
@chapter Standard Library Routines
12947
 
12948
@noindent
12949
The Ada Reference Manual contains in Annex A a full description of an
12950
extensive set of standard library routines that can be used in any Ada
12951
program, and which must be provided by all Ada compilers.  They are
12952
analogous to the standard C library used by C programs.
12953
 
12954
GNAT implements all of the facilities described in annex A, and for most
12955
purposes the description in the Ada Reference Manual, or appropriate Ada
12956
text book, will be sufficient for making use of these facilities.
12957
 
12958
In the case of the input-output facilities,
12959
@xref{The Implementation of Standard I/O},
12960
gives details on exactly how GNAT interfaces to the
12961
file system.  For the remaining packages, the Ada Reference Manual
12962
should be sufficient.  The following is a list of the packages included,
12963
together with a brief description of the functionality that is provided.
12964
 
12965
For completeness, references are included to other predefined library
12966
routines defined in other sections of the Ada Reference Manual (these are
12967
cross-indexed from Annex A).
12968
 
12969
@table @code
12970
@item Ada (A.2)
12971
This is a parent package for all the standard library packages.  It is
12972
usually included implicitly in your program, and itself contains no
12973
useful data or routines.
12974
 
12975
@item Ada.Calendar (9.6)
12976
@code{Calendar} provides time of day access, and routines for
12977
manipulating times and durations.
12978
 
12979
@item Ada.Characters (A.3.1)
12980
This is a dummy parent package that contains no useful entities
12981
 
12982
@item Ada.Characters.Handling (A.3.2)
12983
This package provides some basic character handling capabilities,
12984
including classification functions for classes of characters (e.g.@: test
12985
for letters, or digits).
12986
 
12987
@item Ada.Characters.Latin_1 (A.3.3)
12988
This package includes a complete set of definitions of the characters
12989
that appear in type CHARACTER@.  It is useful for writing programs that
12990
will run in international environments.  For example, if you want an
12991
upper case E with an acute accent in a string, it is often better to use
12992
the definition of @code{UC_E_Acute} in this package.  Then your program
12993
will print in an understandable manner even if your environment does not
12994
support these extended characters.
12995
 
12996
@item Ada.Command_Line (A.15)
12997
This package provides access to the command line parameters and the name
12998
of the current program (analogous to the use of @code{argc} and @code{argv}
12999
in C), and also allows the exit status for the program to be set in a
13000
system-independent manner.
13001
 
13002
@item Ada.Decimal (F.2)
13003
This package provides constants describing the range of decimal numbers
13004
implemented, and also a decimal divide routine (analogous to the COBOL
13005
verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13006
 
13007
@item Ada.Direct_IO (A.8.4)
13008
This package provides input-output using a model of a set of records of
13009
fixed-length, containing an arbitrary definite Ada type, indexed by an
13010
integer record number.
13011
 
13012
@item Ada.Dynamic_Priorities (D.5)
13013
This package allows the priorities of a task to be adjusted dynamically
13014
as the task is running.
13015
 
13016
@item Ada.Exceptions (11.4.1)
13017
This package provides additional information on exceptions, and also
13018
contains facilities for treating exceptions as data objects, and raising
13019
exceptions with associated messages.
13020
 
13021
@item Ada.Finalization (7.6)
13022
This package contains the declarations and subprograms to support the
13023
use of controlled types, providing for automatic initialization and
13024
finalization (analogous to the constructors and destructors of C++)
13025
 
13026
@item Ada.Interrupts (C.3.2)
13027
This package provides facilities for interfacing to interrupts, which
13028
includes the set of signals or conditions that can be raised and
13029
recognized as interrupts.
13030
 
13031
@item Ada.Interrupts.Names (C.3.2)
13032
This package provides the set of interrupt names (actually signal
13033
or condition names) that can be handled by GNAT@.
13034
 
13035
@item Ada.IO_Exceptions (A.13)
13036
This package defines the set of exceptions that can be raised by use of
13037
the standard IO packages.
13038
 
13039
@item Ada.Numerics
13040
This package contains some standard constants and exceptions used
13041
throughout the numerics packages.  Note that the constants pi and e are
13042
defined here, and it is better to use these definitions than rolling
13043
your own.
13044
 
13045
@item Ada.Numerics.Complex_Elementary_Functions
13046
Provides the implementation of standard elementary functions (such as
13047
log and trigonometric functions) operating on complex numbers using the
13048
standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13049
created by the package @code{Numerics.Complex_Types}.
13050
 
13051
@item Ada.Numerics.Complex_Types
13052
This is a predefined instantiation of
13053
@code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13054
build the type @code{Complex} and @code{Imaginary}.
13055
 
13056
@item Ada.Numerics.Discrete_Random
13057
This generic package provides a random number generator suitable for generating
13058
uniformly distributed values of a specified discrete subtype.
13059
 
13060
@item Ada.Numerics.Float_Random
13061
This package provides a random number generator suitable for generating
13062
uniformly distributed floating point values in the unit interval.
13063
 
13064
@item Ada.Numerics.Generic_Complex_Elementary_Functions
13065
This is a generic version of the package that provides the
13066
implementation of standard elementary functions (such as log and
13067
trigonometric functions) for an arbitrary complex type.
13068
 
13069
The following predefined instantiations of this package are provided:
13070
 
13071
@table @code
13072
@item Short_Float
13073
@code{Ada.Numerics.Short_Complex_Elementary_Functions}
13074
@item Float
13075
@code{Ada.Numerics.Complex_Elementary_Functions}
13076
@item Long_Float
13077
@code{Ada.Numerics.Long_Complex_Elementary_Functions}
13078
@end table
13079
 
13080
@item Ada.Numerics.Generic_Complex_Types
13081
This is a generic package that allows the creation of complex types,
13082
with associated complex arithmetic operations.
13083
 
13084
The following predefined instantiations of this package exist
13085
@table @code
13086
@item Short_Float
13087
@code{Ada.Numerics.Short_Complex_Complex_Types}
13088
@item Float
13089
@code{Ada.Numerics.Complex_Complex_Types}
13090
@item Long_Float
13091
@code{Ada.Numerics.Long_Complex_Complex_Types}
13092
@end table
13093
 
13094
@item Ada.Numerics.Generic_Elementary_Functions
13095
This is a generic package that provides the implementation of standard
13096
elementary functions (such as log an trigonometric functions) for an
13097
arbitrary float type.
13098
 
13099
The following predefined instantiations of this package exist
13100
 
13101
@table @code
13102
@item Short_Float
13103
@code{Ada.Numerics.Short_Elementary_Functions}
13104
@item Float
13105
@code{Ada.Numerics.Elementary_Functions}
13106
@item Long_Float
13107
@code{Ada.Numerics.Long_Elementary_Functions}
13108
@end table
13109
 
13110
@item Ada.Real_Time (D.8)
13111
This package provides facilities similar to those of @code{Calendar}, but
13112
operating with a finer clock suitable for real time control. Note that
13113
annex D requires that there be no backward clock jumps, and GNAT generally
13114
guarantees this behavior, but of course if the external clock on which
13115
the GNAT runtime depends is deliberately reset by some external event,
13116
then such a backward jump may occur.
13117
 
13118
@item Ada.Sequential_IO (A.8.1)
13119
This package provides input-output facilities for sequential files,
13120
which can contain a sequence of values of a single type, which can be
13121
any Ada type, including indefinite (unconstrained) types.
13122
 
13123
@item Ada.Storage_IO (A.9)
13124
This package provides a facility for mapping arbitrary Ada types to and
13125
from a storage buffer.  It is primarily intended for the creation of new
13126
IO packages.
13127
 
13128
@item Ada.Streams (13.13.1)
13129
This is a generic package that provides the basic support for the
13130
concept of streams as used by the stream attributes (@code{Input},
13131
@code{Output}, @code{Read} and @code{Write}).
13132
 
13133
@item Ada.Streams.Stream_IO (A.12.1)
13134
This package is a specialization of the type @code{Streams} defined in
13135
package @code{Streams} together with a set of operations providing
13136
Stream_IO capability.  The Stream_IO model permits both random and
13137
sequential access to a file which can contain an arbitrary set of values
13138
of one or more Ada types.
13139
 
13140
@item Ada.Strings (A.4.1)
13141
This package provides some basic constants used by the string handling
13142
packages.
13143
 
13144
@item Ada.Strings.Bounded (A.4.4)
13145
This package provides facilities for handling variable length
13146
strings.  The bounded model requires a maximum length.  It is thus
13147
somewhat more limited than the unbounded model, but avoids the use of
13148
dynamic allocation or finalization.
13149
 
13150
@item Ada.Strings.Fixed (A.4.3)
13151
This package provides facilities for handling fixed length strings.
13152
 
13153
@item Ada.Strings.Maps (A.4.2)
13154
This package provides facilities for handling character mappings and
13155
arbitrarily defined subsets of characters.  For instance it is useful in
13156
defining specialized translation tables.
13157
 
13158
@item Ada.Strings.Maps.Constants (A.4.6)
13159
This package provides a standard set of predefined mappings and
13160
predefined character sets.  For example, the standard upper to lower case
13161
conversion table is found in this package.  Note that upper to lower case
13162
conversion is non-trivial if you want to take the entire set of
13163
characters, including extended characters like E with an acute accent,
13164
into account.  You should use the mappings in this package (rather than
13165
adding 32 yourself) to do case mappings.
13166
 
13167
@item Ada.Strings.Unbounded (A.4.5)
13168
This package provides facilities for handling variable length
13169
strings.  The unbounded model allows arbitrary length strings, but
13170
requires the use of dynamic allocation and finalization.
13171
 
13172
@item Ada.Strings.Wide_Bounded (A.4.7)
13173
@itemx Ada.Strings.Wide_Fixed (A.4.7)
13174
@itemx Ada.Strings.Wide_Maps (A.4.7)
13175
@itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13176
@itemx Ada.Strings.Wide_Unbounded (A.4.7)
13177
These packages provide analogous capabilities to the corresponding
13178
packages without @samp{Wide_} in the name, but operate with the types
13179
@code{Wide_String} and @code{Wide_Character} instead of @code{String}
13180
and @code{Character}.
13181
 
13182
@item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13183
@itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13184
@itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13185
@itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13186
@itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13187
These packages provide analogous capabilities to the corresponding
13188
packages without @samp{Wide_} in the name, but operate with the types
13189
@code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13190
of @code{String} and @code{Character}.
13191
 
13192
@item Ada.Synchronous_Task_Control (D.10)
13193
This package provides some standard facilities for controlling task
13194
communication in a synchronous manner.
13195
 
13196
@item Ada.Tags
13197
This package contains definitions for manipulation of the tags of tagged
13198
values.
13199
 
13200
@item Ada.Task_Attributes
13201
This package provides the capability of associating arbitrary
13202
task-specific data with separate tasks.
13203
 
13204
@item Ada.Text_IO
13205
This package provides basic text input-output capabilities for
13206
character, string and numeric data.  The subpackages of this
13207
package are listed next.
13208
 
13209
@item Ada.Text_IO.Decimal_IO
13210
Provides input-output facilities for decimal fixed-point types
13211
 
13212
@item Ada.Text_IO.Enumeration_IO
13213
Provides input-output facilities for enumeration types.
13214
 
13215
@item Ada.Text_IO.Fixed_IO
13216
Provides input-output facilities for ordinary fixed-point types.
13217
 
13218
@item Ada.Text_IO.Float_IO
13219
Provides input-output facilities for float types.  The following
13220
predefined instantiations of this generic package are available:
13221
 
13222
@table @code
13223
@item Short_Float
13224
@code{Short_Float_Text_IO}
13225
@item Float
13226
@code{Float_Text_IO}
13227
@item Long_Float
13228
@code{Long_Float_Text_IO}
13229
@end table
13230
 
13231
@item Ada.Text_IO.Integer_IO
13232
Provides input-output facilities for integer types.  The following
13233
predefined instantiations of this generic package are available:
13234
 
13235
@table @code
13236
@item Short_Short_Integer
13237
@code{Ada.Short_Short_Integer_Text_IO}
13238
@item Short_Integer
13239
@code{Ada.Short_Integer_Text_IO}
13240
@item Integer
13241
@code{Ada.Integer_Text_IO}
13242
@item Long_Integer
13243
@code{Ada.Long_Integer_Text_IO}
13244
@item Long_Long_Integer
13245
@code{Ada.Long_Long_Integer_Text_IO}
13246
@end table
13247
 
13248
@item Ada.Text_IO.Modular_IO
13249
Provides input-output facilities for modular (unsigned) types
13250
 
13251
@item Ada.Text_IO.Complex_IO (G.1.3)
13252
This package provides basic text input-output capabilities for complex
13253
data.
13254
 
13255
@item Ada.Text_IO.Editing (F.3.3)
13256
This package contains routines for edited output, analogous to the use
13257
of pictures in COBOL@.  The picture formats used by this package are a
13258
close copy of the facility in COBOL@.
13259
 
13260
@item Ada.Text_IO.Text_Streams (A.12.2)
13261
This package provides a facility that allows Text_IO files to be treated
13262
as streams, so that the stream attributes can be used for writing
13263
arbitrary data, including binary data, to Text_IO files.
13264
 
13265
@item Ada.Unchecked_Conversion (13.9)
13266
This generic package allows arbitrary conversion from one type to
13267
another of the same size, providing for breaking the type safety in
13268
special circumstances.
13269
 
13270
If the types have the same Size (more accurately the same Value_Size),
13271
then the effect is simply to transfer the bits from the source to the
13272
target type without any modification.  This usage is well defined, and
13273
for simple types whose representation is typically the same across
13274
all implementations, gives a portable method of performing such
13275
conversions.
13276
 
13277
If the types do not have the same size, then the result is implementation
13278
defined, and thus may be non-portable.  The following describes how GNAT
13279
handles such unchecked conversion cases.
13280
 
13281
If the types are of different sizes, and are both discrete types, then
13282
the effect is of a normal type conversion without any constraint checking.
13283
In particular if the result type has a larger size, the result will be
13284
zero or sign extended.  If the result type has a smaller size, the result
13285
will be truncated by ignoring high order bits.
13286
 
13287
If the types are of different sizes, and are not both discrete types,
13288
then the conversion works as though pointers were created to the source
13289
and target, and the pointer value is converted.  The effect is that bits
13290
are copied from successive low order storage units and bits of the source
13291
up to the length of the target type.
13292
 
13293
A warning is issued if the lengths differ, since the effect in this
13294
case is implementation dependent, and the above behavior may not match
13295
that of some other compiler.
13296
 
13297
A pointer to one type may be converted to a pointer to another type using
13298
unchecked conversion.  The only case in which the effect is undefined is
13299
when one or both pointers are pointers to unconstrained array types.  In
13300
this case, the bounds information may get incorrectly transferred, and in
13301
particular, GNAT uses double size pointers for such types, and it is
13302
meaningless to convert between such pointer types.  GNAT will issue a
13303
warning if the alignment of the target designated type is more strict
13304
than the alignment of the source designated type (since the result may
13305
be unaligned in this case).
13306
 
13307
A pointer other than a pointer to an unconstrained array type may be
13308
converted to and from System.Address.  Such usage is common in Ada 83
13309
programs, but note that Ada.Address_To_Access_Conversions is the
13310
preferred method of performing such conversions in Ada 95 and Ada 2005.
13311
Neither
13312
unchecked conversion nor Ada.Address_To_Access_Conversions should be
13313
used in conjunction with pointers to unconstrained objects, since
13314
the bounds information cannot be handled correctly in this case.
13315
 
13316
@item Ada.Unchecked_Deallocation (13.11.2)
13317
This generic package allows explicit freeing of storage previously
13318
allocated by use of an allocator.
13319
 
13320
@item Ada.Wide_Text_IO (A.11)
13321
This package is similar to @code{Ada.Text_IO}, except that the external
13322
file supports wide character representations, and the internal types are
13323
@code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13324
and @code{String}.  It contains generic subpackages listed next.
13325
 
13326
@item Ada.Wide_Text_IO.Decimal_IO
13327
Provides input-output facilities for decimal fixed-point types
13328
 
13329
@item Ada.Wide_Text_IO.Enumeration_IO
13330
Provides input-output facilities for enumeration types.
13331
 
13332
@item Ada.Wide_Text_IO.Fixed_IO
13333
Provides input-output facilities for ordinary fixed-point types.
13334
 
13335
@item Ada.Wide_Text_IO.Float_IO
13336
Provides input-output facilities for float types.  The following
13337
predefined instantiations of this generic package are available:
13338
 
13339
@table @code
13340
@item Short_Float
13341
@code{Short_Float_Wide_Text_IO}
13342
@item Float
13343
@code{Float_Wide_Text_IO}
13344
@item Long_Float
13345
@code{Long_Float_Wide_Text_IO}
13346
@end table
13347
 
13348
@item Ada.Wide_Text_IO.Integer_IO
13349
Provides input-output facilities for integer types.  The following
13350
predefined instantiations of this generic package are available:
13351
 
13352
@table @code
13353
@item Short_Short_Integer
13354
@code{Ada.Short_Short_Integer_Wide_Text_IO}
13355
@item Short_Integer
13356
@code{Ada.Short_Integer_Wide_Text_IO}
13357
@item Integer
13358
@code{Ada.Integer_Wide_Text_IO}
13359
@item Long_Integer
13360
@code{Ada.Long_Integer_Wide_Text_IO}
13361
@item Long_Long_Integer
13362
@code{Ada.Long_Long_Integer_Wide_Text_IO}
13363
@end table
13364
 
13365
@item Ada.Wide_Text_IO.Modular_IO
13366
Provides input-output facilities for modular (unsigned) types
13367
 
13368
@item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13369
This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13370
external file supports wide character representations.
13371
 
13372
@item Ada.Wide_Text_IO.Editing (F.3.4)
13373
This package is similar to @code{Ada.Text_IO.Editing}, except that the
13374
types are @code{Wide_Character} and @code{Wide_String} instead of
13375
@code{Character} and @code{String}.
13376
 
13377
@item Ada.Wide_Text_IO.Streams (A.12.3)
13378
This package is similar to @code{Ada.Text_IO.Streams}, except that the
13379
types are @code{Wide_Character} and @code{Wide_String} instead of
13380
@code{Character} and @code{String}.
13381
 
13382
@item Ada.Wide_Wide_Text_IO (A.11)
13383
This package is similar to @code{Ada.Text_IO}, except that the external
13384
file supports wide character representations, and the internal types are
13385
@code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13386
and @code{String}.  It contains generic subpackages listed next.
13387
 
13388
@item Ada.Wide_Wide_Text_IO.Decimal_IO
13389
Provides input-output facilities for decimal fixed-point types
13390
 
13391
@item Ada.Wide_Wide_Text_IO.Enumeration_IO
13392
Provides input-output facilities for enumeration types.
13393
 
13394
@item Ada.Wide_Wide_Text_IO.Fixed_IO
13395
Provides input-output facilities for ordinary fixed-point types.
13396
 
13397
@item Ada.Wide_Wide_Text_IO.Float_IO
13398
Provides input-output facilities for float types.  The following
13399
predefined instantiations of this generic package are available:
13400
 
13401
@table @code
13402
@item Short_Float
13403
@code{Short_Float_Wide_Wide_Text_IO}
13404
@item Float
13405
@code{Float_Wide_Wide_Text_IO}
13406
@item Long_Float
13407
@code{Long_Float_Wide_Wide_Text_IO}
13408
@end table
13409
 
13410
@item Ada.Wide_Wide_Text_IO.Integer_IO
13411
Provides input-output facilities for integer types.  The following
13412
predefined instantiations of this generic package are available:
13413
 
13414
@table @code
13415
@item Short_Short_Integer
13416
@code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13417
@item Short_Integer
13418
@code{Ada.Short_Integer_Wide_Wide_Text_IO}
13419
@item Integer
13420
@code{Ada.Integer_Wide_Wide_Text_IO}
13421
@item Long_Integer
13422
@code{Ada.Long_Integer_Wide_Wide_Text_IO}
13423
@item Long_Long_Integer
13424
@code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13425
@end table
13426
 
13427
@item Ada.Wide_Wide_Text_IO.Modular_IO
13428
Provides input-output facilities for modular (unsigned) types
13429
 
13430
@item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13431
This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13432
external file supports wide character representations.
13433
 
13434
@item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13435
This package is similar to @code{Ada.Text_IO.Editing}, except that the
13436
types are @code{Wide_Character} and @code{Wide_String} instead of
13437
@code{Character} and @code{String}.
13438
 
13439
@item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13440
This package is similar to @code{Ada.Text_IO.Streams}, except that the
13441
types are @code{Wide_Character} and @code{Wide_String} instead of
13442
@code{Character} and @code{String}.
13443
@end table
13444
 
13445
@node The Implementation of Standard I/O
13446
@chapter The Implementation of Standard I/O
13447
 
13448
@noindent
13449
GNAT implements all the required input-output facilities described in
13450
A.6 through A.14.  These sections of the Ada Reference Manual describe the
13451
required behavior of these packages from the Ada point of view, and if
13452
you are writing a portable Ada program that does not need to know the
13453
exact manner in which Ada maps to the outside world when it comes to
13454
reading or writing external files, then you do not need to read this
13455
chapter.  As long as your files are all regular files (not pipes or
13456
devices), and as long as you write and read the files only from Ada, the
13457
description in the Ada Reference Manual is sufficient.
13458
 
13459
However, if you want to do input-output to pipes or other devices, such
13460
as the keyboard or screen, or if the files you are dealing with are
13461
either generated by some other language, or to be read by some other
13462
language, then you need to know more about the details of how the GNAT
13463
implementation of these input-output facilities behaves.
13464
 
13465
In this chapter we give a detailed description of exactly how GNAT
13466
interfaces to the file system.  As always, the sources of the system are
13467
available to you for answering questions at an even more detailed level,
13468
but for most purposes the information in this chapter will suffice.
13469
 
13470
Another reason that you may need to know more about how input-output is
13471
implemented arises when you have a program written in mixed languages
13472
where, for example, files are shared between the C and Ada sections of
13473
the same program.  GNAT provides some additional facilities, in the form
13474
of additional child library packages, that facilitate this sharing, and
13475
these additional facilities are also described in this chapter.
13476
 
13477
@menu
13478
* Standard I/O Packages::
13479
* FORM Strings::
13480
* Direct_IO::
13481
* Sequential_IO::
13482
* Text_IO::
13483
* Wide_Text_IO::
13484
* Wide_Wide_Text_IO::
13485
* Stream_IO::
13486
* Text Translation::
13487
* Shared Files::
13488
* Filenames encoding::
13489
* Open Modes::
13490
* Operations on C Streams::
13491
* Interfacing to C Streams::
13492
@end menu
13493
 
13494
@node Standard I/O Packages
13495
@section Standard I/O Packages
13496
 
13497
@noindent
13498
The Standard I/O packages described in Annex A for
13499
 
13500
@itemize @bullet
13501
@item
13502
Ada.Text_IO
13503
@item
13504
Ada.Text_IO.Complex_IO
13505
@item
13506
Ada.Text_IO.Text_Streams
13507
@item
13508
Ada.Wide_Text_IO
13509
@item
13510
Ada.Wide_Text_IO.Complex_IO
13511
@item
13512
Ada.Wide_Text_IO.Text_Streams
13513
@item
13514
Ada.Wide_Wide_Text_IO
13515
@item
13516
Ada.Wide_Wide_Text_IO.Complex_IO
13517
@item
13518
Ada.Wide_Wide_Text_IO.Text_Streams
13519
@item
13520
Ada.Stream_IO
13521
@item
13522
Ada.Sequential_IO
13523
@item
13524
Ada.Direct_IO
13525
@end itemize
13526
 
13527
@noindent
13528
are implemented using the C
13529
library streams facility; where
13530
 
13531
@itemize @bullet
13532
@item
13533
All files are opened using @code{fopen}.
13534
@item
13535
All input/output operations use @code{fread}/@code{fwrite}.
13536
@end itemize
13537
 
13538
@noindent
13539
There is no internal buffering of any kind at the Ada library level. The only
13540
buffering is that provided at the system level in the implementation of the
13541
library routines that support streams. This facilitates shared use of these
13542
streams by mixed language programs. Note though that system level buffering is
13543
explicitly enabled at elaboration of the standard I/O packages and that can
13544
have an impact on mixed language programs, in particular those using I/O before
13545
calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13546
the Ada elaboration routine before performing any I/O or when impractical,
13547
flush the common I/O streams and in particular Standard_Output before
13548
elaborating the Ada code.
13549
 
13550
@node FORM Strings
13551
@section FORM Strings
13552
 
13553
@noindent
13554
The format of a FORM string in GNAT is:
13555
 
13556
@smallexample
13557
"keyword=value,keyword=value,@dots{},keyword=value"
13558
@end smallexample
13559
 
13560
@noindent
13561
where letters may be in upper or lower case, and there are no spaces
13562
between values.  The order of the entries is not important.  Currently
13563
the following keywords defined.
13564
 
13565
@smallexample
13566
TEXT_TRANSLATION=[YES|NO]
13567
SHARED=[YES|NO]
13568
WCEM=[n|h|u|s|e|8|b]
13569
ENCODING=[UTF8|8BITS]
13570
@end smallexample
13571
 
13572
@noindent
13573
The use of these parameters is described later in this section.
13574
 
13575
@node Direct_IO
13576
@section Direct_IO
13577
 
13578
@noindent
13579
Direct_IO can only be instantiated for definite types.  This is a
13580
restriction of the Ada language, which means that the records are fixed
13581
length (the length being determined by @code{@var{type}'Size}, rounded
13582
up to the next storage unit boundary if necessary).
13583
 
13584
The records of a Direct_IO file are simply written to the file in index
13585
sequence, with the first record starting at offset zero, and subsequent
13586
records following.  There is no control information of any kind.  For
13587
example, if 32-bit integers are being written, each record takes
13588
4-bytes, so the record at index @var{K} starts at offset
13589
(@var{K}@minus{}1)*4.
13590
 
13591
There is no limit on the size of Direct_IO files, they are expanded as
13592
necessary to accommodate whatever records are written to the file.
13593
 
13594
@node Sequential_IO
13595
@section Sequential_IO
13596
 
13597
@noindent
13598
Sequential_IO may be instantiated with either a definite (constrained)
13599
or indefinite (unconstrained) type.
13600
 
13601
For the definite type case, the elements written to the file are simply
13602
the memory images of the data values with no control information of any
13603
kind.  The resulting file should be read using the same type, no validity
13604
checking is performed on input.
13605
 
13606
For the indefinite type case, the elements written consist of two
13607
parts.  First is the size of the data item, written as the memory image
13608
of a @code{Interfaces.C.size_t} value, followed by the memory image of
13609
the data value.  The resulting file can only be read using the same
13610
(unconstrained) type.  Normal assignment checks are performed on these
13611
read operations, and if these checks fail, @code{Data_Error} is
13612
raised.  In particular, in the array case, the lengths must match, and in
13613
the variant record case, if the variable for a particular read operation
13614
is constrained, the discriminants must match.
13615
 
13616
Note that it is not possible to use Sequential_IO to write variable
13617
length array items, and then read the data back into different length
13618
arrays.  For example, the following will raise @code{Data_Error}:
13619
 
13620
@smallexample @c ada
13621
 package IO is new Sequential_IO (String);
13622
 F : IO.File_Type;
13623
 S : String (1..4);
13624
 @dots{}
13625
 IO.Create (F)
13626
 IO.Write (F, "hello!")
13627
 IO.Reset (F, Mode=>In_File);
13628
 IO.Read (F, S);
13629
 Put_Line (S);
13630
 
13631
@end smallexample
13632
 
13633
@noindent
13634
On some Ada implementations, this will print @code{hell}, but the program is
13635
clearly incorrect, since there is only one element in the file, and that
13636
element is the string @code{hello!}.
13637
 
13638
In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13639
using Stream_IO, and this is the preferred mechanism.  In particular, the
13640
above program fragment rewritten to use Stream_IO will work correctly.
13641
 
13642
@node Text_IO
13643
@section Text_IO
13644
 
13645
@noindent
13646
Text_IO files consist of a stream of characters containing the following
13647
special control characters:
13648
 
13649
@smallexample
13650
LF (line feed, 16#0A#) Line Mark
13651
FF (form feed, 16#0C#) Page Mark
13652
@end smallexample
13653
 
13654
@noindent
13655
A canonical Text_IO file is defined as one in which the following
13656
conditions are met:
13657
 
13658
@itemize @bullet
13659
@item
13660
The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13661
of the line.
13662
 
13663
@item
13664
The character @code{FF} is used only as a page mark, i.e.@: to mark the
13665
end of a page and consequently can appear only immediately following a
13666
@code{LF} (line mark) character.
13667
 
13668
@item
13669
The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13670
(line mark, page mark).  In the former case, the page mark is implicitly
13671
assumed to be present.
13672
@end itemize
13673
 
13674
@noindent
13675
A file written using Text_IO will be in canonical form provided that no
13676
explicit @code{LF} or @code{FF} characters are written using @code{Put}
13677
or @code{Put_Line}.  There will be no @code{FF} character at the end of
13678
the file unless an explicit @code{New_Page} operation was performed
13679
before closing the file.
13680
 
13681
A canonical Text_IO file that is a regular file (i.e., not a device or a
13682
pipe) can be read using any of the routines in Text_IO@.  The
13683
semantics in this case will be exactly as defined in the Ada Reference
13684
Manual, and all the routines in Text_IO are fully implemented.
13685
 
13686
A text file that does not meet the requirements for a canonical Text_IO
13687
file has one of the following:
13688
 
13689
@itemize @bullet
13690
@item
13691
The file contains @code{FF} characters not immediately following a
13692
@code{LF} character.
13693
 
13694
@item
13695
The file contains @code{LF} or @code{FF} characters written by
13696
@code{Put} or @code{Put_Line}, which are not logically considered to be
13697
line marks or page marks.
13698
 
13699
@item
13700
The file ends in a character other than @code{LF} or @code{FF},
13701
i.e.@: there is no explicit line mark or page mark at the end of the file.
13702
@end itemize
13703
 
13704
@noindent
13705
Text_IO can be used to read such non-standard text files but subprograms
13706
to do with line or page numbers do not have defined meanings.  In
13707
particular, a @code{FF} character that does not follow a @code{LF}
13708
character may or may not be treated as a page mark from the point of
13709
view of page and line numbering.  Every @code{LF} character is considered
13710
to end a line, and there is an implied @code{LF} character at the end of
13711
the file.
13712
 
13713
@menu
13714
* Text_IO Stream Pointer Positioning::
13715
* Text_IO Reading and Writing Non-Regular Files::
13716
* Get_Immediate::
13717
* Treating Text_IO Files as Streams::
13718
* Text_IO Extensions::
13719
* Text_IO Facilities for Unbounded Strings::
13720
@end menu
13721
 
13722
@node Text_IO Stream Pointer Positioning
13723
@subsection Stream Pointer Positioning
13724
 
13725
@noindent
13726
@code{Ada.Text_IO} has a definition of current position for a file that
13727
is being read.  No internal buffering occurs in Text_IO, and usually the
13728
physical position in the stream used to implement the file corresponds
13729
to this logical position defined by Text_IO@.  There are two exceptions:
13730
 
13731
@itemize @bullet
13732
@item
13733
After a call to @code{End_Of_Page} that returns @code{True}, the stream
13734
is positioned past the @code{LF} (line mark) that precedes the page
13735
mark.  Text_IO maintains an internal flag so that subsequent read
13736
operations properly handle the logical position which is unchanged by
13737
the @code{End_Of_Page} call.
13738
 
13739
@item
13740
After a call to @code{End_Of_File} that returns @code{True}, if the
13741
Text_IO file was positioned before the line mark at the end of file
13742
before the call, then the logical position is unchanged, but the stream
13743
is physically positioned right at the end of file (past the line mark,
13744
and past a possible page mark following the line mark.  Again Text_IO
13745
maintains internal flags so that subsequent read operations properly
13746
handle the logical position.
13747
@end itemize
13748
 
13749
@noindent
13750
These discrepancies have no effect on the observable behavior of
13751
Text_IO, but if a single Ada stream is shared between a C program and
13752
Ada program, or shared (using @samp{shared=yes} in the form string)
13753
between two Ada files, then the difference may be observable in some
13754
situations.
13755
 
13756
@node Text_IO Reading and Writing Non-Regular Files
13757
@subsection Reading and Writing Non-Regular Files
13758
 
13759
@noindent
13760
A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
13761
can be used for reading and writing.  Writing is not affected and the
13762
sequence of characters output is identical to the normal file case, but
13763
for reading, the behavior of Text_IO is modified to avoid undesirable
13764
look-ahead as follows:
13765
 
13766
An input file that is not a regular file is considered to have no page
13767
marks.  Any @code{Ascii.FF} characters (the character normally used for a
13768
page mark) appearing in the file are considered to be data
13769
characters.  In particular:
13770
 
13771
@itemize @bullet
13772
@item
13773
@code{Get_Line} and @code{Skip_Line} do not test for a page mark
13774
following a line mark.  If a page mark appears, it will be treated as a
13775
data character.
13776
 
13777
@item
13778
This avoids the need to wait for an extra character to be typed or
13779
entered from the pipe to complete one of these operations.
13780
 
13781
@item
13782
@code{End_Of_Page} always returns @code{False}
13783
 
13784
@item
13785
@code{End_Of_File} will return @code{False} if there is a page mark at
13786
the end of the file.
13787
@end itemize
13788
 
13789
@noindent
13790
Output to non-regular files is the same as for regular files.  Page marks
13791
may be written to non-regular files using @code{New_Page}, but as noted
13792
above they will not be treated as page marks on input if the output is
13793
piped to another Ada program.
13794
 
13795
Another important discrepancy when reading non-regular files is that the end
13796
of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
13797
pressing the @key{EOT} key,
13798
then end of file
13799
is signaled once (i.e.@: the test @code{End_Of_File}
13800
will yield @code{True}, or a read will
13801
raise @code{End_Error}), but then reading can resume
13802
to read data past that end of
13803
file indication, until another end of file indication is entered.
13804
 
13805
@node Get_Immediate
13806
@subsection Get_Immediate
13807
@cindex Get_Immediate
13808
 
13809
@noindent
13810
Get_Immediate returns the next character (including control characters)
13811
from the input file.  In particular, Get_Immediate will return LF or FF
13812
characters used as line marks or page marks.  Such operations leave the
13813
file positioned past the control character, and it is thus not treated
13814
as having its normal function.  This means that page, line and column
13815
counts after this kind of Get_Immediate call are set as though the mark
13816
did not occur.  In the case where a Get_Immediate leaves the file
13817
positioned between the line mark and page mark (which is not normally
13818
possible), it is undefined whether the FF character will be treated as a
13819
page mark.
13820
 
13821
@node Treating Text_IO Files as Streams
13822
@subsection Treating Text_IO Files as Streams
13823
@cindex Stream files
13824
 
13825
@noindent
13826
The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13827
as a stream.  Data written to a Text_IO file in this stream mode is
13828
binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
13829
16#0C# (@code{FF}), the resulting file may have non-standard
13830
format.  Similarly if read operations are used to read from a Text_IO
13831
file treated as a stream, then @code{LF} and @code{FF} characters may be
13832
skipped and the effect is similar to that described above for
13833
@code{Get_Immediate}.
13834
 
13835
@node Text_IO Extensions
13836
@subsection Text_IO Extensions
13837
@cindex Text_IO extensions
13838
 
13839
@noindent
13840
A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13841
to the standard @code{Text_IO} package:
13842
 
13843
@itemize @bullet
13844
@item function File_Exists (Name : String) return Boolean;
13845
Determines if a file of the given name exists.
13846
 
13847
@item function Get_Line return String;
13848
Reads a string from the standard input file.  The value returned is exactly
13849
the length of the line that was read.
13850
 
13851
@item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13852
Similar, except that the parameter File specifies the file from which
13853
the string is to be read.
13854
 
13855
@end itemize
13856
 
13857
@node Text_IO Facilities for Unbounded Strings
13858
@subsection Text_IO Facilities for Unbounded Strings
13859
@cindex Text_IO for unbounded strings
13860
@cindex Unbounded_String, Text_IO operations
13861
 
13862
@noindent
13863
The package @code{Ada.Strings.Unbounded.Text_IO}
13864
in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13865
subprograms useful for Text_IO operations on unbounded strings:
13866
 
13867
@itemize @bullet
13868
 
13869
@item function Get_Line (File : File_Type) return Unbounded_String;
13870
Reads a line from the specified file
13871
and returns the result as an unbounded string.
13872
 
13873
@item procedure Put (File : File_Type; U : Unbounded_String);
13874
Writes the value of the given unbounded string to the specified file
13875
Similar to the effect of
13876
@code{Put (To_String (U))} except that an extra copy is avoided.
13877
 
13878
@item procedure Put_Line (File : File_Type; U : Unbounded_String);
13879
Writes the value of the given unbounded string to the specified file,
13880
followed by a @code{New_Line}.
13881
Similar to the effect of @code{Put_Line (To_String (U))} except
13882
that an extra copy is avoided.
13883
@end itemize
13884
 
13885
@noindent
13886
In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13887
and is optional.  If the parameter is omitted, then the standard input or
13888
output file is referenced as appropriate.
13889
 
13890
The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13891
files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13892
@code{Wide_Text_IO} functionality for unbounded wide strings.
13893
 
13894
The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13895
files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13896
@code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13897
 
13898
@node Wide_Text_IO
13899
@section Wide_Text_IO
13900
 
13901
@noindent
13902
@code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13903
both input and output files may contain special sequences that represent
13904
wide character values.  The encoding scheme for a given file may be
13905
specified using a FORM parameter:
13906
 
13907
@smallexample
13908
WCEM=@var{x}
13909
@end smallexample
13910
 
13911
@noindent
13912
as part of the FORM string (WCEM = wide character encoding method),
13913
where @var{x} is one of the following characters
13914
 
13915
@table @samp
13916
@item h
13917
Hex ESC encoding
13918
@item u
13919
Upper half encoding
13920
@item s
13921
Shift-JIS encoding
13922
@item e
13923
EUC Encoding
13924
@item 8
13925
UTF-8 encoding
13926
@item b
13927
Brackets encoding
13928
@end table
13929
 
13930
@noindent
13931
The encoding methods match those that
13932
can be used in a source
13933
program, but there is no requirement that the encoding method used for
13934
the source program be the same as the encoding method used for files,
13935
and different files may use different encoding methods.
13936
 
13937
The default encoding method for the standard files, and for opened files
13938
for which no WCEM parameter is given in the FORM string matches the
13939
wide character encoding specified for the main program (the default
13940
being brackets encoding if no coding method was specified with -gnatW).
13941
 
13942
@table @asis
13943
@item Hex Coding
13944
In this encoding, a wide character is represented by a five character
13945
sequence:
13946
 
13947
@smallexample
13948
ESC a b c d
13949
@end smallexample
13950
 
13951
@noindent
13952
where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13953
characters (using upper case letters) of the wide character code.  For
13954
example, ESC A345 is used to represent the wide character with code
13955
16#A345#.  This scheme is compatible with use of the full
13956
@code{Wide_Character} set.
13957
 
13958
@item Upper Half Coding
13959
The wide character with encoding 16#abcd#, where the upper bit is on
13960
(i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13961
16#cd#.  The second byte may never be a format control character, but is
13962
not required to be in the upper half.  This method can be also used for
13963
shift-JIS or EUC where the internal coding matches the external coding.
13964
 
13965
@item Shift JIS Coding
13966
A wide character is represented by a two character sequence 16#ab# and
13967
16#cd#, with the restrictions described for upper half encoding as
13968
described above.  The internal character code is the corresponding JIS
13969
character according to the standard algorithm for Shift-JIS
13970
conversion.  Only characters defined in the JIS code set table can be
13971
used with this encoding method.
13972
 
13973
@item EUC Coding
13974
A wide character is represented by a two character sequence 16#ab# and
13975
16#cd#, with both characters being in the upper half.  The internal
13976
character code is the corresponding JIS character according to the EUC
13977
encoding algorithm.  Only characters defined in the JIS code set table
13978
can be used with this encoding method.
13979
 
13980
@item UTF-8 Coding
13981
A wide character is represented using
13982
UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13983
10646-1/Am.2.  Depending on the character value, the representation
13984
is a one, two, or three byte sequence:
13985
 
13986
@smallexample
13987
16#0000#-16#007f#: 2#0xxxxxxx#
13988
16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13989
16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13990
@end smallexample
13991
 
13992
@noindent
13993
where the @var{xxx} bits correspond to the left-padded bits of the
13994
16-bit character value.  Note that all lower half ASCII characters
13995
are represented as ASCII bytes and all upper half characters and
13996
other wide characters are represented as sequences of upper-half
13997
(The full UTF-8 scheme allows for encoding 31-bit characters as
13998
6-byte sequences, but in this implementation, all UTF-8 sequences
13999
of four or more bytes length will raise a Constraint_Error, as
14000
will all invalid UTF-8 sequences.)
14001
 
14002
@item Brackets Coding
14003
In this encoding, a wide character is represented by the following eight
14004
character sequence:
14005
 
14006
@smallexample
14007
[ " a b c d " ]
14008
@end smallexample
14009
 
14010
@noindent
14011
where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14012
characters (using uppercase letters) of the wide character code.  For
14013
example, @code{["A345"]} is used to represent the wide character with code
14014
@code{16#A345#}.
14015
This scheme is compatible with use of the full Wide_Character set.
14016
On input, brackets coding can also be used for upper half characters,
14017
e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
14018
is only used for wide characters with a code greater than @code{16#FF#}.
14019
 
14020
Note that brackets coding is not normally used in the context of
14021
Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14022
a portable way of encoding source files. In the context of Wide_Text_IO
14023
or Wide_Wide_Text_IO, it can only be used if the file does not contain
14024
any instance of the left bracket character other than to encode wide
14025
character values using the brackets encoding method. In practice it is
14026
expected that some standard wide character encoding method such
14027
as UTF-8 will be used for text input output.
14028
 
14029
If brackets notation is used, then any occurrence of a left bracket
14030
in the input file which is not the start of a valid wide character
14031
sequence will cause Constraint_Error to be raised. It is possible to
14032
encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14033
input will interpret this as a left bracket.
14034
 
14035
However, when a left bracket is output, it will be output as a left bracket
14036
and not as ["5B"]. We make this decision because for normal use of
14037
Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14038
brackets. For example, if we write:
14039
 
14040
@smallexample
14041
   Put_Line ("Start of output [first run]");
14042
@end smallexample
14043
 
14044
@noindent
14045
we really do not want to have the left bracket in this message clobbered so
14046
that the output reads:
14047
 
14048
@smallexample
14049
   Start of output ["5B"]first run]
14050
@end smallexample
14051
 
14052
@noindent
14053
In practice brackets encoding is reasonably useful for normal Put_Line use
14054
since we won't get confused between left brackets and wide character
14055
sequences in the output. But for input, or when files are written out
14056
and read back in, it really makes better sense to use one of the standard
14057
encoding methods such as UTF-8.
14058
 
14059
@end table
14060
 
14061
@noindent
14062
For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14063
not all wide character
14064
values can be represented.  An attempt to output a character that cannot
14065
be represented using the encoding scheme for the file causes
14066
Constraint_Error to be raised.  An invalid wide character sequence on
14067
input also causes Constraint_Error to be raised.
14068
 
14069
@menu
14070
* Wide_Text_IO Stream Pointer Positioning::
14071
* Wide_Text_IO Reading and Writing Non-Regular Files::
14072
@end menu
14073
 
14074
@node Wide_Text_IO Stream Pointer Positioning
14075
@subsection Stream Pointer Positioning
14076
 
14077
@noindent
14078
@code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14079
of stream pointer positioning (@pxref{Text_IO}).  There is one additional
14080
case:
14081
 
14082
If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14083
normal lower ASCII set (i.e.@: a character in the range:
14084
 
14085
@smallexample @c ada
14086
Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14087
@end smallexample
14088
 
14089
@noindent
14090
then although the logical position of the file pointer is unchanged by
14091
the @code{Look_Ahead} call, the stream is physically positioned past the
14092
wide character sequence.  Again this is to avoid the need for buffering
14093
or backup, and all @code{Wide_Text_IO} routines check the internal
14094
indication that this situation has occurred so that this is not visible
14095
to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
14096
can be observed if the wide text file shares a stream with another file.
14097
 
14098
@node Wide_Text_IO Reading and Writing Non-Regular Files
14099
@subsection Reading and Writing Non-Regular Files
14100
 
14101
@noindent
14102
As in the case of Text_IO, when a non-regular file is read, it is
14103
assumed that the file contains no page marks (any form characters are
14104
treated as data characters), and @code{End_Of_Page} always returns
14105
@code{False}.  Similarly, the end of file indication is not sticky, so
14106
it is possible to read beyond an end of file.
14107
 
14108
@node Wide_Wide_Text_IO
14109
@section Wide_Wide_Text_IO
14110
 
14111
@noindent
14112
@code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14113
both input and output files may contain special sequences that represent
14114
wide wide character values.  The encoding scheme for a given file may be
14115
specified using a FORM parameter:
14116
 
14117
@smallexample
14118
WCEM=@var{x}
14119
@end smallexample
14120
 
14121
@noindent
14122
as part of the FORM string (WCEM = wide character encoding method),
14123
where @var{x} is one of the following characters
14124
 
14125
@table @samp
14126
@item h
14127
Hex ESC encoding
14128
@item u
14129
Upper half encoding
14130
@item s
14131
Shift-JIS encoding
14132
@item e
14133
EUC Encoding
14134
@item 8
14135
UTF-8 encoding
14136
@item b
14137
Brackets encoding
14138
@end table
14139
 
14140
@noindent
14141
The encoding methods match those that
14142
can be used in a source
14143
program, but there is no requirement that the encoding method used for
14144
the source program be the same as the encoding method used for files,
14145
and different files may use different encoding methods.
14146
 
14147
The default encoding method for the standard files, and for opened files
14148
for which no WCEM parameter is given in the FORM string matches the
14149
wide character encoding specified for the main program (the default
14150
being brackets encoding if no coding method was specified with -gnatW).
14151
 
14152
@table @asis
14153
 
14154
@item UTF-8 Coding
14155
A wide character is represented using
14156
UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14157
10646-1/Am.2.  Depending on the character value, the representation
14158
is a one, two, three, or four byte sequence:
14159
 
14160
@smallexample
14161
16#000000#-16#00007f#: 2#0xxxxxxx#
14162
16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14163
16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14164
16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14165
@end smallexample
14166
 
14167
@noindent
14168
where the @var{xxx} bits correspond to the left-padded bits of the
14169
21-bit character value.  Note that all lower half ASCII characters
14170
are represented as ASCII bytes and all upper half characters and
14171
other wide characters are represented as sequences of upper-half
14172
characters.
14173
 
14174
@item Brackets Coding
14175
In this encoding, a wide wide character is represented by the following eight
14176
character sequence if is in wide character range
14177
 
14178
@smallexample
14179
[ " a b c d " ]
14180
@end smallexample
14181
 
14182
and by the following ten character sequence if not
14183
 
14184
@smallexample
14185
[ " a b c d e f " ]
14186
@end smallexample
14187
 
14188
@noindent
14189
where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14190
are the four or six hexadecimal
14191
characters (using uppercase letters) of the wide wide character code.  For
14192
example, @code{["01A345"]} is used to represent the wide wide character
14193
with code @code{16#01A345#}.
14194
 
14195
This scheme is compatible with use of the full Wide_Wide_Character set.
14196
On input, brackets coding can also be used for upper half characters,
14197
e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
14198
is only used for wide characters with a code greater than @code{16#FF#}.
14199
 
14200
@end table
14201
 
14202
@noindent
14203
If is also possible to use the other Wide_Character encoding methods,
14204
such as Shift-JIS, but the other schemes cannot support the full range
14205
of wide wide characters.
14206
An attempt to output a character that cannot
14207
be represented using the encoding scheme for the file causes
14208
Constraint_Error to be raised.  An invalid wide character sequence on
14209
input also causes Constraint_Error to be raised.
14210
 
14211
@menu
14212
* Wide_Wide_Text_IO Stream Pointer Positioning::
14213
* Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14214
@end menu
14215
 
14216
@node Wide_Wide_Text_IO Stream Pointer Positioning
14217
@subsection Stream Pointer Positioning
14218
 
14219
@noindent
14220
@code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14221
of stream pointer positioning (@pxref{Text_IO}).  There is one additional
14222
case:
14223
 
14224
If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14225
normal lower ASCII set (i.e.@: a character in the range:
14226
 
14227
@smallexample @c ada
14228
Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14229
@end smallexample
14230
 
14231
@noindent
14232
then although the logical position of the file pointer is unchanged by
14233
the @code{Look_Ahead} call, the stream is physically positioned past the
14234
wide character sequence.  Again this is to avoid the need for buffering
14235
or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14236
indication that this situation has occurred so that this is not visible
14237
to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
14238
can be observed if the wide text file shares a stream with another file.
14239
 
14240
@node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14241
@subsection Reading and Writing Non-Regular Files
14242
 
14243
@noindent
14244
As in the case of Text_IO, when a non-regular file is read, it is
14245
assumed that the file contains no page marks (any form characters are
14246
treated as data characters), and @code{End_Of_Page} always returns
14247
@code{False}.  Similarly, the end of file indication is not sticky, so
14248
it is possible to read beyond an end of file.
14249
 
14250
@node Stream_IO
14251
@section Stream_IO
14252
 
14253
@noindent
14254
A stream file is a sequence of bytes, where individual elements are
14255
written to the file as described in the Ada Reference Manual.  The type
14256
@code{Stream_Element} is simply a byte.  There are two ways to read or
14257
write a stream file.
14258
 
14259
@itemize @bullet
14260
@item
14261
The operations @code{Read} and @code{Write} directly read or write a
14262
sequence of stream elements with no control information.
14263
 
14264
@item
14265
The stream attributes applied to a stream file transfer data in the
14266
manner described for stream attributes.
14267
@end itemize
14268
 
14269
@node Text Translation
14270
@section Text Translation
14271
 
14272
@noindent
14273
@samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14274
passed to Text_IO.Create and Text_IO.Open:
14275
@samp{Text_Translation=@var{Yes}} is the default, which means to
14276
translate LF to/from CR/LF on Windows systems.
14277
@samp{Text_Translation=@var{No}} disables this translation; i.e. it
14278
uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14279
may be used to create Unix-style files on
14280
Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14281
systems.
14282
 
14283
@node Shared Files
14284
@section Shared Files
14285
 
14286
@noindent
14287
Section A.14 of the Ada Reference Manual allows implementations to
14288
provide a wide variety of behavior if an attempt is made to access the
14289
same external file with two or more internal files.
14290
 
14291
To provide a full range of functionality, while at the same time
14292
minimizing the problems of portability caused by this implementation
14293
dependence, GNAT handles file sharing as follows:
14294
 
14295
@itemize @bullet
14296
@item
14297
In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14298
to open two or more files with the same full name is considered an error
14299
and is not supported.  The exception @code{Use_Error} will be
14300
raised.  Note that a file that is not explicitly closed by the program
14301
remains open until the program terminates.
14302
 
14303
@item
14304
If the form parameter @samp{shared=no} appears in the form string, the
14305
file can be opened or created with its own separate stream identifier,
14306
regardless of whether other files sharing the same external file are
14307
opened.  The exact effect depends on how the C stream routines handle
14308
multiple accesses to the same external files using separate streams.
14309
 
14310
@item
14311
If the form parameter @samp{shared=yes} appears in the form string for
14312
each of two or more files opened using the same full name, the same
14313
stream is shared between these files, and the semantics are as described
14314
in Ada Reference Manual, Section A.14.
14315
@end itemize
14316
 
14317
@noindent
14318
When a program that opens multiple files with the same name is ported
14319
from another Ada compiler to GNAT, the effect will be that
14320
@code{Use_Error} is raised.
14321
 
14322
The documentation of the original compiler and the documentation of the
14323
program should then be examined to determine if file sharing was
14324
expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14325
and @code{Create} calls as required.
14326
 
14327
When a program is ported from GNAT to some other Ada compiler, no
14328
special attention is required unless the @samp{shared=@var{xxx}} form
14329
parameter is used in the program.  In this case, you must examine the
14330
documentation of the new compiler to see if it supports the required
14331
file sharing semantics, and form strings modified appropriately.  Of
14332
course it may be the case that the program cannot be ported if the
14333
target compiler does not support the required functionality.  The best
14334
approach in writing portable code is to avoid file sharing (and hence
14335
the use of the @samp{shared=@var{xxx}} parameter in the form string)
14336
completely.
14337
 
14338
One common use of file sharing in Ada 83 is the use of instantiations of
14339
Sequential_IO on the same file with different types, to achieve
14340
heterogeneous input-output.  Although this approach will work in GNAT if
14341
@samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14342
for this purpose (using the stream attributes)
14343
 
14344
@node Filenames encoding
14345
@section Filenames encoding
14346
 
14347
@noindent
14348
An encoding form parameter can be used to specify the filename
14349
encoding @samp{encoding=@var{xxx}}.
14350
 
14351
@itemize @bullet
14352
@item
14353
If the form parameter @samp{encoding=utf8} appears in the form string, the
14354
filename must be encoded in UTF-8.
14355
 
14356
@item
14357
If the form parameter @samp{encoding=8bits} appears in the form
14358
string, the filename must be a standard 8bits string.
14359
@end itemize
14360
 
14361
In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14362
encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14363
variable. And if not set @samp{utf8} is assumed.
14364
 
14365
@table @samp
14366
@item CP_ACP
14367
The current system Windows ANSI code page.
14368
@item CP_UTF8
14369
UTF-8 encoding
14370
@end table
14371
 
14372
This encoding form parameter is only supported on the Windows
14373
platform. On the other Operating Systems the run-time is supporting
14374
UTF-8 natively.
14375
 
14376
@node Open Modes
14377
@section Open Modes
14378
 
14379
@noindent
14380
@code{Open} and @code{Create} calls result in a call to @code{fopen}
14381
using the mode shown in the following table:
14382
 
14383
@sp 2
14384
@center @code{Open} and @code{Create} Call Modes
14385
@smallexample
14386
                               @b{OPEN }           @b{CREATE}
14387
Append_File                    "r+"             "w+"
14388
In_File                        "r"              "w+"
14389
Out_File (Direct_IO)           "r+"             "w"
14390
Out_File (all other cases)     "w"              "w"
14391
Inout_File                     "r+"             "w+"
14392
@end smallexample
14393
 
14394
@noindent
14395
If text file translation is required, then either @samp{b} or @samp{t}
14396
is added to the mode, depending on the setting of Text.  Text file
14397
translation refers to the mapping of CR/LF sequences in an external file
14398
to LF characters internally.  This mapping only occurs in DOS and
14399
DOS-like systems, and is not relevant to other systems.
14400
 
14401
A special case occurs with Stream_IO@.  As shown in the above table, the
14402
file is initially opened in @samp{r} or @samp{w} mode for the
14403
@code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
14404
subsequently requires switching from reading to writing or vice-versa,
14405
then the file is reopened in @samp{r+} mode to permit the required operation.
14406
 
14407
@node Operations on C Streams
14408
@section Operations on C Streams
14409
The package @code{Interfaces.C_Streams} provides an Ada program with direct
14410
access to the C library functions for operations on C streams:
14411
 
14412
@smallexample @c adanocomment
14413
package Interfaces.C_Streams is
14414
  -- Note: the reason we do not use the types that are in
14415
  -- Interfaces.C is that we want to avoid dragging in the
14416
  -- code in this unit if possible.
14417
  subtype chars is System.Address;
14418
  -- Pointer to null-terminated array of characters
14419
  subtype FILEs is System.Address;
14420
  -- Corresponds to the C type FILE*
14421
  subtype voids is System.Address;
14422
  -- Corresponds to the C type void*
14423
  subtype int is Integer;
14424
  subtype long is Long_Integer;
14425
  -- Note: the above types are subtypes deliberately, and it
14426
  -- is part of this spec that the above correspondences are
14427
  -- guaranteed.  This means that it is legitimate to, for
14428
  -- example, use Integer instead of int.  We provide these
14429
  -- synonyms for clarity, but in some cases it may be
14430
  -- convenient to use the underlying types (for example to
14431
  -- avoid an unnecessary dependency of a spec on the spec
14432
  -- of this unit).
14433
  type size_t is mod 2 ** Standard'Address_Size;
14434
  NULL_Stream : constant FILEs;
14435
  -- Value returned (NULL in C) to indicate an
14436
  -- fdopen/fopen/tmpfile error
14437
  ----------------------------------
14438
  -- Constants Defined in stdio.h --
14439
  ----------------------------------
14440
  EOF : constant int;
14441
  -- Used by a number of routines to indicate error or
14442
  -- end of file
14443
  IOFBF : constant int;
14444
  IOLBF : constant int;
14445
  IONBF : constant int;
14446
  -- Used to indicate buffering mode for setvbuf call
14447
  SEEK_CUR : constant int;
14448
  SEEK_END : constant int;
14449
  SEEK_SET : constant int;
14450
  -- Used to indicate origin for fseek call
14451
  function stdin return FILEs;
14452
  function stdout return FILEs;
14453
  function stderr return FILEs;
14454
  -- Streams associated with standard files
14455
  --------------------------
14456
  -- Standard C functions --
14457
  --------------------------
14458
  -- The functions selected below are ones that are
14459
  -- available in UNIX (but not necessarily in ANSI C).
14460
  -- These are very thin interfaces
14461
  -- which copy exactly the C headers.  For more
14462
  -- documentation on these functions, see the Microsoft C
14463
  -- "Run-Time Library Reference" (Microsoft Press, 1990,
14464
  -- ISBN 1-55615-225-6), which includes useful information
14465
  -- on system compatibility.
14466
  procedure clearerr (stream : FILEs);
14467
  function fclose (stream : FILEs) return int;
14468
  function fdopen (handle : int; mode : chars) return FILEs;
14469
  function feof (stream : FILEs) return int;
14470
  function ferror (stream : FILEs) return int;
14471
  function fflush (stream : FILEs) return int;
14472
  function fgetc (stream : FILEs) return int;
14473
  function fgets (strng : chars; n : int; stream : FILEs)
14474
      return chars;
14475
  function fileno (stream : FILEs) return int;
14476
  function fopen (filename : chars; Mode : chars)
14477
      return FILEs;
14478
  -- Note: to maintain target independence, use
14479
  -- text_translation_required, a boolean variable defined in
14480
  -- a-sysdep.c to deal with the target dependent text
14481
  -- translation requirement.  If this variable is set,
14482
  -- then  b/t should be appended to the standard mode
14483
  -- argument to set the text translation mode off or on
14484
  -- as required.
14485
  function fputc (C : int; stream : FILEs) return int;
14486
  function fputs (Strng : chars; Stream : FILEs) return int;
14487
  function fread
14488
     (buffer : voids;
14489
      size : size_t;
14490
      count : size_t;
14491
      stream : FILEs)
14492
      return size_t;
14493
  function freopen
14494
     (filename : chars;
14495
      mode : chars;
14496
      stream : FILEs)
14497
      return FILEs;
14498
  function fseek
14499
     (stream : FILEs;
14500
      offset : long;
14501
      origin : int)
14502
      return int;
14503
  function ftell (stream : FILEs) return long;
14504
  function fwrite
14505
     (buffer : voids;
14506
      size : size_t;
14507
      count : size_t;
14508
      stream : FILEs)
14509
      return size_t;
14510
  function isatty (handle : int) return int;
14511
  procedure mktemp (template : chars);
14512
  -- The return value (which is just a pointer to template)
14513
  -- is discarded
14514
  procedure rewind (stream : FILEs);
14515
  function rmtmp return int;
14516
  function setvbuf
14517
     (stream : FILEs;
14518
      buffer : chars;
14519
      mode : int;
14520
      size : size_t)
14521
      return int;
14522
 
14523
  function tmpfile return FILEs;
14524
  function ungetc (c : int; stream : FILEs) return int;
14525
  function unlink (filename : chars) return int;
14526
  ---------------------
14527
  -- Extra functions --
14528
  ---------------------
14529
  -- These functions supply slightly thicker bindings than
14530
  -- those above.  They are derived from functions in the
14531
  -- C Run-Time Library, but may do a bit more work than
14532
  -- just directly calling one of the Library functions.
14533
  function is_regular_file (handle : int) return int;
14534
  -- Tests if given handle is for a regular file (result 1)
14535
  -- or for a non-regular file (pipe or device, result 0).
14536
  ---------------------------------
14537
  -- Control of Text/Binary Mode --
14538
  ---------------------------------
14539
  -- If text_translation_required is true, then the following
14540
  -- functions may be used to dynamically switch a file from
14541
  -- binary to text mode or vice versa.  These functions have
14542
  -- no effect if text_translation_required is false (i.e.@: in
14543
  -- normal UNIX mode).  Use fileno to get a stream handle.
14544
  procedure set_binary_mode (handle : int);
14545
  procedure set_text_mode (handle : int);
14546
  ----------------------------
14547
  -- Full Path Name support --
14548
  ----------------------------
14549
  procedure full_name (nam : chars; buffer : chars);
14550
  -- Given a NUL terminated string representing a file
14551
  -- name, returns in buffer a NUL terminated string
14552
  -- representing the full path name for the file name.
14553
  -- On systems where it is relevant the   drive is also
14554
  -- part of the full path name.  It is the responsibility
14555
  -- of the caller to pass an actual parameter for buffer
14556
  -- that is big enough for any full path name.  Use
14557
  -- max_path_len given below as the size of buffer.
14558
  max_path_len : integer;
14559
  -- Maximum length of an allowable full path name on the
14560
  -- system, including a terminating NUL character.
14561
end Interfaces.C_Streams;
14562
@end smallexample
14563
 
14564
@node Interfacing to C Streams
14565
@section Interfacing to C Streams
14566
 
14567
@noindent
14568
The packages in this section permit interfacing Ada files to C Stream
14569
operations.
14570
 
14571
@smallexample @c ada
14572
 with Interfaces.C_Streams;
14573
 package Ada.Sequential_IO.C_Streams is
14574
    function C_Stream (F : File_Type)
14575
       return Interfaces.C_Streams.FILEs;
14576
    procedure Open
14577
      (File : in out File_Type;
14578
       Mode : in File_Mode;
14579
       C_Stream : in Interfaces.C_Streams.FILEs;
14580
       Form : in String := "");
14581
 end Ada.Sequential_IO.C_Streams;
14582
 
14583
  with Interfaces.C_Streams;
14584
  package Ada.Direct_IO.C_Streams is
14585
     function C_Stream (F : File_Type)
14586
        return Interfaces.C_Streams.FILEs;
14587
     procedure Open
14588
       (File : in out File_Type;
14589
        Mode : in File_Mode;
14590
        C_Stream : in Interfaces.C_Streams.FILEs;
14591
        Form : in String := "");
14592
  end Ada.Direct_IO.C_Streams;
14593
 
14594
  with Interfaces.C_Streams;
14595
  package Ada.Text_IO.C_Streams is
14596
     function C_Stream (F : File_Type)
14597
        return Interfaces.C_Streams.FILEs;
14598
     procedure Open
14599
       (File : in out File_Type;
14600
        Mode : in File_Mode;
14601
        C_Stream : in Interfaces.C_Streams.FILEs;
14602
        Form : in String := "");
14603
  end Ada.Text_IO.C_Streams;
14604
 
14605
  with Interfaces.C_Streams;
14606
  package Ada.Wide_Text_IO.C_Streams is
14607
     function C_Stream (F : File_Type)
14608
        return Interfaces.C_Streams.FILEs;
14609
     procedure Open
14610
       (File : in out File_Type;
14611
        Mode : in File_Mode;
14612
        C_Stream : in Interfaces.C_Streams.FILEs;
14613
        Form : in String := "");
14614
 end Ada.Wide_Text_IO.C_Streams;
14615
 
14616
  with Interfaces.C_Streams;
14617
  package Ada.Wide_Wide_Text_IO.C_Streams is
14618
     function C_Stream (F : File_Type)
14619
        return Interfaces.C_Streams.FILEs;
14620
     procedure Open
14621
       (File : in out File_Type;
14622
        Mode : in File_Mode;
14623
        C_Stream : in Interfaces.C_Streams.FILEs;
14624
        Form : in String := "");
14625
 end Ada.Wide_Wide_Text_IO.C_Streams;
14626
 
14627
 with Interfaces.C_Streams;
14628
 package Ada.Stream_IO.C_Streams is
14629
    function C_Stream (F : File_Type)
14630
       return Interfaces.C_Streams.FILEs;
14631
    procedure Open
14632
      (File : in out File_Type;
14633
       Mode : in File_Mode;
14634
       C_Stream : in Interfaces.C_Streams.FILEs;
14635
       Form : in String := "");
14636
 end Ada.Stream_IO.C_Streams;
14637
@end smallexample
14638
 
14639
@noindent
14640
In each of these six packages, the @code{C_Stream} function obtains the
14641
@code{FILE} pointer from a currently opened Ada file.  It is then
14642
possible to use the @code{Interfaces.C_Streams} package to operate on
14643
this stream, or the stream can be passed to a C program which can
14644
operate on it directly.  Of course the program is responsible for
14645
ensuring that only appropriate sequences of operations are executed.
14646
 
14647
One particular use of relevance to an Ada program is that the
14648
@code{setvbuf} function can be used to control the buffering of the
14649
stream used by an Ada file.  In the absence of such a call the standard
14650
default buffering is used.
14651
 
14652
The @code{Open} procedures in these packages open a file giving an
14653
existing C Stream instead of a file name.  Typically this stream is
14654
imported from a C program, allowing an Ada file to operate on an
14655
existing C file.
14656
 
14657
@node The GNAT Library
14658
@chapter The GNAT Library
14659
 
14660
@noindent
14661
The GNAT library contains a number of general and special purpose packages.
14662
It represents functionality that the GNAT developers have found useful, and
14663
which is made available to GNAT users.  The packages described here are fully
14664
supported, and upwards compatibility will be maintained in future releases,
14665
so you can use these facilities with the confidence that the same functionality
14666
will be available in future releases.
14667
 
14668
The chapter here simply gives a brief summary of the facilities available.
14669
The full documentation is found in the spec file for the package.  The full
14670
sources of these library packages, including both spec and body, are provided
14671
with all GNAT releases.  For example, to find out the full specifications of
14672
the SPITBOL pattern matching capability, including a full tutorial and
14673
extensive examples, look in the @file{g-spipat.ads} file in the library.
14674
 
14675
For each entry here, the package name (as it would appear in a @code{with}
14676
clause) is given, followed by the name of the corresponding spec file in
14677
parentheses.  The packages are children in four hierarchies, @code{Ada},
14678
@code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14679
GNAT-specific hierarchy.
14680
 
14681
Note that an application program should only use packages in one of these
14682
four hierarchies if the package is defined in the Ada Reference Manual,
14683
or is listed in this section of the GNAT Programmers Reference Manual.
14684
All other units should be considered internal implementation units and
14685
should not be directly @code{with}'ed by application code.  The use of
14686
a @code{with} statement that references one of these internal implementation
14687
units makes an application potentially dependent on changes in versions
14688
of GNAT, and will generate a warning message.
14689
 
14690
@menu
14691
* Ada.Characters.Latin_9 (a-chlat9.ads)::
14692
* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14693
* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14694
* Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14695
* Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14696
* Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14697
* Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14698
* Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14699
* Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14700
* Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14701
* Ada.Containers.Formal_Vectors (a-cofove.ads)::
14702
* Ada.Command_Line.Environment (a-colien.ads)::
14703
* Ada.Command_Line.Remove (a-colire.ads)::
14704
* Ada.Command_Line.Response_File (a-clrefi.ads)::
14705
* Ada.Direct_IO.C_Streams (a-diocst.ads)::
14706
* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14707
* Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14708
* Ada.Exceptions.Traceback (a-exctra.ads)::
14709
* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14710
* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14711
* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14712
* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14713
* Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14714
* Ada.Text_IO.C_Streams (a-tiocst.ads)::
14715
* Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14716
* Ada.Wide_Characters.Unicode (a-wichun.ads)::
14717
* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14718
* Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14719
* Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14720
* Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14721
* Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14722
* GNAT.Altivec (g-altive.ads)::
14723
* GNAT.Altivec.Conversions (g-altcon.ads)::
14724
* GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14725
* GNAT.Altivec.Vector_Types (g-alvety.ads)::
14726
* GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14727
* GNAT.Array_Split (g-arrspl.ads)::
14728
* GNAT.AWK (g-awk.ads)::
14729
* GNAT.Bounded_Buffers (g-boubuf.ads)::
14730
* GNAT.Bounded_Mailboxes (g-boumai.ads)::
14731
* GNAT.Bubble_Sort (g-bubsor.ads)::
14732
* GNAT.Bubble_Sort_A (g-busora.ads)::
14733
* GNAT.Bubble_Sort_G (g-busorg.ads)::
14734
* GNAT.Byte_Order_Mark (g-byorma.ads)::
14735
* GNAT.Byte_Swapping (g-bytswa.ads)::
14736
* GNAT.Calendar (g-calend.ads)::
14737
* GNAT.Calendar.Time_IO (g-catiio.ads)::
14738
* GNAT.Case_Util (g-casuti.ads)::
14739
* GNAT.CGI (g-cgi.ads)::
14740
* GNAT.CGI.Cookie (g-cgicoo.ads)::
14741
* GNAT.CGI.Debug (g-cgideb.ads)::
14742
* GNAT.Command_Line (g-comlin.ads)::
14743
* GNAT.Compiler_Version (g-comver.ads)::
14744
* GNAT.Ctrl_C (g-ctrl_c.ads)::
14745
* GNAT.CRC32 (g-crc32.ads)::
14746
* GNAT.Current_Exception (g-curexc.ads)::
14747
* GNAT.Debug_Pools (g-debpoo.ads)::
14748
* GNAT.Debug_Utilities (g-debuti.ads)::
14749
* GNAT.Decode_String (g-decstr.ads)::
14750
* GNAT.Decode_UTF8_String (g-deutst.ads)::
14751
* GNAT.Directory_Operations (g-dirope.ads)::
14752
* GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14753
* GNAT.Dynamic_HTables (g-dynhta.ads)::
14754
* GNAT.Dynamic_Tables (g-dyntab.ads)::
14755
* GNAT.Encode_String (g-encstr.ads)::
14756
* GNAT.Encode_UTF8_String (g-enutst.ads)::
14757
* GNAT.Exception_Actions (g-excact.ads)::
14758
* GNAT.Exception_Traces (g-exctra.ads)::
14759
* GNAT.Exceptions (g-except.ads)::
14760
* GNAT.Expect (g-expect.ads)::
14761
* GNAT.Expect.TTY (g-exptty.ads)::
14762
* GNAT.Float_Control (g-flocon.ads)::
14763
* GNAT.Heap_Sort (g-heasor.ads)::
14764
* GNAT.Heap_Sort_A (g-hesora.ads)::
14765
* GNAT.Heap_Sort_G (g-hesorg.ads)::
14766
* GNAT.HTable (g-htable.ads)::
14767
* GNAT.IO (g-io.ads)::
14768
* GNAT.IO_Aux (g-io_aux.ads)::
14769
* GNAT.Lock_Files (g-locfil.ads)::
14770
* GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14771
* GNAT.MBBS_Float_Random (g-mbflra.ads)::
14772
* GNAT.MD5 (g-md5.ads)::
14773
* GNAT.Memory_Dump (g-memdum.ads)::
14774
* GNAT.Most_Recent_Exception (g-moreex.ads)::
14775
* GNAT.OS_Lib (g-os_lib.ads)::
14776
* GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14777
* GNAT.Random_Numbers (g-rannum.ads)::
14778
* GNAT.Regexp (g-regexp.ads)::
14779
* GNAT.Registry (g-regist.ads)::
14780
* GNAT.Regpat (g-regpat.ads)::
14781
* GNAT.Secondary_Stack_Info (g-sestin.ads)::
14782
* GNAT.Semaphores (g-semaph.ads)::
14783
* GNAT.Serial_Communications (g-sercom.ads)::
14784
* GNAT.SHA1 (g-sha1.ads)::
14785
* GNAT.SHA224 (g-sha224.ads)::
14786
* GNAT.SHA256 (g-sha256.ads)::
14787
* GNAT.SHA384 (g-sha384.ads)::
14788
* GNAT.SHA512 (g-sha512.ads)::
14789
* GNAT.Signals (g-signal.ads)::
14790
* GNAT.Sockets (g-socket.ads)::
14791
* GNAT.Source_Info (g-souinf.ads)::
14792
* GNAT.Spelling_Checker (g-speche.ads)::
14793
* GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14794
* GNAT.Spitbol.Patterns (g-spipat.ads)::
14795
* GNAT.Spitbol (g-spitbo.ads)::
14796
* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14797
* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14798
* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14799
* GNAT.SSE (g-sse.ads)::
14800
* GNAT.SSE.Vector_Types (g-ssvety.ads)::
14801
* GNAT.Strings (g-string.ads)::
14802
* GNAT.String_Split (g-strspl.ads)::
14803
* GNAT.Table (g-table.ads)::
14804
* GNAT.Task_Lock (g-tasloc.ads)::
14805
* GNAT.Threads (g-thread.ads)::
14806
* GNAT.Time_Stamp (g-timsta.ads)::
14807
* GNAT.Traceback (g-traceb.ads)::
14808
* GNAT.Traceback.Symbolic (g-trasym.ads)::
14809
* GNAT.UTF_32 (g-utf_32.ads)::
14810
* GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14811
* GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14812
* GNAT.Wide_String_Split (g-wistsp.ads)::
14813
* GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14814
* GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14815
* Interfaces.C.Extensions (i-cexten.ads)::
14816
* Interfaces.C.Streams (i-cstrea.ads)::
14817
* Interfaces.CPP (i-cpp.ads)::
14818
* Interfaces.Packed_Decimal (i-pacdec.ads)::
14819
* Interfaces.VxWorks (i-vxwork.ads)::
14820
* Interfaces.VxWorks.IO (i-vxwoio.ads)::
14821
* System.Address_Image (s-addima.ads)::
14822
* System.Assertions (s-assert.ads)::
14823
* System.Memory (s-memory.ads)::
14824
* System.Partition_Interface (s-parint.ads)::
14825
* System.Pool_Global (s-pooglo.ads)::
14826
* System.Pool_Local (s-pooloc.ads)::
14827
* System.Restrictions (s-restri.ads)::
14828
* System.Rident (s-rident.ads)::
14829
* System.Strings.Stream_Ops (s-ststop.ads)::
14830
* System.Task_Info (s-tasinf.ads)::
14831
* System.Wch_Cnv (s-wchcnv.ads)::
14832
* System.Wch_Con (s-wchcon.ads)::
14833
@end menu
14834
 
14835
@node Ada.Characters.Latin_9 (a-chlat9.ads)
14836
@section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14837
@cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14838
@cindex Latin_9 constants for Character
14839
 
14840
@noindent
14841
This child of @code{Ada.Characters}
14842
provides a set of definitions corresponding to those in the
14843
RM-defined package @code{Ada.Characters.Latin_1} but with the
14844
few modifications required for @code{Latin-9}
14845
The provision of such a package
14846
is specifically authorized by the Ada Reference Manual
14847
(RM A.3.3(27)).
14848
 
14849
@node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14850
@section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14851
@cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14852
@cindex Latin_1 constants for Wide_Character
14853
 
14854
@noindent
14855
This child of @code{Ada.Characters}
14856
provides a set of definitions corresponding to those in the
14857
RM-defined package @code{Ada.Characters.Latin_1} but with the
14858
types of the constants being @code{Wide_Character}
14859
instead of @code{Character}.  The provision of such a package
14860
is specifically authorized by the Ada Reference Manual
14861
(RM A.3.3(27)).
14862
 
14863
@node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14864
@section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14865
@cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14866
@cindex Latin_9 constants for Wide_Character
14867
 
14868
@noindent
14869
This child of @code{Ada.Characters}
14870
provides a set of definitions corresponding to those in the
14871
GNAT defined package @code{Ada.Characters.Latin_9} but with the
14872
types of the constants being @code{Wide_Character}
14873
instead of @code{Character}.  The provision of such a package
14874
is specifically authorized by the Ada Reference Manual
14875
(RM A.3.3(27)).
14876
 
14877
@node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14878
@section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14879
@cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14880
@cindex Latin_1 constants for Wide_Wide_Character
14881
 
14882
@noindent
14883
This child of @code{Ada.Characters}
14884
provides a set of definitions corresponding to those in the
14885
RM-defined package @code{Ada.Characters.Latin_1} but with the
14886
types of the constants being @code{Wide_Wide_Character}
14887
instead of @code{Character}.  The provision of such a package
14888
is specifically authorized by the Ada Reference Manual
14889
(RM A.3.3(27)).
14890
 
14891
@node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14892
@section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14893
@cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14894
@cindex Latin_9 constants for Wide_Wide_Character
14895
 
14896
@noindent
14897
This child of @code{Ada.Characters}
14898
provides a set of definitions corresponding to those in the
14899
GNAT defined package @code{Ada.Characters.Latin_9} but with the
14900
types of the constants being @code{Wide_Wide_Character}
14901
instead of @code{Character}.  The provision of such a package
14902
is specifically authorized by the Ada Reference Manual
14903
(RM A.3.3(27)).
14904
 
14905
@node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14906
@section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14907
@cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14908
@cindex Formal container for doubly linked lists
14909
 
14910
@noindent
14911
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14912
container for doubly linked lists, meant to facilitate formal verification of
14913
code using such containers.
14914
 
14915
@node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14916
@section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14917
@cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14918
@cindex Formal container for hashed maps
14919
 
14920
@noindent
14921
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14922
container for hashed maps, meant to facilitate formal verification of
14923
code using such containers.
14924
 
14925
@node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14926
@section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14927
@cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14928
@cindex Formal container for hashed sets
14929
 
14930
@noindent
14931
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14932
container for hashed sets, meant to facilitate formal verification of
14933
code using such containers.
14934
 
14935
@node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14936
@section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14937
@cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14938
@cindex Formal container for ordered maps
14939
 
14940
@noindent
14941
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14942
container for ordered maps, meant to facilitate formal verification of
14943
code using such containers.
14944
 
14945
@node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14946
@section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14947
@cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14948
@cindex Formal container for ordered sets
14949
 
14950
@noindent
14951
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14952
container for ordered sets, meant to facilitate formal verification of
14953
code using such containers.
14954
 
14955
@node Ada.Containers.Formal_Vectors (a-cofove.ads)
14956
@section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14957
@cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14958
@cindex Formal container for vectors
14959
 
14960
@noindent
14961
This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14962
container for vectors, meant to facilitate formal verification of
14963
code using such containers.
14964
 
14965
@node Ada.Command_Line.Environment (a-colien.ads)
14966
@section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14967
@cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14968
@cindex Environment entries
14969
 
14970
@noindent
14971
This child of @code{Ada.Command_Line}
14972
provides a mechanism for obtaining environment values on systems
14973
where this concept makes sense.
14974
 
14975
@node Ada.Command_Line.Remove (a-colire.ads)
14976
@section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14977
@cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14978
@cindex Removing command line arguments
14979
@cindex Command line, argument removal
14980
 
14981
@noindent
14982
This child of @code{Ada.Command_Line}
14983
provides a mechanism for logically removing
14984
arguments from the argument list.  Once removed, an argument is not visible
14985
to further calls on the subprograms in @code{Ada.Command_Line} will not
14986
see the removed argument.
14987
 
14988
@node Ada.Command_Line.Response_File (a-clrefi.ads)
14989
@section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14990
@cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14991
@cindex Response file for command line
14992
@cindex Command line, response file
14993
@cindex Command line, handling long command lines
14994
 
14995
@noindent
14996
This child of @code{Ada.Command_Line} provides a mechanism facilities for
14997
getting command line arguments from a text file, called a "response file".
14998
Using a response file allow passing a set of arguments to an executable longer
14999
than the maximum allowed by the system on the command line.
15000
 
15001
@node Ada.Direct_IO.C_Streams (a-diocst.ads)
15002
@section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15003
@cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15004
@cindex C Streams, Interfacing with Direct_IO
15005
 
15006
@noindent
15007
This package provides subprograms that allow interfacing between
15008
C streams and @code{Direct_IO}.  The stream identifier can be
15009
extracted from a file opened on the Ada side, and an Ada file
15010
can be constructed from a stream opened on the C side.
15011
 
15012
@node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15013
@section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15014
@cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15015
@cindex Null_Occurrence, testing for
15016
 
15017
@noindent
15018
This child subprogram provides a way of testing for the null
15019
exception occurrence (@code{Null_Occurrence}) without raising
15020
an exception.
15021
 
15022
@node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15023
@section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15024
@cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15025
@cindex Null_Occurrence, testing for
15026
 
15027
@noindent
15028
This child subprogram is used for handling otherwise unhandled
15029
exceptions (hence the name last chance), and perform clean ups before
15030
terminating the program. Note that this subprogram never returns.
15031
 
15032
@node Ada.Exceptions.Traceback (a-exctra.ads)
15033
@section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15034
@cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15035
@cindex Traceback for Exception Occurrence
15036
 
15037
@noindent
15038
This child package provides the subprogram (@code{Tracebacks}) to
15039
give a traceback array of addresses based on an exception
15040
occurrence.
15041
 
15042
@node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15043
@section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15044
@cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15045
@cindex C Streams, Interfacing with Sequential_IO
15046
 
15047
@noindent
15048
This package provides subprograms that allow interfacing between
15049
C streams and @code{Sequential_IO}.  The stream identifier can be
15050
extracted from a file opened on the Ada side, and an Ada file
15051
can be constructed from a stream opened on the C side.
15052
 
15053
@node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15054
@section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15055
@cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15056
@cindex C Streams, Interfacing with Stream_IO
15057
 
15058
@noindent
15059
This package provides subprograms that allow interfacing between
15060
C streams and @code{Stream_IO}.  The stream identifier can be
15061
extracted from a file opened on the Ada side, and an Ada file
15062
can be constructed from a stream opened on the C side.
15063
 
15064
@node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15065
@section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15066
@cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15067
@cindex @code{Unbounded_String}, IO support
15068
@cindex @code{Text_IO}, extensions for unbounded strings
15069
 
15070
@noindent
15071
This package provides subprograms for Text_IO for unbounded
15072
strings, avoiding the necessity for an intermediate operation
15073
with ordinary strings.
15074
 
15075
@node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15076
@section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15077
@cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15078
@cindex @code{Unbounded_Wide_String}, IO support
15079
@cindex @code{Text_IO}, extensions for unbounded wide strings
15080
 
15081
@noindent
15082
This package provides subprograms for Text_IO for unbounded
15083
wide strings, avoiding the necessity for an intermediate operation
15084
with ordinary wide strings.
15085
 
15086
@node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15087
@section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15088
@cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15089
@cindex @code{Unbounded_Wide_Wide_String}, IO support
15090
@cindex @code{Text_IO}, extensions for unbounded wide wide strings
15091
 
15092
@noindent
15093
This package provides subprograms for Text_IO for unbounded
15094
wide wide strings, avoiding the necessity for an intermediate operation
15095
with ordinary wide wide strings.
15096
 
15097
@node Ada.Text_IO.C_Streams (a-tiocst.ads)
15098
@section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15099
@cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15100
@cindex C Streams, Interfacing with @code{Text_IO}
15101
 
15102
@noindent
15103
This package provides subprograms that allow interfacing between
15104
C streams and @code{Text_IO}.  The stream identifier can be
15105
extracted from a file opened on the Ada side, and an Ada file
15106
can be constructed from a stream opened on the C side.
15107
 
15108
@node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15109
@section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15110
@cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15111
@cindex @code{Text_IO} resetting standard files
15112
 
15113
@noindent
15114
This procedure is used to reset the status of the standard files used
15115
by Ada.Text_IO.  This is useful in a situation (such as a restart in an
15116
embedded application) where the status of the files may change during
15117
execution (for example a standard input file may be redefined to be
15118
interactive).
15119
 
15120
@node Ada.Wide_Characters.Unicode (a-wichun.ads)
15121
@section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15122
@cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15123
@cindex Unicode categorization, Wide_Character
15124
 
15125
@noindent
15126
This package provides subprograms that allow categorization of
15127
Wide_Character values according to Unicode categories.
15128
 
15129
@node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15130
@section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15131
@cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15132
@cindex C Streams, Interfacing with @code{Wide_Text_IO}
15133
 
15134
@noindent
15135
This package provides subprograms that allow interfacing between
15136
C streams and @code{Wide_Text_IO}.  The stream identifier can be
15137
extracted from a file opened on the Ada side, and an Ada file
15138
can be constructed from a stream opened on the C side.
15139
 
15140
@node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15141
@section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15142
@cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15143
@cindex @code{Wide_Text_IO} resetting standard files
15144
 
15145
@noindent
15146
This procedure is used to reset the status of the standard files used
15147
by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
15148
embedded application) where the status of the files may change during
15149
execution (for example a standard input file may be redefined to be
15150
interactive).
15151
 
15152
@node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15153
@section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15154
@cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15155
@cindex Unicode categorization, Wide_Wide_Character
15156
 
15157
@noindent
15158
This package provides subprograms that allow categorization of
15159
Wide_Wide_Character values according to Unicode categories.
15160
 
15161
@node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15162
@section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15163
@cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15164
@cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15165
 
15166
@noindent
15167
This package provides subprograms that allow interfacing between
15168
C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
15169
extracted from a file opened on the Ada side, and an Ada file
15170
can be constructed from a stream opened on the C side.
15171
 
15172
@node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15173
@section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15174
@cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15175
@cindex @code{Wide_Wide_Text_IO} resetting standard files
15176
 
15177
@noindent
15178
This procedure is used to reset the status of the standard files used
15179
by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15180
restart in an embedded application) where the status of the files may
15181
change during execution (for example a standard input file may be
15182
redefined to be interactive).
15183
 
15184
@node GNAT.Altivec (g-altive.ads)
15185
@section @code{GNAT.Altivec} (@file{g-altive.ads})
15186
@cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15187
@cindex AltiVec
15188
 
15189
@noindent
15190
This is the root package of the GNAT AltiVec binding. It provides
15191
definitions of constants and types common to all the versions of the
15192
binding.
15193
 
15194
@node GNAT.Altivec.Conversions (g-altcon.ads)
15195
@section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15196
@cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15197
@cindex AltiVec
15198
 
15199
@noindent
15200
This package provides the Vector/View conversion routines.
15201
 
15202
@node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15203
@section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15204
@cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15205
@cindex AltiVec
15206
 
15207
@noindent
15208
This package exposes the Ada interface to the AltiVec operations on
15209
vector objects. A soft emulation is included by default in the GNAT
15210
library. The hard binding is provided as a separate package. This unit
15211
is common to both bindings.
15212
 
15213
@node GNAT.Altivec.Vector_Types (g-alvety.ads)
15214
@section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15215
@cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15216
@cindex AltiVec
15217
 
15218
@noindent
15219
This package exposes the various vector types part of the Ada binding
15220
to AltiVec facilities.
15221
 
15222
@node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15223
@section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15224
@cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15225
@cindex AltiVec
15226
 
15227
@noindent
15228
This package provides public 'View' data types from/to which private
15229
vector representations can be converted via
15230
GNAT.Altivec.Conversions. This allows convenient access to individual
15231
vector elements and provides a simple way to initialize vector
15232
objects.
15233
 
15234
@node GNAT.Array_Split (g-arrspl.ads)
15235
@section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15236
@cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15237
@cindex Array splitter
15238
 
15239
@noindent
15240
Useful array-manipulation routines: given a set of separators, split
15241
an array wherever the separators appear, and provide direct access
15242
to the resulting slices.
15243
 
15244
@node GNAT.AWK (g-awk.ads)
15245
@section @code{GNAT.AWK} (@file{g-awk.ads})
15246
@cindex @code{GNAT.AWK} (@file{g-awk.ads})
15247
@cindex Parsing
15248
@cindex AWK
15249
 
15250
@noindent
15251
Provides AWK-like parsing functions, with an easy interface for parsing one
15252
or more files containing formatted data.  The file is viewed as a database
15253
where each record is a line and a field is a data element in this line.
15254
 
15255
@node GNAT.Bounded_Buffers (g-boubuf.ads)
15256
@section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15257
@cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15258
@cindex Parsing
15259
@cindex Bounded Buffers
15260
 
15261
@noindent
15262
Provides a concurrent generic bounded buffer abstraction.  Instances are
15263
useful directly or as parts of the implementations of other abstractions,
15264
such as mailboxes.
15265
 
15266
@node GNAT.Bounded_Mailboxes (g-boumai.ads)
15267
@section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15268
@cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15269
@cindex Parsing
15270
@cindex Mailboxes
15271
 
15272
@noindent
15273
Provides a thread-safe asynchronous intertask mailbox communication facility.
15274
 
15275
@node GNAT.Bubble_Sort (g-bubsor.ads)
15276
@section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15277
@cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15278
@cindex Sorting
15279
@cindex Bubble sort
15280
 
15281
@noindent
15282
Provides a general implementation of bubble sort usable for sorting arbitrary
15283
data items.  Exchange and comparison procedures are provided by passing
15284
access-to-procedure values.
15285
 
15286
@node GNAT.Bubble_Sort_A (g-busora.ads)
15287
@section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15288
@cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15289
@cindex Sorting
15290
@cindex Bubble sort
15291
 
15292
@noindent
15293
Provides a general implementation of bubble sort usable for sorting arbitrary
15294
data items.  Move and comparison procedures are provided by passing
15295
access-to-procedure values. This is an older version, retained for
15296
compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15297
 
15298
@node GNAT.Bubble_Sort_G (g-busorg.ads)
15299
@section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15300
@cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15301
@cindex Sorting
15302
@cindex Bubble sort
15303
 
15304
@noindent
15305
Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15306
are provided as generic parameters, this improves efficiency, especially
15307
if the procedures can be inlined, at the expense of duplicating code for
15308
multiple instantiations.
15309
 
15310
@node GNAT.Byte_Order_Mark (g-byorma.ads)
15311
@section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15312
@cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15313
@cindex UTF-8 representation
15314
@cindex Wide characte representations
15315
 
15316
@noindent
15317
Provides a routine which given a string, reads the start of the string to
15318
see whether it is one of the standard byte order marks (BOM's) which signal
15319
the encoding of the string. The routine includes detection of special XML
15320
sequences for various UCS input formats.
15321
 
15322
@node GNAT.Byte_Swapping (g-bytswa.ads)
15323
@section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15324
@cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15325
@cindex Byte swapping
15326
@cindex Endian
15327
 
15328
@noindent
15329
General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15330
Machine-specific implementations are available in some cases.
15331
 
15332
@node GNAT.Calendar (g-calend.ads)
15333
@section @code{GNAT.Calendar} (@file{g-calend.ads})
15334
@cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15335
@cindex @code{Calendar}
15336
 
15337
@noindent
15338
Extends the facilities provided by @code{Ada.Calendar} to include handling
15339
of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15340
Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15341
C @code{timeval} format.
15342
 
15343
@node GNAT.Calendar.Time_IO (g-catiio.ads)
15344
@section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15345
@cindex @code{Calendar}
15346
@cindex Time
15347
@cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15348
 
15349
@node GNAT.CRC32 (g-crc32.ads)
15350
@section @code{GNAT.CRC32} (@file{g-crc32.ads})
15351
@cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15352
@cindex CRC32
15353
@cindex Cyclic Redundancy Check
15354
 
15355
@noindent
15356
This package implements the CRC-32 algorithm.  For a full description
15357
of this algorithm see
15358
``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15359
@cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15360
Aug.@: 1988.  Sarwate, D.V@.
15361
 
15362
@node GNAT.Case_Util (g-casuti.ads)
15363
@section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15364
@cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15365
@cindex Casing utilities
15366
@cindex Character handling (@code{GNAT.Case_Util})
15367
 
15368
@noindent
15369
A set of simple routines for handling upper and lower casing of strings
15370
without the overhead of the full casing tables
15371
in @code{Ada.Characters.Handling}.
15372
 
15373
@node GNAT.CGI (g-cgi.ads)
15374
@section @code{GNAT.CGI} (@file{g-cgi.ads})
15375
@cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15376
@cindex CGI (Common Gateway Interface)
15377
 
15378
@noindent
15379
This is a package for interfacing a GNAT program with a Web server via the
15380
Common Gateway Interface (CGI)@.  Basically this package parses the CGI
15381
parameters, which are a set of key/value pairs sent by the Web server.  It
15382
builds a table whose index is the key and provides some services to deal
15383
with this table.
15384
 
15385
@node GNAT.CGI.Cookie (g-cgicoo.ads)
15386
@section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15387
@cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15388
@cindex CGI (Common Gateway Interface) cookie support
15389
@cindex Cookie support in CGI
15390
 
15391
@noindent
15392
This is a package to interface a GNAT program with a Web server via the
15393
Common Gateway Interface (CGI).  It exports services to deal with Web
15394
cookies (piece of information kept in the Web client software).
15395
 
15396
@node GNAT.CGI.Debug (g-cgideb.ads)
15397
@section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15398
@cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15399
@cindex CGI (Common Gateway Interface) debugging
15400
 
15401
@noindent
15402
This is a package to help debugging CGI (Common Gateway Interface)
15403
programs written in Ada.
15404
 
15405
@node GNAT.Command_Line (g-comlin.ads)
15406
@section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15407
@cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15408
@cindex Command line
15409
 
15410
@noindent
15411
Provides a high level interface to @code{Ada.Command_Line} facilities,
15412
including the ability to scan for named switches with optional parameters
15413
and expand file names using wild card notations.
15414
 
15415
@node GNAT.Compiler_Version (g-comver.ads)
15416
@section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15417
@cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15418
@cindex Compiler Version
15419
@cindex Version, of compiler
15420
 
15421
@noindent
15422
Provides a routine for obtaining the version of the compiler used to
15423
compile the program. More accurately this is the version of the binder
15424
used to bind the program (this will normally be the same as the version
15425
of the compiler if a consistent tool set is used to compile all units
15426
of a partition).
15427
 
15428
@node GNAT.Ctrl_C (g-ctrl_c.ads)
15429
@section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15430
@cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15431
@cindex Interrupt
15432
 
15433
@noindent
15434
Provides a simple interface to handle Ctrl-C keyboard events.
15435
 
15436
@node GNAT.Current_Exception (g-curexc.ads)
15437
@section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15438
@cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15439
@cindex Current exception
15440
@cindex Exception retrieval
15441
 
15442
@noindent
15443
Provides access to information on the current exception that has been raised
15444
without the need for using the Ada 95 / Ada 2005 exception choice parameter
15445
specification syntax.
15446
This is particularly useful in simulating typical facilities for
15447
obtaining information about exceptions provided by Ada 83 compilers.
15448
 
15449
@node GNAT.Debug_Pools (g-debpoo.ads)
15450
@section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15451
@cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15452
@cindex Debugging
15453
@cindex Debug pools
15454
@cindex Memory corruption debugging
15455
 
15456
@noindent
15457
Provide a debugging storage pools that helps tracking memory corruption
15458
problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15459
@value{EDITION} User's Guide}.
15460
 
15461
@node GNAT.Debug_Utilities (g-debuti.ads)
15462
@section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15463
@cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15464
@cindex Debugging
15465
 
15466
@noindent
15467
Provides a few useful utilities for debugging purposes, including conversion
15468
to and from string images of address values. Supports both C and Ada formats
15469
for hexadecimal literals.
15470
 
15471
@node GNAT.Decode_String (g-decstr.ads)
15472
@section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15473
@cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15474
@cindex Decoding strings
15475
@cindex String decoding
15476
@cindex Wide character encoding
15477
@cindex UTF-8
15478
@cindex Unicode
15479
 
15480
@noindent
15481
A generic package providing routines for decoding wide character and wide wide
15482
character strings encoded as sequences of 8-bit characters using a specified
15483
encoding method. Includes validation routines, and also routines for stepping
15484
to next or previous encoded character in an encoded string.
15485
Useful in conjunction with Unicode character coding. Note there is a
15486
preinstantiation for UTF-8. See next entry.
15487
 
15488
@node GNAT.Decode_UTF8_String (g-deutst.ads)
15489
@section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15490
@cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15491
@cindex Decoding strings
15492
@cindex Decoding UTF-8 strings
15493
@cindex UTF-8 string decoding
15494
@cindex Wide character decoding
15495
@cindex UTF-8
15496
@cindex Unicode
15497
 
15498
@noindent
15499
A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15500
 
15501
@node GNAT.Directory_Operations (g-dirope.ads)
15502
@section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15503
@cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15504
@cindex Directory operations
15505
 
15506
@noindent
15507
Provides a set of routines for manipulating directories, including changing
15508
the current directory, making new directories, and scanning the files in a
15509
directory.
15510
 
15511
@node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15512
@section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15513
@cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15514
@cindex Directory operations iteration
15515
 
15516
@noindent
15517
A child unit of GNAT.Directory_Operations providing additional operations
15518
for iterating through directories.
15519
 
15520
@node GNAT.Dynamic_HTables (g-dynhta.ads)
15521
@section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15522
@cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15523
@cindex Hash tables
15524
 
15525
@noindent
15526
A generic implementation of hash tables that can be used to hash arbitrary
15527
data.  Provided in two forms, a simple form with built in hash functions,
15528
and a more complex form in which the hash function is supplied.
15529
 
15530
@noindent
15531
This package provides a facility similar to that of @code{GNAT.HTable},
15532
except that this package declares a type that can be used to define
15533
dynamic instances of the hash table, while an instantiation of
15534
@code{GNAT.HTable} creates a single instance of the hash table.
15535
 
15536
@node GNAT.Dynamic_Tables (g-dyntab.ads)
15537
@section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15538
@cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15539
@cindex Table implementation
15540
@cindex Arrays, extendable
15541
 
15542
@noindent
15543
A generic package providing a single dimension array abstraction where the
15544
length of the array can be dynamically modified.
15545
 
15546
@noindent
15547
This package provides a facility similar to that of @code{GNAT.Table},
15548
except that this package declares a type that can be used to define
15549
dynamic instances of the table, while an instantiation of
15550
@code{GNAT.Table} creates a single instance of the table type.
15551
 
15552
@node GNAT.Encode_String (g-encstr.ads)
15553
@section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15554
@cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15555
@cindex Encoding strings
15556
@cindex String encoding
15557
@cindex Wide character encoding
15558
@cindex UTF-8
15559
@cindex Unicode
15560
 
15561
@noindent
15562
A generic package providing routines for encoding wide character and wide
15563
wide character strings as sequences of 8-bit characters using a specified
15564
encoding method. Useful in conjunction with Unicode character coding.
15565
Note there is a preinstantiation for UTF-8. See next entry.
15566
 
15567
@node GNAT.Encode_UTF8_String (g-enutst.ads)
15568
@section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15569
@cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15570
@cindex Encoding strings
15571
@cindex Encoding UTF-8 strings
15572
@cindex UTF-8 string encoding
15573
@cindex Wide character encoding
15574
@cindex UTF-8
15575
@cindex Unicode
15576
 
15577
@noindent
15578
A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15579
 
15580
@node GNAT.Exception_Actions (g-excact.ads)
15581
@section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15582
@cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15583
@cindex Exception actions
15584
 
15585
@noindent
15586
Provides callbacks when an exception is raised. Callbacks can be registered
15587
for specific exceptions, or when any exception is raised. This
15588
can be used for instance to force a core dump to ease debugging.
15589
 
15590
@node GNAT.Exception_Traces (g-exctra.ads)
15591
@section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15592
@cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15593
@cindex Exception traces
15594
@cindex Debugging
15595
 
15596
@noindent
15597
Provides an interface allowing to control automatic output upon exception
15598
occurrences.
15599
 
15600
@node GNAT.Exceptions (g-except.ads)
15601
@section @code{GNAT.Exceptions} (@file{g-expect.ads})
15602
@cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15603
@cindex Exceptions, Pure
15604
@cindex Pure packages, exceptions
15605
 
15606
@noindent
15607
Normally it is not possible to raise an exception with
15608
a message from a subprogram in a pure package, since the
15609
necessary types and subprograms are in @code{Ada.Exceptions}
15610
which is not a pure unit. @code{GNAT.Exceptions} provides a
15611
facility for getting around this limitation for a few
15612
predefined exceptions, and for example allow raising
15613
@code{Constraint_Error} with a message from a pure subprogram.
15614
 
15615
@node GNAT.Expect (g-expect.ads)
15616
@section @code{GNAT.Expect} (@file{g-expect.ads})
15617
@cindex @code{GNAT.Expect} (@file{g-expect.ads})
15618
 
15619
@noindent
15620
Provides a set of subprograms similar to what is available
15621
with the standard Tcl Expect tool.
15622
It allows you to easily spawn and communicate with an external process.
15623
You can send commands or inputs to the process, and compare the output
15624
with some expected regular expression. Currently @code{GNAT.Expect}
15625
is implemented on all native GNAT ports except for OpenVMS@.
15626
It is not implemented for cross ports, and in particular is not
15627
implemented for VxWorks or LynxOS@.
15628
 
15629
@node GNAT.Expect.TTY (g-exptty.ads)
15630
@section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15631
@cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15632
 
15633
@noindent
15634
As GNAT.Expect but using pseudo-terminal.
15635
Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15636
ports except for OpenVMS@. It is not implemented for cross ports, and
15637
in particular is not implemented for VxWorks or LynxOS@.
15638
 
15639
@node GNAT.Float_Control (g-flocon.ads)
15640
@section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15641
@cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15642
@cindex Floating-Point Processor
15643
 
15644
@noindent
15645
Provides an interface for resetting the floating-point processor into the
15646
mode required for correct semantic operation in Ada.  Some third party
15647
library calls may cause this mode to be modified, and the Reset procedure
15648
in this package can be used to reestablish the required mode.
15649
 
15650
@node GNAT.Heap_Sort (g-heasor.ads)
15651
@section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15652
@cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15653
@cindex Sorting
15654
 
15655
@noindent
15656
Provides a general implementation of heap sort usable for sorting arbitrary
15657
data items. Exchange and comparison procedures are provided by passing
15658
access-to-procedure values.  The algorithm used is a modified heap sort
15659
that performs approximately N*log(N) comparisons in the worst case.
15660
 
15661
@node GNAT.Heap_Sort_A (g-hesora.ads)
15662
@section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15663
@cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15664
@cindex Sorting
15665
 
15666
@noindent
15667
Provides a general implementation of heap sort usable for sorting arbitrary
15668
data items. Move and comparison procedures are provided by passing
15669
access-to-procedure values.  The algorithm used is a modified heap sort
15670
that performs approximately N*log(N) comparisons in the worst case.
15671
This differs from @code{GNAT.Heap_Sort} in having a less convenient
15672
interface, but may be slightly more efficient.
15673
 
15674
@node GNAT.Heap_Sort_G (g-hesorg.ads)
15675
@section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15676
@cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15677
@cindex Sorting
15678
 
15679
@noindent
15680
Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15681
are provided as generic parameters, this improves efficiency, especially
15682
if the procedures can be inlined, at the expense of duplicating code for
15683
multiple instantiations.
15684
 
15685
@node GNAT.HTable (g-htable.ads)
15686
@section @code{GNAT.HTable} (@file{g-htable.ads})
15687
@cindex @code{GNAT.HTable} (@file{g-htable.ads})
15688
@cindex Hash tables
15689
 
15690
@noindent
15691
A generic implementation of hash tables that can be used to hash arbitrary
15692
data.  Provides two approaches, one a simple static approach, and the other
15693
allowing arbitrary dynamic hash tables.
15694
 
15695
@node GNAT.IO (g-io.ads)
15696
@section @code{GNAT.IO} (@file{g-io.ads})
15697
@cindex @code{GNAT.IO} (@file{g-io.ads})
15698
@cindex Simple I/O
15699
@cindex Input/Output facilities
15700
 
15701
@noindent
15702
A simple preelaborable input-output package that provides a subset of
15703
simple Text_IO functions for reading characters and strings from
15704
Standard_Input, and writing characters, strings and integers to either
15705
Standard_Output or Standard_Error.
15706
 
15707
@node GNAT.IO_Aux (g-io_aux.ads)
15708
@section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15709
@cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15710
@cindex Text_IO
15711
@cindex Input/Output facilities
15712
 
15713
Provides some auxiliary functions for use with Text_IO, including a test
15714
for whether a file exists, and functions for reading a line of text.
15715
 
15716
@node GNAT.Lock_Files (g-locfil.ads)
15717
@section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15718
@cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15719
@cindex File locking
15720
@cindex Locking using files
15721
 
15722
@noindent
15723
Provides a general interface for using files as locks.  Can be used for
15724
providing program level synchronization.
15725
 
15726
@node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15727
@section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15728
@cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15729
@cindex Random number generation
15730
 
15731
@noindent
15732
The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
15733
a modified version of the Blum-Blum-Shub generator.
15734
 
15735
@node GNAT.MBBS_Float_Random (g-mbflra.ads)
15736
@section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15737
@cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15738
@cindex Random number generation
15739
 
15740
@noindent
15741
The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
15742
a modified version of the Blum-Blum-Shub generator.
15743
 
15744
@node GNAT.MD5 (g-md5.ads)
15745
@section @code{GNAT.MD5} (@file{g-md5.ads})
15746
@cindex @code{GNAT.MD5} (@file{g-md5.ads})
15747
@cindex Message Digest MD5
15748
 
15749
@noindent
15750
Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15751
 
15752
@node GNAT.Memory_Dump (g-memdum.ads)
15753
@section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15754
@cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15755
@cindex Dump Memory
15756
 
15757
@noindent
15758
Provides a convenient routine for dumping raw memory to either the
15759
standard output or standard error files. Uses GNAT.IO for actual
15760
output.
15761
 
15762
@node GNAT.Most_Recent_Exception (g-moreex.ads)
15763
@section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15764
@cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15765
@cindex Exception, obtaining most recent
15766
 
15767
@noindent
15768
Provides access to the most recently raised exception.  Can be used for
15769
various logging purposes, including duplicating functionality of some
15770
Ada 83 implementation dependent extensions.
15771
 
15772
@node GNAT.OS_Lib (g-os_lib.ads)
15773
@section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15774
@cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15775
@cindex Operating System interface
15776
@cindex Spawn capability
15777
 
15778
@noindent
15779
Provides a range of target independent operating system interface functions,
15780
including time/date management, file operations, subprocess management,
15781
including a portable spawn procedure, and access to environment variables
15782
and error return codes.
15783
 
15784
@node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15785
@section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15786
@cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15787
@cindex Hash functions
15788
 
15789
@noindent
15790
Provides a generator of static minimal perfect hash functions. No
15791
collisions occur and each item can be retrieved from the table in one
15792
probe (perfect property). The hash table size corresponds to the exact
15793
size of the key set and no larger (minimal property). The key set has to
15794
be know in advance (static property). The hash functions are also order
15795
preserving. If w2 is inserted after w1 in the generator, their
15796
hashcode are in the same order. These hashing functions are very
15797
convenient for use with realtime applications.
15798
 
15799
@node GNAT.Random_Numbers (g-rannum.ads)
15800
@section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15801
@cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15802
@cindex Random number generation
15803
 
15804
@noindent
15805
Provides random number capabilities which extend those available in the
15806
standard Ada library and are more convenient to use.
15807
 
15808
@node GNAT.Regexp (g-regexp.ads)
15809
@section @code{GNAT.Regexp} (@file{g-regexp.ads})
15810
@cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15811
@cindex Regular expressions
15812
@cindex Pattern matching
15813
 
15814
@noindent
15815
A simple implementation of regular expressions, using a subset of regular
15816
expression syntax copied from familiar Unix style utilities.  This is the
15817
simples of the three pattern matching packages provided, and is particularly
15818
suitable for ``file globbing'' applications.
15819
 
15820
@node GNAT.Registry (g-regist.ads)
15821
@section @code{GNAT.Registry} (@file{g-regist.ads})
15822
@cindex @code{GNAT.Registry} (@file{g-regist.ads})
15823
@cindex Windows Registry
15824
 
15825
@noindent
15826
This is a high level binding to the Windows registry.  It is possible to
15827
do simple things like reading a key value, creating a new key.  For full
15828
registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15829
package provided with the Win32Ada binding
15830
 
15831
@node GNAT.Regpat (g-regpat.ads)
15832
@section @code{GNAT.Regpat} (@file{g-regpat.ads})
15833
@cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15834
@cindex Regular expressions
15835
@cindex Pattern matching
15836
 
15837
@noindent
15838
A complete implementation of Unix-style regular expression matching, copied
15839
from the original V7 style regular expression library written in C by
15840
Henry Spencer (and binary compatible with this C library).
15841
 
15842
@node GNAT.Secondary_Stack_Info (g-sestin.ads)
15843
@section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15844
@cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15845
@cindex Secondary Stack Info
15846
 
15847
@noindent
15848
Provide the capability to query the high water mark of the current task's
15849
secondary stack.
15850
 
15851
@node GNAT.Semaphores (g-semaph.ads)
15852
@section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15853
@cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15854
@cindex Semaphores
15855
 
15856
@noindent
15857
Provides classic counting and binary semaphores using protected types.
15858
 
15859
@node GNAT.Serial_Communications (g-sercom.ads)
15860
@section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15861
@cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15862
@cindex Serial_Communications
15863
 
15864
@noindent
15865
Provides a simple interface to send and receive data over a serial
15866
port. This is only supported on GNU/Linux and Windows.
15867
 
15868
@node GNAT.SHA1 (g-sha1.ads)
15869
@section @code{GNAT.SHA1} (@file{g-sha1.ads})
15870
@cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15871
@cindex Secure Hash Algorithm SHA-1
15872
 
15873
@noindent
15874
Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15875
and RFC 3174.
15876
 
15877
@node GNAT.SHA224 (g-sha224.ads)
15878
@section @code{GNAT.SHA224} (@file{g-sha224.ads})
15879
@cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15880
@cindex Secure Hash Algorithm SHA-224
15881
 
15882
@noindent
15883
Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15884
 
15885
@node GNAT.SHA256 (g-sha256.ads)
15886
@section @code{GNAT.SHA256} (@file{g-sha256.ads})
15887
@cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15888
@cindex Secure Hash Algorithm SHA-256
15889
 
15890
@noindent
15891
Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15892
 
15893
@node GNAT.SHA384 (g-sha384.ads)
15894
@section @code{GNAT.SHA384} (@file{g-sha384.ads})
15895
@cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15896
@cindex Secure Hash Algorithm SHA-384
15897
 
15898
@noindent
15899
Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15900
 
15901
@node GNAT.SHA512 (g-sha512.ads)
15902
@section @code{GNAT.SHA512} (@file{g-sha512.ads})
15903
@cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15904
@cindex Secure Hash Algorithm SHA-512
15905
 
15906
@noindent
15907
Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15908
 
15909
@node GNAT.Signals (g-signal.ads)
15910
@section @code{GNAT.Signals} (@file{g-signal.ads})
15911
@cindex @code{GNAT.Signals} (@file{g-signal.ads})
15912
@cindex Signals
15913
 
15914
@noindent
15915
Provides the ability to manipulate the blocked status of signals on supported
15916
targets.
15917
 
15918
@node GNAT.Sockets (g-socket.ads)
15919
@section @code{GNAT.Sockets} (@file{g-socket.ads})
15920
@cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15921
@cindex Sockets
15922
 
15923
@noindent
15924
A high level and portable interface to develop sockets based applications.
15925
This package is based on the sockets thin binding found in
15926
@code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15927
on all native GNAT ports except for OpenVMS@.  It is not implemented
15928
for the LynxOS@ cross port.
15929
 
15930
@node GNAT.Source_Info (g-souinf.ads)
15931
@section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15932
@cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15933
@cindex Source Information
15934
 
15935
@noindent
15936
Provides subprograms that give access to source code information known at
15937
compile time, such as the current file name and line number.
15938
 
15939
@node GNAT.Spelling_Checker (g-speche.ads)
15940
@section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15941
@cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15942
@cindex Spell checking
15943
 
15944
@noindent
15945
Provides a function for determining whether one string is a plausible
15946
near misspelling of another string.
15947
 
15948
@node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15949
@section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15950
@cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15951
@cindex Spell checking
15952
 
15953
@noindent
15954
Provides a generic function that can be instantiated with a string type for
15955
determining whether one string is a plausible near misspelling of another
15956
string.
15957
 
15958
@node GNAT.Spitbol.Patterns (g-spipat.ads)
15959
@section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15960
@cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15961
@cindex SPITBOL pattern matching
15962
@cindex Pattern matching
15963
 
15964
@noindent
15965
A complete implementation of SNOBOL4 style pattern matching.  This is the
15966
most elaborate of the pattern matching packages provided.  It fully duplicates
15967
the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15968
efficient algorithm developed by Robert Dewar for the SPITBOL system.
15969
 
15970
@node GNAT.Spitbol (g-spitbo.ads)
15971
@section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15972
@cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15973
@cindex SPITBOL interface
15974
 
15975
@noindent
15976
The top level package of the collection of SPITBOL-style functionality, this
15977
package provides basic SNOBOL4 string manipulation functions, such as
15978
Pad, Reverse, Trim, Substr capability, as well as a generic table function
15979
useful for constructing arbitrary mappings from strings in the style of
15980
the SNOBOL4 TABLE function.
15981
 
15982
@node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15983
@section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15984
@cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15985
@cindex Sets of strings
15986
@cindex SPITBOL Tables
15987
 
15988
@noindent
15989
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15990
for type @code{Standard.Boolean}, giving an implementation of sets of
15991
string values.
15992
 
15993
@node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15994
@section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15995
@cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15996
@cindex Integer maps
15997
@cindex Maps
15998
@cindex SPITBOL Tables
15999
 
16000
@noindent
16001
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16002
for type @code{Standard.Integer}, giving an implementation of maps
16003
from string to integer values.
16004
 
16005
@node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16006
@section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16007
@cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16008
@cindex String maps
16009
@cindex Maps
16010
@cindex SPITBOL Tables
16011
 
16012
@noindent
16013
A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16014
a variable length string type, giving an implementation of general
16015
maps from strings to strings.
16016
 
16017
@node GNAT.SSE (g-sse.ads)
16018
@section @code{GNAT.SSE} (@file{g-sse.ads})
16019
@cindex @code{GNAT.SSE} (@file{g-sse.ads})
16020
 
16021
@noindent
16022
Root of a set of units aimed at offering Ada bindings to a subset of
16023
the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16024
targets.  It exposes vector component types together with a general
16025
introduction to the binding contents and use.
16026
 
16027
@node GNAT.SSE.Vector_Types (g-ssvety.ads)
16028
@section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16029
@cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16030
 
16031
@noindent
16032
SSE vector types for use with SSE related intrinsics.
16033
 
16034
@node GNAT.Strings (g-string.ads)
16035
@section @code{GNAT.Strings} (@file{g-string.ads})
16036
@cindex @code{GNAT.Strings} (@file{g-string.ads})
16037
 
16038
@noindent
16039
Common String access types and related subprograms. Basically it
16040
defines a string access and an array of string access types.
16041
 
16042
@node GNAT.String_Split (g-strspl.ads)
16043
@section @code{GNAT.String_Split} (@file{g-strspl.ads})
16044
@cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16045
@cindex String splitter
16046
 
16047
@noindent
16048
Useful string manipulation routines: given a set of separators, split
16049
a string wherever the separators appear, and provide direct access
16050
to the resulting slices. This package is instantiated from
16051
@code{GNAT.Array_Split}.
16052
 
16053
@node GNAT.Table (g-table.ads)
16054
@section @code{GNAT.Table} (@file{g-table.ads})
16055
@cindex @code{GNAT.Table} (@file{g-table.ads})
16056
@cindex Table implementation
16057
@cindex Arrays, extendable
16058
 
16059
@noindent
16060
A generic package providing a single dimension array abstraction where the
16061
length of the array can be dynamically modified.
16062
 
16063
@noindent
16064
This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16065
except that this package declares a single instance of the table type,
16066
while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16067
used to define dynamic instances of the table.
16068
 
16069
@node GNAT.Task_Lock (g-tasloc.ads)
16070
@section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16071
@cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16072
@cindex Task synchronization
16073
@cindex Task locking
16074
@cindex Locking
16075
 
16076
@noindent
16077
A very simple facility for locking and unlocking sections of code using a
16078
single global task lock.  Appropriate for use in situations where contention
16079
between tasks is very rarely expected.
16080
 
16081
@node GNAT.Time_Stamp (g-timsta.ads)
16082
@section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16083
@cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16084
@cindex Time stamp
16085
@cindex Current time
16086
 
16087
@noindent
16088
Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16089
represents the current date and time in ISO 8601 format. This is a very simple
16090
routine with minimal code and there are no dependencies on any other unit.
16091
 
16092
@node GNAT.Threads (g-thread.ads)
16093
@section @code{GNAT.Threads} (@file{g-thread.ads})
16094
@cindex @code{GNAT.Threads} (@file{g-thread.ads})
16095
@cindex Foreign threads
16096
@cindex Threads, foreign
16097
 
16098
@noindent
16099
Provides facilities for dealing with foreign threads which need to be known
16100
by the GNAT run-time system. Consult the documentation of this package for
16101
further details if your program has threads that are created by a non-Ada
16102
environment which then accesses Ada code.
16103
 
16104
@node GNAT.Traceback (g-traceb.ads)
16105
@section @code{GNAT.Traceback} (@file{g-traceb.ads})
16106
@cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16107
@cindex Trace back facilities
16108
 
16109
@noindent
16110
Provides a facility for obtaining non-symbolic traceback information, useful
16111
in various debugging situations.
16112
 
16113
@node GNAT.Traceback.Symbolic (g-trasym.ads)
16114
@section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16115
@cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16116
@cindex Trace back facilities
16117
 
16118
@node GNAT.UTF_32 (g-utf_32.ads)
16119
@section @code{GNAT.UTF_32} (@file{g-table.ads})
16120
@cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16121
@cindex Wide character codes
16122
 
16123
@noindent
16124
This is a package intended to be used in conjunction with the
16125
@code{Wide_Character} type in Ada 95 and the
16126
@code{Wide_Wide_Character} type in Ada 2005 (available
16127
in @code{GNAT} in Ada 2005 mode). This package contains
16128
Unicode categorization routines, as well as lexical
16129
categorization routines corresponding to the Ada 2005
16130
lexical rules for identifiers and strings, and also a
16131
lower case to upper case fold routine corresponding to
16132
the Ada 2005 rules for identifier equivalence.
16133
 
16134
@node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16135
@section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16136
@cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16137
@cindex Spell checking
16138
 
16139
@noindent
16140
Provides a function for determining whether one wide wide string is a plausible
16141
near misspelling of another wide wide string, where the strings are represented
16142
using the UTF_32_String type defined in System.Wch_Cnv.
16143
 
16144
@node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16145
@section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16146
@cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16147
@cindex Spell checking
16148
 
16149
@noindent
16150
Provides a function for determining whether one wide string is a plausible
16151
near misspelling of another wide string.
16152
 
16153
@node GNAT.Wide_String_Split (g-wistsp.ads)
16154
@section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16155
@cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16156
@cindex Wide_String splitter
16157
 
16158
@noindent
16159
Useful wide string manipulation routines: given a set of separators, split
16160
a wide string wherever the separators appear, and provide direct access
16161
to the resulting slices. This package is instantiated from
16162
@code{GNAT.Array_Split}.
16163
 
16164
@node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16165
@section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16166
@cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16167
@cindex Spell checking
16168
 
16169
@noindent
16170
Provides a function for determining whether one wide wide string is a plausible
16171
near misspelling of another wide wide string.
16172
 
16173
@node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16174
@section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16175
@cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16176
@cindex Wide_Wide_String splitter
16177
 
16178
@noindent
16179
Useful wide wide string manipulation routines: given a set of separators, split
16180
a wide wide string wherever the separators appear, and provide direct access
16181
to the resulting slices. This package is instantiated from
16182
@code{GNAT.Array_Split}.
16183
 
16184
@node Interfaces.C.Extensions (i-cexten.ads)
16185
@section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16186
@cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16187
 
16188
@noindent
16189
This package contains additional C-related definitions, intended
16190
for use with either manually or automatically generated bindings
16191
to C libraries.
16192
 
16193
@node Interfaces.C.Streams (i-cstrea.ads)
16194
@section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16195
@cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16196
@cindex  C streams, interfacing
16197
 
16198
@noindent
16199
This package is a binding for the most commonly used operations
16200
on C streams.
16201
 
16202
@node Interfaces.CPP (i-cpp.ads)
16203
@section @code{Interfaces.CPP} (@file{i-cpp.ads})
16204
@cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16205
@cindex  C++ interfacing
16206
@cindex  Interfacing, to C++
16207
 
16208
@noindent
16209
This package provides facilities for use in interfacing to C++.  It
16210
is primarily intended to be used in connection with automated tools
16211
for the generation of C++ interfaces.
16212
 
16213
@node Interfaces.Packed_Decimal (i-pacdec.ads)
16214
@section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16215
@cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16216
@cindex  IBM Packed Format
16217
@cindex  Packed Decimal
16218
 
16219
@noindent
16220
This package provides a set of routines for conversions to and
16221
from a packed decimal format compatible with that used on IBM
16222
mainframes.
16223
 
16224
@node Interfaces.VxWorks (i-vxwork.ads)
16225
@section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16226
@cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16227
@cindex Interfacing to VxWorks
16228
@cindex VxWorks, interfacing
16229
 
16230
@noindent
16231
This package provides a limited binding to the VxWorks API.
16232
In particular, it interfaces with the
16233
VxWorks hardware interrupt facilities.
16234
 
16235
@node Interfaces.VxWorks.IO (i-vxwoio.ads)
16236
@section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16237
@cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16238
@cindex Interfacing to VxWorks' I/O
16239
@cindex VxWorks, I/O interfacing
16240
@cindex VxWorks, Get_Immediate
16241
@cindex Get_Immediate, VxWorks
16242
 
16243
@noindent
16244
This package provides a binding to the ioctl (IO/Control)
16245
function of VxWorks, defining a set of option values and
16246
function codes. A particular use of this package is
16247
to enable the use of Get_Immediate under VxWorks.
16248
 
16249
@node System.Address_Image (s-addima.ads)
16250
@section @code{System.Address_Image} (@file{s-addima.ads})
16251
@cindex @code{System.Address_Image} (@file{s-addima.ads})
16252
@cindex Address image
16253
@cindex Image, of an address
16254
 
16255
@noindent
16256
This function provides a useful debugging
16257
function that gives an (implementation dependent)
16258
string which identifies an address.
16259
 
16260
@node System.Assertions (s-assert.ads)
16261
@section @code{System.Assertions} (@file{s-assert.ads})
16262
@cindex @code{System.Assertions} (@file{s-assert.ads})
16263
@cindex Assertions
16264
@cindex Assert_Failure, exception
16265
 
16266
@noindent
16267
This package provides the declaration of the exception raised
16268
by an run-time assertion failure, as well as the routine that
16269
is used internally to raise this assertion.
16270
 
16271
@node System.Memory (s-memory.ads)
16272
@section @code{System.Memory} (@file{s-memory.ads})
16273
@cindex @code{System.Memory} (@file{s-memory.ads})
16274
@cindex Memory allocation
16275
 
16276
@noindent
16277
This package provides the interface to the low level routines used
16278
by the generated code for allocation and freeing storage for the
16279
default storage pool (analogous to the C routines malloc and free.
16280
It also provides a reallocation interface analogous to the C routine
16281
realloc. The body of this unit may be modified to provide alternative
16282
allocation mechanisms for the default pool, and in addition, direct
16283
calls to this unit may be made for low level allocation uses (for
16284
example see the body of @code{GNAT.Tables}).
16285
 
16286
@node System.Partition_Interface (s-parint.ads)
16287
@section @code{System.Partition_Interface} (@file{s-parint.ads})
16288
@cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16289
@cindex Partition interfacing functions
16290
 
16291
@noindent
16292
This package provides facilities for partition interfacing.  It
16293
is used primarily in a distribution context when using Annex E
16294
with @code{GLADE}.
16295
 
16296
@node System.Pool_Global (s-pooglo.ads)
16297
@section @code{System.Pool_Global} (@file{s-pooglo.ads})
16298
@cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16299
@cindex Storage pool, global
16300
@cindex Global storage pool
16301
 
16302
@noindent
16303
This package provides a storage pool that is equivalent to the default
16304
storage pool used for access types for which no pool is specifically
16305
declared. It uses malloc/free to allocate/free and does not attempt to
16306
do any automatic reclamation.
16307
 
16308
@node System.Pool_Local (s-pooloc.ads)
16309
@section @code{System.Pool_Local} (@file{s-pooloc.ads})
16310
@cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16311
@cindex Storage pool, local
16312
@cindex Local storage pool
16313
 
16314
@noindent
16315
This package provides a storage pool that is intended for use with locally
16316
defined access types. It uses malloc/free for allocate/free, and maintains
16317
a list of allocated blocks, so that all storage allocated for the pool can
16318
be freed automatically when the pool is finalized.
16319
 
16320
@node System.Restrictions (s-restri.ads)
16321
@section @code{System.Restrictions} (@file{s-restri.ads})
16322
@cindex @code{System.Restrictions} (@file{s-restri.ads})
16323
@cindex Run-time restrictions access
16324
 
16325
@noindent
16326
This package provides facilities for accessing at run time
16327
the status of restrictions specified at compile time for
16328
the partition. Information is available both with regard
16329
to actual restrictions specified, and with regard to
16330
compiler determined information on which restrictions
16331
are violated by one or more packages in the partition.
16332
 
16333
@node System.Rident (s-rident.ads)
16334
@section @code{System.Rident} (@file{s-rident.ads})
16335
@cindex @code{System.Rident} (@file{s-rident.ads})
16336
@cindex Restrictions definitions
16337
 
16338
@noindent
16339
This package provides definitions of the restrictions
16340
identifiers supported by GNAT, and also the format of
16341
the restrictions provided in package System.Restrictions.
16342
It is not normally necessary to @code{with} this generic package
16343
since the necessary instantiation is included in
16344
package System.Restrictions.
16345
 
16346
@node System.Strings.Stream_Ops (s-ststop.ads)
16347
@section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16348
@cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16349
@cindex Stream operations
16350
@cindex String stream operations
16351
 
16352
@noindent
16353
This package provides a set of stream subprograms for standard string types.
16354
It is intended primarily to support implicit use of such subprograms when
16355
stream attributes are applied to string types, but the subprograms in this
16356
package can be used directly by application programs.
16357
 
16358
@node System.Task_Info (s-tasinf.ads)
16359
@section @code{System.Task_Info} (@file{s-tasinf.ads})
16360
@cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16361
@cindex Task_Info pragma
16362
 
16363
@noindent
16364
This package provides target dependent functionality that is used
16365
to support the @code{Task_Info} pragma
16366
 
16367
@node System.Wch_Cnv (s-wchcnv.ads)
16368
@section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16369
@cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16370
@cindex Wide Character, Representation
16371
@cindex Wide String, Conversion
16372
@cindex Representation of wide characters
16373
 
16374
@noindent
16375
This package provides routines for converting between
16376
wide and wide wide characters and a representation as a value of type
16377
@code{Standard.String}, using a specified wide character
16378
encoding method.  It uses definitions in
16379
package @code{System.Wch_Con}.
16380
 
16381
@node System.Wch_Con (s-wchcon.ads)
16382
@section @code{System.Wch_Con} (@file{s-wchcon.ads})
16383
@cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16384
 
16385
@noindent
16386
This package provides definitions and descriptions of
16387
the various methods used for encoding wide characters
16388
in ordinary strings.  These definitions are used by
16389
the package @code{System.Wch_Cnv}.
16390
 
16391
@node Interfacing to Other Languages
16392
@chapter Interfacing to Other Languages
16393
@noindent
16394
The facilities in annex B of the Ada Reference Manual are fully
16395
implemented in GNAT, and in addition, a full interface to C++ is
16396
provided.
16397
 
16398
@menu
16399
* Interfacing to C::
16400
* Interfacing to C++::
16401
* Interfacing to COBOL::
16402
* Interfacing to Fortran::
16403
* Interfacing to non-GNAT Ada code::
16404
@end menu
16405
 
16406
@node Interfacing to C
16407
@section Interfacing to C
16408
 
16409
@noindent
16410
Interfacing to C with GNAT can use one of two approaches:
16411
 
16412
@itemize @bullet
16413
@item
16414
The types in the package @code{Interfaces.C} may be used.
16415
@item
16416
Standard Ada types may be used directly.  This may be less portable to
16417
other compilers, but will work on all GNAT compilers, which guarantee
16418
correspondence between the C and Ada types.
16419
@end itemize
16420
 
16421
@noindent
16422
Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16423
effect, since this is the default.  The following table shows the
16424
correspondence between Ada scalar types and the corresponding C types.
16425
 
16426
@table @code
16427
@item Integer
16428
@code{int}
16429
@item Short_Integer
16430
@code{short}
16431
@item Short_Short_Integer
16432
@code{signed char}
16433
@item Long_Integer
16434
@code{long}
16435
@item Long_Long_Integer
16436
@code{long long}
16437
@item Short_Float
16438
@code{float}
16439
@item Float
16440
@code{float}
16441
@item Long_Float
16442
@code{double}
16443
@item Long_Long_Float
16444
This is the longest floating-point type supported by the hardware.
16445
@end table
16446
 
16447
@noindent
16448
Additionally, there are the following general correspondences between Ada
16449
and C types:
16450
@itemize @bullet
16451
@item
16452
Ada enumeration types map to C enumeration types directly if pragma
16453
@code{Convention C} is specified, which causes them to have int
16454
length.  Without pragma @code{Convention C}, Ada enumeration types map to
16455
8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16456
@code{int}, respectively) depending on the number of values passed.
16457
This is the only case in which pragma @code{Convention C} affects the
16458
representation of an Ada type.
16459
 
16460
@item
16461
Ada access types map to C pointers, except for the case of pointers to
16462
unconstrained types in Ada, which have no direct C equivalent.
16463
 
16464
@item
16465
Ada arrays map directly to C arrays.
16466
 
16467
@item
16468
Ada records map directly to C structures.
16469
 
16470
@item
16471
Packed Ada records map to C structures where all members are bit fields
16472
of the length corresponding to the @code{@var{type}'Size} value in Ada.
16473
@end itemize
16474
 
16475
@node Interfacing to C++
16476
@section Interfacing to C++
16477
 
16478
@noindent
16479
The interface to C++ makes use of the following pragmas, which are
16480
primarily intended to be constructed automatically using a binding generator
16481
tool, although it is possible to construct them by hand.  No suitable binding
16482
generator tool is supplied with GNAT though.
16483
 
16484
Using these pragmas it is possible to achieve complete
16485
inter-operability between Ada tagged types and C++ class definitions.
16486
See @ref{Implementation Defined Pragmas}, for more details.
16487
 
16488
@table @code
16489
@item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16490
The argument denotes an entity in the current declarative region that is
16491
declared as a tagged or untagged record type. It indicates that the type
16492
corresponds to an externally declared C++ class type, and is to be laid
16493
out the same way that C++ would lay out the type.
16494
 
16495
Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16496
for backward compatibility but its functionality is available
16497
using pragma @code{Import} with @code{Convention} = @code{CPP}.
16498
 
16499
@item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16500
This pragma identifies an imported function (imported in the usual way
16501
with pragma @code{Import}) as corresponding to a C++ constructor.
16502
@end table
16503
 
16504
@node Interfacing to COBOL
16505
@section Interfacing to COBOL
16506
 
16507
@noindent
16508
Interfacing to COBOL is achieved as described in section B.4 of
16509
the Ada Reference Manual.
16510
 
16511
@node Interfacing to Fortran
16512
@section Interfacing to Fortran
16513
 
16514
@noindent
16515
Interfacing to Fortran is achieved as described in section B.5 of the
16516
Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
16517
multi-dimensional array causes the array to be stored in column-major
16518
order as required for convenient interface to Fortran.
16519
 
16520
@node Interfacing to non-GNAT Ada code
16521
@section Interfacing to non-GNAT Ada code
16522
 
16523
It is possible to specify the convention @code{Ada} in a pragma
16524
@code{Import} or pragma @code{Export}.  However this refers to
16525
the calling conventions used by GNAT, which may or may not be
16526
similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16527
compiler to allow interoperation.
16528
 
16529
If arguments types are kept simple, and if the foreign compiler generally
16530
follows system calling conventions, then it may be possible to integrate
16531
files compiled by other Ada compilers, provided that the elaboration
16532
issues are adequately addressed (for example by eliminating the
16533
need for any load time elaboration).
16534
 
16535
In particular, GNAT running on VMS is designed to
16536
be highly compatible with the DEC Ada 83 compiler, so this is one
16537
case in which it is possible to import foreign units of this type,
16538
provided that the data items passed are restricted to simple scalar
16539
values or simple record types without variants, or simple array
16540
types with fixed bounds.
16541
 
16542
@node Specialized Needs Annexes
16543
@chapter Specialized Needs Annexes
16544
 
16545
@noindent
16546
Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16547
required in all implementations.  However, as described in this chapter,
16548
GNAT implements all of these annexes:
16549
 
16550
@table @asis
16551
@item Systems Programming (Annex C)
16552
The Systems Programming Annex is fully implemented.
16553
 
16554
@item Real-Time Systems (Annex D)
16555
The Real-Time Systems Annex is fully implemented.
16556
 
16557
@item Distributed Systems (Annex E)
16558
Stub generation is fully implemented in the GNAT compiler.  In addition,
16559
a complete compatible PCS is available as part of the GLADE system,
16560
a separate product.  When the two
16561
products are used in conjunction, this annex is fully implemented.
16562
 
16563
@item Information Systems (Annex F)
16564
The Information Systems annex is fully implemented.
16565
 
16566
@item Numerics (Annex G)
16567
The Numerics Annex is fully implemented.
16568
 
16569
@item Safety and Security / High-Integrity Systems (Annex H)
16570
The Safety and Security Annex (termed the High-Integrity Systems Annex
16571
in Ada 2005) is fully implemented.
16572
@end table
16573
 
16574
@node Implementation of Specific Ada Features
16575
@chapter Implementation of Specific Ada Features
16576
 
16577
@noindent
16578
This chapter describes the GNAT implementation of several Ada language
16579
facilities.
16580
 
16581
@menu
16582
* Machine Code Insertions::
16583
* GNAT Implementation of Tasking::
16584
* GNAT Implementation of Shared Passive Packages::
16585
* Code Generation for Array Aggregates::
16586
* The Size of Discriminated Records with Default Discriminants::
16587
* Strict Conformance to the Ada Reference Manual::
16588
@end menu
16589
 
16590
@node Machine Code Insertions
16591
@section Machine Code Insertions
16592
@cindex Machine Code insertions
16593
 
16594
@noindent
16595
Package @code{Machine_Code} provides machine code support as described
16596
in the Ada Reference Manual in two separate forms:
16597
@itemize @bullet
16598
@item
16599
Machine code statements, consisting of qualified expressions that
16600
fit the requirements of RM section 13.8.
16601
@item
16602
An intrinsic callable procedure, providing an alternative mechanism of
16603
including machine instructions in a subprogram.
16604
@end itemize
16605
 
16606
@noindent
16607
The two features are similar, and both are closely related to the mechanism
16608
provided by the asm instruction in the GNU C compiler.  Full understanding
16609
and use of the facilities in this package requires understanding the asm
16610
instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16611
Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16612
 
16613
Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16614
semantic restrictions and effects as described below.  Both are provided so
16615
that the procedure call can be used as a statement, and the function call
16616
can be used to form a code_statement.
16617
 
16618
The first example given in the GCC documentation is the C @code{asm}
16619
instruction:
16620
@smallexample
16621
   asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16622
@end smallexample
16623
 
16624
@noindent
16625
The equivalent can be written for GNAT as:
16626
 
16627
@smallexample @c ada
16628
Asm ("fsinx %1 %0",
16629
     My_Float'Asm_Output ("=f", result),
16630
     My_Float'Asm_Input  ("f",  angle));
16631
@end smallexample
16632
 
16633
@noindent
16634
The first argument to @code{Asm} is the assembler template, and is
16635
identical to what is used in GNU C@.  This string must be a static
16636
expression.  The second argument is the output operand list.  It is
16637
either a single @code{Asm_Output} attribute reference, or a list of such
16638
references enclosed in parentheses (technically an array aggregate of
16639
such references).
16640
 
16641
The @code{Asm_Output} attribute denotes a function that takes two
16642
parameters.  The first is a string, the second is the name of a variable
16643
of the type designated by the attribute prefix.  The first (string)
16644
argument is required to be a static expression and designates the
16645
constraint for the parameter (e.g.@: what kind of register is
16646
required).  The second argument is the variable to be updated with the
16647
result.  The possible values for constraint are the same as those used in
16648
the RTL, and are dependent on the configuration file used to build the
16649
GCC back end.  If there are no output operands, then this argument may
16650
either be omitted, or explicitly given as @code{No_Output_Operands}.
16651
 
16652
The second argument of @code{@var{my_float}'Asm_Output} functions as
16653
though it were an @code{out} parameter, which is a little curious, but
16654
all names have the form of expressions, so there is no syntactic
16655
irregularity, even though normally functions would not be permitted
16656
@code{out} parameters.  The third argument is the list of input
16657
operands.  It is either a single @code{Asm_Input} attribute reference, or
16658
a list of such references enclosed in parentheses (technically an array
16659
aggregate of such references).
16660
 
16661
The @code{Asm_Input} attribute denotes a function that takes two
16662
parameters.  The first is a string, the second is an expression of the
16663
type designated by the prefix.  The first (string) argument is required
16664
to be a static expression, and is the constraint for the parameter,
16665
(e.g.@: what kind of register is required).  The second argument is the
16666
value to be used as the input argument.  The possible values for the
16667
constant are the same as those used in the RTL, and are dependent on
16668
the configuration file used to built the GCC back end.
16669
 
16670
If there are no input operands, this argument may either be omitted, or
16671
explicitly given as @code{No_Input_Operands}.  The fourth argument, not
16672
present in the above example, is a list of register names, called the
16673
@dfn{clobber} argument.  This argument, if given, must be a static string
16674
expression, and is a space or comma separated list of names of registers
16675
that must be considered destroyed as a result of the @code{Asm} call.  If
16676
this argument is the null string (the default value), then the code
16677
generator assumes that no additional registers are destroyed.
16678
 
16679
The fifth argument, not present in the above example, called the
16680
@dfn{volatile} argument, is by default @code{False}.  It can be set to
16681
the literal value @code{True} to indicate to the code generator that all
16682
optimizations with respect to the instruction specified should be
16683
suppressed, and that in particular, for an instruction that has outputs,
16684
the instruction will still be generated, even if none of the outputs are
16685
used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16686
gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16687
Generally it is strongly advisable to use Volatile for any ASM statement
16688
that is missing either input or output operands, or when two or more ASM
16689
statements appear in sequence, to avoid unwanted optimizations. A warning
16690
is generated if this advice is not followed.
16691
 
16692
The @code{Asm} subprograms may be used in two ways.  First the procedure
16693
forms can be used anywhere a procedure call would be valid, and
16694
correspond to what the RM calls ``intrinsic'' routines.  Such calls can
16695
be used to intersperse machine instructions with other Ada statements.
16696
Second, the function forms, which return a dummy value of the limited
16697
private type @code{Asm_Insn}, can be used in code statements, and indeed
16698
this is the only context where such calls are allowed.  Code statements
16699
appear as aggregates of the form:
16700
 
16701
@smallexample @c ada
16702
Asm_Insn'(Asm (@dots{}));
16703
Asm_Insn'(Asm_Volatile (@dots{}));
16704
@end smallexample
16705
 
16706
@noindent
16707
In accordance with RM rules, such code statements are allowed only
16708
within subprograms whose entire body consists of such statements.  It is
16709
not permissible to intermix such statements with other Ada statements.
16710
 
16711
Typically the form using intrinsic procedure calls is more convenient
16712
and more flexible.  The code statement form is provided to meet the RM
16713
suggestion that such a facility should be made available.  The following
16714
is the exact syntax of the call to @code{Asm}. As usual, if named notation
16715
is used, the arguments may be given in arbitrary order, following the
16716
normal rules for use of positional and named arguments)
16717
 
16718
@smallexample
16719
ASM_CALL ::= Asm (
16720
                 [Template =>] static_string_EXPRESSION
16721
               [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
16722
               [,[Inputs   =>] INPUT_OPERAND_LIST       ]
16723
               [,[Clobber  =>] static_string_EXPRESSION ]
16724
               [,[Volatile =>] static_boolean_EXPRESSION] )
16725
 
16726
OUTPUT_OPERAND_LIST ::=
16727
  [PREFIX.]No_Output_Operands
16728
| OUTPUT_OPERAND_ATTRIBUTE
16729
| (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16730
 
16731
OUTPUT_OPERAND_ATTRIBUTE ::=
16732
  SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16733
 
16734
INPUT_OPERAND_LIST ::=
16735
  [PREFIX.]No_Input_Operands
16736
| INPUT_OPERAND_ATTRIBUTE
16737
| (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16738
 
16739
INPUT_OPERAND_ATTRIBUTE ::=
16740
  SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16741
@end smallexample
16742
 
16743
@noindent
16744
The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16745
are declared in the package @code{Machine_Code} and must be referenced
16746
according to normal visibility rules. In particular if there is no
16747
@code{use} clause for this package, then appropriate package name
16748
qualification is required.
16749
 
16750
@node GNAT Implementation of Tasking
16751
@section GNAT Implementation of Tasking
16752
 
16753
@noindent
16754
This chapter outlines the basic GNAT approach to tasking (in particular,
16755
a multi-layered library for portability) and discusses issues related
16756
to compliance with the Real-Time Systems Annex.
16757
 
16758
@menu
16759
* Mapping Ada Tasks onto the Underlying Kernel Threads::
16760
* Ensuring Compliance with the Real-Time Annex::
16761
@end menu
16762
 
16763
@node Mapping Ada Tasks onto the Underlying Kernel Threads
16764
@subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16765
 
16766
@noindent
16767
GNAT's run-time support comprises two layers:
16768
 
16769
@itemize @bullet
16770
@item GNARL (GNAT Run-time Layer)
16771
@item GNULL (GNAT Low-level Library)
16772
@end itemize
16773
 
16774
@noindent
16775
In GNAT, Ada's tasking services rely on a platform and OS independent
16776
layer known as GNARL@.  This code is responsible for implementing the
16777
correct semantics of Ada's task creation, rendezvous, protected
16778
operations etc.
16779
 
16780
GNARL decomposes Ada's tasking semantics into simpler lower level
16781
operations such as create a thread, set the priority of a thread,
16782
yield, create a lock, lock/unlock, etc.  The spec for these low-level
16783
operations constitutes GNULLI, the GNULL Interface.  This interface is
16784
directly inspired from the POSIX real-time API@.
16785
 
16786
If the underlying executive or OS implements the POSIX standard
16787
faithfully, the GNULL Interface maps as is to the services offered by
16788
the underlying kernel.  Otherwise, some target dependent glue code maps
16789
the services offered by the underlying kernel to the semantics expected
16790
by GNARL@.
16791
 
16792
Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16793
key point is that each Ada task is mapped on a thread in the underlying
16794
kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
16795
 
16796
In addition Ada task priorities map onto the underlying thread priorities.
16797
Mapping Ada tasks onto the underlying kernel threads has several advantages:
16798
 
16799
@itemize @bullet
16800
@item
16801
The underlying scheduler is used to schedule the Ada tasks.  This
16802
makes Ada tasks as efficient as kernel threads from a scheduling
16803
standpoint.
16804
 
16805
@item
16806
Interaction with code written in C containing threads is eased
16807
since at the lowest level Ada tasks and C threads map onto the same
16808
underlying kernel concept.
16809
 
16810
@item
16811
When an Ada task is blocked during I/O the remaining Ada tasks are
16812
able to proceed.
16813
 
16814
@item
16815
On multiprocessor systems Ada tasks can execute in parallel.
16816
@end itemize
16817
 
16818
@noindent
16819
Some threads libraries offer a mechanism to fork a new process, with the
16820
child process duplicating the threads from the parent.
16821
GNAT does not
16822
support this functionality when the parent contains more than one task.
16823
@cindex Forking a new process
16824
 
16825
@node Ensuring Compliance with the Real-Time Annex
16826
@subsection Ensuring Compliance with the Real-Time Annex
16827
@cindex Real-Time Systems Annex compliance
16828
 
16829
@noindent
16830
Although mapping Ada tasks onto
16831
the underlying threads has significant advantages, it does create some
16832
complications when it comes to respecting the scheduling semantics
16833
specified in the real-time annex (Annex D).
16834
 
16835
For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16836
scheduling policy states:
16837
 
16838
@quotation
16839
@emph{When the active priority of a ready task that is not running
16840
changes, or the setting of its base priority takes effect, the
16841
task is removed from the ready queue for its old active priority
16842
and is added at the tail of the ready queue for its new active
16843
priority, except in the case where the active priority is lowered
16844
due to the loss of inherited priority, in which case the task is
16845
added at the head of the ready queue for its new active priority.}
16846
@end quotation
16847
 
16848
@noindent
16849
While most kernels do put tasks at the end of the priority queue when
16850
a task changes its priority, (which respects the main
16851
FIFO_Within_Priorities requirement), almost none keep a thread at the
16852
beginning of its priority queue when its priority drops from the loss
16853
of inherited priority.
16854
 
16855
As a result most vendors have provided incomplete Annex D implementations.
16856
 
16857
The GNAT run-time, has a nice cooperative solution to this problem
16858
which ensures that accurate FIFO_Within_Priorities semantics are
16859
respected.
16860
 
16861
The principle is as follows.  When an Ada task T is about to start
16862
running, it checks whether some other Ada task R with the same
16863
priority as T has been suspended due to the loss of priority
16864
inheritance.  If this is the case, T yields and is placed at the end of
16865
its priority queue.  When R arrives at the front of the queue it
16866
executes.
16867
 
16868
Note that this simple scheme preserves the relative order of the tasks
16869
that were ready to execute in the priority queue where R has been
16870
placed at the end.
16871
 
16872
@node GNAT Implementation of Shared Passive Packages
16873
@section GNAT Implementation of Shared Passive Packages
16874
@cindex Shared passive packages
16875
 
16876
@noindent
16877
GNAT fully implements the pragma @code{Shared_Passive} for
16878
@cindex pragma @code{Shared_Passive}
16879
the purpose of designating shared passive packages.
16880
This allows the use of passive partitions in the
16881
context described in the Ada Reference Manual; i.e., for communication
16882
between separate partitions of a distributed application using the
16883
features in Annex E.
16884
@cindex Annex E
16885
@cindex Distribution Systems Annex
16886
 
16887
However, the implementation approach used by GNAT provides for more
16888
extensive usage as follows:
16889
 
16890
@table @emph
16891
@item Communication between separate programs
16892
 
16893
This allows separate programs to access the data in passive
16894
partitions, using protected objects for synchronization where
16895
needed. The only requirement is that the two programs have a
16896
common shared file system. It is even possible for programs
16897
running on different machines with different architectures
16898
(e.g.@: different endianness) to communicate via the data in
16899
a passive partition.
16900
 
16901
@item Persistence between program runs
16902
 
16903
The data in a passive package can persist from one run of a
16904
program to another, so that a later program sees the final
16905
values stored by a previous run of the same program.
16906
 
16907
@end table
16908
 
16909
@noindent
16910
The implementation approach used is to store the data in files. A
16911
separate stream file is created for each object in the package, and
16912
an access to an object causes the corresponding file to be read or
16913
written.
16914
 
16915
The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16916
@cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16917
set to the directory to be used for these files.
16918
The files in this directory
16919
have names that correspond to their fully qualified names. For
16920
example, if we have the package
16921
 
16922
@smallexample @c ada
16923
package X is
16924
  pragma Shared_Passive (X);
16925
  Y : Integer;
16926
  Z : Float;
16927
end X;
16928
@end smallexample
16929
 
16930
@noindent
16931
and the environment variable is set to @code{/stemp/}, then the files created
16932
will have the names:
16933
 
16934
@smallexample
16935
/stemp/x.y
16936
/stemp/x.z
16937
@end smallexample
16938
 
16939
@noindent
16940
These files are created when a value is initially written to the object, and
16941
the files are retained until manually deleted. This provides the persistence
16942
semantics. If no file exists, it means that no partition has assigned a value
16943
to the variable; in this case the initial value declared in the package
16944
will be used. This model ensures that there are no issues in synchronizing
16945
the elaboration process, since elaboration of passive packages elaborates the
16946
initial values, but does not create the files.
16947
 
16948
The files are written using normal @code{Stream_IO} access.
16949
If you want to be able
16950
to communicate between programs or partitions running on different
16951
architectures, then you should use the XDR versions of the stream attribute
16952
routines, since these are architecture independent.
16953
 
16954
If active synchronization is required for access to the variables in the
16955
shared passive package, then as described in the Ada Reference Manual, the
16956
package may contain protected objects used for this purpose. In this case
16957
a lock file (whose name is @file{___lock} (three underscores)
16958
is created in the shared memory directory.
16959
@cindex @file{___lock} file (for shared passive packages)
16960
This is used to provide the required locking
16961
semantics for proper protected object synchronization.
16962
 
16963
As of January 2003, GNAT supports shared passive packages on all platforms
16964
except for OpenVMS.
16965
 
16966
@node Code Generation for Array Aggregates
16967
@section Code Generation for Array Aggregates
16968
 
16969
@menu
16970
* Static constant aggregates with static bounds::
16971
* Constant aggregates with unconstrained nominal types::
16972
* Aggregates with static bounds::
16973
* Aggregates with non-static bounds::
16974
* Aggregates in assignment statements::
16975
@end menu
16976
 
16977
@noindent
16978
Aggregates have a rich syntax and allow the user to specify the values of
16979
complex data structures by means of a single construct.  As a result, the
16980
code generated for aggregates can be quite complex and involve loops, case
16981
statements and multiple assignments.  In the simplest cases, however, the
16982
compiler will recognize aggregates whose components and constraints are
16983
fully static, and in those cases the compiler will generate little or no
16984
executable code.  The following is an outline of the code that GNAT generates
16985
for various aggregate constructs.  For further details, you will find it
16986
useful to examine the output produced by the -gnatG flag to see the expanded
16987
source that is input to the code generator.  You may also want to examine
16988
the assembly code generated at various levels of optimization.
16989
 
16990
The code generated for aggregates depends on the context, the component values,
16991
and the type.  In the context of an object declaration the code generated is
16992
generally simpler than in the case of an assignment.  As a general rule, static
16993
component values and static subtypes also lead to simpler code.
16994
 
16995
@node Static constant aggregates with static bounds
16996
@subsection Static constant aggregates with static bounds
16997
 
16998
@noindent
16999
For the declarations:
17000
@smallexample @c ada
17001
    type One_Dim is array (1..10) of integer;
17002
    ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17003
@end smallexample
17004
 
17005
@noindent
17006
GNAT generates no executable code: the constant ar0 is placed in static memory.
17007
The same is true for constant aggregates with named associations:
17008
 
17009
@smallexample @c ada
17010
    Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17011
    Cr3 : constant One_Dim := (others => 7777);
17012
@end smallexample
17013
 
17014
@noindent
17015
The same is true for multidimensional constant arrays such as:
17016
 
17017
@smallexample @c ada
17018
    type two_dim is array (1..3, 1..3) of integer;
17019
    Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17020
@end smallexample
17021
 
17022
@noindent
17023
The same is true for arrays of one-dimensional arrays: the following are
17024
static:
17025
 
17026
@smallexample @c ada
17027
type ar1b  is array (1..3) of boolean;
17028
type ar_ar is array (1..3) of ar1b;
17029
None  : constant ar1b := (others => false);     --  fully static
17030
None2 : constant ar_ar := (1..3 => None);       --  fully static
17031
@end smallexample
17032
 
17033
@noindent
17034
However, for multidimensional aggregates with named associations, GNAT will
17035
generate assignments and loops, even if all associations are static.  The
17036
following two declarations generate a loop for the first dimension, and
17037
individual component assignments for the second dimension:
17038
 
17039
@smallexample @c ada
17040
Zero1: constant two_dim := (1..3 => (1..3 => 0));
17041
Zero2: constant two_dim := (others => (others => 0));
17042
@end smallexample
17043
 
17044
@node Constant aggregates with unconstrained nominal types
17045
@subsection Constant aggregates with unconstrained nominal types
17046
 
17047
@noindent
17048
In such cases the aggregate itself establishes the subtype, so that
17049
associations with @code{others} cannot be used.  GNAT determines the
17050
bounds for the actual subtype of the aggregate, and allocates the
17051
aggregate statically as well.  No code is generated for the following:
17052
 
17053
@smallexample @c ada
17054
    type One_Unc is array (natural range <>) of integer;
17055
    Cr_Unc : constant One_Unc := (12,24,36);
17056
@end smallexample
17057
 
17058
@node Aggregates with static bounds
17059
@subsection Aggregates with static bounds
17060
 
17061
@noindent
17062
In all previous examples the aggregate was the initial (and immutable) value
17063
of a constant.  If the aggregate initializes a variable, then code is generated
17064
for it as a combination of individual assignments and loops over the target
17065
object.  The declarations
17066
 
17067
@smallexample @c ada
17068
       Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17069
       Cr_Var2 : One_Dim := (others > -1);
17070
@end smallexample
17071
 
17072
@noindent
17073
generate the equivalent of
17074
 
17075
@smallexample @c ada
17076
       Cr_Var1 (1) := 2;
17077
       Cr_Var1 (2) := 3;
17078
       Cr_Var1 (3) := 5;
17079
       Cr_Var1 (4) := 11;
17080
 
17081
       for I in Cr_Var2'range loop
17082
          Cr_Var2 (I) := -1;
17083
       end loop;
17084
@end smallexample
17085
 
17086
@node Aggregates with non-static bounds
17087
@subsection Aggregates with non-static bounds
17088
 
17089
@noindent
17090
If the bounds of the aggregate are not statically compatible with the bounds
17091
of the nominal subtype  of the target, then constraint checks have to be
17092
generated on the bounds.  For a multidimensional array, constraint checks may
17093
have to be applied to sub-arrays individually, if they do not have statically
17094
compatible subtypes.
17095
 
17096
@node Aggregates in assignment statements
17097
@subsection Aggregates in assignment statements
17098
 
17099
@noindent
17100
In general, aggregate assignment requires the construction of a temporary,
17101
and a copy from the temporary to the target of the assignment.  This is because
17102
it is not always possible to convert the assignment into a series of individual
17103
component assignments.  For example, consider the simple case:
17104
 
17105
@smallexample @c ada
17106
        A := (A(2), A(1));
17107
@end smallexample
17108
 
17109
@noindent
17110
This cannot be converted into:
17111
 
17112
@smallexample @c ada
17113
        A(1) := A(2);
17114
        A(2) := A(1);
17115
@end smallexample
17116
 
17117
@noindent
17118
So the aggregate has to be built first in a separate location, and then
17119
copied into the target.  GNAT recognizes simple cases where this intermediate
17120
step is not required, and the assignments can be performed in place, directly
17121
into the target.  The following sufficient criteria are applied:
17122
 
17123
@itemize @bullet
17124
@item
17125
The bounds of the aggregate are static, and the associations are static.
17126
@item
17127
The components of the aggregate are static constants, names of
17128
simple variables that are not renamings, or expressions not involving
17129
indexed components whose operands obey these rules.
17130
@end itemize
17131
 
17132
@noindent
17133
If any of these conditions are violated, the aggregate will be built in
17134
a temporary (created either by the front-end or the code generator) and then
17135
that temporary will be copied onto the target.
17136
 
17137
@node The Size of Discriminated Records with Default Discriminants
17138
@section The Size of Discriminated Records with Default Discriminants
17139
 
17140
@noindent
17141
If a discriminated type @code{T} has discriminants with default values, it is
17142
possible to declare an object of this type without providing an explicit
17143
constraint:
17144
 
17145
@smallexample @c ada
17146
@group
17147
type Size is range 1..100;
17148
 
17149
type Rec (D : Size := 15) is record
17150
   Name : String (1..D);
17151
end T;
17152
 
17153
Word : Rec;
17154
@end group
17155
@end smallexample
17156
 
17157
@noindent
17158
Such an object is said to be @emph{unconstrained}.
17159
The discriminant of the object
17160
can be modified by a full assignment to the object, as long as it preserves the
17161
relation between the value of the discriminant, and the value of the components
17162
that depend on it:
17163
 
17164
@smallexample @c ada
17165
@group
17166
Word := (3, "yes");
17167
 
17168
Word := (5, "maybe");
17169
 
17170
Word := (5, "no"); -- raises Constraint_Error
17171
@end group
17172
@end smallexample
17173
 
17174
@noindent
17175
In order to support this behavior efficiently, an unconstrained object is
17176
given the maximum size that any value of the type requires. In the case
17177
above, @code{Word} has storage for the discriminant and for
17178
a @code{String} of length 100.
17179
It is important to note that unconstrained objects do not require dynamic
17180
allocation. It would be an improper implementation to place on the heap those
17181
components whose size depends on discriminants. (This improper implementation
17182
was used by some Ada83 compilers, where the @code{Name} component above
17183
would have
17184
been stored as a pointer to a dynamic string). Following the principle that
17185
dynamic storage management should never be introduced implicitly,
17186
an Ada compiler should reserve the full size for an unconstrained declared
17187
object, and place it on the stack.
17188
 
17189
This maximum size approach
17190
has been a source of surprise to some users, who expect the default
17191
values of the discriminants to determine the size reserved for an
17192
unconstrained object: ``If the default is 15, why should the object occupy
17193
a larger size?''
17194
The answer, of course, is that the discriminant may be later modified,
17195
and its full range of values must be taken into account. This is why the
17196
declaration:
17197
 
17198
@smallexample
17199
@group
17200
type Rec (D : Positive := 15) is record
17201
   Name : String (1..D);
17202
end record;
17203
 
17204
Too_Large : Rec;
17205
@end group
17206
@end smallexample
17207
 
17208
@noindent
17209
is flagged by the compiler with a warning:
17210
an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17211
because the required size includes @code{Positive'Last}
17212
bytes. As the first example indicates, the proper approach is to declare an
17213
index type of ``reasonable'' range so that unconstrained objects are not too
17214
large.
17215
 
17216
One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17217
created in the heap by means of an allocator, then it is @emph{not}
17218
unconstrained:
17219
it is constrained by the default values of the discriminants, and those values
17220
cannot be modified by full assignment. This is because in the presence of
17221
aliasing all views of the object (which may be manipulated by different tasks,
17222
say) must be consistent, so it is imperative that the object, once created,
17223
remain invariant.
17224
 
17225
@node Strict Conformance to the Ada Reference Manual
17226
@section Strict Conformance to the Ada Reference Manual
17227
 
17228
@noindent
17229
The dynamic semantics defined by the Ada Reference Manual impose a set of
17230
run-time checks to be generated. By default, the GNAT compiler will insert many
17231
run-time checks into the compiled code, including most of those required by the
17232
Ada Reference Manual. However, there are three checks that are not enabled
17233
in the default mode for efficiency reasons: arithmetic overflow checking for
17234
integer operations (including division by zero), checks for access before
17235
elaboration on subprogram calls, and stack overflow checking (most operating
17236
systems do not perform this check by default).
17237
 
17238
Strict conformance to the Ada Reference Manual can be achieved by adding
17239
three compiler options for overflow checking for integer operations
17240
(@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17241
calls and generic instantiations (@option{-gnatE}), and stack overflow
17242
checking (@option{-fstack-check}).
17243
 
17244
Note that the result of a floating point arithmetic operation in overflow and
17245
invalid situations, when the @code{Machine_Overflows} attribute of the result
17246
type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17247
case for machines compliant with the IEEE floating-point standard, but on
17248
machines that are not fully compliant with this standard, such as Alpha, the
17249
@option{-mieee} compiler flag must be used for achieving IEEE confirming
17250
behavior (although at the cost of a significant performance penalty), so
17251
infinite and NaN values are properly generated.
17252
 
17253
 
17254
@node Implementation of Ada 2012 Features
17255
@chapter Implementation of Ada 2012 Features
17256
@cindex Ada 2012 implementation status
17257
 
17258
This chapter contains a complete list of Ada 2012 features that have been
17259
implemented as of GNAT version 6.4. Generally, these features are only
17260
available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17261
@cindex @option{-gnat12} option
17262
or if the configuration pragma @code{Ada_2012} is used.
17263
@cindex pragma @code{Ada_2012}
17264
@cindex configuration pragma @code{Ada_2012}
17265
@cindex @code{Ada_2012} configuration pragma
17266
However, new pragmas, attributes, and restrictions are
17267
unconditionally available, since the Ada 95 standard allows the addition of
17268
new pragmas, attributes, and restrictions (there are exceptions, which are
17269
documented in the individual descriptions), and also certain packages
17270
were made available in earlier versions of Ada.
17271
 
17272
An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17273
This date shows the implementation date of the feature. Any wavefront
17274
subsequent to this date will contain the indicated feature, as will any
17275
subsequent releases. A date of 0000-00-00 means that GNAT has always
17276
implemented the feature, or implemented it as soon as it appeared as a
17277
binding interpretation.
17278
 
17279
Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17280
standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17281
The features are ordered based on the relevant sections of the Ada
17282
Reference Manual (``RM'').  When a given AI relates to multiple points
17283
in the RM, the earliest is used.
17284
 
17285
A complete description of the AIs may be found in
17286
@url{www.ada-auth.org/ai05-summary.html}.
17287
 
17288
@itemize @bullet
17289
 
17290
@item
17291
@emph{AI-0176 Quantified expressions (2010-09-29)}
17292
@cindex AI-0176 (Ada 2012 feature)
17293
 
17294
@noindent
17295
  Both universally and existentially quantified expressions are implemented.
17296
  They use the new syntax for iterators proposed in AI05-139-2, as well as
17297
  the standard Ada loop syntax.
17298
 
17299
@noindent
17300
  RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
17301
 
17302
@item
17303
@emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17304
@cindex AI-0079 (Ada 2012 feature)
17305
 
17306
@noindent
17307
  Wide characters in the unicode category @i{other_format} are now allowed in
17308
  source programs between tokens, but not within a token such as an identifier.
17309
 
17310
@noindent
17311
  RM References:  2.01 (4/2)   2.02 (7)
17312
 
17313
@item
17314
@emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17315
@cindex AI-0091 (Ada 2012 feature)
17316
 
17317
@noindent
17318
  Wide characters in the unicode category @i{other_format} are not permitted
17319
  within  an identifier, since this can be a security problem. The error
17320
  message for this case has been improved to be more specific, but GNAT has
17321
  never allowed such characters to appear in identifiers.
17322
 
17323
@noindent
17324
  RM References:  2.03 (3.1/2)   2.03 (4/2)   2.03 (5/2)   2.03 (5.1/2)   2.03 (5.2/2)   2.03 (5.3/2)   2.09 (2/2)
17325
 
17326
@item
17327
@emph{AI-0100 Placement of pragmas  (2010-07-01)}
17328
@cindex AI-0100 (Ada 2012 feature)
17329
 
17330
@noindent
17331
  This AI is an earlier version of AI-163. It simplifies the rules
17332
  for legal placement of pragmas. In the case of lists that allow pragmas, if
17333
  the list may have no elements, then the list may consist solely of pragmas.
17334
 
17335
@noindent
17336
  RM References:  2.08 (7)
17337
 
17338
@item
17339
@emph{AI-0163 Pragmas in place of null (2010-07-01)}
17340
@cindex AI-0163 (Ada 2012 feature)
17341
 
17342
@noindent
17343
  A statement sequence may be composed entirely of pragmas. It is no longer
17344
  necessary to add a dummy @code{null} statement to make the sequence legal.
17345
 
17346
@noindent
17347
  RM References:  2.08 (7)   2.08 (16)
17348
 
17349
 
17350
@item
17351
@emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17352
@cindex AI-0080 (Ada 2012 feature)
17353
 
17354
@noindent
17355
  This is an editorial change only, described as non-testable in the AI.
17356
 
17357
@noindent
17358
  RM References:  3.01 (7)
17359
 
17360
 
17361
@item
17362
@emph{AI-0183 Aspect specifications (2010-08-16)}
17363
@cindex AI-0183 (Ada 2012 feature)
17364
 
17365
@noindent
17366
  Aspect specifications have been fully implemented except for pre and post-
17367
  conditions, and type invariants, which have their own separate AI's. All
17368
  forms of declarations listed in the AI are supported. The following is a
17369
  list of the aspects supported (with GNAT implementation aspects marked)
17370
 
17371
@multitable {@code{Preelaborable_Initialization}} {--GNAT}
17372
@item @code{Ada_2005} @tab                      -- GNAT
17373
@item @code{Ada_2012} @tab                      -- GNAT
17374
@item @code{Address} @tab
17375
@item @code{Alignment} @tab
17376
@item @code{Atomic} @tab
17377
@item @code{Atomic_Components} @tab
17378
@item @code{Bit_Order} @tab
17379
@item @code{Component_Size} @tab
17380
@item @code{Discard_Names} @tab
17381
@item @code{External_Tag} @tab
17382
@item @code{Favor_Top_Level} @tab               -- GNAT
17383
@item @code{Inline} @tab
17384
@item @code{Inline_Always} @tab                 -- GNAT
17385
@item @code{Invariant} @tab
17386
@item @code{Machine_Radix} @tab
17387
@item @code{No_Return} @tab
17388
@item @code{Object_Size} @tab                   -- GNAT
17389
@item @code{Pack} @tab
17390
@item @code{Persistent_BSS} @tab                -- GNAT
17391
@item @code{Post} @tab
17392
@item @code{Pre} @tab
17393
@item @code{Predicate} @tab
17394
@item @code{Preelaborable_Initialization} @tab
17395
@item @code{Pure_Function} @tab                 -- GNAT
17396
@item @code{Remote_Access_Type} @tab            -- GNAT
17397
@item @code{Shared} @tab                        -- GNAT
17398
@item @code{Size} @tab
17399
@item @code{Storage_Pool} @tab
17400
@item @code{Storage_Size} @tab
17401
@item @code{Stream_Size} @tab
17402
@item @code{Suppress} @tab
17403
@item @code{Suppress_Debug_Info} @tab           -- GNAT
17404
@item @code{Test_Case} @tab                     -- GNAT
17405
@item @code{Unchecked_Union} @tab
17406
@item @code{Universal_Aliasing} @tab            -- GNAT
17407
@item @code{Unmodified} @tab                    -- GNAT
17408
@item @code{Unreferenced} @tab                  -- GNAT
17409
@item @code{Unreferenced_Objects} @tab          -- GNAT
17410
@item @code{Unsuppress} @tab
17411
@item @code{Value_Size} @tab                    -- GNAT
17412
@item @code{Volatile} @tab
17413
@item @code{Volatile_Components}
17414
@item @code{Warnings} @tab                      -- GNAT
17415
@end multitable
17416
 
17417
@noindent
17418
  Note that for aspects with an expression, e.g. @code{Size}, the expression is
17419
  treated like a default expression (visibility is analyzed at the point of
17420
  occurrence of the aspect, but evaluation of the expression occurs at the
17421
  freeze point of the entity involved.
17422
 
17423
@noindent
17424
  RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
17425
  3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
17426
  (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
17427
  9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
17428
  12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
17429
  13.03.01 (0)
17430
 
17431
 
17432
@item
17433
@emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17434
@cindex AI-0128 (Ada 2012 feature)
17435
 
17436
@noindent
17437
  If an equality operator ("=") is declared for a type, then the implicitly
17438
  declared inequality operator ("/=") is a primitive operation of the type.
17439
  This is the only reasonable interpretation, and is the one always implemented
17440
  by GNAT, but the RM was not entirely clear in making this point.
17441
 
17442
@noindent
17443
  RM References:  3.02.03 (6)   6.06 (6)
17444
 
17445
@item
17446
@emph{AI-0003 Qualified expressions as names (2010-07-11)}
17447
@cindex AI-0003 (Ada 2012 feature)
17448
 
17449
@noindent
17450
   In Ada 2012, a qualified expression is considered to be syntactically a name,
17451
   meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17452
   useful in disambiguating some cases of overloading.
17453
 
17454
@noindent
17455
  RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
17456
  5.04 (7)
17457
 
17458
@item
17459
@emph{AI-0120 Constant instance of protected object (0000-00-00)}
17460
@cindex AI-0120 (Ada 2012 feature)
17461
 
17462
@noindent
17463
  This is an RM editorial change only. The section that lists objects that are
17464
  constant failed to include the current instance of a protected object
17465
  within a protected function. This has always been treated as a constant
17466
  in GNAT.
17467
 
17468
@noindent
17469
  RM References:  3.03 (21)
17470
 
17471
@item
17472
@emph{AI-0008 General access to constrained objects (0000-00-00)}
17473
@cindex AI-0008 (Ada 2012 feature)
17474
 
17475
@noindent
17476
  The wording in the RM implied that if you have a general access to a
17477
  constrained object, it could be used to modify the discriminants. This was
17478
  obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17479
  has always done so in this situation.
17480
 
17481
@noindent
17482
  RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
17483
 
17484
 
17485
@item
17486
@emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17487
@cindex AI-0093 (Ada 2012 feature)
17488
 
17489
@noindent
17490
  This is an editorial change only, to make more widespread use of the Ada 2012
17491
  ``immutably limited''.
17492
 
17493
@noindent
17494
  RM References:  3.03 (23.4/3)
17495
 
17496
 
17497
 
17498
@item
17499
@emph{AI-0096 Deriving from formal private types (2010-07-20)}
17500
@cindex AI-0096 (Ada 2012 feature)
17501
 
17502
@noindent
17503
  In general it is illegal for a type derived from a formal limited type to be
17504
  nonlimited.  This AI makes an exception to this rule: derivation is legal
17505
  if it appears in the private part of the generic, and the formal type is not
17506
  tagged. If the type is tagged, the legality check must be applied to the
17507
  private part of the package.
17508
 
17509
@noindent
17510
  RM References:  3.04 (5.1/2)   6.02 (7)
17511
 
17512
 
17513
@item
17514
@emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17515
@cindex AI-0181 (Ada 2012 feature)
17516
 
17517
@noindent
17518
  From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17519
  means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17520
  @code{Image} and @code{Value} attributes for the character types. Strictly
17521
  speaking this is an inconsistency with Ada 95, but in practice the use of
17522
  these attributes is so obscure that it will not cause problems.
17523
 
17524
@noindent
17525
  RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
17526
 
17527
 
17528
@item
17529
@emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17530
@cindex AI-0182 (Ada 2012 feature)
17531
 
17532
@noindent
17533
  This AI allows @code{Character'Value} to accept the string @code{'?'} where
17534
  @code{?} is any character including non-graphic control characters. GNAT has
17535
  always accepted such strings. It also allows strings such as
17536
  @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17537
  permission and raises @code{Constraint_Error}, as is certainly still
17538
  permitted.
17539
 
17540
@noindent
17541
  RM References:  3.05 (56/2)
17542
 
17543
 
17544
@item
17545
@emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17546
@cindex AI-0214 (Ada 2012 feature)
17547
 
17548
@noindent
17549
  Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17550
  to have default expressions by allowing them when the type is limited. It
17551
  is often useful to define a default value for a discriminant even though
17552
  it can't be changed by assignment.
17553
 
17554
@noindent
17555
  RM References:  3.07 (9.1/2)   3.07.02 (3)
17556
 
17557
 
17558
@item
17559
@emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17560
@cindex AI-0102 (Ada 2012 feature)
17561
 
17562
@noindent
17563
  It is illegal to assign an anonymous access constant to an anonymous access
17564
  variable. The RM did not have a clear rule to prevent this, but GNAT has
17565
  always generated an error for this usage.
17566
 
17567
@noindent
17568
  RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
17569
 
17570
 
17571
@item
17572
@emph{AI-0158 Generalizing membership tests (2010-09-16)}
17573
@cindex AI-0158 (Ada 2012 feature)
17574
 
17575
@noindent
17576
  This AI extends the syntax of membership tests to simplify complex conditions
17577
  that can be expressed as membership in a subset of values of any type. It
17578
  introduces syntax for a list of expressions that may be used in loop contexts
17579
  as well.
17580
 
17581
@noindent
17582
  RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
17583
 
17584
 
17585
@item
17586
@emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17587
@cindex AI-0173 (Ada 2012 feature)
17588
 
17589
@noindent
17590
  The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17591
  with the tag of an abstract type, and @code{False} otherwise.
17592
 
17593
@noindent
17594
  RM References:  3.09 (7.4/2)   3.09 (12.4/2)
17595
 
17596
 
17597
 
17598
@item
17599
@emph{AI-0076 function with controlling result (0000-00-00)}
17600
@cindex AI-0076 (Ada 2012 feature)
17601
 
17602
@noindent
17603
  This is an editorial change only. The RM defines calls with controlling
17604
  results, but uses the term ``function with controlling result'' without an
17605
  explicit definition.
17606
 
17607
@noindent
17608
  RM References:  3.09.02 (2/2)
17609
 
17610
 
17611
@item
17612
@emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17613
@cindex AI-0126 (Ada 2012 feature)
17614
 
17615
@noindent
17616
  This AI clarifies dispatching rules, and simply confirms that dispatching
17617
  executes the operation of the parent type when there is no explicitly or
17618
  implicitly declared operation for the descendant type. This has always been
17619
  the case in all versions of GNAT.
17620
 
17621
@noindent
17622
  RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
17623
 
17624
 
17625
@item
17626
@emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17627
@cindex AI-0097 (Ada 2012 feature)
17628
 
17629
@noindent
17630
  The RM as written implied that in some cases it was possible to create an
17631
  object of an abstract type, by having an abstract extension inherit a non-
17632
  abstract constructor from its parent type. This mistake has been corrected
17633
  in GNAT and in the RM, and this construct is now illegal.
17634
 
17635
@noindent
17636
  RM References:  3.09.03 (4/2)
17637
 
17638
 
17639
@item
17640
@emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17641
@cindex AI-0203 (Ada 2012 feature)
17642
 
17643
@noindent
17644
  A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17645
  permitted such usage.
17646
 
17647
@noindent
17648
  RM References:  3.09.03 (8/3)
17649
 
17650
 
17651
@item
17652
@emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
17653
@cindex AI-0198 (Ada 2012 feature)
17654
 
17655
@noindent
17656
  This AI resolves a conflict between two rules involving inherited abstract
17657
  operations and predefined operators. If a derived numeric type inherits
17658
  an abstract operator, it overrides the predefined one. This interpretation
17659
  was always the one implemented in GNAT.
17660
 
17661
@noindent
17662
  RM References:  3.09.03 (4/3)
17663
 
17664
@item
17665
@emph{AI-0073 Functions returning abstract types (2010-07-10)}
17666
@cindex AI-0073 (Ada 2012 feature)
17667
 
17668
@noindent
17669
  This AI covers a number of issues regarding returning abstract types. In
17670
  particular generic functions cannot have abstract result types or access
17671
  result types designated an abstract type. There are some other cases which
17672
  are detailed in the AI. Note that this binding interpretation has not been
17673
  retrofitted to operate before Ada 2012 mode, since it caused a significant
17674
  number of regressions.
17675
 
17676
@noindent
17677
  RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
17678
 
17679
 
17680
@item
17681
@emph{AI-0070 Elaboration of interface types (0000-00-00)}
17682
@cindex AI-0070 (Ada 2012 feature)
17683
 
17684
@noindent
17685
  This is an editorial change only, there are no testable consequences short of
17686
  checking for the absence of generated code for an interface declaration.
17687
 
17688
@noindent
17689
  RM References:  3.09.04 (18/2)
17690
 
17691
 
17692
@item
17693
@emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17694
@cindex AI-0208 (Ada 2012 feature)
17695
 
17696
@noindent
17697
  The wording in the Ada 2005 RM concerning characteristics of incomplete views
17698
  was incorrect and implied that some programs intended to be legal were now
17699
  illegal. GNAT had never considered such programs illegal, so it has always
17700
  implemented the intent of this AI.
17701
 
17702
@noindent
17703
  RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
17704
 
17705
 
17706
@item
17707
@emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17708
@cindex AI-0162 (Ada 2012 feature)
17709
 
17710
@noindent
17711
  Incomplete types are made more useful by allowing them to be completed by
17712
  private types and private extensions.
17713
 
17714
@noindent
17715
  RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
17716
 
17717
 
17718
 
17719
@item
17720
@emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17721
@cindex AI-0098 (Ada 2012 feature)
17722
 
17723
@noindent
17724
  An unintentional omission in the RM implied some inconsistent restrictions on
17725
  the use of anonymous access to subprogram values. These restrictions were not
17726
  intentional, and have never been enforced by GNAT.
17727
 
17728
@noindent
17729
  RM References:  3.10.01 (6)   3.10.01 (9.2/2)
17730
 
17731
 
17732
@item
17733
@emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17734
@cindex AI-0199 (Ada 2012 feature)
17735
 
17736
@noindent
17737
  A choice list in a record aggregate can include several components of
17738
  (distinct) anonymous access types as long as they have matching designated
17739
  subtypes.
17740
 
17741
@noindent
17742
  RM References:  4.03.01 (16)
17743
 
17744
 
17745
@item
17746
@emph{AI-0220 Needed components for aggregates (0000-00-00)}
17747
@cindex AI-0220 (Ada 2012 feature)
17748
 
17749
@noindent
17750
  This AI addresses a wording problem in the RM that appears to permit some
17751
  complex cases of aggregates with non-static discriminants. GNAT has always
17752
  implemented the intended semantics.
17753
 
17754
@noindent
17755
  RM References:  4.03.01 (17)
17756
 
17757
@item
17758
@emph{AI-0147 Conditional expressions (2009-03-29)}
17759
@cindex AI-0147 (Ada 2012 feature)
17760
 
17761
@noindent
17762
  Conditional expressions are permitted. The form of such an expression is:
17763
 
17764
@smallexample
17765
    (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17766
@end smallexample
17767
 
17768
  The parentheses can be omitted in contexts where parentheses are present
17769
  anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17770
  clause is omitted, @b{else True} is assumed;
17771
  thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17772
  @emph{(A implies B)} in standard logic.
17773
 
17774
@noindent
17775
  RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
17776
  4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
17777
 
17778
 
17779
@item
17780
@emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17781
@cindex AI-0037 (Ada 2012 feature)
17782
 
17783
@noindent
17784
  This AI confirms that an association of the form @code{Indx => <>} in an
17785
  array aggregate must raise @code{Constraint_Error} if @code{Indx}
17786
  is out of range. The RM specified a range check on other associations, but
17787
  not when the value of the association was defaulted. GNAT has always inserted
17788
  a constraint check on the index value.
17789
 
17790
@noindent
17791
  RM References:  4.03.03 (29)
17792
 
17793
 
17794
@item
17795
@emph{AI-0123 Composability of equality (2010-04-13)}
17796
@cindex AI-0123 (Ada 2012 feature)
17797
 
17798
@noindent
17799
  Equality of untagged record composes, so that the predefined equality for a
17800
  composite type that includes a component of some untagged record type
17801
  @code{R} uses the equality operation of @code{R} (which may be user-defined
17802
  or predefined). This makes the behavior of untagged records identical to that
17803
  of tagged types in this respect.
17804
 
17805
  This change is an incompatibility with previous versions of Ada, but it
17806
  corrects a non-uniformity that was often a source of confusion. Analysis of
17807
  a large number of industrial programs indicates that in those rare cases
17808
  where a composite type had an untagged record component with a user-defined
17809
  equality, either there was no use of the composite equality, or else the code
17810
  expected the same composability as for tagged types, and thus had a bug that
17811
  would be fixed by this change.
17812
 
17813
@noindent
17814
  RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
17815
  8.05.04 (8)
17816
 
17817
 
17818
@item
17819
@emph{AI-0088 The value of exponentiation (0000-00-00)}
17820
@cindex AI-0088 (Ada 2012 feature)
17821
 
17822
@noindent
17823
  This AI clarifies the equivalence rule given for the dynamic semantics of
17824
  exponentiation: the value of the operation can be obtained by repeated
17825
  multiplication, but the operation can be implemented otherwise (for example
17826
  using the familiar divide-by-two-and-square algorithm, even if this is less
17827
  accurate), and does not imply repeated reads of a volatile base.
17828
 
17829
@noindent
17830
  RM References:  4.05.06 (11)
17831
 
17832
@item
17833
@emph{AI-0188 Case expressions (2010-01-09)}
17834
@cindex AI-0188 (Ada 2012 feature)
17835
 
17836
@noindent
17837
  Case expressions are permitted. This allows use of constructs such as:
17838
@smallexample
17839
  X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17840
@end smallexample
17841
 
17842
@noindent
17843
  RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
17844
 
17845
@item
17846
@emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17847
@cindex AI-0104 (Ada 2012 feature)
17848
 
17849
@noindent
17850
  The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17851
  @code{Constraint_Error} because the default value of the allocated object is
17852
  @b{null}. This useless construct is illegal in Ada 2012.
17853
 
17854
@noindent
17855
  RM References:  4.08 (2)
17856
 
17857
@item
17858
@emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17859
@cindex AI-0157 (Ada 2012 feature)
17860
 
17861
@noindent
17862
  Allocation and Deallocation from an empty storage pool (i.e. allocation or
17863
  deallocation of a pointer for which a static storage size clause of zero
17864
  has been given) is now illegal and is detected as such. GNAT
17865
  previously gave a warning but not an error.
17866
 
17867
@noindent
17868
  RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
17869
 
17870
@item
17871
@emph{AI-0179 Statement not required after label (2010-04-10)}
17872
@cindex AI-0179 (Ada 2012 feature)
17873
 
17874
@noindent
17875
  It is not necessary to have a statement following a label, so a label
17876
  can appear at the end of a statement sequence without the need for putting a
17877
  null statement afterwards, but it is not allowable to have only labels and
17878
  no real statements in a statement sequence.
17879
 
17880
@noindent
17881
  RM References:  5.01 (2)
17882
 
17883
 
17884
@item
17885
@emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17886
@cindex AI-139-2 (Ada 2012 feature)
17887
 
17888
@noindent
17889
  The new syntax for iterating over arrays and containers is now implemented.
17890
  Iteration over containers is for now limited to read-only iterators. Only
17891
  default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
17892
 
17893
@noindent
17894
  RM References:  5.05
17895
 
17896
@item
17897
@emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17898
@cindex AI-0134 (Ada 2012 feature)
17899
 
17900
@noindent
17901
  For full conformance, the profiles of anonymous-access-to-subprogram
17902
  parameters must match. GNAT has always enforced this rule.
17903
 
17904
@noindent
17905
  RM References:  6.03.01 (18)
17906
 
17907
@item
17908
@emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17909
@cindex AI-0207 (Ada 2012 feature)
17910
 
17911
@noindent
17912
  This AI confirms that access_to_constant indication must match for mode
17913
  conformance. This was implemented in GNAT when the qualifier was originally
17914
  introduced in Ada 2005.
17915
 
17916
@noindent
17917
  RM References:  6.03.01 (16/2)
17918
 
17919
 
17920
@item
17921
@emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17922
@cindex AI-0046 (Ada 2012 feature)
17923
 
17924
@noindent
17925
  For full conformance, in the case of access parameters, the null exclusion
17926
  must match (either both or neither must have @code{@b{not null}}).
17927
 
17928
@noindent
17929
  RM References:  6.03.02 (18)
17930
 
17931
 
17932
@item
17933
@emph{AI-0118 The association of parameter associations (0000-00-00)}
17934
@cindex AI-0118 (Ada 2012 feature)
17935
 
17936
@noindent
17937
  This AI clarifies the rules for named associations in subprogram calls and
17938
  generic instantiations. The rules have been in place since Ada 83.
17939
 
17940
@noindent
17941
  RM References:  6.04.01 (2)   12.03 (9)
17942
 
17943
 
17944
@item
17945
@emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17946
@cindex AI-0196 (Ada 2012 feature)
17947
 
17948
@noindent
17949
  Null exclusion checks are not made for @code{@b{out}} parameters when
17950
  evaluating the actual parameters. GNAT has never generated these checks.
17951
 
17952
@noindent
17953
  RM References:  6.04.01 (13)
17954
 
17955
@item
17956
@emph{AI-0015 Constant return objects (0000-00-00)}
17957
@cindex AI-0015 (Ada 2012 feature)
17958
 
17959
@noindent
17960
  The return object declared in an @i{extended_return_statement} may be
17961
  declared constant. This was always intended, and GNAT has always allowed it.
17962
 
17963
@noindent
17964
  RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
17965
  6.05 (5.7/2)
17966
 
17967
 
17968
@item
17969
@emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17970
@cindex AI-0032 (Ada 2012 feature)
17971
 
17972
@noindent
17973
  If a function returns a class-wide type, the object of an extended return
17974
  statement can be declared with a specific type that is covered by the class-
17975
  wide type. This has been implemented in GNAT since the introduction of
17976
  extended returns. Note AI-0103 complements this AI by imposing matching
17977
  rules for constrained return types.
17978
 
17979
@noindent
17980
  RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
17981
  6.05 (8/2)
17982
 
17983
@item
17984
@emph{AI-0103 Static matching for extended return (2010-07-23)}
17985
@cindex AI-0103 (Ada 2012 feature)
17986
 
17987
@noindent
17988
  If the return subtype of a function is an elementary type or a constrained
17989
  type, the subtype indication in an extended return statement must match
17990
  statically this return subtype.
17991
 
17992
@noindent
17993
  RM References:  6.05 (5.2/2)
17994
 
17995
 
17996
@item
17997
@emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17998
@cindex AI-0058 (Ada 2012 feature)
17999
 
18000
@noindent
18001
  The RM had some incorrect wording implying wrong treatment of abnormal
18002
  completion in an extended return. GNAT has always implemented the intended
18003
  correct semantics as described by this AI.
18004
 
18005
@noindent
18006
  RM References:  6.05 (22/2)
18007
 
18008
 
18009
@item
18010
@emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18011
@cindex AI-0050 (Ada 2012 feature)
18012
 
18013
@noindent
18014
  The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
18015
  not take advantage of these incorrect permissions in any case.
18016
 
18017
@noindent
18018
  RM References:  6.05 (24/2)
18019
 
18020
 
18021
@item
18022
@emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18023
@cindex AI-0125 (Ada 2012 feature)
18024
 
18025
@noindent
18026
  In Ada 2012, the declaration of a primitive operation of a type extension
18027
  or private extension can also override an inherited primitive that is not
18028
  visible at the point of this declaration.
18029
 
18030
@noindent
18031
  RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
18032
 
18033
@item
18034
@emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18035
@cindex AI-0062 (Ada 2012 feature)
18036
 
18037
@noindent
18038
  A full constant may have a null exclusion even if its associated deferred
18039
  constant does not. GNAT has always allowed this.
18040
 
18041
@noindent
18042
  RM References:  7.04 (6/2)   7.04 (7.1/2)
18043
 
18044
 
18045
@item
18046
@emph{AI-0178 Incomplete views are limited (0000-00-00)}
18047
@cindex AI-0178 (Ada 2012 feature)
18048
 
18049
@noindent
18050
  This AI clarifies the role of incomplete views and plugs an omission in the
18051
  RM. GNAT always correctly restricted the use of incomplete views and types.
18052
 
18053
@noindent
18054
  RM References:  7.05 (3/2)   7.05 (6/2)
18055
 
18056
@item
18057
@emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18058
@cindex AI-0087 (Ada 2012 feature)
18059
 
18060
@noindent
18061
  The actual for a formal nonlimited derived type cannot be limited. In
18062
  particular, a formal derived type that extends a limited interface but which
18063
  is not explicitly limited cannot be instantiated with a limited type.
18064
 
18065
@noindent
18066
  RM References:  7.05 (5/2)   12.05.01 (5.1/2)
18067
 
18068
@item
18069
@emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18070
@cindex AI-0099 (Ada 2012 feature)
18071
 
18072
@noindent
18073
  This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18074
  and therefore depends on the run-time characteristics of an object (i.e. its
18075
  tag) and not on its nominal type. As the AI indicates: ``we do not expect
18076
  this to affect any implementation''.
18077
 
18078
@noindent
18079
  RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
18080
 
18081
 
18082
 
18083
@item
18084
@emph{AI-0064 Redundant finalization rule (0000-00-00)}
18085
@cindex AI-0064 (Ada 2012 feature)
18086
 
18087
@noindent
18088
  This is an editorial change only. The intended behavior is already checked
18089
  by an existing ACATS test, which GNAT has always executed correctly.
18090
 
18091
@noindent
18092
  RM References:  7.06.01 (17.1/1)
18093
 
18094
@item
18095
@emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18096
@cindex AI-0026 (Ada 2012 feature)
18097
 
18098
@noindent
18099
  Record representation clauses concerning Unchecked_Union types cannot mention
18100
  the discriminant of the type. The type of a component declared in the variant
18101
  part of an Unchecked_Union cannot be controlled, have controlled components,
18102
  nor have protected or task parts. If an Unchecked_Union type is declared
18103
  within the body of a generic unit or its descendants, then the type of a
18104
  component declared in the variant part cannot be a formal private type or a
18105
  formal private extension declared within the same generic unit.
18106
 
18107
@noindent
18108
  RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
18109
 
18110
 
18111
@item
18112
@emph{AI-0205 Extended return declares visible name (0000-00-00)}
18113
@cindex AI-0205 (Ada 2012 feature)
18114
 
18115
@noindent
18116
  This AI corrects a simple omission in the RM. Return objects have always
18117
  been visible within an extended return statement.
18118
 
18119
@noindent
18120
  RM References:  8.03 (17)
18121
 
18122
 
18123
@item
18124
@emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18125
@cindex AI-0042 (Ada 2012 feature)
18126
 
18127
@noindent
18128
  This AI fixes a wording gap in the RM. An operation of a synchronized
18129
  interface can be implemented by a protected or task entry, but the abstract
18130
  operation is not being overridden in the usual sense, and it must be stated
18131
  separately that this implementation is legal. This has always been the case
18132
  in GNAT.
18133
 
18134
@noindent
18135
  RM References:  9.01 (9.2/2)   9.04 (11.1/2)
18136
 
18137
@item
18138
@emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18139
@cindex AI-0030 (Ada 2012 feature)
18140
 
18141
@noindent
18142
  Requeue is permitted to a protected, synchronized or task interface primitive
18143
  providing it is known that the overriding operation is an entry. Otherwise
18144
  the requeue statement has the same effect as a procedure call. Use of pragma
18145
  @code{Implemented} provides a way to impose a static requirement on the
18146
  overriding operation by adhering to one of the implementation kinds: entry,
18147
  protected procedure or any of the above.
18148
 
18149
@noindent
18150
  RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
18151
  9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
18152
 
18153
 
18154
@item
18155
@emph{AI-0201 Independence of atomic object components (2010-07-22)}
18156
@cindex AI-0201 (Ada 2012 feature)
18157
 
18158
@noindent
18159
  If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18160
  attribute, then individual components may not be addressable by independent
18161
  tasks. However, if the representation clause has no effect (is confirming),
18162
  then independence is not compromised. Furthermore, in GNAT, specification of
18163
  other appropriately addressable component sizes (e.g. 16 for 8-bit
18164
  characters) also preserves independence. GNAT now gives very clear warnings
18165
  both for the declaration of such a type, and for any assignment to its components.
18166
 
18167
@noindent
18168
  RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
18169
 
18170
@item
18171
@emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18172
@cindex AI-0009 (Ada 2012 feature)
18173
 
18174
@noindent
18175
  This AI introduces the new pragmas @code{Independent} and
18176
  @code{Independent_Components},
18177
  which control guaranteeing independence of access to objects and components.
18178
  The AI also requires independence not unaffected by confirming rep clauses.
18179
 
18180
@noindent
18181
  RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
18182
  C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
18183
 
18184
 
18185
@item
18186
@emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18187
@cindex AI-0072 (Ada 2012 feature)
18188
 
18189
@noindent
18190
  This AI clarifies that task signalling for reading @code{'Terminated} only
18191
  occurs if the result is True. GNAT semantics has always been consistent with
18192
  this notion of task signalling.
18193
 
18194
@noindent
18195
  RM References:  9.10 (6.1/1)
18196
 
18197
@item
18198
@emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18199
@cindex AI-0108 (Ada 2012 feature)
18200
 
18201
@noindent
18202
  This AI confirms that an incomplete type from a limited view does not have
18203
  discriminants. This has always been the case in GNAT.
18204
 
18205
@noindent
18206
  RM References:  10.01.01 (12.3/2)
18207
 
18208
@item
18209
@emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18210
@cindex AI-0129 (Ada 2012 feature)
18211
 
18212
@noindent
18213
  This AI clarifies the description of limited views: a limited view of a
18214
  package includes only one view of a type that has an incomplete declaration
18215
  and a full declaration (there is no possible ambiguity in a client package).
18216
  This AI also fixes an omission: a nested package in the private part has no
18217
  limited view. GNAT always implemented this correctly.
18218
 
18219
@noindent
18220
  RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
18221
 
18222
 
18223
 
18224
@item
18225
@emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18226
@cindex AI-0077 (Ada 2012 feature)
18227
 
18228
@noindent
18229
  This AI clarifies that a declaration does not include a context clause,
18230
  and confirms that it is illegal to have a context in which both a limited
18231
  and a nonlimited view of a package are accessible. Such double visibility
18232
  was always rejected by GNAT.
18233
 
18234
@noindent
18235
  RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
18236
 
18237
@item
18238
@emph{AI-0122 Private with and children of generics (0000-00-00)}
18239
@cindex AI-0122 (Ada 2012 feature)
18240
 
18241
@noindent
18242
  This AI clarifies the visibility of private children of generic units within
18243
  instantiations of a parent. GNAT has always handled this correctly.
18244
 
18245
@noindent
18246
  RM References:  10.01.02 (12/2)
18247
 
18248
 
18249
 
18250
@item
18251
@emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18252
@cindex AI-0040 (Ada 2012 feature)
18253
 
18254
@noindent
18255
  This AI confirms that a limited with clause in a child unit cannot name
18256
  an ancestor of the unit. This has always been checked in GNAT.
18257
 
18258
@noindent
18259
  RM References:  10.01.02 (20/2)
18260
 
18261
@item
18262
@emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18263
@cindex AI-0132 (Ada 2012 feature)
18264
 
18265
@noindent
18266
  This AI fills a gap in the description of library unit pragmas. The pragma
18267
  clearly must apply to a library unit, even if it does not carry the name
18268
  of the enclosing unit. GNAT has always enforced the required check.
18269
 
18270
@noindent
18271
  RM References:  10.01.05 (7)
18272
 
18273
 
18274
@item
18275
@emph{AI-0034 Categorization of limited views (0000-00-00)}
18276
@cindex AI-0034 (Ada 2012 feature)
18277
 
18278
@noindent
18279
  The RM makes certain limited with clauses illegal because of categorization
18280
  considerations, when the corresponding normal with would be legal. This is
18281
  not intended, and GNAT has always implemented the recommended behavior.
18282
 
18283
@noindent
18284
  RM References:  10.02.01 (11/1)   10.02.01 (17/2)
18285
 
18286
 
18287
@item
18288
@emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18289
@cindex AI-0035 (Ada 2012 feature)
18290
 
18291
@noindent
18292
  This AI remedies some inconsistencies in the legality rules for Pure units.
18293
  Derived access types are legal in a pure unit (on the assumption that the
18294
  rule for a zero storage pool size has been enforced on the ancestor type).
18295
  The rules are enforced in generic instances and in subunits. GNAT has always
18296
  implemented the recommended behavior.
18297
 
18298
@noindent
18299
  RM References:  10.02.01 (15.1/2)   10.02.01 (15.4/2)   10.02.01 (15.5/2)   10.02.01 (17/2)
18300
 
18301
 
18302
@item
18303
@emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18304
@cindex AI-0219 (Ada 2012 feature)
18305
 
18306
@noindent
18307
  This AI refines the rules for the cases with limited parameters which do not
18308
  allow the implementations to omit ``redundant''. GNAT now properly conforms
18309
  to the requirements of this binding interpretation.
18310
 
18311
@noindent
18312
  RM References:  10.02.01 (18/2)
18313
 
18314
@item
18315
@emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18316
@cindex AI-0043 (Ada 2012 feature)
18317
 
18318
@noindent
18319
  This AI covers various omissions in the RM regarding the raising of
18320
  exceptions. GNAT has always implemented the intended semantics.
18321
 
18322
@noindent
18323
  RM References:  11.04.01 (10.1/2)   11 (2)
18324
 
18325
 
18326
@item
18327
@emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18328
@cindex AI-0200 (Ada 2012 feature)
18329
 
18330
@noindent
18331
  This AI plugs a gap in the RM which appeared to allow some obviously intended
18332
  illegal instantiations. GNAT has never allowed these instantiations.
18333
 
18334
@noindent
18335
  RM References:  12.07 (16)
18336
 
18337
 
18338
@item
18339
@emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18340
@cindex AI-0112 (Ada 2012 feature)
18341
 
18342
@noindent
18343
  This AI concerns giving names to various representation aspects, but the
18344
  practical effect is simply to make the use of duplicate
18345
  @code{Atomic}[@code{_Components}],
18346
  @code{Volatile}[@code{_Components}] and
18347
  @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18348
  now performs this required check.
18349
 
18350
@noindent
18351
  RM References:  13.01 (8)
18352
 
18353
@item
18354
@emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18355
@cindex AI-0106 (Ada 2012 feature)
18356
 
18357
@noindent
18358
  The RM appeared to allow representation pragmas on generic formal parameters,
18359
  but this was not intended, and GNAT has never permitted this usage.
18360
 
18361
@noindent
18362
  RM References:  13.01 (9.1/1)
18363
 
18364
 
18365
@item
18366
@emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18367
@cindex AI-0012 (Ada 2012 feature)
18368
 
18369
@noindent
18370
  It is now illegal to give an inappropriate component size or a pragma
18371
  @code{Pack} that attempts to change the component size in the case of atomic
18372
  or aliased components. Previously GNAT ignored such an attempt with a
18373
  warning.
18374
 
18375
@noindent
18376
  RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
18377
 
18378
 
18379
@item
18380
@emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18381
@cindex AI-0039 (Ada 2012 feature)
18382
 
18383
@noindent
18384
  The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18385
  for stream attributes, but these were never useful and are now illegal. GNAT
18386
  has always regarded such expressions as illegal.
18387
 
18388
@noindent
18389
  RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
18390
 
18391
 
18392
@item
18393
@emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18394
@cindex AI-0095 (Ada 2012 feature)
18395
 
18396
@noindent
18397
  The prefix of @code{'Address} cannot statically denote a subprogram with
18398
  convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18399
  @code{Program_Error} if the prefix denotes a subprogram with convention
18400
  @code{Intrinsic}.
18401
 
18402
@noindent
18403
  RM References:  13.03 (11/1)
18404
 
18405
 
18406
@item
18407
@emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18408
@cindex AI-0116 (Ada 2012 feature)
18409
 
18410
@noindent
18411
  This AI requires that the alignment of a class-wide object be no greater
18412
  than the alignment of any type in the class. GNAT has always followed this
18413
  recommendation.
18414
 
18415
@noindent
18416
  RM References:  13.03 (29)   13.11 (16)
18417
 
18418
 
18419
@item
18420
@emph{AI-0146 Type invariants (2009-09-21)}
18421
@cindex AI-0146 (Ada 2012 feature)
18422
 
18423
@noindent
18424
  Type invariants may be specified for private types using the aspect notation.
18425
  Aspect @code{Invariant} may be specified for any private type,
18426
  @code{Invariant'Class} can
18427
  only be specified for tagged types, and is inherited by any descendent of the
18428
  tagged types. The invariant is a boolean expression that is tested for being
18429
  true in the following situations: conversions to the private type, object
18430
  declarations for the private type that are default initialized, and
18431
  [@b{in}] @b{out}
18432
  parameters and returned result on return from any primitive operation for
18433
  the type that is visible to a client.
18434
 
18435
@noindent
18436
  RM References:  13.03.03 (00)
18437
 
18438
@item
18439
@emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18440
@cindex AI-0078 (Ada 2012 feature)
18441
 
18442
@noindent
18443
  In Ada 2012, compilers are required to support unchecked conversion where the
18444
  target alignment is a multiple of the source alignment. GNAT always supported
18445
  this case (and indeed all cases of differing alignments, doing copies where
18446
  required if the alignment was reduced).
18447
 
18448
@noindent
18449
  RM References:  13.09 (7)
18450
 
18451
 
18452
@item
18453
@emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18454
@cindex AI-0195 (Ada 2012 feature)
18455
 
18456
@noindent
18457
  The handling of invalid values is now designated to be implementation
18458
  defined. This is a documentation change only, requiring Annex M in the GNAT
18459
  Reference Manual to document this handling.
18460
  In GNAT, checks for invalid values are made
18461
  only when necessary to avoid erroneous behavior. Operations like assignments
18462
  which cannot cause erroneous behavior ignore the possibility of invalid
18463
  values and do not do a check. The date given above applies only to the
18464
  documentation change, this behavior has always been implemented by GNAT.
18465
 
18466
@noindent
18467
  RM References:  13.09.01 (10)
18468
 
18469
@item
18470
@emph{AI-0193 Alignment of allocators (2010-09-16)}
18471
@cindex AI-0193 (Ada 2012 feature)
18472
 
18473
@noindent
18474
  This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18475
  analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18476
  of size.
18477
 
18478
@noindent
18479
  RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
18480
  13.11.01 (2)   13.11.01 (3)
18481
 
18482
 
18483
@item
18484
@emph{AI-0177 Parameterized expressions (2010-07-10)}
18485
@cindex AI-0177 (Ada 2012 feature)
18486
 
18487
@noindent
18488
  The new Ada 2012 notion of parameterized expressions is implemented. The form
18489
  is:
18490
@smallexample
18491
  @i{function specification} @b{is} (@i{expression})
18492
@end smallexample
18493
 
18494
@noindent
18495
  This is exactly equivalent to the
18496
  corresponding function body that returns the expression, but it can appear
18497
  in a package spec. Note that the expression must be parenthesized.
18498
 
18499
@noindent
18500
  RM References:  13.11.01 (3/2)
18501
 
18502
@item
18503
@emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18504
@cindex AI-0033 (Ada 2012 feature)
18505
 
18506
@noindent
18507
  Neither of these two pragmas may appear within a generic template, because
18508
  the generic might be instantiated at other than the library level.
18509
 
18510
@noindent
18511
  RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
18512
 
18513
 
18514
@item
18515
@emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18516
@cindex AI-0161 (Ada 2012 feature)
18517
 
18518
@noindent
18519
  A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18520
  of the default stream attributes for elementary types. If this restriction is
18521
  in force, then it is necessary to provide explicit subprograms for any
18522
  stream attributes used.
18523
 
18524
@noindent
18525
  RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
18526
 
18527
@item
18528
@emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18529
@cindex AI-0194 (Ada 2012 feature)
18530
 
18531
@noindent
18532
  The @code{Stream_Size} attribute returns the default number of bits in the
18533
  stream representation of the given type.
18534
  This value is not affected by the presence
18535
  of stream subprogram attributes for the type. GNAT has always implemented
18536
  this interpretation.
18537
 
18538
@noindent
18539
  RM References:  13.13.02 (1.2/2)
18540
 
18541
@item
18542
@emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18543
@cindex AI-0109 (Ada 2012 feature)
18544
 
18545
@noindent
18546
  This AI is an editorial change only. It removes the need for a tag check
18547
  that can never fail.
18548
 
18549
@noindent
18550
  RM References:  13.13.02 (34/2)
18551
 
18552
@item
18553
@emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18554
@cindex AI-0007 (Ada 2012 feature)
18555
 
18556
@noindent
18557
  The RM as written appeared to limit the possibilities of declaring read
18558
  attribute procedures for private scalar types. This limitation was not
18559
  intended, and has never been enforced by GNAT.
18560
 
18561
@noindent
18562
  RM References:  13.13.02 (50/2)   13.13.02 (51/2)
18563
 
18564
 
18565
@item
18566
@emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18567
@cindex AI-0065 (Ada 2012 feature)
18568
 
18569
@noindent
18570
  This AI clarifies the fact that all remote access types support external
18571
  streaming. This fixes an obvious oversight in the definition of the
18572
  language, and GNAT always implemented the intended correct rules.
18573
 
18574
@noindent
18575
  RM References:  13.13.02 (52/2)
18576
 
18577
@item
18578
@emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18579
@cindex AI-0019 (Ada 2012 feature)
18580
 
18581
@noindent
18582
  The RM suggests that primitive subprograms of a specific tagged type are
18583
  frozen when the tagged type is frozen. This would be an incompatible change
18584
  and is not intended. GNAT has never attempted this kind of freezing and its
18585
  behavior is consistent with the recommendation of this AI.
18586
 
18587
@noindent
18588
  RM References:  13.14 (2)   13.14 (3/1)   13.14 (8.1/1)   13.14 (10)   13.14 (14)   13.14 (15.1/2)
18589
 
18590
@item
18591
@emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18592
@cindex AI-0017 (Ada 2012 feature)
18593
 
18594
@noindent
18595
  So-called ``Taft-amendment types'' (i.e., types that are completed in package
18596
  bodies) are not frozen by the occurrence of bodies in the
18597
  enclosing declarative part. GNAT always implemented this properly.
18598
 
18599
@noindent
18600
  RM References:  13.14 (3/1)
18601
 
18602
 
18603
@item
18604
@emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18605
@cindex AI-0060 (Ada 2012 feature)
18606
 
18607
@noindent
18608
  This AI extends the definition of remote access types to include access
18609
  to limited, synchronized, protected or task class-wide interface types.
18610
  GNAT already implemented this extension.
18611
 
18612
@noindent
18613
  RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
18614
 
18615
@item
18616
@emph{AI-0114 Classification of letters (0000-00-00)}
18617
@cindex AI-0114 (Ada 2012 feature)
18618
 
18619
@noindent
18620
  The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18621
  181 (@code{MICRO SIGN}), and
18622
  186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18623
  lower case letters by Unicode.
18624
  However, they are not allowed in identifiers, and they
18625
  return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18626
  This behavior is consistent with that defined in Ada 95.
18627
 
18628
@noindent
18629
  RM References:  A.03.02 (59)   A.04.06 (7)
18630
 
18631
 
18632
@item
18633
@emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18634
@cindex AI-0185 (Ada 2012 feature)
18635
 
18636
@noindent
18637
  Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18638
  classification functions for @code{Wide_Character} and
18639
  @code{Wide_Wide_Character}, as well as providing
18640
  case folding routines for @code{Wide_[Wide_]Character} and
18641
  @code{Wide_[Wide_]String}.
18642
 
18643
@noindent
18644
  RM References:  A.03.05 (0)   A.03.06 (0)
18645
 
18646
 
18647
@item
18648
@emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18649
@cindex AI-0031 (Ada 2012 feature)
18650
 
18651
@noindent
18652
  A new version of @code{Find_Token} is added to all relevant string packages,
18653
  with an extra parameter @code{From}. Instead of starting at the first
18654
  character of the string, the search for a matching Token starts at the
18655
  character indexed by the value of @code{From}.
18656
  These procedures are available in all versions of Ada
18657
  but if used in versions earlier than Ada 2012 they will generate a warning
18658
  that an Ada 2012 subprogram is being used.
18659
 
18660
@noindent
18661
  RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
18662
  A.04.05 (46)
18663
 
18664
 
18665
@item
18666
@emph{AI-0056 Index on null string returns zero (0000-00-00)}
18667
@cindex AI-0056 (Ada 2012 feature)
18668
 
18669
@noindent
18670
  The wording in the Ada 2005 RM implied an incompatible handling of the
18671
  @code{Index} functions, resulting in raising an exception instead of
18672
  returning zero in some situations.
18673
  This was not intended and has been corrected.
18674
  GNAT always returned zero, and is thus consistent with this AI.
18675
 
18676
@noindent
18677
  RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
18678
 
18679
 
18680
@item
18681
@emph{AI-0137 String encoding package (2010-03-25)}
18682
@cindex AI-0137 (Ada 2012 feature)
18683
 
18684
@noindent
18685
  The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18686
  packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18687
  and @code{Wide_Wide_Strings} have been
18688
  implemented. These packages (whose documentation can be found in the spec
18689
  files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18690
  @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18691
  @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18692
  values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18693
  UTF-16), as well as conversions between the different UTF encodings. With
18694
  the exception of @code{Wide_Wide_Strings}, these packages are available in
18695
  Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18696
  The @code{Wide_Wide_Strings package}
18697
  is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18698
  mode since it uses @code{Wide_Wide_Character}).
18699
 
18700
@noindent
18701
  RM References:  A.04.11
18702
 
18703
@item
18704
@emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18705
@cindex AI-0038 (Ada 2012 feature)
18706
 
18707
@noindent
18708
  These are minor errors in the description on three points. The intent on
18709
  all these points has always been clear, and GNAT has always implemented the
18710
  correct intended semantics.
18711
 
18712
@noindent
18713
  RM References:  A.10.05 (37)   A.10.07 (8/1)   A.10.07 (10)   A.10.07 (12)   A.10.08 (10)   A.10.08 (24)
18714
 
18715
@item
18716
@emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18717
@cindex AI-0044 (Ada 2012 feature)
18718
 
18719
@noindent
18720
  This AI places restrictions on allowed instantiations of generic containers.
18721
  These restrictions are not checked by the compiler, so there is nothing to
18722
  change in the implementation. This affects only the RM documentation.
18723
 
18724
@noindent
18725
  RM References:  A.18 (4/2)   A.18.02 (231/2)   A.18.03 (145/2)   A.18.06 (56/2)   A.18.08 (66/2)   A.18.09 (79/2)   A.18.26 (5/2)   A.18.26 (9/2)
18726
 
18727
@item
18728
@emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18729
@cindex AI-0127 (Ada 2012 feature)
18730
 
18731
@noindent
18732
  This package provides an interface for identifying the current locale.
18733
 
18734
@noindent
18735
  RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
18736
  A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
18737
 
18738
 
18739
 
18740
@item
18741
@emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18742
@cindex AI-0002 (Ada 2012 feature)
18743
 
18744
@noindent
18745
  The compiler is not required to support exporting an Ada subprogram with
18746
  convention C if there are parameters or a return type of an unconstrained
18747
  array type (such as @code{String}). GNAT allows such declarations but
18748
  generates warnings. It is possible, but complicated, to write the
18749
  corresponding C code and certainly such code would be specific to GNAT and
18750
  non-portable.
18751
 
18752
@noindent
18753
  RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
18754
 
18755
 
18756
@item
18757
@emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18758
@cindex AI05-0216 (Ada 2012 feature)
18759
 
18760
@noindent
18761
  It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18762
  forbid tasks declared locally within subprograms, or functions returning task
18763
  objects, and that is the implementation that GNAT has always provided.
18764
  However the language in the RM was not sufficiently clear on this point.
18765
  Thus this is a documentation change in the RM only.
18766
 
18767
@noindent
18768
  RM References:  D.07 (3/3)
18769
 
18770
@item
18771
@emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18772
@cindex AI-0211 (Ada 2012 feature)
18773
 
18774
@noindent
18775
  The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18776
  @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18777
 
18778
@noindent
18779
  RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
18780
 
18781
@item
18782
@emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18783
@cindex AI-0190 (Ada 2012 feature)
18784
 
18785
@noindent
18786
  This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18787
  used to control storage pools globally.
18788
  In particular, you can force every access
18789
  type that is used for allocation (@b{new}) to have an explicit storage pool,
18790
  or you can declare a pool globally to be used for all access types that lack
18791
  an explicit one.
18792
 
18793
@noindent
18794
  RM References:  D.07 (8)
18795
 
18796
@item
18797
@emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18798
@cindex AI-0189 (Ada 2012 feature)
18799
 
18800
@noindent
18801
  This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18802
  which says that no dynamic allocation will occur once elaboration is
18803
  completed.
18804
  In general this requires a run-time check, which is not required, and which
18805
  GNAT does not attempt. But the static cases of allocators in a task body or
18806
  in the body of the main program are detected and flagged at compile or bind
18807
  time.
18808
 
18809
@noindent
18810
  RM References:  D.07 (19.1/2)   H.04 (23.3/2)
18811
 
18812
@item
18813
@emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18814
@cindex AI-0171 (Ada 2012 feature)
18815
 
18816
@noindent
18817
  A new package @code{System.Multiprocessors} is added, together with the
18818
  definition of pragma @code{CPU} for controlling task affinity. A new no
18819
  dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18820
  is added to the Ravenscar profile.
18821
 
18822
@noindent
18823
  RM References:  D.13.01 (4/2)   D.16
18824
 
18825
 
18826
@item
18827
@emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18828
@cindex AI-0210 (Ada 2012 feature)
18829
 
18830
@noindent
18831
  This is a documentation only issue regarding wording of metric requirements,
18832
  that does not affect the implementation of the compiler.
18833
 
18834
@noindent
18835
  RM References:  D.15 (24/2)
18836
 
18837
 
18838
@item
18839
@emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18840
@cindex AI-0206 (Ada 2012 feature)
18841
 
18842
@noindent
18843
  Remote types packages are now allowed to depend on preelaborated packages.
18844
  This was formerly considered illegal.
18845
 
18846
@noindent
18847
  RM References:  E.02.02 (6)
18848
 
18849
 
18850
 
18851
@item
18852
@emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18853
@cindex AI-0152 (Ada 2012 feature)
18854
 
18855
@noindent
18856
  Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18857
  where the type of the returned value is an anonymous access type.
18858
 
18859
@noindent
18860
  RM References:  H.04 (8/1)
18861
@end itemize
18862
 
18863
 
18864
@node Obsolescent Features
18865
@chapter Obsolescent Features
18866
 
18867
@noindent
18868
This chapter describes features that are provided by GNAT, but are
18869
considered obsolescent since there are preferred ways of achieving
18870
the same effect. These features are provided solely for historical
18871
compatibility purposes.
18872
 
18873
@menu
18874
* pragma No_Run_Time::
18875
* pragma Ravenscar::
18876
* pragma Restricted_Run_Time::
18877
@end menu
18878
 
18879
@node pragma No_Run_Time
18880
@section pragma No_Run_Time
18881
 
18882
The pragma @code{No_Run_Time} is used to achieve an affect similar
18883
to the use of the "Zero Foot Print" configurable run time, but without
18884
requiring a specially configured run time. The result of using this
18885
pragma, which must be used for all units in a partition, is to restrict
18886
the use of any language features requiring run-time support code. The
18887
preferred usage is to use an appropriately configured run-time that
18888
includes just those features that are to be made accessible.
18889
 
18890
@node pragma Ravenscar
18891
@section pragma Ravenscar
18892
 
18893
The pragma @code{Ravenscar} has exactly the same effect as pragma
18894
@code{Profile (Ravenscar)}. The latter usage is preferred since it
18895
is part of the new Ada 2005 standard.
18896
 
18897
@node pragma Restricted_Run_Time
18898
@section pragma Restricted_Run_Time
18899
 
18900
The pragma @code{Restricted_Run_Time} has exactly the same effect as
18901
pragma @code{Profile (Restricted)}. The latter usage is
18902
preferred since the Ada 2005 pragma @code{Profile} is intended for
18903
this kind of implementation dependent addition.
18904
 
18905
@include fdl.texi
18906
@c GNU Free Documentation License
18907
 
18908
@node Index,,GNU Free Documentation License, Top
18909
@unnumbered Index
18910
 
18911
@printindex cp
18912
 
18913
@contents
18914
 
18915
@bye

powered by: WebSVN 2.1.0

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