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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Re: Compiler doesn't respect 'Size for atomic object Date: Wed, 20 Dec 2017 19:23:32 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Wed, 20 Dec 2017 19:23:32 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="b730f3f8a4a99b3edd32530cc8db11a2"; logging-data="16043"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rNAua0JzyqL84NFaumVdS0PyKfv3ky3A=" User-Agent: slrn/0.9.8.1 (VMS/Multinet) Cancel-Lock: sha1:ga4DTh3yaCGch7gVcPsRczHuTjE= Xref: reader02.eternal-september.org comp.lang.ada:49551 Date: 2017-12-20T19:23:32+00:00 List-Id: On 2017-12-20, Simon Wright wrote: > The code below is an abstract of one for a Cortex-M processor; it > generates an external interrupt, useful for testing. > > All released GNAT compilers I have access to and which accept the syntax > (GPL 2015+, FSF GCC 5+) produce the result that the hardware needs and > that I intended, i.e. 16#1#. > > GCC 8, which is still under development, produces 16#FFFFFF01#, i.e. has > only written the least significant byte. > > I'm pretty sure this is an error, rather than an unhelpful > interpretation: can anyone confirm one way or the other, before I raise > a bug, please? > And an old friend (for various values of "friend" :-)) has raised its head again. A skim through AI12-0128 might be useful although my AI only refers to components within an atomic composite object. My instinct is that this is a compiler problem although I don't know if something is going on due to you extending the underlying data type to 32 bits. If you use a naturally 32-bit variable instead of your Interrupt_ID data type, does it work ok ? Simon. >======================================================================== > with Ada.Text_IO; > with Interfaces; > > procedure Full_Word is > > Register : Interfaces.Unsigned_32; > > type Interrupt_ID is range 0 .. 44; > > procedure Trigger_Interrupt (IRQ : Interrupt_ID) is > -- The Software Trigger Interrupt Register. > NVIC_STIR : Interrupt_ID > with > Import, > Atomic, > Size => 32, > Address => Register'Address; > > begin > NVIC_STIR := IRQ; -- h/w requires 32-bit write > end Trigger_Interrupt; > > package Unsigned_32_IO > is new Ada.Text_IO.Modular_IO (Interfaces.Unsigned_32); > > begin > Register := 16#ffff_ffff#; > Trigger_Interrupt (1); > Unsigned_32_IO.Put (Register, Base => 16); > Ada.Text_IO.New_Line; > end Full_Word; -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world