From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,69431b06fe9a3239,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!p16g2000vbo.googlegroups.com!not-for-mail From: Lucretia Newsgroups: comp.lang.ada Subject: How do I disable elaboration code on this Date: Sat, 9 Apr 2011 06:58:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: <58bc4fb4-5f6a-48d6-9c98-0dde7ac619df@p16g2000vbo.googlegroups.com> NNTP-Posting-Host: 90.194.162.198 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1302357481 7155 127.0.0.1 (9 Apr 2011 13:58:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 9 Apr 2011 13:58:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p16g2000vbo.googlegroups.com; posting-host=90.194.162.198; posting-account=L2-UcQkAAAAfd_BqbeNHs3XeM0jTXloS User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.1.16) Gecko/20110302 Iceweasel/3.5.16 (like Firefox/3.5.16),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19699 Date: 2011-04-09T06:58:00-07:00 List-Id: The following code will not compile no matter what I do. Basically, I want to write the startup code for Cortex-M3 in Ada with no assembly. So, the ISR code needs to be elaboration free as it's the first bit of code that would run on reset. Essentially, at address 0 the exception vectors are stored. These are in flash ROM so elaboration code is out of the question anyway. Each element of the array is a pointer to an interrupt service routine. I've specified a 4 element vector to test this out: I've compiled with: ~/opt/tamp/bin/arm-none-eabi-gnatmake --RTS=/home/laguest/src/mine/ tamp/rts/boards/xpresso1769 -c -g -gnatyy -gnaty-s -mcpu=cortex-m3 - mthumb -gnatG test.adb and used my own build of the compiler and my own zero footprint runtime. I get the following output: -- Start of output Source recreated from tree for ISR (body) ----------------------------------------- package body isr is procedure isr__dummy is begin %push_constraint_error_label () %push_program_error_label () %push_storage_error_label () null; %pop_constraint_error_label %pop_program_error_label %pop_storage_error_label return; end isr__dummy; begin null; end isr; Source recreated from tree for ISR (spec) ----------------------------------------- pragma restrictions (no_elaboration_code); with system; with system; isr_E : boolean := false; package isr is procedure isr__dummy; pragma convention (c, isr__dummy); private type isr__cb is not null access procedure; pragma convention (c, isr__cb); type isr__vectors is array (1 .. 4) of isr__cb; pragma convention (c, isr__vectors); isr__addr : constant system.system__address := system__address!( 0); [type isr__TvectorsB is array (1 .. 4 range <>) of isr__cb] freeze isr__TvectorsB [ procedure isr__TvectorsBIP (_init : in out isr__TvectorsB) is %push_constraint_error_label () %push_program_error_label () %push_storage_error_label () subtype isr__TvectorsBIP__S4s is isr__TvectorsB (_init'first( 1) .. _init'last(1)); begin for J1 in _init'first(1) .. _init'last(1) loop [constraint_error "access check failed"] _init (J1) := null; end loop; %pop_constraint_error_label %pop_program_error_label %pop_storage_error_label return; end isr__TvectorsBIP; ] [subtype isr__T12s is isr__TvectorsB (1 .. 4)] reference isr__T12s reference isr__T12s isr__vector : constant isr__vectors := (isr__dummy'access, isr__dummy'access, isr__dummy'access, isr__dummy'access); pragma convention (c, isr__vector); for isr__vector'address use isr__addr; end isr; isr.ads:20:04: violation of restriction "NO_ELABORATION_CODE" at line 1 arm-none-eabi-gnatmake: "isr.adb" compilation error -- End of output I've also tried an array of addresses, this produces the same problem. Can anyone point me in the right direction? Surely, this is possible in Ada? -------------------------- Code below -------------------------------------- pragma Restrictions (No_Elaboration_Code); with System; package ISR is procedure Dummy; pragma Convention (C, Dummy); private type Cb is not null access procedure; pragma Convention (C, Cb); type Vectors is array (1 .. 4) of Cb; pragma Convention (C, Vectors); Addr : constant System.Address := System'To_Address (16#0000_0000#); Vector : constant Vectors := (Dummy'Access, Dummy'Access, Dummy'Access, Dummy'Access); pragma Convention (C, Vector); for Vector'Address use Addr; end ISR; package body ISR is procedure Dummy is begin null; end Dummy; end ISR; pragma Restrictions (No_Floating_Point); with ISR; procedure Test is begin null; end Test;