comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP>
Subject: Re: Compiler doesn't respect 'Size for atomic object
Date: Wed, 20 Dec 2017 19:23:32 -0000 (UTC)
Date: 2017-12-20T19:23:32+00:00	[thread overview]
Message-ID: <p1edbj$flb$1@dont-email.me> (raw)
In-Reply-To: lyy3lxfufs.fsf@pushface.org

On 2017-12-20, Simon Wright <simon@pushface.org> 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


  reply	other threads:[~2017-12-20 19:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 12:35 Compiler doesn't respect 'Size for atomic object Simon Wright
2017-12-20 19:23 ` Simon Clubley [this message]
2017-12-20 20:19   ` Simon Wright
2017-12-20 20:45     ` Simon Clubley
2017-12-21  7:10       ` Randy Brukardt
2017-12-21 14:08         ` Simon Wright
2017-12-20 21:20     ` Simon Wright
2017-12-21  5:55       ` Robert Eachus
2017-12-21 14:02         ` Simon Wright
2017-12-21 22:02         ` Simon Wright
2017-12-22  4:51           ` Robert Eachus
2017-12-22 10:21             ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox