aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/array41.adb
blob: d0d5a69eeaf0f15f50ca32afb4fe78c24100b3d8 (plain)
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
-- { dg-do compile }

with System.Storage_Elements;

package body Array41 is

   procedure Program_Initialization
   with
     Export,
     Convention => Ada,
     External_Name => "program_initialization";

   procedure Program_Initialization is
      use System.Storage_Elements;

      Sdata : Storage_Element
        with Import, Convention => Asm, External_Name => "_sdata";
      Edata : Storage_Element
        with Import, Convention => Asm, External_Name => "_edata";

      Data_Size : constant Storage_Offset := Edata'Address - Sdata'Address;

      --  Index from 1 so as to avoid subtracting 1 from the size
      Data_In_Flash : constant Storage_Array (1 .. Data_Size)
        with Import, Convention => Asm, External_Name => "_sidata";

      Data_In_Sram : Storage_Array (1 .. Data_Size)
        with Volatile, Import, Convention => Asm, External_Name => "_sdata";

   begin
      --  Copy rw data from flash to ram
      for J in Data_In_Flash'Range loop
         Data_In_Sram (J) := Data_In_Flash (J);
      end loop;
   end Program_Initialization;

end Array41;