blob: 600dc5396ca6c7764c44e7cf0216a8068525523d [file] [log] [blame]
Thomas Heijligen62268ee2023-11-27 15:10:41 +00001with Interfaces;
2
Nico Huber98417fc2023-11-30 16:46:25 +01003use Interfaces;
4
Thomas Heijligend1e04572023-11-27 14:28:55 +00005package FS is
6
Nico Huber98417fc2023-11-30 16:46:25 +01007 subtype Index_Type is Natural range 0 .. Natural'Last - 1;
8 subtype Index_Type16 is Index_Type range 0 .. Index_Type'Last - 1;
9 subtype Index_Type32 is Index_Type16 range 0 .. Index_Type16'Last - 2;
10
11 type Buffer_Type is array (Index_Type range <>) of Unsigned_8;
12
13 function Read_LE16 (Buf : Buffer_Type; Off : Index_Type16) return Unsigned_16
14 is
Nico Hubercd6b7ec2023-12-04 15:21:26 +010015 (Shift_Left (Unsigned_16 (Buf (Off + 1)), 8) or Unsigned_16 (Buf (Off)))
16 with
17 Pre => Buf'First <= Off and Off + 1 <= Buf'Last;
Nico Huber98417fc2023-11-30 16:46:25 +010018
19 function Read_LE32 (Buf : Buffer_Type; Off : Index_Type32) return Unsigned_32
20 is
21 (Shift_Left (Unsigned_32 (Buf (Off + 3)), 24) or
22 Shift_Left (Unsigned_32 (Buf (Off + 2)), 16) or
23 Shift_Left (Unsigned_32 (Buf (Off + 1)), 8) or
Nico Hubercd6b7ec2023-12-04 15:21:26 +010024 Unsigned_32 (Buf (Off)))
25 with
26 Pre => Buf'First <= Off and Off + 3 <= Buf'Last;
Thomas Heijligend1e04572023-11-27 14:28:55 +000027
28end FS;