gnatprove_13.2.1_28fc3583/libexec/spark/lib/gcc/x86_64-pc-linux-gnu/13.2.0/adainclude/s-stratt.adb

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT RUN-TIME COMPONENTS                         --
--                                                                          --
--             S Y S T E M . S T R E A M _ A T T R I B U T E S              --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--          Copyright (C) 1992-2023, Free Software Foundation, Inc.         --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

with Ada.IO_Exceptions;
with Ada.Streams; use Ada.Streams;
with Ada.Unchecked_Conversion;
with System.Stream_Attributes.XDR;

package body System.Stream_Attributes is

   XDR_Stream : constant Integer;
   pragma Import (C, XDR_Stream, "__gl_xdr_stream");
   --  This imported value is used to determine whether the build had the
   --  binder switch "-xdr" present which enables XDR streaming and sets this
   --  flag to 1.

   function XDR_Support return Boolean is (XDR_Stream = 1);
   pragma Inline (XDR_Support);
   --  Return True if XDR streaming should be used. Note that 128-bit integers
   --  are not supported by the XDR protocol and will raise Device_Error.

   Err : exception renames Ada.IO_Exceptions.End_Error;
   --  Exception raised if insufficient data read (note that the RM implies
   --  that Data_Error might be the appropriate choice, but AI95-00132
   --  decides with a binding interpretation that End_Error is preferred).

   SU : constant := System.Storage_Unit;

   subtype SEA is Ada.Streams.Stream_Element_Array;
   subtype SEO is Ada.Streams.Stream_Element_Offset;

   generic function UC renames Ada.Unchecked_Conversion;

   --  Subtypes used to define Stream_Element_Array values that map
   --  into the elementary types, using unchecked conversion.

   Thin_Pointer_Size : constant := System.Address'Size;
   Fat_Pointer_Size  : constant := System.Address'Size * 2;

   subtype S_AD   is SEA (1 .. (Fat_Pointer_Size              + SU - 1) / SU);
   subtype S_AS   is SEA (1 .. (Thin_Pointer_Size             + SU - 1) / SU);
   subtype S_B    is SEA (1 .. (Boolean'Size                  + SU - 1) / SU);
   subtype S_C    is SEA (1 .. (Character'Size                + SU - 1) / SU);
   subtype S_F    is SEA (1 .. (Float'Size                    + SU - 1) / SU);
   subtype S_I    is SEA (1 .. (Integer'Size                  + SU - 1) / SU);
   subtype S_I24  is SEA (1 .. (Integer_24'Size               + SU - 1) / SU);
   subtype S_LF   is SEA (1 .. (Long_Float'Size               + SU - 1) / SU);
   subtype S_LI   is SEA (1 .. (Long_Integer'Size             + SU - 1) / SU);
   subtype S_LLF  is SEA (1 .. (Long_Long_Float'Size          + SU - 1) / SU);
   subtype S_LLI  is SEA (1 .. (Long_Long_Integer'Size        + SU - 1) / SU);
   subtype S_LLLI is SEA (1 .. (Long_Long_Long_Integer'Size   + SU - 1) / SU);
   subtype S_LLLU is
                  SEA (1 .. (UST.Long_Long_Long_Unsigned'Size + SU - 1) / SU);
   subtype S_LLU  is SEA (1 .. (UST.Long_Long_Unsigned'Size   + SU - 1) / SU);
   subtype S_LU   is SEA (1 .. (UST.Long_Unsigned'Size        + SU - 1) / SU);
   subtype S_SF   is SEA (1 .. (Short_Float'Size              + SU - 1) / SU);
   subtype S_SI   is SEA (1 .. (Short_Integer'Size            + SU - 1) / SU);
   subtype S_SSI  is SEA (1 .. (Short_Short_Integer'Size      + SU - 1) / SU);
   subtype S_SSU  is SEA (1 .. (UST.Short_Short_Unsigned'Size + SU - 1) / SU);
   subtype S_SU   is SEA (1 .. (UST.Short_Unsigned'Size       + SU - 1) / SU);
   subtype S_U    is SEA (1 .. (UST.Unsigned'Size             + SU - 1) / SU);
   subtype S_U24  is SEA (1 .. (Unsigned_24'Size              + SU - 1) / SU);
   subtype S_WC   is SEA (1 .. (Wide_Character'Size           + SU - 1) / SU);
   subtype S_WWC  is SEA (1 .. (Wide_Wide_Character'Size      + SU - 1) / SU);

   --  Unchecked conversions from the elementary type to the stream type

   function From_AD   is new UC (Fat_Pointer,                 S_AD);
   function From_AS   is new UC (Thin_Pointer,                S_AS);
   function From_F    is new UC (Float,                       S_F);
   function From_I    is new UC (Integer,                     S_I);
   function From_I24  is new UC (Integer_24,                  S_I24);
   function From_LF   is new UC (Long_Float,                  S_LF);
   function From_LI   is new UC (Long_Integer,                S_LI);
   function From_LLF  is new UC (Long_Long_Float,             S_LLF);
   function From_LLI  is new UC (Long_Long_Integer,           S_LLI);
   function From_LLLI is new UC (Long_Long_Long_Integer,      S_LLLI);
   function From_LLLU is new UC (UST.Long_Long_Long_Unsigned, S_LLLU);
   function From_LLU  is new UC (UST.Long_Long_Unsigned,      S_LLU);
   function From_LU   is new UC (UST.Long_Unsigned,           S_LU);
   function From_SF   is new UC (Short_Float,                 S_SF);
   function From_SI   is new UC (Short_Integer,               S_SI);
   function From_SSI  is new UC (Short_Short_Integer,         S_SSI);
   function From_SSU  is new UC (UST.Short_Short_Unsigned,    S_SSU);
   function From_SU   is new UC (UST.Short_Unsigned,          S_SU);
   function From_U    is new UC (UST.Unsigned,                S_U);
   function From_U24  is new UC (Unsigned_24,                 S_U24);
   function From_WC   is new UC (Wide_Character,              S_WC);
   function From_WWC  is new UC (Wide_Wide_Character,         S_WWC);

   --  Unchecked conversions from the stream type to elementary type

   function To_AD   is new UC (S_AD,   Fat_Pointer);
   function To_AS   is new UC (S_AS,   Thin_Pointer);
   function To_F    is new UC (S_F,    Float);
   function To_I    is new UC (S_I,    Integer);
   function To_I24  is new UC (S_I24,  Integer_24);
   function To_LF   is new UC (S_LF,   Long_Float);
   function To_LI   is new UC (S_LI,   Long_Integer);
   function To_LLF  is new UC (S_LLF,  Long_Long_Float);
   function To_LLI  is new UC (S_LLI,  Long_Long_Integer);
   function To_LLLI is new UC (S_LLLI, Long_Long_Long_Integer);
   function To_LLLU is new UC (S_LLLU, UST.Long_Long_Long_Unsigned);
   function To_LLU  is new UC (S_LLU,  UST.Long_Long_Unsigned);
   function To_LU   is new UC (S_LU,   UST.Long_Unsigned);
   function To_SF   is new UC (S_SF,   Short_Float);
   function To_SI   is new UC (S_SI,   Short_Integer);
   function To_SSI  is new UC (S_SSI,  Short_Short_Integer);
   function To_SSU  is new UC (S_SSU,  UST.Short_Short_Unsigned);
   function To_SU   is new UC (S_SU,   UST.Short_Unsigned);
   function To_U    is new UC (S_U,    UST.Unsigned);
   function To_U24  is new UC (S_U24,  Unsigned_24);
   function To_WC   is new UC (S_WC,   Wide_Character);
   function To_WWC  is new UC (S_WWC,  Wide_Wide_Character);

   -----------------
   -- Block_IO_OK --
   -----------------

   function Block_IO_OK return Boolean is
   begin
      return not XDR_Support;
   end Block_IO_OK;

   ----------
   -- I_AD --
   ----------

   function I_AD (Stream : not null access RST) return Fat_Pointer is
      T : S_AD;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_AD (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_AD (T);
      end if;
   end I_AD;

   ----------
   -- I_AS --
   ----------

   function I_AS (Stream : not null access RST) return Thin_Pointer is
      T : S_AS;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_AS (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_AS (T);
      end if;
   end I_AS;

   ---------
   -- I_B --
   ---------

   function I_B (Stream : not null access RST) return Boolean is
      T : S_B;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_B (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return Boolean'Val (T (1));
      end if;
   end I_B;

   ---------
   -- I_C --
   ---------

   function I_C (Stream : not null access RST) return Character is
      T : S_C;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_C (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return Character'Val (T (1));
      end if;
   end I_C;

   ---------
   -- I_F --
   ---------

   function I_F (Stream : not null access RST) return Float is
      T : S_F;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_F (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_F (T);
      end if;
   end I_F;

   ---------
   -- I_I --
   ---------

   function I_I (Stream : not null access RST) return Integer is
      T : S_I;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_I (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_I (T);
      end if;
   end I_I;

   -----------
   -- I_I24 --
   -----------

   function I_I24 (Stream : not null access RST) return Integer_24 is
      T : S_I24;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_I24 (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_I24 (T);
      end if;
   end I_I24;

   ----------
   -- I_LF --
   ----------

   function I_LF (Stream : not null access RST) return Long_Float is
      T : S_LF;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LF (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LF (T);
      end if;
   end I_LF;

   ----------
   -- I_LI --
   ----------

   function I_LI (Stream : not null access RST) return Long_Integer is
      T : S_LI;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LI (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LI (T);
      end if;
   end I_LI;

   -----------
   -- I_LLF --
   -----------

   function I_LLF (Stream : not null access RST) return Long_Long_Float is
      T : S_LLF;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LLF (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LLF (T);
      end if;
   end I_LLF;

   -----------
   -- I_LLI --
   -----------

   function I_LLI (Stream : not null access RST) return Long_Long_Integer is
      T : S_LLI;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LLI (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LLI (T);
      end if;
   end I_LLI;

   ------------
   -- I_LLLI --
   ------------

   function I_LLLI (Stream : not null access RST) return Long_Long_Long_Integer
   is
      T : S_LLLI;
      L : SEO;

   begin
      if XDR_Support then
         raise Ada.IO_Exceptions.Device_Error;
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LLLI (T);
      end if;
   end I_LLLI;

   ------------
   -- I_LLLU --
   ------------

   function I_LLLU
     (Stream : not null access RST) return UST.Long_Long_Long_Unsigned
   is
      T : S_LLLU;
      L : SEO;

   begin
      if XDR_Support then
         raise Ada.IO_Exceptions.Device_Error;
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LLLU (T);
      end if;
   end I_LLLU;

   -----------
   -- I_LLU --
   -----------

   function I_LLU
     (Stream : not null access RST) return UST.Long_Long_Unsigned
   is
      T : S_LLU;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LLU (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LLU (T);
      end if;
   end I_LLU;

   ----------
   -- I_LU --
   ----------

   function I_LU (Stream : not null access RST) return UST.Long_Unsigned is
      T : S_LU;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_LU (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_LU (T);
      end if;
   end I_LU;

   ----------
   -- I_SF --
   ----------

   function I_SF (Stream : not null access RST) return Short_Float is
      T : S_SF;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_SF (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_SF (T);
      end if;
   end I_SF;

   ----------
   -- I_SI --
   ----------

   function I_SI (Stream : not null access RST) return Short_Integer is
      T : S_SI;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_SI (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_SI (T);
      end if;
   end I_SI;

   -----------
   -- I_SSI --
   -----------

   function I_SSI (Stream : not null access RST) return Short_Short_Integer is
      T : S_SSI;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_SSI (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_SSI (T);
      end if;
   end I_SSI;

   -----------
   -- I_SSU --
   -----------

   function I_SSU
     (Stream : not null access RST) return UST.Short_Short_Unsigned
   is
      T : S_SSU;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_SSU (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_SSU (T);
      end if;
   end I_SSU;

   ----------
   -- I_SU --
   ----------

   function I_SU (Stream : not null access RST) return UST.Short_Unsigned is
      T : S_SU;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_SU (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_SU (T);
      end if;
   end I_SU;

   ---------
   -- I_U --
   ---------

   function I_U (Stream : not null access RST) return UST.Unsigned is
      T : S_U;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_U (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_U (T);
      end if;
   end I_U;

   -----------
   -- I_U24 --
   -----------

   function I_U24 (Stream : not null access RST) return Unsigned_24 is
      T : S_U24;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_U24 (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_U24 (T);
      end if;
   end I_U24;

   ----------
   -- I_WC --
   ----------

   function I_WC (Stream : not null access RST) return Wide_Character is
      T : S_WC;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_WC (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_WC (T);
      end if;
   end I_WC;

   -----------
   -- I_WWC --
   -----------

   function I_WWC (Stream : not null access RST) return Wide_Wide_Character is
      T : S_WWC;
      L : SEO;

   begin
      if XDR_Support then
         return XDR.I_WWC (Stream);
      end if;

      Ada.Streams.Read (Stream.all, T, L);

      if L < T'Last then
         raise Err;
      else
         return To_WWC (T);
      end if;
   end I_WWC;

   ----------
   -- W_AD --
   ----------

   procedure W_AD (Stream : not null access RST; Item : Fat_Pointer) is
      T : constant S_AD := From_AD (Item);
   begin
      if XDR_Support then
         XDR.W_AD (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, T);
   end W_AD;

   ----------
   -- W_AS --
   ----------

   procedure W_AS (Stream : not null access RST; Item : Thin_Pointer) is
      T : constant S_AS := From_AS (Item);
   begin
      if XDR_Support then
         XDR.W_AS (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, T);
   end W_AS;

   ---------
   -- W_B --
   ---------

   procedure W_B (Stream : not null access RST; Item : Boolean) is
      T : S_B;
   begin
      if XDR_Support then
         XDR.W_B (Stream, Item);
         return;
      end if;

      T (1) := Boolean'Pos (Item);
      Ada.Streams.Write (Stream.all, T);
   end W_B;

   ---------
   -- W_C --
   ---------

   procedure W_C (Stream : not null access RST; Item : Character) is
      T : S_C;
   begin
      if XDR_Support then
         XDR.W_C (Stream, Item);
         return;
      end if;

      T (1) := Character'Pos (Item);
      Ada.Streams.Write (Stream.all, T);
   end W_C;

   ---------
   -- W_F --
   ---------

   procedure W_F (Stream : not null access RST; Item : Float) is
   begin
      if XDR_Support then
         XDR.W_F (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_F (Item));
   end W_F;

   ---------
   -- W_I --
   ---------

   procedure W_I (Stream : not null access RST; Item : Integer) is
   begin
      if XDR_Support then
         XDR.W_I (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_I (Item));
   end W_I;

   -----------
   -- W_I24 --
   -----------

   procedure W_I24 (Stream : not null access RST; Item : Integer_24) is
   begin
      if XDR_Support then
         XDR.W_I24 (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_I24 (Item));
   end W_I24;

   ----------
   -- W_LF --
   ----------

   procedure W_LF (Stream : not null access RST; Item : Long_Float) is
   begin
      if XDR_Support then
         XDR.W_LF (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LF (Item));
   end W_LF;

   ----------
   -- W_LI --
   ----------

   procedure W_LI (Stream : not null access RST; Item : Long_Integer) is
   begin
      if XDR_Support then
         XDR.W_LI (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LI (Item));
   end W_LI;

   -----------
   -- W_LLF --
   -----------

   procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float) is
   begin
      if XDR_Support then
         XDR.W_LLF (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LLF (Item));
   end W_LLF;

   -----------
   -- W_LLI --
   -----------

   procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer) is
   begin
      if XDR_Support then
         XDR.W_LLI (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LLI (Item));
   end W_LLI;

   ------------
   -- W_LLLI --
   ------------

   procedure W_LLLI
     (Stream : not null access RST; Item : Long_Long_Long_Integer) is
   begin
      if XDR_Support then
         raise Ada.IO_Exceptions.Device_Error;
      end if;

      Ada.Streams.Write (Stream.all, From_LLLI (Item));
   end W_LLLI;

   ------------
   -- W_LLLU --
   ------------

   procedure W_LLLU
     (Stream : not null access RST; Item : UST.Long_Long_Long_Unsigned)
   is
   begin
      if XDR_Support then
         raise Ada.IO_Exceptions.Device_Error;
      end if;

      Ada.Streams.Write (Stream.all, From_LLLU (Item));
   end W_LLLU;

   -----------
   -- W_LLU --
   -----------

   procedure W_LLU
     (Stream : not null access RST; Item : UST.Long_Long_Unsigned)
   is
   begin
      if XDR_Support then
         XDR.W_LLU (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LLU (Item));
   end W_LLU;

   ----------
   -- W_LU --
   ----------

   procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned) is
   begin
      if XDR_Support then
         XDR.W_LU (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_LU (Item));
   end W_LU;

   ----------
   -- W_SF --
   ----------

   procedure W_SF (Stream : not null access RST; Item : Short_Float) is
   begin
      if XDR_Support then
         XDR.W_SF (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_SF (Item));
   end W_SF;

   ----------
   -- W_SI --
   ----------

   procedure W_SI (Stream : not null access RST; Item : Short_Integer) is
   begin
      if XDR_Support then
         XDR.W_SI (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_SI (Item));
   end W_SI;

   -----------
   -- W_SSI --
   -----------

   procedure W_SSI
     (Stream : not null access RST; Item : Short_Short_Integer)
   is
   begin
      if XDR_Support then
         XDR.W_SSI (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_SSI (Item));
   end W_SSI;

   -----------
   -- W_SSU --
   -----------

   procedure W_SSU
     (Stream : not null access RST; Item : UST.Short_Short_Unsigned)
   is
   begin
      if XDR_Support then
         XDR.W_SSU (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_SSU (Item));
   end W_SSU;

   ----------
   -- W_SU --
   ----------

   procedure W_SU (Stream : not null access RST; Item : UST.Short_Unsigned) is
   begin
      if XDR_Support then
         XDR.W_SU (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_SU (Item));
   end W_SU;

   ---------
   -- W_U --
   ---------

   procedure W_U (Stream : not null access RST; Item : UST.Unsigned) is
   begin
      if XDR_Support then
         XDR.W_U (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_U (Item));
   end W_U;

   -----------
   -- W_U24 --
   -----------

   procedure W_U24 (Stream : not null access RST; Item : Unsigned_24) is
   begin
      if XDR_Support then
         XDR.W_U24 (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_U24 (Item));
   end W_U24;

   ----------
   -- W_WC --
   ----------

   procedure W_WC (Stream : not null access RST; Item : Wide_Character) is
   begin
      if XDR_Support then
         XDR.W_WC (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_WC (Item));
   end W_WC;

   -----------
   -- W_WWC --
   -----------

   procedure W_WWC
     (Stream : not null access RST; Item : Wide_Wide_Character)
   is
   begin
      if XDR_Support then
         XDR.W_WWC (Stream, Item);
         return;
      end if;

      Ada.Streams.Write (Stream.all, From_WWC (Item));
   end W_WWC;

end System.Stream_Attributes;