Debian Codegraph @

gcc/ada/doc/gnat_rm/implementation_advice.rst

raw
1 .. _Implementation_Advice:
2
3 *********************
4 Implementation Advice
5 *********************
6
7 The main text of the Ada Reference Manual describes the required
8 behavior of all Ada compilers, and the GNAT compiler conforms to
9 these requirements.
10
11 In addition, there are sections throughout the Ada Reference Manual headed
12 by the phrase 'Implementation advice'. These sections are not normative,
13 i.e., they do not specify requirements that all compilers must
14 follow. Rather they provide advice on generally desirable behavior.
15 They are not requirements, because they describe behavior that cannot
16 be provided on all systems, or may be undesirable on some systems.
17
18 As far as practical, GNAT follows the implementation advice in
19 the Ada Reference Manual. Each such RM section corresponds to a section
20 in this chapter whose title specifies the
21 RM section number and paragraph number and the subject of
22 the advice. The contents of each section consists of the RM text within
23 quotation marks,
24 followed by the GNAT interpretation of the advice. Most often, this simply says
25 'followed', which means that GNAT follows the advice. However, in a
26 number of cases, GNAT deliberately deviates from this advice, in which
27 case the text describes what GNAT does and why.
28
29 .. index:: Error detection
30
31 RM 1.1.3(20): Error Detection
32 =============================
33
34 "If an implementation detects the use of an unsupported Specialized Needs
35 Annex feature at run time, it should raise ``Program_Error`` if
36 feasible."
37
38 Not relevant. All specialized needs annex features are either supported,
39 or diagnosed at compile time.
40
41 .. index:: Child Units
42
43 RM 1.1.3(31): Child Units
44 =========================
45
46
47 "If an implementation wishes to provide implementation-defined
48 extensions to the functionality of a language-defined library unit, it
49 should normally do so by adding children to the library unit."
50
51 Followed.
52
53 .. index:: Bounded errors
54
55 RM 1.1.5(12): Bounded Errors
56 ============================
57
58 "If an implementation detects a bounded error or erroneous
59 execution, it should raise ``Program_Error``."
60
61 Followed in all cases in which the implementation detects a bounded
62 error or erroneous execution. Not all such situations are detected at
63 runtime.
64
65 .. index:: Pragmas
66
67 .. _RM_2_8_16_Pragmas:
68
69 RM 2.8(16): Pragmas
70 ===================
71
72 "Normally, implementation-defined pragmas should have no semantic effect
73 for error-free programs; that is, if the implementation-defined pragmas
74 are removed from a working program, the program should still be legal,
75 and should still have the same semantics."
76
77 The following implementation defined pragmas are exceptions to this
78 rule:
79
80 +--------------------+-------------------+
81 | Pragma | Explanation |
82 +====================+===================+
83 | *Abort_Defer* | Affects semantics |
84 +--------------------+-------------------+
85 |*Ada_83* | Affects legality |
86 +--------------------+-------------------+
87 |*Assert* | Affects semantics |
88 +--------------------+-------------------+
89 |*CPP_Class* | Affects semantics |
90 +--------------------+-------------------+
91 |*CPP_Constructor* | Affects semantics |
92 +--------------------+-------------------+
93 |*Debug* | Affects semantics |
94 +--------------------+-------------------+
95 |*Interface_Name* | Affects semantics |
96 +--------------------+-------------------+
97 |*Machine_Attribute* | Affects semantics |
98 +--------------------+-------------------+
99 |*Unimplemented_Unit*| Affects legality |
100 +--------------------+-------------------+
101 |*Unchecked_Union* | Affects semantics |
102 +--------------------+-------------------+
103
104 In each of the above cases, it is essential to the purpose of the pragma
105 that this advice not be followed. For details see
106 :ref:`Implementation_Defined_Pragmas`.
107
108 RM 2.8(17-19): Pragmas
109 ======================
110
111 "Normally, an implementation should not define pragmas that can
112 make an illegal program legal, except as follows:
113
114 * A pragma used to complete a declaration, such as a pragma ``Import``;
115
116 * A pragma used to configure the environment by adding, removing, or
117 replacing ``library_items``."
118
119 See :ref:`RM_2_8_16_Pragmas`.
120
121 .. index:: Character Sets
122
123 .. index:: Alternative Character Sets
124
125 RM 3.5.2(5): Alternative Character Sets
126 =======================================
127
128 "If an implementation supports a mode with alternative interpretations
129 for ``Character`` and ``Wide_Character``, the set of graphic
130 characters of ``Character`` should nevertheless remain a proper
131 subset of the set of graphic characters of ``Wide_Character``. Any
132 character set 'localizations' should be reflected in the results of
133 the subprograms defined in the language-defined package
134 ``Characters.Handling`` (see A.3) available in such a mode. In a mode with
135 an alternative interpretation of ``Character``, the implementation should
136 also support a corresponding change in what is a legal
137 ``identifier_letter``."
138
139 Not all wide character modes follow this advice, in particular the JIS
140 and IEC modes reflect standard usage in Japan, and in these encoding,
141 the upper half of the Latin-1 set is not part of the wide-character
142 subset, since the most significant bit is used for wide character
143 encoding. However, this only applies to the external forms. Internally
144 there is no such restriction.
145
146 .. index:: Integer types
147
148 RM 3.5.4(28): Integer Types
149 ===========================
150
151 "An implementation should support ``Long_Integer`` in addition to
152 ``Integer`` if the target machine supports 32-bit (or longer)
153 arithmetic. No other named integer subtypes are recommended for package
154 ``Standard``. Instead, appropriate named integer subtypes should be
155 provided in the library package ``Interfaces`` (see B.2)."
156
157 ``Long_Integer`` is supported. Other standard integer types are supported
158 so this advice is not fully followed. These types
159 are supported for convenient interface to C, and so that all hardware
160 types of the machine are easily available.
161
162 RM 3.5.4(29): Integer Types
163 ===========================
164
165 "An implementation for a two's complement machine should support
166 modular types with a binary modulus up to ``System.Max_Int*2+2``. An
167 implementation should support a non-binary modules up to ``Integer'Last``."
168
169 Followed.
170
171 .. index:: Enumeration values
172
173 RM 3.5.5(8): Enumeration Values
174 ===============================
175
176 "For the evaluation of a call on ``S'Pos`` for an enumeration
177 subtype, if the value of the operand does not correspond to the internal
178 code for any enumeration literal of its type (perhaps due to an
179 un-initialized variable), then the implementation should raise
180 ``Program_Error``. This is particularly important for enumeration
181 types with noncontiguous internal codes specified by an
182 enumeration_representation_clause."
183
184 Followed.
185
186 .. index:: Float types
187
188 RM 3.5.7(17): Float Types
189 =========================
190
191 "An implementation should support ``Long_Float`` in addition to
192 ``Float`` if the target machine supports 11 or more digits of
193 precision. No other named floating point subtypes are recommended for
194 package ``Standard``. Instead, appropriate named floating point subtypes
195 should be provided in the library package ``Interfaces`` (see B.2)."
196
197 ``Short_Float`` and ``Long_Long_Float`` are also provided. The
198 former provides improved compatibility with other implementations
199 supporting this type. The latter corresponds to the highest precision
200 floating-point type supported by the hardware. On most machines, this
201 will be the same as ``Long_Float``, but on some machines, it will
202 correspond to the IEEE extended form. The notable case is all x86
203 implementations, where ``Long_Long_Float`` corresponds to the 80-bit
204 extended precision format supported in hardware on this processor.
205 Note that the 128-bit format on SPARC is not supported, since this
206 is a software rather than a hardware format.
207
208 .. index:: Multidimensional arrays
209
210 .. index:: Arrays, multidimensional
211
212 RM 3.6.2(11): Multidimensional Arrays
213 =====================================
214
215 "An implementation should normally represent multidimensional arrays in
216 row-major order, consistent with the notation used for multidimensional
217 array aggregates (see 4.3.3). However, if a pragma ``Convention``
218 (``Fortran``, ...) applies to a multidimensional array type, then
219 column-major order should be used instead (see B.5, *Interfacing with Fortran*)."
220
221 Followed.
222
223 .. index:: Duration'Small
224
225 RM 9.6(30-31): Duration'Small
226 =============================
227
228 "Whenever possible in an implementation, the value of ``Duration'Small``
229 should be no greater than 100 microseconds."
230
231 Followed. (``Duration'Small`` = 10**(-9)).
232
233 "The time base for ``delay_relative_statements`` should be monotonic;
234 it need not be the same time base as used for ``Calendar.Clock``."
235
236 Followed.
237
238 RM 10.2.1(12): Consistent Representation
239 ========================================
240
241 "In an implementation, a type declared in a pre-elaborated package should
242 have the same representation in every elaboration of a given version of
243 the package, whether the elaborations occur in distinct executions of
244 the same program, or in executions of distinct programs or partitions
245 that include the given version."
246
247 Followed, except in the case of tagged types. Tagged types involve
248 implicit pointers to a local copy of a dispatch table, and these pointers
249 have representations which thus depend on a particular elaboration of the
250 package. It is not easy to see how it would be possible to follow this
251 advice without severely impacting efficiency of execution.
252
253 .. index:: Exception information
254
255 RM 11.4.1(19): Exception Information
256 ====================================
257
258 "``Exception_Message`` by default and ``Exception_Information``
259 should produce information useful for
260 debugging. ``Exception_Message`` should be short, about one
261 line. ``Exception_Information`` can be long. ``Exception_Message``
262 should not include the
263 ``Exception_Name``. ``Exception_Information`` should include both
264 the ``Exception_Name`` and the ``Exception_Message``."
265
266 Followed. For each exception that doesn't have a specified
267 ``Exception_Message``, the compiler generates one containing the location
268 of the raise statement. This location has the form 'file_name:line', where
269 file_name is the short file name (without path information) and line is the line
270 number in the file. Note that in the case of the Zero Cost Exception
271 mechanism, these messages become redundant with the Exception_Information that
272 contains a full backtrace of the calling sequence, so they are disabled.
273 To disable explicitly the generation of the source location message, use the
274 Pragma ``Discard_Names``.
275
276 .. index:: Suppression of checks
277
278 .. index:: Checks, suppression of
279
280 RM 11.5(28): Suppression of Checks
281 ==================================
282
283 "The implementation should minimize the code executed for checks that
284 have been suppressed."
285
286 Followed.
287
288 .. index:: Representation clauses
289
290 RM 13.1 (21-24): Representation Clauses
291 =======================================
292
293 "The recommended level of support for all representation items is
294 qualified as follows:
295
296 An implementation need not support representation items containing
297 nonstatic expressions, except that an implementation should support a
298 representation item for a given entity if each nonstatic expression in
299 the representation item is a name that statically denotes a constant
300 declared before the entity."
301
302 Followed. In fact, GNAT goes beyond the recommended level of support
303 by allowing nonstatic expressions in some representation clauses even
304 without the need to declare constants initialized with the values of
305 such expressions.
306 For example:
307
308 .. code-block:: ada
309
310 X : Integer;
311 Y : Float;
312 for Y'Address use X'Address;>>
313
314
315 "An implementation need not support a specification for the ``Size``
316 for a given composite subtype, nor the size or storage place for an
317 object (including a component) of a given composite subtype, unless the
318 constraints on the subtype and its composite subcomponents (if any) are
319 all static constraints."
320
321 Followed. Size Clauses are not permitted on nonstatic components, as
322 described above.
323
324
325 "An aliased component, or a component whose type is by-reference, should
326 always be allocated at an addressable location."
327
328 Followed.
329
330 .. index:: Packed types
331
332 RM 13.2(6-8): Packed Types
333 ==========================
334
335 "If a type is packed, then the implementation should try to minimize
336 storage allocated to objects of the type, possibly at the expense of
337 speed of accessing components, subject to reasonable complexity in
338 addressing calculations.
339
340 The recommended level of support pragma ``Pack`` is:
341
342 For a packed record type, the components should be packed as tightly as
343 possible subject to the Sizes of the component subtypes, and subject to
344 any *record_representation_clause* that applies to the type; the
345 implementation may, but need not, reorder components or cross aligned
346 word boundaries to improve the packing. A component whose ``Size`` is
347 greater than the word size may be allocated an integral number of words."
348
349 Followed. Tight packing of arrays is supported for all component sizes
350 up to 64-bits. If the array component size is 1 (that is to say, if
351 the component is a boolean type or an enumeration type with two values)
352 then values of the type are implicitly initialized to zero. This
353 happens both for objects of the packed type, and for objects that have a
354 subcomponent of the packed type.
355
356 .. index:: Address clauses
357
358 RM 13.3(14-19): Address Clauses
359 ===============================
360
361 "For an array ``X``, ``X'Address`` should point at the first
362 component of the array, and not at the array bounds."
363
364 Followed.
365
366 "The recommended level of support for the ``Address`` attribute is:
367
368 ``X'Address`` should produce a useful result if ``X`` is an
369 object that is aliased or of a by-reference type, or is an entity whose
370 ``Address`` has been specified."
371
372 Followed. A valid address will be produced even if none of those
373 conditions have been met. If necessary, the object is forced into
374 memory to ensure the address is valid.
375
376 "An implementation should support ``Address`` clauses for imported
377 subprograms."
378
379 Followed.
380
381 "Objects (including subcomponents) that are aliased or of a by-reference
382 type should be allocated on storage element boundaries."
383
384 Followed.
385
386 "If the ``Address`` of an object is specified, or it is imported or exported,
387 then the implementation should not perform optimizations based on
388 assumptions of no aliases."
389
390 Followed.
391
392 .. index:: Alignment clauses
393
394 RM 13.3(29-35): Alignment Clauses
395 =================================
396
397 "The recommended level of support for the ``Alignment`` attribute for
398 subtypes is:
399
400 An implementation should support specified Alignments that are factors
401 and multiples of the number of storage elements per word, subject to the
402 following:"
403
404 Followed.
405
406 "An implementation need not support specified Alignments for
407 combinations of Sizes and Alignments that cannot be easily
408 loaded and stored by available machine instructions."
409
410 Followed.
411
412 "An implementation need not support specified Alignments that are
413 greater than the maximum ``Alignment`` the implementation ever returns by
414 default."
415
416 Followed.
417
418 "The recommended level of support for the ``Alignment`` attribute for
419 objects is:
420
421 Same as above, for subtypes, but in addition:"
422
423 Followed.
424
425 "For stand-alone library-level objects of statically constrained
426 subtypes, the implementation should support all alignments
427 supported by the target linker. For example, page alignment is likely to
428 be supported for such objects, but not for subtypes."
429
430 Followed.
431
432 .. index:: Size clauses
433
434 RM 13.3(42-43): Size Clauses
435 ============================
436
437 "The recommended level of support for the ``Size`` attribute of
438 objects is:
439
440 A ``Size`` clause should be supported for an object if the specified
441 ``Size`` is at least as large as its subtype's ``Size``, and
442 corresponds to a size in storage elements that is a multiple of the
443 object's ``Alignment`` (if the ``Alignment`` is nonzero)."
444
445 Followed.
446
447 RM 13.3(50-56): Size Clauses
448 ============================
449
450 "If the ``Size`` of a subtype is specified, and allows for efficient
451 independent addressability (see 9.10) on the target architecture, then
452 the ``Size`` of the following objects of the subtype should equal the
453 ``Size`` of the subtype:
454
455 Aliased objects (including components)."
456
457 Followed.
458
459 "`Size` clause on a composite subtype should not affect the
460 internal layout of components."
461
462 Followed. But note that this can be overridden by use of the implementation
463 pragma Implicit_Packing in the case of packed arrays.
464
465 "The recommended level of support for the ``Size`` attribute of subtypes is:
466
467 The ``Size`` (if not specified) of a static discrete or fixed point
468 subtype should be the number of bits needed to represent each value
469 belonging to the subtype using an unbiased representation, leaving space
470 for a sign bit only if the subtype contains negative values. If such a
471 subtype is a first subtype, then an implementation should support a
472 specified ``Size`` for it that reflects this representation."
473
474 Followed.
475
476 "For a subtype implemented with levels of indirection, the ``Size``
477 should include the size of the pointers, but not the size of what they
478 point at."
479
480 Followed.
481
482 .. index:: Component_Size clauses
483
484 RM 13.3(71-73): Component Size Clauses
485 ======================================
486
487 "The recommended level of support for the ``Component_Size``
488 attribute is:
489
490 An implementation need not support specified ``Component_Sizes`` that are
491 less than the ``Size`` of the component subtype."
492
493 Followed.
494
495 "An implementation should support specified Component_Sizes that
496 are factors and multiples of the word size. For such
497 Component_Sizes, the array should contain no gaps between
498 components. For other Component_Sizes (if supported), the array
499 should contain no gaps between components when packing is also
500 specified; the implementation should forbid this combination in cases
501 where it cannot support a no-gaps representation."
502
503 Followed.
504
505 .. index:: Enumeration representation clauses
506
507 .. index:: Representation clauses, enumeration
508
509 RM 13.4(9-10): Enumeration Representation Clauses
510 =================================================
511
512 "The recommended level of support for enumeration representation clauses
513 is:
514
515 An implementation need not support enumeration representation clauses
516 for boolean types, but should at minimum support the internal codes in
517 the range ``System.Min_Int .. System.Max_Int``."
518
519 Followed.
520
521 .. index:: Record representation clauses
522
523 .. index:: Representation clauses, records
524
525 RM 13.5.1(17-22): Record Representation Clauses
526 ===============================================
527
528 "The recommended level of support for
529 *record_representation_clause*\ s is:
530
531 An implementation should support storage places that can be extracted
532 with a load, mask, shift sequence of machine code, and set with a load,
533 shift, mask, store sequence, given the available machine instructions
534 and run-time model."
535
536 Followed.
537
538 "A storage place should be supported if its size is equal to the
539 ``Size`` of the component subtype, and it starts and ends on a
540 boundary that obeys the ``Alignment`` of the component subtype."
541
542 Followed.
543
544 "If the default bit ordering applies to the declaration of a given type,
545 then for a component whose subtype's ``Size`` is less than the word
546 size, any storage place that does not cross an aligned word boundary
547 should be supported."
548
549 Followed.
550
551 "An implementation may reserve a storage place for the tag field of a
552 tagged type, and disallow other components from overlapping that place."
553
554 Followed. The storage place for the tag field is the beginning of the tagged
555 record, and its size is Address'Size. GNAT will reject an explicit component
556 clause for the tag field.
557
558 "An implementation need not support a *component_clause* for a
559 component of an extension part if the storage place is not after the
560 storage places of all components of the parent type, whether or not
561 those storage places had been specified."
562
563 Followed. The above advice on record representation clauses is followed,
564 and all mentioned features are implemented.
565
566 .. index:: Storage place attributes
567
568 RM 13.5.2(5): Storage Place Attributes
569 ======================================
570
571 "If a component is represented using some form of pointer (such as an
572 offset) to the actual data of the component, and this data is contiguous
573 with the rest of the object, then the storage place attributes should
574 reflect the place of the actual data, not the pointer. If a component is
575 allocated discontinuously from the rest of the object, then a warning
576 should be generated upon reference to one of its storage place
577 attributes."
578
579 Followed. There are no such components in GNAT.
580
581 .. index:: Bit ordering
582
583 RM 13.5.3(7-8): Bit Ordering
584 ============================
585
586 "The recommended level of support for the non-default bit ordering is:
587
588 If ``Word_Size`` = ``Storage_Unit``, then the implementation
589 should support the non-default bit ordering in addition to the default
590 bit ordering."
591
592 Followed. Word size does not equal storage size in this implementation.
593 Thus non-default bit ordering is not supported.
594
595 .. index:: Address, as private type
596
597 RM 13.7(37): Address as Private
598 ===============================
599
600 "`Address` should be of a private type."
601
602 Followed.
603
604 .. index:: Operations, on ``Address``
605
606 .. index:: Address, operations of
607
608 RM 13.7.1(16): Address Operations
609 =================================
610
611 "Operations in ``System`` and its children should reflect the target
612 environment semantics as closely as is reasonable. For example, on most
613 machines, it makes sense for address arithmetic to 'wrap around'.
614 Operations that do not make sense should raise ``Program_Error``."
615
616 Followed. Address arithmetic is modular arithmetic that wraps around. No
617 operation raises ``Program_Error``, since all operations make sense.
618
619 .. index:: Unchecked conversion
620
621 RM 13.9(14-17): Unchecked Conversion
622 ====================================
623
624 "The ``Size`` of an array object should not include its bounds; hence,
625 the bounds should not be part of the converted data."
626
627 Followed.
628
629 "The implementation should not generate unnecessary run-time checks to
630 ensure that the representation of ``S`` is a representation of the
631 target type. It should take advantage of the permission to return by
632 reference when possible. Restrictions on unchecked conversions should be
633 avoided unless required by the target environment."
634
635 Followed. There are no restrictions on unchecked conversion. A warning is
636 generated if the source and target types do not have the same size since
637 the semantics in this case may be target dependent.
638
639 "The recommended level of support for unchecked conversions is:
640
641 Unchecked conversions should be supported and should be reversible in
642 the cases where this clause defines the result. To enable meaningful use
643 of unchecked conversion, a contiguous representation should be used for
644 elementary subtypes, for statically constrained array subtypes whose
645 component subtype is one of the subtypes described in this paragraph,
646 and for record subtypes without discriminants whose component subtypes
647 are described in this paragraph."
648
649 Followed.
650
651 .. index:: Heap usage, implicit
652
653 RM 13.11(23-25): Implicit Heap Usage
654 ====================================
655
656 "An implementation should document any cases in which it dynamically
657 allocates heap storage for a purpose other than the evaluation of an
658 allocator."
659
660 Followed, the only other points at which heap storage is dynamically
661 allocated are as follows:
662
663 *
664 At initial elaboration time, to allocate dynamically sized global
665 objects.
666
667 *
668 To allocate space for a task when a task is created.
669
670 *
671 To extend the secondary stack dynamically when needed. The secondary
672 stack is used for returning variable length results.
673
674 ..
675
676 "A default (implementation-provided) storage pool for an
677 access-to-constant type should not have overhead to support deallocation of
678 individual objects."
679
680 Followed.
681
682 "A storage pool for an anonymous access type should be created at the
683 point of an allocator for the type, and be reclaimed when the designated
684 object becomes inaccessible."
685
686 Followed.
687
688 .. index:: Unchecked deallocation
689
690 RM 13.11.2(17): Unchecked Deallocation
691 ======================================
692
693 "For a standard storage pool, ``Free`` should actually reclaim the
694 storage."
695
696 Followed.
697
698 .. index:: Stream oriented attributes
699
700 RM 13.13.2(1.6): Stream Oriented Attributes
701 ===========================================
702
703 "If not specified, the value of Stream_Size for an elementary type
704 should be the number of bits that corresponds to the minimum number of
705 stream elements required by the first subtype of the type, rounded up
706 to the nearest factor or multiple of the word size that is also a
707 multiple of the stream element size."
708
709 Followed, except that the number of stream elements is 1, 2, 3, 4 or 8.
710 The Stream_Size may be used to override the default choice.
711
712 The default implementation is based on direct binary representations and is
713 therefore target- and endianness-dependent. To address this issue, GNAT also
714 supplies an alternate implementation of the stream attributes ``Read`` and
715 ``Write``, which uses the target-independent XDR standard representation for
716 scalar types. This XDR alternative can be enabled via the binder switch -xdr.
717
718 .. index:: XDR representation
719 .. index:: Read attribute
720 .. index:: Write attribute
721 .. index:: Stream oriented attributes
722
723 RM A.1(52): Names of Predefined Numeric Types
724 =============================================
725
726 "If an implementation provides additional named predefined integer types,
727 then the names should end with ``Integer`` as in
728 ``Long_Integer``. If an implementation provides additional named
729 predefined floating point types, then the names should end with
730 ``Float`` as in ``Long_Float``."
731
732 Followed.
733
734 .. index:: Ada.Characters.Handling
735
736 RM A.3.2(49): ``Ada.Characters.Handling``
737 =========================================
738
739 "If an implementation provides a localized definition of ``Character``
740 or ``Wide_Character``, then the effects of the subprograms in
741 ``Characters.Handling`` should reflect the localizations.
742 See also 3.5.2."
743
744 Followed. GNAT provides no such localized definitions.
745
746 .. index:: Bounded-length strings
747
748 RM A.4.4(106): Bounded-Length String Handling
749 =============================================
750
751 "Bounded string objects should not be implemented by implicit pointers
752 and dynamic allocation."
753
754 Followed. No implicit pointers or dynamic allocation are used.
755
756 .. index:: Random number generation
757
758 RM A.5.2(46-47): Random Number Generation
759 =========================================
760
761 "Any storage associated with an object of type ``Generator`` should be
762 reclaimed on exit from the scope of the object."
763
764 Followed.
765
766 "If the generator period is sufficiently long in relation to the number
767 of distinct initiator values, then each possible value of
768 ``Initiator`` passed to ``Reset`` should initiate a sequence of
769 random numbers that does not, in a practical sense, overlap the sequence
770 initiated by any other value. If this is not possible, then the mapping
771 between initiator values and generator states should be a rapidly
772 varying function of the initiator value."
773
774 Followed. The generator period is sufficiently long for the first
775 condition here to hold true.
776
777 .. index:: Get_Immediate
778
779 RM A.10.7(23): ``Get_Immediate``
780 ================================
781
782 "The ``Get_Immediate`` procedures should be implemented with
783 unbuffered input. For a device such as a keyboard, input should be
784 available if a key has already been typed, whereas for a disk
785 file, input should always be available except at end of file. For a file
786 associated with a keyboard-like device, any line-editing features of the
787 underlying operating system should be disabled during the execution of
788 ``Get_Immediate``."
789
790 Followed on all targets except VxWorks. For VxWorks, there is no way to
791 provide this functionality that does not result in the input buffer being
792 flushed before the ``Get_Immediate`` call. A special unit
793 ``Interfaces.Vxworks.IO`` is provided that contains routines to enable
794 this functionality.
795
796 .. index:: Containers
797
798 RM A.18: ``Containers``
799 ================================
800
801 All implementation advice pertaining to Ada.Containers and its
802 child units (that is, all implementation advice occurring within
803 section A.18 and its subsections) is followed except for A.18.24(17):
804
805 "Bounded ordered set objects should be implemented without implicit pointers or dynamic allocation. "
806
807 The implementations of the two Reference_Preserving_Key functions of
808 the generic package Ada.Containers.Bounded_Ordered_Sets each currently make
809 use of dynamic allocation; other operations on bounded ordered set objects
810 follow the implementation advice.
811
812 .. index:: Export
813
814 RM B.1(39-41): Pragma ``Export``
815 ================================
816
817 "If an implementation supports pragma ``Export`` to a given language,
818 then it should also allow the main subprogram to be written in that
819 language. It should support some mechanism for invoking the elaboration
820 of the Ada library units included in the system, and for invoking the
821 finalization of the environment task. On typical systems, the
822 recommended mechanism is to provide two subprograms whose link names are
823 ``adainit`` and ``adafinal``. ``adainit`` should contain the
824 elaboration code for library units. ``adafinal`` should contain the
825 finalization code. These subprograms should have no effect the second
826 and subsequent time they are called."
827
828 Followed.
829
830 "Automatic elaboration of pre-elaborated packages should be
831 provided when pragma ``Export`` is supported."
832
833 Followed when the main program is in Ada. If the main program is in a
834 foreign language, then
835 ``adainit`` must be called to elaborate pre-elaborated
836 packages.
837
838 "For each supported convention *L* other than ``Intrinsic``, an
839 implementation should support ``Import`` and ``Export`` pragmas
840 for objects of *L*\ -compatible types and for subprograms, and pragma
841 `Convention` for *L*\ -eligible types and for subprograms,
842 presuming the other language has corresponding features. Pragma
843 ``Convention`` need not be supported for scalar types."
844
845 Followed.
846
847 .. index:: Package Interfaces
848
849 .. index:: Interfaces
850
851 RM B.2(12-13): Package ``Interfaces``
852 =====================================
853
854 "For each implementation-defined convention identifier, there should be a
855 child package of package Interfaces with the corresponding name. This
856 package should contain any declarations that would be useful for
857 interfacing to the language (implementation) represented by the
858 convention. Any declarations useful for interfacing to any language on
859 the given hardware architecture should be provided directly in
860 ``Interfaces``."
861
862 Followed.
863
864 "An implementation supporting an interface to C, COBOL, or Fortran should
865 provide the corresponding package or packages described in the following
866 clauses."
867
868 Followed. GNAT provides all the packages described in this section.
869
870 .. index:: C, interfacing with
871
872 RM B.3(63-71): Interfacing with C
873 =================================
874
875 "An implementation should support the following interface correspondences
876 between Ada and C."
877
878 Followed.
879
880 "An Ada procedure corresponds to a void-returning C function."
881
882 Followed.
883
884 "An Ada function corresponds to a non-void C function."
885
886 Followed.
887
888 "An Ada ``in`` scalar parameter is passed as a scalar argument to a C
889 function."
890
891 Followed.
892
893 "An Ada ``in`` parameter of an access-to-object type with designated
894 type ``T`` is passed as a ``t*`` argument to a C function,
895 where ``t`` is the C type corresponding to the Ada type ``T``."
896
897 Followed.
898
899 "An Ada access ``T`` parameter, or an Ada ``out`` or ``in out``
900 parameter of an elementary type ``T``, is passed as a ``t*``
901 argument to a C function, where ``t`` is the C type corresponding to
902 the Ada type ``T``. In the case of an elementary ``out`` or
903 ``in out`` parameter, a pointer to a temporary copy is used to
904 preserve by-copy semantics."
905
906 Followed.
907
908 "An Ada parameter of a record type ``T``, of any mode, is passed as a
909 ``t*`` argument to a C function, where ``t`` is the C
910 structure corresponding to the Ada type ``T``."
911
912 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
913 pragma, or Convention, or by explicitly specifying the mechanism for a given
914 call using an extended import or export pragma.
915
916 "An Ada parameter of an array type with component type ``T``, of any
917 mode, is passed as a ``t*`` argument to a C function, where
918 ``t`` is the C type corresponding to the Ada type ``T``."
919
920 Followed.
921
922 "An Ada parameter of an access-to-subprogram type is passed as a pointer
923 to a C function whose prototype corresponds to the designated
924 subprogram's specification."
925
926 Followed.
927
928 .. index:: COBOL, interfacing with
929
930 RM B.4(95-98): Interfacing with COBOL
931 =====================================
932
933 "An Ada implementation should support the following interface
934 correspondences between Ada and COBOL."
935
936 Followed.
937
938 "An Ada access ``T`` parameter is passed as a ``BY REFERENCE`` data item of
939 the COBOL type corresponding to ``T``."
940
941 Followed.
942
943 "An Ada in scalar parameter is passed as a ``BY CONTENT`` data item of
944 the corresponding COBOL type."
945
946 Followed.
947
948 "Any other Ada parameter is passed as a ``BY REFERENCE`` data item of the
949 COBOL type corresponding to the Ada parameter type; for scalars, a local
950 copy is used if necessary to ensure by-copy semantics."
951
952 Followed.
953
954 .. index:: Fortran, interfacing with
955
956 RM B.5(22-26): Interfacing with Fortran
957 =======================================
958
959 "An Ada implementation should support the following interface
960 correspondences between Ada and Fortran:"
961
962 Followed.
963
964 "An Ada procedure corresponds to a Fortran subroutine."
965
966 Followed.
967
968 "An Ada function corresponds to a Fortran function."
969
970 Followed.
971
972 "An Ada parameter of an elementary, array, or record type ``T`` is
973 passed as a ``T`` argument to a Fortran procedure, where ``T`` is
974 the Fortran type corresponding to the Ada type ``T``, and where the
975 INTENT attribute of the corresponding dummy argument matches the Ada
976 formal parameter mode; the Fortran implementation's parameter passing
977 conventions are used. For elementary types, a local copy is used if
978 necessary to ensure by-copy semantics."
979
980 Followed.
981
982 "An Ada parameter of an access-to-subprogram type is passed as a
983 reference to a Fortran procedure whose interface corresponds to the
984 designated subprogram's specification."
985
986 Followed.
987
988 .. index:: Machine operations
989
990 RM C.1(3-5): Access to Machine Operations
991 =========================================
992
993 "The machine code or intrinsic support should allow access to all
994 operations normally available to assembly language programmers for the
995 target environment, including privileged instructions, if any."
996
997 Followed.
998
999 "The interfacing pragmas (see Annex B) should support interface to
1000 assembler; the default assembler should be associated with the
1001 convention identifier ``Assembler``."
1002
1003 Followed.
1004
1005 "If an entity is exported to assembly language, then the implementation
1006 should allocate it at an addressable location, and should ensure that it
1007 is retained by the linking process, even if not otherwise referenced
1008 from the Ada code. The implementation should assume that any call to a
1009 machine code or assembler subprogram is allowed to read or update every
1010 object that is specified as exported."
1011
1012 Followed.
1013
1014 RM C.1(10-16): Access to Machine Operations
1015 ===========================================
1016
1017 "The implementation should ensure that little or no overhead is
1018 associated with calling intrinsic and machine-code subprograms."
1019
1020 Followed for both intrinsics and machine-code subprograms.
1021
1022 "It is recommended that intrinsic subprograms be provided for convenient
1023 access to any machine operations that provide special capabilities or
1024 efficiency and that are not otherwise available through the language
1025 constructs."
1026
1027 Followed. A full set of machine operation intrinsic subprograms is provided.
1028
1029 "Atomic read-modify-write operations---e.g., test and set, compare and
1030 swap, decrement and test, enqueue/dequeue."
1031
1032 Followed on any target supporting such operations.
1033
1034 "Standard numeric functions---e.g.:, sin, log."
1035
1036 Followed on any target supporting such operations.
1037
1038 "String manipulation operations---e.g.:, translate and test."
1039
1040 Followed on any target supporting such operations.
1041
1042 "Vector operations---e.g.:, compare vector against thresholds."
1043
1044 Followed on any target supporting such operations.
1045
1046 "Direct operations on I/O ports."
1047
1048 Followed on any target supporting such operations.
1049
1050 .. index:: Interrupt support
1051
1052 RM C.3(28): Interrupt Support
1053 =============================
1054
1055 "If the ``Ceiling_Locking`` policy is not in effect, the
1056 implementation should provide means for the application to specify which
1057 interrupts are to be blocked during protected actions, if the underlying
1058 system allows for a finer-grain control of interrupt blocking."
1059
1060 Followed. The underlying system does not allow for finer-grain control
1061 of interrupt blocking.
1062
1063 .. index:: Protected procedure handlers
1064
1065 RM C.3.1(20-21): Protected Procedure Handlers
1066 =============================================
1067
1068 "Whenever possible, the implementation should allow interrupt handlers to
1069 be called directly by the hardware."
1070
1071 Followed on any target where the underlying operating system permits
1072 such direct calls.
1073
1074 "Whenever practical, violations of any
1075 implementation-defined restrictions should be detected before run time."
1076
1077 Followed. Compile time warnings are given when possible.
1078
1079 .. index:: Package ``Interrupts``
1080
1081 .. index:: Interrupts
1082
1083 RM C.3.2(25): Package ``Interrupts``
1084 ====================================
1085
1086 "If implementation-defined forms of interrupt handler procedures are
1087 supported, such as protected procedures with parameters, then for each
1088 such form of a handler, a type analogous to ``Parameterless_Handler``
1089 should be specified in a child package of ``Interrupts``, with the
1090 same operations as in the predefined package Interrupts."
1091
1092 Followed.
1093
1094 .. index:: Pre-elaboration requirements
1095
1096 RM C.4(14): Pre-elaboration Requirements
1097 ========================================
1098
1099 "It is recommended that pre-elaborated packages be implemented in such a
1100 way that there should be little or no code executed at run time for the
1101 elaboration of entities not already covered by the Implementation
1102 Requirements."
1103
1104 Followed. Executable code is generated in some cases, e.g., loops
1105 to initialize large arrays.
1106
1107 RM C.5(8): Pragma ``Discard_Names``
1108 ===================================
1109
1110 "If the pragma applies to an entity, then the implementation should
1111 reduce the amount of storage used for storing names associated with that
1112 entity."
1113
1114 Followed.
1115
1116 .. index:: Package Task_Attributes
1117
1118 .. index:: Task_Attributes
1119
1120 RM C.7.2(30): The Package Task_Attributes
1121 =========================================
1122
1123 "Some implementations are targeted to domains in which memory use at run
1124 time must be completely deterministic. For such implementations, it is
1125 recommended that the storage for task attributes will be pre-allocated
1126 statically and not from the heap. This can be accomplished by either
1127 placing restrictions on the number and the size of the task's
1128 attributes, or by using the pre-allocated storage for the first ``N``
1129 attribute objects, and the heap for the others. In the latter case,
1130 ``N`` should be documented."
1131
1132 Not followed. This implementation is not targeted to such a domain.
1133
1134 .. index:: Locking Policies
1135
1136 RM D.3(17): Locking Policies
1137 ============================
1138
1139 "The implementation should use names that end with ``_Locking`` for
1140 locking policies defined by the implementation."
1141
1142 Followed. Two implementation-defined locking policies are defined,
1143 whose names (``Inheritance_Locking`` and
1144 ``Concurrent_Readers_Locking``) follow this suggestion.
1145
1146 .. index:: Entry queuing policies
1147
1148 RM D.4(16): Entry Queuing Policies
1149 ==================================
1150
1151 "Names that end with ``_Queuing`` should be used
1152 for all implementation-defined queuing policies."
1153
1154 Followed. No such implementation-defined queuing policies exist.
1155
1156 .. index:: Preemptive abort
1157
1158 RM D.6(9-10): Preemptive Abort
1159 ==============================
1160
1161 "Even though the *abort_statement* is included in the list of
1162 potentially blocking operations (see 9.5.1), it is recommended that this
1163 statement be implemented in a way that never requires the task executing
1164 the *abort_statement* to block."
1165
1166 Followed.
1167
1168 "On a multi-processor, the delay associated with aborting a task on
1169 another processor should be bounded; the implementation should use
1170 periodic polling, if necessary, to achieve this."
1171
1172 Followed.
1173
1174 .. index:: Tasking restrictions
1175
1176 RM D.7(21): Tasking Restrictions
1177 ================================
1178
1179 "When feasible, the implementation should take advantage of the specified
1180 restrictions to produce a more efficient implementation."
1181
1182 GNAT currently takes advantage of these restrictions by providing an optimized
1183 run time when the Ravenscar profile and the GNAT restricted run time set
1184 of restrictions are specified. See pragma ``Profile (Ravenscar)`` and
1185 pragma ``Profile (Restricted)`` for more details.
1186
1187 .. index:: Time, monotonic
1188
1189 RM D.8(47-49): Monotonic Time
1190 =============================
1191
1192 "When appropriate, implementations should provide configuration
1193 mechanisms to change the value of ``Tick``."
1194
1195 Such configuration mechanisms are not appropriate to this implementation
1196 and are thus not supported.
1197
1198 "It is recommended that ``Calendar.Clock`` and ``Real_Time.Clock``
1199 be implemented as transformations of the same time base."
1200
1201 Followed.
1202
1203
1204 "It is recommended that the best time base which exists in
1205 the underlying system be available to the application through
1206 ``Clock``. `Best` may mean highest accuracy or largest range."
1207
1208 Followed.
1209
1210 .. index:: Partition communication subsystem
1211
1212 .. index:: PCS
1213
1214 RM E.5(28-29): Partition Communication Subsystem
1215 ================================================
1216
1217 "Whenever possible, the PCS on the called partition should allow for
1218 multiple tasks to call the RPC-receiver with different messages and
1219 should allow them to block until the corresponding subprogram body
1220 returns."
1221
1222 Followed by GLADE, a separately supplied PCS that can be used with
1223 GNAT.
1224
1225 "The ``Write`` operation on a stream of type ``Params_Stream_Type``
1226 should raise ``Storage_Error`` if it runs out of space trying to
1227 write the ``Item`` into the stream."
1228
1229 Followed by GLADE, a separately supplied PCS that can be used with
1230 GNAT.
1231
1232 .. index:: COBOL support
1233
1234 RM F(7): COBOL Support
1235 ======================
1236
1237 "If COBOL (respectively, C) is widely supported in the target
1238 environment, implementations supporting the Information Systems Annex
1239 should provide the child package ``Interfaces.COBOL`` (respectively,
1240 ``Interfaces.C``) specified in Annex B and should support a
1241 ``convention_identifier`` of COBOL (respectively, C) in the interfacing
1242 pragmas (see Annex B), thus allowing Ada programs to interface with
1243 programs written in that language."
1244
1245 Followed.
1246
1247 .. index:: Decimal radix support
1248
1249 RM F.1(2): Decimal Radix Support
1250 ================================
1251
1252 "Packed decimal should be used as the internal representation for objects
1253 of subtype ``S`` when ``S``'Machine_Radix = 10."
1254
1255 Not followed. GNAT ignores ``S``'Machine_Radix and always uses binary
1256 representations.
1257
1258 .. index:: Numerics
1259
1260 RM G: Numerics
1261 ==============
1262
1263 "If Fortran (respectively, C) is widely supported in the target
1264 environment, implementations supporting the Numerics Annex
1265 should provide the child package ``Interfaces.Fortran`` (respectively,
1266 ``Interfaces.C``) specified in Annex B and should support a
1267 ``convention_identifier`` of Fortran (respectively, C) in the interfacing
1268 pragmas (see Annex B), thus allowing Ada programs to interface with
1269 programs written in that language."
1270
1271 Followed.
1272
1273 .. index:: Complex types
1274
1275 RM G.1.1(56-58): Complex Types
1276 ==============================
1277
1278 "Because the usual mathematical meaning of multiplication of a complex
1279 operand and a real operand is that of the scaling of both components of
1280 the former by the latter, an implementation should not perform this
1281 operation by first promoting the real operand to complex type and then
1282 performing a full complex multiplication. In systems that, in the
1283 future, support an Ada binding to IEC 559:1989, the latter technique
1284 will not generate the required result when one of the components of the
1285 complex operand is infinite. (Explicit multiplication of the infinite
1286 component by the zero component obtained during promotion yields a NaN
1287 that propagates into the final result.) Analogous advice applies in the
1288 case of multiplication of a complex operand and a pure-imaginary
1289 operand, and in the case of division of a complex operand by a real or
1290 pure-imaginary operand."
1291
1292 Not followed.
1293
1294 "Similarly, because the usual mathematical meaning of addition of a
1295 complex operand and a real operand is that the imaginary operand remains
1296 unchanged, an implementation should not perform this operation by first
1297 promoting the real operand to complex type and then performing a full
1298 complex addition. In implementations in which the ``Signed_Zeros``
1299 attribute of the component type is ``True`` (and which therefore
1300 conform to IEC 559:1989 in regard to the handling of the sign of zero in
1301 predefined arithmetic operations), the latter technique will not
1302 generate the required result when the imaginary component of the complex
1303 operand is a negatively signed zero. (Explicit addition of the negative
1304 zero to the zero obtained during promotion yields a positive zero.)
1305 Analogous advice applies in the case of addition of a complex operand
1306 and a pure-imaginary operand, and in the case of subtraction of a
1307 complex operand and a real or pure-imaginary operand."
1308
1309 Not followed.
1310
1311 "Implementations in which ``Real'Signed_Zeros`` is ``True`` should
1312 attempt to provide a rational treatment of the signs of zero results and
1313 result components. As one example, the result of the ``Argument``
1314 function should have the sign of the imaginary component of the
1315 parameter ``X`` when the point represented by that parameter lies on
1316 the positive real axis; as another, the sign of the imaginary component
1317 of the ``Compose_From_Polar`` function should be the same as
1318 (respectively, the opposite of) that of the ``Argument`` parameter when that
1319 parameter has a value of zero and the ``Modulus`` parameter has a
1320 nonnegative (respectively, negative) value."
1321
1322 Followed.
1323
1324 .. index:: Complex elementary functions
1325
1326 RM G.1.2(49): Complex Elementary Functions
1327 ==========================================
1328
1329 "Implementations in which ``Complex_Types.Real'Signed_Zeros`` is
1330 ``True`` should attempt to provide a rational treatment of the signs
1331 of zero results and result components. For example, many of the complex
1332 elementary functions have components that are odd functions of one of
1333 the parameter components; in these cases, the result component should
1334 have the sign of the parameter component at the origin. Other complex
1335 elementary functions have zero components whose sign is opposite that of
1336 a parameter component at the origin, or is always positive or always
1337 negative."
1338
1339 Followed.
1340
1341 .. index:: Accuracy requirements
1342
1343 RM G.2.4(19): Accuracy Requirements
1344 ===================================
1345
1346 "The versions of the forward trigonometric functions without a
1347 ``Cycle`` parameter should not be implemented by calling the
1348 corresponding version with a ``Cycle`` parameter of
1349 ``2.0*Numerics.Pi``, since this will not provide the required
1350 accuracy in some portions of the domain. For the same reason, the
1351 version of ``Log`` without a ``Base`` parameter should not be
1352 implemented by calling the corresponding version with a ``Base``
1353 parameter of ``Numerics.e``."
1354
1355 Followed.
1356
1357 .. index:: Complex arithmetic accuracy
1358
1359 .. index:: Accuracy, complex arithmetic
1360
1361 RM G.2.6(15): Complex Arithmetic Accuracy
1362 =========================================
1363
1364 "The version of the ``Compose_From_Polar`` function without a
1365 ``Cycle`` parameter should not be implemented by calling the
1366 corresponding version with a ``Cycle`` parameter of
1367 ``2.0*Numerics.Pi``, since this will not provide the required
1368 accuracy in some portions of the domain."
1369
1370 Followed.
1371
1372 .. index:: Sequential elaboration policy
1373
1374 RM H.6(15/2): Pragma Partition_Elaboration_Policy
1375 =================================================
1376
1377 "If the partition elaboration policy is ``Sequential`` and the
1378 Environment task becomes permanently blocked during elaboration then the
1379 partition is deadlocked and it is recommended that the partition be
1380 immediately terminated."
1381
1382 Not followed.